ETH Price: $1,982.26 (-5.06%)

Contract

0xf44F8EeA027Cfe94367726fC17200b2bC4aEd638
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Token Holdings

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Unstake210533442024-10-27 0:21:47496 days ago1729988507IN
0xf44F8EeA...bC4aEd638
0 ETH0.000414643.6
Unstake208844652024-10-03 10:42:59519 days ago1727952179IN
0xf44F8EeA...bC4aEd638
0 ETH0.000361173.85875898
Unstake208843162024-10-03 10:13:11519 days ago1727950391IN
0xf44F8EeA...bC4aEd638
0 ETH0.000373513.79673705
Unstake208346102024-09-26 11:52:23526 days ago1727351543IN
0xf44F8EeA...bC4aEd638
0 ETH0.0034316314.61987655
Process Rewards207169422024-09-10 1:29:47543 days ago1725931787IN
0xf44F8EeA...bC4aEd638
0 ETH0.000640333.10784804
Unstake206915252024-09-06 12:22:47546 days ago1725625367IN
0xf44F8EeA...bC4aEd638
0 ETH0.000282412.5867733
Unstake206915232024-09-06 12:22:23546 days ago1725625343IN
0xf44F8EeA...bC4aEd638
0 ETH0.000647512.63098815
Process Rewards205976642024-08-24 9:48:23559 days ago1724492903IN
0xf44F8EeA...bC4aEd638
0 ETH0.00010421.2832519
Unstake205976632024-08-24 9:48:11559 days ago1724492891IN
0xf44F8EeA...bC4aEd638
0 ETH0.00015131.28140423
Unstake205976632024-08-24 9:48:11559 days ago1724492891IN
0xf44F8EeA...bC4aEd638
0 ETH0.000154531.2880909
Unstake205976622024-08-24 9:47:59559 days ago1724492879IN
0xf44F8EeA...bC4aEd638
0 ETH0.00031591.22248181
Unstake205641242024-08-19 17:20:47564 days ago1724088047IN
0xf44F8EeA...bC4aEd638
0 ETH0.000258112.71701892
Process Rewards205641212024-08-19 17:20:11564 days ago1724088011IN
0xf44F8EeA...bC4aEd638
0 ETH0.000547332.65647664
Process Rewards205545722024-08-18 9:19:35565 days ago1723972775IN
0xf44F8EeA...bC4aEd638
0 ETH0.000448052.12827125
Transfer Ownersh...204292312024-07-31 21:31:11583 days ago1722461471IN
0xf44F8EeA...bC4aEd638
0 ETH0.000199516.96347376
Process Rewards203657422024-07-23 0:46:47592 days ago1721695607IN
0xf44F8EeA...bC4aEd638
0 ETH0.000430642.09009487
Unstake203550042024-07-21 12:46:23593 days ago1721565983IN
0xf44F8EeA...bC4aEd638
0 ETH0.000819892.22575434
Unstake203290082024-07-17 21:42:47597 days ago1721252567IN
0xf44F8EeA...bC4aEd638
0 ETH0.00056294.69181339
Unstake203050162024-07-14 13:23:11600 days ago1720963391IN
0xf44F8EeA...bC4aEd638
0 ETH0.00085172.70931047
Unstake203050102024-07-14 13:21:59600 days ago1720963319IN
0xf44F8EeA...bC4aEd638
0 ETH0.000848112.6978914
Unstake202964552024-07-13 8:41:11601 days ago1720860071IN
0xf44F8EeA...bC4aEd638
0 ETH0.001112241.68509405
Unstake202964512024-07-13 8:40:23601 days ago1720860023IN
0xf44F8EeA...bC4aEd638
0 ETH0.001136911.72246533
Unstake202964472024-07-13 8:39:35601 days ago1720859975IN
0xf44F8EeA...bC4aEd638
0 ETH0.001128841.71023912
Unstake202964442024-07-13 8:38:59601 days ago1720859939IN
0xf44F8EeA...bC4aEd638
0 ETH0.001100581.6674225
Unstake202964402024-07-13 8:38:11601 days ago1720859891IN
0xf44F8EeA...bC4aEd638
0 ETH0.001161621.75990878
View all transactions

Latest 1 internal transaction

Advanced mode:
Parent Transaction Hash Method Block
From
To
0x61012060178742692023-08-09 2:08:23940 days ago1691546903  Contract Creation0 ETH
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ModaCorePool

Compiler Version
v0.8.6+commit.11564f7e

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
// SPDX-License-Identifier: MIT

pragma solidity 0.8.6;

import './ModaConstants.sol';
import './ModaPoolBase.sol';

/**
 * @title Moda Core Pool
 *
 * @notice Core pools represent permanent pools like MODA or MODA/ETH Pair pool,
 *      core pools allow staking for arbitrary periods of time up to 1 year
 *
 * @dev See ModaPoolBase for more details
 */
contract ModaCorePool is ModaPoolBase {
	/// @dev Pool tokens value available in the pool;
	///      pool token examples are MODA (MODA core pool) or MODA/ETH pair (LP core pool)
	/// @dev For LP core pool this value doesn't count for MODA tokens received as Vault rewards
	///      while for MODA core pool it does count for such tokens as well
	uint256 public poolTokenReserve;

	/**
	 * @dev Creates/deploys an instance of the core pool
	 *
	 * @param _moda MODA ERC20 Token ModaERC20 address
	 * @param _modaPoolFactory MODA Pool Factory Address
	 * @param _modaPool MODA Pool Address or address(0) if this is the Moda pool.
	 * @param _poolToken The token this pool uses.
	 * @param _weight number representing a weight of the pool, actual weight fraction
	 *      is calculated as that number divided by the total pools weight and doesn't exceed one
	 * @param _startTimestamp The start time for this pool as an EVM timestamp (seconds since epoch)
	 */
	constructor(
		address _moda,
		address _modaPoolFactory,
		address _modaPool,
		address _poolToken,
		uint32 _weight,
		uint256 _startTimestamp
	)
		ModaPoolBase(
			_moda,
			_modaPoolFactory,
			_modaPool,
			_poolToken,
			_weight,
			_startTimestamp
		)
	{
		poolTokenReserve = 0;
	}

	/**
	 * @notice Service function to calculate and pay pending vault and yield rewards to the sender
	 *
	 * @dev Internally executes similar function `_processRewards` from the parent smart contract
	 *      to calculate and pay yield rewards; adds vault rewards processing
	 *
	 * @dev Can be executed by anyone at any time, but has an effect only when
	 *      executed by deposit holder and when at least one block passes from the
	 *      previous reward processing
	 * @dev Executed internally when "staking as a pool" (`stakeAsPool`)
	 * @dev When timing conditions are not met (executed too frequently, or after
	 *      end block), function doesn't throw and exits silently
	 */
	function processRewards() external override {
		_processRewards(msg.sender);
	}

	/**
	 * @dev Executed by another pool (from the parent `ModaPoolBase` smart contract)
	 *      as part of yield rewards processing logic (`ModaPoolBase._processRewards` function)
	 * @dev Executed when pool is not an Moda pool - see `ModaPoolBase._processRewards`
	 *
	 * @param _staker an address which stakes (the yield reward)
	 * @param _amount amount to be staked (yield reward amount)
	 */
	function stakeAsPool(address _staker, uint256 _amount)
		external
	{
		require(modaPoolFactory.poolExists(msg.sender), 'pool is not registered');

		User storage user = users[_staker];
		if (user.tokenAmount > 0) {
			_processRewards(_staker);
		}

		uint256 depositWeight = _amount * YEAR_STAKE_WEIGHT_MULTIPLIER;
		Deposit memory newDeposit = Deposit({
			tokenAmount: _amount,
			lockedFrom: block.timestamp,
			lockedUntil: block.timestamp + rewardLockingPeriod,
			weight: depositWeight,
			isYield: true
		});
		user.tokenAmount += _amount;
		user.totalWeight += depositWeight;
		user.deposits.push(newDeposit);

		usersLockingWeight += depositWeight;

		// update `poolTokenReserve` only if this is a LP Core Pool (stakeAsPool can be executed only for LP pool)
		poolTokenReserve += _amount;

		// Tell the world we've done this
		emit Staked(_staker, _staker, _amount);
	}

	/**
	 * @inheritdoc ModaPoolBase
	 *
	 * @dev Additionally to the parent smart contract,
	 *      and updates (increases) pool token reserve (pool tokens value available in the pool)
	 */
	function _stake(
		address _staker,
		uint256 _amount,
		uint256 _lockUntil,
		bool _isYield
	) internal override {
		super._stake(_staker, _amount, _lockUntil, _isYield);
		poolTokenReserve += _amount;
	}

	/**
	 * @inheritdoc ModaPoolBase
	 *
	 * @dev Additionally to the parent smart contract,
	 *      and updates (decreases) pool token reserve
	 *      (pool tokens value available in the pool)
	 */
	function _unstake(
		address _staker,
		uint256 _depositId,
		uint256 _amount
	) internal override {
		User storage user = users[_staker];
		Deposit memory stakeDeposit = user.deposits[_depositId];
		require(
			block.timestamp > stakeDeposit.lockedUntil,
			'deposit not yet unlocked'
		);
		poolTokenReserve -= _amount;
		super._unstake(_staker, _depositId, _amount);
	}

	/**
	 * @inheritdoc ModaPoolBase
	 *
	 * @dev Additionally to the parent smart contract,
	 *      and for MODA pool updates (increases) pool token reserve
	 *      (pool tokens value available in the pool)
	 */
	function _processRewards(address _staker) internal override returns (uint256 rewards) {
		rewards = super._processRewards(_staker);

		// update `poolTokenReserve` only if this is a MODA Core Pool
		if (poolToken == moda) {
			poolTokenReserve += rewards;
		}
	}
}

File 2 of 32 : ModaConstants.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.6;

library ModaConstants {
	/**
	 * @dev Smart contract unique identifier, a random number
	 * @dev Should be regenerated each time smart contact source code is changed
	 *      and changes smart contract itself is to be redeployed
	 * @dev Generated using https://www.random.org/bytes/
	 */
	uint256 public constant TOKEN_UID =
		0xc8de2a18ae1c61538a5f880f5c8eb7ff85aa3996c4363a27b1c6112a190e65b4;

	/**
	 * @dev Smart contract unique identifier, a random number
	 * @dev Should be regenerated each time smart contact source code is changed
	 *      and changes smart contract itself is to be redeployed
	 * @dev Generated using https://www.random.org/bytes/
	 */
	uint256 public constant ESCROWTOKEN_UID =
		0x0a9a93ba9d22fa5ed507ff32440b8750c8951e4864438c8afc02be22ad238ebf;

	/**
	 * @dev Smart contract unique identifier, a random number
	 * @dev Should be regenerated each time smart contact source code is changed
	 *      and changes smart contract itself is to be redeployed
	 * @dev Generated using https://www.random.org/bytes/
	 */
	uint256 public constant POOL_UID =
		0x8ca5f5bb5e4f02345a019a993ce37018dd549b22e88027f4f5c1f614ef6fb3c0;

	/**
	 * @dev Smart contract unique identifier, a random number
	 * @dev Should be regenerated each time smart contact source code is changed
	 *      and changes smart contract itself is to be redeployed
	 * @dev Generated using https://www.random.org/bytes/
	 */
	uint256 public constant FACTORY_UID =
		0x871acfd60315c19d4e011a9b2fe668860c17caf2dea3882043e8270ec8b5696c;

	/**
	 * @notice Upgrader is responsible for managing future versions
	 *         of the contract.
	 */
	bytes32 public constant ROLE_UPGRADER = '\x00\x0A\x00\x00';

	/**
	 * @notice Token creator is responsible for creating (minting)
	 *      tokens to an arbitrary address
	 * @dev Role ROLE_TOKEN_CREATOR allows minting tokens
	 *      (calling `mint` function)
	 */
	bytes32 public constant ROLE_TOKEN_CREATOR = '\x00\x0B\x00\x00';
}

// SPDX-License-Identifier: MIT
pragma solidity 0.8.6;

import '@openzeppelin/contracts/access/Ownable.sol';
import '@openzeppelin/contracts/security/ReentrancyGuard.sol';
import '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';
import './IPool.sol';
import './ICorePool.sol';
import './ModaConstants.sol';
import './ModaPoolFactory.sol';

/**
 * @title Moda Pool Base
 * @notice An abstract contract containing common logic for any MODA pool,
 *      be it core pool (permanent pool like MODA/ETH or MODA core pool) or something else.
 * @dev Deployment and initialization.
 *      Any pool deployed must have 3 token instance addresses defined on deployment:
 *          - MODA token address
 *          - pool token address, it can be MODA token address, MODA/ETH pair address, and others
 */
abstract contract ModaPoolBase is Ownable, IPool, ModaAware, ReentrancyGuard {
	// @dev POOL_UID defined to add another check to ensure compliance with the contract.
	function POOL_UID() public pure returns (uint256) {
		return ModaConstants.POOL_UID;
	}

	// @dev modaPool MODA ERC20 Liquidity Pool contract address.
	// @dev This value is address(0) for the default MODA Core Pool.
	// @dev This value MUST be provided for any pool created which is not a MODA pool.
	// @dev This is used in the case where poolToken != moda.
	//      The use case relates to shadowing Liquidity Pool stakes
	//      by allowing people to store the LP tokens here to gain
	//      further MODA rewards. I'm not sure it's both. (dex 2021.09.16)
	address immutable modaPool;

	/// @dev Data structure representing token holder using a pool
	struct User {
		// @dev Total staked amount
		uint256 tokenAmount;
		// @dev Total weight
		uint256 totalWeight;
		// @dev An array of holder's deposits
		Deposit[] deposits;
		// @dev timestamp of when the user last processed rewards
		uint256 lastProcessedRewards;
	}

	/// @dev Token holder storage, maps token holder address to their data record
	mapping(address => User) public users;

	/// @dev Link to the pool token instance, for example MODA or MODA/ETH pair
	address public immutable override poolToken;

	/// @dev Link to the pool factory instance that manages weights
	ModaPoolFactory public immutable modaPoolFactory;

	/// @dev Pool weight, 200 for MODA pool or 800 for MODA/ETH
	uint32 public override weight;

	/// @dev Used to calculate yield rewards, keeps track of the tokens weight locked in staking
	uint256 public override usersLockingWeight;

	/// @dev Used to calculate yield rewards, keeps track of when the pool started
	uint256 public immutable override startTimestamp;

	/// @dev Reward locking period, added to block.timestamp when rewards are locked up in the pool
	///      Can be changed by the contract owner.
	uint public rewardLockingPeriod = 150 days;

	/**
	 * @dev Stake weight is proportional to deposit amount and time locked, precisely
	 *      "deposit amount wei multiplied by (fraction of the year locked plus one)"
	 * @dev To avoid significant precision loss due to multiplication by "fraction of the year" [0, 1],
	 *      weight is stored multiplied by 1e6 constant, as an integer
	 * @dev Corner case 1: if time locked is zero, weight is deposit amount multiplied by 1e6
	 * @dev Corner case 2: if time locked is one year, fraction of the year locked is one, and
	 *      weight is a deposit amount multiplied by 2 * 1e6
	 */
	uint256 internal constant WEIGHT_MULTIPLIER = 1e6;

	/**
	 * @dev When we know beforehand that staking is done for a year, and fraction of the year locked is one,
	 *      we use simplified calculation and use the following constant instead previous one
	 */
	uint256 internal constant YEAR_STAKE_WEIGHT_MULTIPLIER = 2 * WEIGHT_MULTIPLIER;

	/**
	 * @dev Fired in _stake() and stake()
	 *
	 * @param _by an address which performed an operation, usually token holder
	 * @param _from token holder address, the tokens will be returned to that address
	 * @param amount amount of tokens staked
	 */
	event Staked(address indexed _by, address indexed _from, uint256 amount);

	/**
	 * @dev Fired in _updateStakeLock() and updateStakeLock()
	 *
	 * @param _by an address which performed an operation
	 * @param depositId updated deposit ID
	 * @param lockedFrom deposit locked from value
	 * @param lockedUntil updated deposit locked until value
	 */
	event StakeLockUpdated(address indexed _by, uint256 depositId, uint256 lockedFrom, uint256 lockedUntil);

	/**
	 * @dev Fired in _unstake() and unstake()
	 *
	 * @param _by an address which performed an operation, usually token holder
	 * @param _to an address which received the unstaked tokens, usually token holder
	 * @param amount amount of tokens unstaked
	 */
	event Unstaked(address indexed _by, address indexed _to, uint256 amount);

	/**
	 * @dev Fired in _processRewards(), processRewards() and dependent functions (stake, unstake, etc.)
	 *
	 * @param _by an address which performed an operation
	 * @param _to an address which claimed the yield reward
	 * @param amount amount of yield paid
	 */
	event YieldClaimed(address indexed _by, address indexed _to, uint256 amount);

	/**
	 * @dev Fired in setWeight()
	 *
	 * @param _by an address which performed an operation, always a factory
	 * @param _fromVal old pool weight value
	 * @param _toVal new pool weight value
	 */
	event PoolWeightUpdated(address indexed _by, uint32 _fromVal, uint32 _toVal);

	/**
	 * @dev Fired whenever the owner sets the reward locking period. Existing stakes
	 *      are not affected by this change, as it's queried and added on lock up.
	 *
	 * @param _from the previous reward locking period in seconds
	 * @param _to the new reward locking period in seconds
	 */
	event RewardLockingPeriodUpdated(uint _from, uint _to);

	/**
	 * @dev Overridden in sub-contracts to construct the pool
	 *
	 * @param _moda MODA ERC20 Token ModaERC20 address
	 * @param _modaPoolFactory MODA Pool Factory Address
	 * @param _modaPool MODA ERC20 Liquidity Pool contract address
	 * @param _poolToken token the pool operates on, for example MODA or MODA/ETH pair
	 * @param _weight number representing a weight of the pool, actual weight fraction
	 *      is calculated as that number divided by the total pools weight and doesn't exceed one
	 * @param _startTimestamp timestamp that pool should start from
	 */
	constructor(
		address _moda,
		address _modaPoolFactory,
		address _modaPool,
		address _poolToken,
		uint32 _weight,
		uint256 _startTimestamp
	) ModaAware(_moda) {
		require(_poolToken != address(0), 'pool token address not set');
		require(_modaPoolFactory != address(0), 'pool factory address not set');
		require(_weight > 0, 'pool weight not set');
		require(_startTimestamp >= block.timestamp, 'start already passed');
		require(
			_startTimestamp < ModaPoolFactory(_modaPoolFactory).endTimestamp(),
			'start too late compared to factory'
		);
		require(
			((_poolToken == _moda ? 1 : 0) ^ (_modaPool != address(0) ? 1 : 0)) == 1,
			'Either a MODA pool or manage external tokens, never both'
		);

		require(Token(_moda).TOKEN_UID() == ModaConstants.TOKEN_UID, 'Moda TOKEN_UID invalid');
		require(
			ModaPoolFactory(_modaPoolFactory).FACTORY_UID() == ModaConstants.FACTORY_UID,
			'Moda FACTORY_UID invalid'
		);
		if (_modaPool != address(0)) {
			require(ModaPoolBase(_modaPool).POOL_UID() == ModaConstants.POOL_UID, 'Moda POOL_UID invalid');
		}

		modaPool = _modaPool;
		modaPoolFactory = ModaPoolFactory(_modaPoolFactory);
		poolToken = _poolToken;
		weight = _weight;
		startTimestamp = _startTimestamp;
	}

	/**
	 * @notice Calculates current yield rewards value available for address specified
	 * @param _staker an address to calculate yield rewards value for
	 * @return calculated yield reward value for the given address
	 */
	function pendingYieldRewards(address _staker) public view override returns (uint256) {
		if (block.timestamp < startTimestamp) return 0;
		if (usersLockingWeight == 0) return 0;

		uint256 factoryEnd = modaPoolFactory.endTimestamp();
		uint256 endOfTimeframe = block.timestamp > factoryEnd ? factoryEnd : block.timestamp;

		User memory user = users[_staker];
		if (user.lastProcessedRewards > endOfTimeframe) return 0;

		uint256 depositCount = user.deposits.length;
		if (depositCount < 1) return 0;

		Deposit memory stakeDeposit = user.deposits[depositCount - 1];
		uint256 lastRewards = user.lastProcessedRewards > 0 ? user.lastProcessedRewards : stakeDeposit.lockedFrom;

		uint256 timeElapsedSinceLastReward = endOfTimeframe < startTimestamp
			? endOfTimeframe - startTimestamp
			: endOfTimeframe - lastRewards;

		uint256 modaPerSecond = modaPoolFactory.modaPerSecondAt(endOfTimeframe);
		uint256 allPoolsTotalSinceLastReward = modaPerSecond * timeElapsedSinceLastReward;
		uint256 poolRewards = (allPoolsTotalSinceLastReward * weight) / modaPoolFactory.totalWeight();

		return (poolRewards * user.totalWeight) / usersLockingWeight;
	}

	/**
	 * @notice Returns total staked token balance for the given address
	 *
	 * @param _user an address to query balance for
	 * @return total staked token balance
	 */
	function balanceOf(address _user) external view override returns (uint256) {
		return users[_user].tokenAmount;
	}

	/**
	 * @notice Returns information on the given deposit for the given address
	 * @dev See getDepositsLength
	 * @param _user an address to query deposit for
	 * @param _depositId zero-indexed deposit ID for the address specified
	 * @return deposit info as Deposit structure
	 */
	function getDeposit(address _user, uint256 _depositId) external view override returns (Deposit memory) {
		return users[_user].deposits[_depositId];
	}

	/**
	 * @notice Returns number of deposits for the given address. Allows iteration over deposits.
	 * @dev See getDeposit
	 * @param _user an address to query deposit length for
	 * @return number of deposits for the given address
	 */
	function getDepositsLength(address _user) external view override returns (uint256) {
		return users[_user].deposits.length;
	}

	/**
	 * @notice Stakes specified amount of tokens for the specified amount of time,
	 *      and pays pending yield rewards if any
	 * @dev Requires amount to stake to be greater than zero
	 * @param _amount amount of tokens to stake
	 * @param _lockUntil stake period as unix timestamp; zero means no locking
	 */
	function stake(uint256 _amount, uint256 _lockUntil) external override {
		_stake(msg.sender, _amount, _lockUntil, false);
	}

	/**
	 * @notice Un-stakes specified amount of tokens, and pays pending yield rewards if any
	 * @dev Requires amount to unstake to be greater than zero
	 * @param _depositId deposit ID to unstake from, zero-indexed
	 * @param _amount amount of tokens to unstake
	 */
	function unstake(uint256 _depositId, uint256 _amount) external override {
		_unstake(msg.sender, _depositId, _amount);
	}

	/**
	 * @notice Extends locking period for a given deposit
	 * @dev Requires new lockedUntil value to be:
	 *      higher than the current one, and
	 *      in the future, but
	 *      no more than 1 year in the future
	 * @param depositId updated deposit ID
	 * @param lockedUntil updated deposit locked until value
	 */
	function updateStakeLock(uint256 depositId, uint256 lockedUntil) external {
		_processRewards(msg.sender);
		_updateStakeLock(msg.sender, depositId, lockedUntil);
	}

	/**
	 * @notice Service function to calculate and pay pending yield rewards to the sender
	 * @dev Can be executed by anyone at any time, but has an effect only when
	 *      executed by deposit holder and when at least one block passes from the
	 *      previous reward processing
	 * @dev When timing conditions are not met (executed too frequently, or after
	 *      end block), function doesn't throw and exits silently
	 */
	function processRewards() external virtual override {
		_processRewards(msg.sender);
	}

	/**
	 * @dev Executed by the factory to modify pool weight; the factory is expected
	 *      to keep track of the total pools weight when updating
	 * @dev Set weight to zero to disable the pool
	 * @param _weight new weight to set for the pool
	 */
	function setWeight(uint32 _weight) external override {
		require(msg.sender == address(modaPoolFactory), 'Access denied: factory only');

		uint32 oldWeight = weight;
		weight = _weight;

		emit PoolWeightUpdated(msg.sender, oldWeight, weight);
	}

	/**
	 * @dev Used internally, mostly by children implementations, see stake()
	 * @param _staker an address which stakes tokens and which will receive them back
	 * @param _amount amount of tokens to stake
	 * @param _lockUntil stake period as unix timestamp; zero means no locking
	 * @param _isYield a flag indicating if that stake is created to store yield reward
	 *      from the previously unstaked stake
	 */
	function _stake(address _staker, uint256 _amount, uint256 _lockUntil, bool _isYield) internal virtual {
		require(_amount > 0, 'zero amount');
		require(block.timestamp >= startTimestamp, 'pool not active');
		require(
			_lockUntil == 0 || (_lockUntil > block.timestamp && _lockUntil - block.timestamp <= 365 days),
			'invalid lock interval'
		);

		User storage user = users[_staker];
		if (user.tokenAmount > 0) {
			_processRewards(_staker);
		}

		uint256 previousBalance = IERC20(poolToken).balanceOf(address(this));
		transferPoolTokenFrom(address(msg.sender), address(this), _amount);
		// Note: some tokens may get burnt here if the token contract
		// withholds fees on transfers. We must re-fetch the balance. Usually
		// this is just the difference: `previousBalance - _amount`
		uint256 newBalance = IERC20(poolToken).balanceOf(address(this));
		// calculate real amount taking into account deflation
		uint256 addedAmount = newBalance - previousBalance;

		// set the `lockFrom` and `lockUntil` taking into account that
		// zero value for `_lockUntil` means "no locking" and leads to zero values
		// for both `lockFrom` and `lockUntil`
		uint256 lockFrom = block.timestamp;
		uint256 lockUntil = _lockUntil;

		// Stake weight rewards formula for locking
		uint256 stakeWeight = lockUntil == 0
			? WEIGHT_MULTIPLIER * addedAmount
			: ((WEIGHT_MULTIPLIER * (lockUntil - lockFrom)) / 365 days + WEIGHT_MULTIPLIER) * addedAmount;

		require(stakeWeight > 0, 'Stake weight is zero');

		Deposit memory deposit = Deposit({
			tokenAmount: addedAmount,
			weight: stakeWeight,
			lockedFrom: lockFrom,
			lockedUntil: lockUntil,
			isYield: _isYield
		});
		user.deposits.push(deposit);

		user.tokenAmount += addedAmount;
		user.totalWeight += stakeWeight;

		usersLockingWeight += stakeWeight;

		emit Staked(msg.sender, _staker, _amount);
	}

	/**
	 * @dev Used internally, mostly by children implementations, see unstake()
	 * @param _staker an address which un-stakes tokens (which previously staked them)
	 * @param _depositId deposit ID to unstake from, zero-indexed
	 * @param _amount amount of tokens to unstake
	 */
	function _unstake(address _staker, uint256 _depositId, uint256 _amount) internal virtual {
		require(_amount > 0, 'zero amount');

		User storage user = users[_staker];
		Deposit storage stakeDeposit = user.deposits[_depositId];
		bool isYield = stakeDeposit.isYield;

		require(stakeDeposit.tokenAmount >= _amount, 'amount exceeds stake');

		_processRewards(_staker);

		uint256 previousWeight = stakeDeposit.weight;
		uint256 newWeight = stakeDeposit.lockedUntil == 0
			? WEIGHT_MULTIPLIER * (stakeDeposit.tokenAmount - _amount)
			: ((stakeDeposit.lockedUntil - stakeDeposit.lockedFrom) / 365 days + 1) *
				(WEIGHT_MULTIPLIER * (stakeDeposit.tokenAmount - _amount));

		if (stakeDeposit.tokenAmount - _amount == 0) {
			delete user.deposits[_depositId];
		} else {
			stakeDeposit.tokenAmount -= _amount;
			stakeDeposit.weight = newWeight;
		}

		user.tokenAmount -= _amount;
		user.totalWeight = user.totalWeight - previousWeight + newWeight;

		usersLockingWeight = usersLockingWeight - previousWeight + newWeight;

		if (isYield) {
			modaPoolFactory.mintYieldTo(msg.sender, _amount);
		} else {
			transferPoolToken(msg.sender, _amount);
		}

		emit Unstaked(msg.sender, _staker, _amount);
	}

	/**
	 * @dev Used internally, mostly by children implementations, see processRewards()
	 * @param _staker an address which receives the reward (which has staked some tokens earlier)
	 * @return pendingYield the rewards calculated and optionally re-staked
	 */
	function _processRewards(address _staker) internal virtual returns (uint256 pendingYield) {
		pendingYield = pendingYieldRewards(_staker);
		if (pendingYield == 0) return 0;

		User storage user = users[_staker];
		user.lastProcessedRewards = block.timestamp;

		if (poolToken == moda) {
			uint256 depositWeight = pendingYield * YEAR_STAKE_WEIGHT_MULTIPLIER;

			Deposit memory newDeposit = Deposit({
				tokenAmount: pendingYield,
				lockedFrom: block.timestamp,
				lockedUntil: block.timestamp + rewardLockingPeriod,
				weight: depositWeight,
				isYield: true
			});
			user.deposits.push(newDeposit);

			user.tokenAmount += pendingYield;
			user.totalWeight += depositWeight;

			usersLockingWeight += depositWeight;
		} else {
			require(modaPool != address(0), 'modaPool address is zero');

			ICorePool(modaPool).stakeAsPool(_staker, pendingYield);
		}

		emit YieldClaimed(msg.sender, _staker, pendingYield);
	}

	/**
	 * @dev See updateStakeLock()
	 * @param _staker an address to update stake lock
	 * @param _depositId updated deposit ID
	 * @param _lockedUntil updated deposit locked until value
	 */
	function _updateStakeLock(address _staker, uint256 _depositId, uint256 _lockedUntil) internal {
		require(_lockedUntil > block.timestamp, 'lock should be in the future');

		User storage user = users[_staker];
		Deposit storage stakeDeposit = user.deposits[_depositId];
		require(_lockedUntil > stakeDeposit.lockedUntil, 'invalid new lock');

		if (stakeDeposit.lockedFrom == 0) {
			require(_lockedUntil - block.timestamp <= 365 days, 'max lock period is 365 days');
			stakeDeposit.lockedFrom = block.timestamp;
		} else {
			require(_lockedUntil - stakeDeposit.lockedFrom <= 365 days, 'max lock period is 365 days');
		}

		stakeDeposit.lockedUntil = _lockedUntil;
		uint256 newWeight = (((stakeDeposit.lockedUntil - stakeDeposit.lockedFrom) * WEIGHT_MULTIPLIER) /
			365 days +
			WEIGHT_MULTIPLIER) * stakeDeposit.tokenAmount;

		uint256 previousWeight = stakeDeposit.weight;
		stakeDeposit.weight = newWeight;

		user.totalWeight = user.totalWeight - previousWeight + newWeight;
		usersLockingWeight = usersLockingWeight - previousWeight + newWeight;

		emit StakeLockUpdated(_staker, _depositId, stakeDeposit.lockedFrom, _lockedUntil);
	}

	/**
	 * @dev Executes SafeERC20.safeTransfer on a pool token
	 * @dev Reentrancy safety enforced via `ReentrancyGuard.nonReentrant`
	 */
	function transferPoolToken(address _to, uint256 _value) internal nonReentrant {
		SafeERC20.safeTransfer(IERC20(poolToken), _to, _value);
	}

	/**
	 * @dev Executes SafeERC20.safeTransferFrom on a pool token
	 * @dev Reentrancy safety enforced via `ReentrancyGuard.nonReentrant`
	 */
	function transferPoolTokenFrom(address _from, address _to, uint256 _value) internal nonReentrant {
		SafeERC20.safeTransferFrom(IERC20(poolToken), _from, _to, _value);
	}

	/**
	 * @dev Allows the owner to update the reward locking period
	 */
	function setRewardLockingPeriod(uint newRewardLockingPeriod) external override onlyOwner {
		uint oldRewardLockingPeriod = rewardLockingPeriod;
		rewardLockingPeriod = newRewardLockingPeriod;

		emit RewardLockingPeriodUpdated(oldRewardLockingPeriod, rewardLockingPeriod);
	}

	/**
	 * @dev Here because of multiple inheritance, we have to override.
	 */
	function transferOwnership(address newOwner) public virtual override(IPool, Ownable) onlyOwner {
		require(newOwner != address(0), 'Ownable: new owner is the zero address');
		_transferOwnership(newOwner);
	}
}

// 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);
    }
}

File 5 of 32 : ReentrancyGuard.sol
// 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/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
pragma solidity =0.8.6;

import './ILinkedToMODA.sol';

/**
 * @title Moda Pool
 *
 * @notice An abstraction representing a pool, see ModaPoolBase for details
 *
 * @author Pedro Bergamini, reviewed by Basil Gorin
 */
interface IPool is ILinkedToMODA {
	/**
	 * @dev Deposit is a key data structure used in staking,
	 *      it represents a unit of stake with its amount, weight and term (time interval)
	 */
	struct Deposit {
		// @dev token amount staked
		uint256 tokenAmount;
		// @dev stake weight
		uint256 weight;
		// @dev locking period - from
		uint256 lockedFrom;
		// @dev locking period - until
		uint256 lockedUntil;
		// @dev indicates if the stake was created as a yield reward
		bool isYield;
	}

	// for the rest of the functions see Soldoc in ModaPoolBase

	function poolToken() external view returns (address);

	function weight() external view returns (uint32);

	function usersLockingWeight() external view returns (uint256);

	function startTimestamp() external view returns (uint256);

	function pendingYieldRewards(address _user) external view returns (uint256);

	function balanceOf(address _user) external view returns (uint256);

	function getDeposit(address _user, uint256 _depositId) external view returns (Deposit memory);

	function getDepositsLength(address _user) external view returns (uint256);

	function stake(
		uint256 _amount,
		uint256 _lockedUntil
	) external;

	function unstake(
		uint256 _depositId,
		uint256 _amount
	) external;

	function processRewards() external;

	function setWeight(uint32 _weight) external;

	function setRewardLockingPeriod(uint newRewardLockingPeriod) external;

	function transferOwnership(address newOwner) external;
}

// SPDX-License-Identifier: MIT

pragma solidity 0.8.6;

import './IPool.sol';

interface ICorePool is IPool {
	function vaultRewardsPerToken() external view returns (uint256);

	function poolTokenReserve() external view returns (uint256);

	function stakeAsPool(address _staker, uint256 _amount) external;
}

// SPDX-License-Identifier: MIT
pragma solidity 0.8.6;

import './IPool.sol';
import './ModaAware.sol';
import './ModaCorePool.sol';
import '@openzeppelin/contracts/access/Ownable.sol';
import 'abdk-libraries-solidity/ABDKMath64x64.sol';

/**
 * @title Moda Pool Factory
 *
 * @notice Moda Pool Factory manages Moda Yield farming pools, provides a single
 *      public interface to access the pools, provides an interface for the pools
 *      to mint yield rewards, access pool-related info, update weights, etc.
 *
 * @notice The factory is authorized (via its owner) to register new pools, change weights
 *      of the existing pools, removing the pools (by changing their weights to zero)
 *
 * @dev The factory requires ROLE_TOKEN_CREATOR permission on the Moda token to mint yield
 *      (see `mintYieldTo` function)
 *
 * @author Kevin Brown, based on Illuvium Pool Factory Contract by Pedro Bergamini, reviewed by Basil Gorin
 */
contract ModaPoolFactory is Ownable, ModaAware {
	// @dev FACTORY_UID defined to add another check to ensure compliance with the contract.
	function FACTORY_UID() external pure returns (uint256) {
		return ModaConstants.FACTORY_UID;
	}

	/// @dev Auxiliary data structure used only in getPoolData() view function
	struct PoolData {
		// @dev pool token address (like Moda, or an LP token)
		address poolToken;
		// @dev pool address (like deployed core pool instance)
		address poolAddress;
		// @dev pool weight (200 for Moda pools, 400 for Moda/ETH pools - set during deployment)
		uint32 weight;
	}

	/**
	 * @dev Moda/second determines yield farming reward base
	 *      used by the yield pools controlled by the factory
	 */
	uint256 public immutable initialModaPerSecond;

	/**
	 * @dev The yield is distributed proportionally to pool weights;
	 *      total weight is here to help in determining the proportion
	 */
	uint32 public totalWeight;

	/**
	 * @dev Moda/second decreases by 3% every period;
	 *      updates are lazy calculated via a compound interest function.
	 */
	uint32 public immutable secondsPerUpdate;

	/**
	 * @dev Start timestamp is when the pool starts.
	 */
	uint public immutable startTimestamp;

	/**
	 * @dev End timestamp is the last time when Moda/second can be decreased;
	 *      it is implied that yield farming stops after that block
	 */
	uint public immutable endTimestamp;

	/// @dev Maps pool token address (like Moda) -> pool address (like core pool instance)
	mapping(address => address) public pools;

	/// @dev Keeps track of registered pool addresses, maps pool address -> exists flag
	mapping(address => bool) public poolExists;

	/**
	 * @dev Fired in createPool() and registerPool()
	 *
	 * @param _by an address which executed an action
	 * @param poolToken pool token address (like Moda or a Moda / ETH LP token)
	 * @param poolAddress deployed pool instance address
	 * @param weight pool weight
	 */
	event PoolRegistered(address indexed _by, address indexed poolToken, address indexed poolAddress, uint64 weight);

	/**
	 * @dev Fired in changePoolWeight()
	 *
	 * @param _by an address which executed an action
	 * @param _poolAddress deployed pool instance address
	 * @param _weight new pool weight
	 */
	event WeightUpdated(address indexed _by, address indexed _poolAddress, uint32 _weight);

	/**
	 * @dev Fired in mintYieldTo()
	 *
	 * @param _to recipient of the minting
	 * @param _amount amount minted in wei
	 */
	event YieldMinted(address indexed _to, uint256 _amount);

	/**
	 * @dev Fired in createCorePool()
	 *
	 * @param _by an address which executed an action
	 * @param poolAddress deployed pool instance address
	 */
	event CorePoolCreated(address indexed _by, address indexed poolAddress);

	/**
	 * @dev Creates/deploys a factory instance
	 *
	 * @param _moda Moda ERC20 token address
	 * @param _modaPerSecond initial Moda/second value for rewards
	 * @param _secondsPerUpdate how frequently the rewards gets updated (decreased by 3%)
	 * @param _startTimestamp timestamp to measure _secondsPerUpdate from
	 * @param _endTimestamp timestamp when farming stops and rewards cannot be updated anymore
	 */
	constructor(
		address _moda,
		uint256 _modaPerSecond,
		uint32 _secondsPerUpdate,
		uint _startTimestamp,
		uint _endTimestamp
	) ModaAware(_moda) {
		// verify the inputs are set
		require(_modaPerSecond > 0, 'Moda/second not set');
		require(_secondsPerUpdate > 0, 'seconds/update not set');
		require(_startTimestamp > 0, 'start timestamp not set');
		require(_endTimestamp > _startTimestamp, 'invalid end timestamp: must be greater than init timestamp');

		// save the inputs into internal state variables
		initialModaPerSecond = _modaPerSecond;
		secondsPerUpdate = _secondsPerUpdate;
		startTimestamp = _startTimestamp;
		endTimestamp = _endTimestamp;
	}

	/**
	 * @notice Given a pool token retrieves corresponding pool address
	 *
	 * @dev A shortcut for `pools` mapping
	 *
	 * @param poolToken pool token address (like Moda) to query pool address for
	 * @return pool address for the token specified
	 */
	function getPoolAddress(address poolToken) external view returns (address) {
		// read the mapping and return
		return pools[poolToken];
	}

	/**
	 * @notice Reads pool information for the pool defined by its pool token address,
	 *      designed to simplify integration with the front ends
	 *
	 * @param _poolToken pool token address to query pool information for
	 * @return pool information packed in a PoolData struct
	 */
	function getPoolData(address _poolToken) external view returns (PoolData memory) {
		// get the pool address from the mapping
		address poolAddr = pools[_poolToken];

		// throw if there is no pool registered for the token specified
		require(poolAddr != address(0), 'pool not found');

		// read pool information from the pool smart contract
		// via the pool interface (IPool)
		address poolToken = IPool(poolAddr).poolToken();
		uint32 weight = IPool(poolAddr).weight();

		// create the in-memory structure and return it
		return PoolData({poolToken: poolToken, poolAddress: poolAddr, weight: weight});
	}

	/**
	 * @dev Creates a core pool (ModaCorePool) and registers it within the factory
	 *
	 * @dev Can be executed by the pool factory owner only
	 *
	 * @param poolStartTimestamp init timestamp to be used for the pool creation time
	 * @param weight weight of the pool to be created
	 */
	function createCorePool(uint256 poolStartTimestamp, uint32 weight) external virtual onlyOwner {
		// create/deploy new core pool instance
		IPool pool = new ModaCorePool(moda, address(this), address(0), moda, weight, poolStartTimestamp);

		// Now the owner needs to be set to whoever is calling this function.
		pool.transferOwnership(msg.sender);

		// register it within this factory
		registerPool(address(pool));

		// Tell the world we've done that
		emit CorePoolCreated(msg.sender, address(pool));
	}

	/**
	 * @dev Registers an already deployed pool instance within the factory
	 *
	 * @dev Can be executed by the pool factory owner only
	 *
	 * @param poolAddr address of the already deployed pool instance
	 */
	function registerPool(address poolAddr) public onlyOwner {
		// read pool information from the pool smart contract
		// via the pool interface (IPool)
		address poolToken = IPool(poolAddr).poolToken();
		uint32 weight = IPool(poolAddr).weight();

		// ensure that the pool is not already registered within the factory
		require(pools[poolToken] == address(0), 'this pool is already registered');

		// create pool structure, register it within the factory
		pools[poolToken] = poolAddr;
		poolExists[poolAddr] = true;
		// update total pool weight of the factory
		totalWeight += weight;

		// emit an event
		emit PoolRegistered(msg.sender, poolToken, poolAddr, weight);
	}

	/**
	 * @notice Calculates compound interest
	 */
	function compound(uint principal, uint periods) public pure returns (uint) {
		return
			ABDKMath64x64.mulu(
				// Rate is -3% per period, e.g. 97/100.
				ABDKMath64x64.pow(ABDKMath64x64.div(97, 100), periods),
				principal
			);
	}

	/// @notice Calculates the effective moda per second at a future timestamp.
	function modaPerSecondAt(uint time) external view returns (uint256) {
		// If we're before the start, just return initial.
		if (time < startTimestamp) return 0;

		// Override for now. Return initialModaPerSecond for all times
		return initialModaPerSecond;

		// // If we're at the end, we don't continue to decrease.
		// if (time > endTimestamp) time = endTimestamp;

		// // How many times do we need to decrease the rewards
		// // between the last time we've calculated and now?
		// uint periods = (time - startTimestamp) / secondsPerUpdate;

		// // Calculate the resulting amount after applying that many decreases.
		// return compound(initialModaPerSecond, periods);
	}

	/**
	 * @dev Mints Moda tokens; executed by Moda Pool only
	 *
	 * @dev Requires factory to have ROLE_TOKEN_CREATOR permission
	 *      on the Moda ERC20 token instance
	 *
	 * @param _to an address to mint tokens to
	 * @param _amount amount of Moda tokens to mint
	 */
	function mintYieldTo(address _to, uint256 _amount) external {
		// verify that sender is a pool registered withing the factory
		require(poolExists[msg.sender], 'pool is not registered with this factory');

		// mint Moda tokens as required
		mintModa(_to, _amount);

		// Tell the world we've done this
		emit YieldMinted(_to, _amount);
	}

	/**
	 * @dev Changes the weight of the pool;
	 *      executed by the pool itself or by the factory owner
	 *
	 * @param poolAddr address of the pool to change weight for
	 * @param weight new weight value to set to
	 */
	function changePoolWeight(address poolAddr, uint32 weight) external {
		// verify function is executed either by factory owner or by the pool itself
		require(msg.sender == owner(), 'Must be owner');
		require(poolExists[poolAddr], 'Pool not registered');

		// recalculate total weight
		totalWeight = totalWeight + weight - IPool(poolAddr).weight();

		// set the new pool weight
		IPool(poolAddr).setWeight(weight);

		// emit an event
		emit WeightUpdated(msg.sender, poolAddr, weight);
	}
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) external returns (bool);

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);
}

// 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);
            }
        }
    }
}

File 13 of 32 : ILinkedToMODA.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.6;

/**
 * @title Linked to moda Marker Interface
 *
 * @notice Marks smart contracts which are linked to ModaERC20 token instance upon construction,
 *      all these smart contracts share a common moda() address getter
 *
 * @notice Implementing smart contracts MUST verify that they get linked to real ModaERC20 instance
 *      and that moda() getter returns this very same instance address
 *
 * @author Basil Gorin
 */
interface ILinkedToMODA {
  /**
   * @notice Getter for a verified MODAERC20 instance address
   *
   * @return MODAERC20 token instance address smart contract is linked to
   */
  function moda() external view returns (address);
}

File 14 of 32 : ModaAware.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.6;

import './ILinkedToMODA.sol';
import './ModaConstants.sol';
import './Token.sol';

/**
 * @title Moda Aware
 *
 * @notice Helper smart contract to be inherited by other smart contracts requiring to
 *      be linked to verified ModaERC20 instance and performing some basic tasks on it
 *
 * @author Basil Gorin
 * @author Kevin Brown (Moda DAO)
 */
abstract contract ModaAware is ILinkedToMODA {
	/// @dev Link to MODA ERC20 Token ModaERC20 instance
	address public immutable override moda;

	/**
	 * @dev Creates ModaAware instance, requiring to supply deployed ModaERC20 instance address
	 *
	 * @param _moda deployed ModaERC20 instance address
	 */
	constructor(address _moda) {
		// verify MODA address is set and is correct
		require(_moda != address(0), 'MODA address not set');
		require(Token(_moda).TOKEN_UID() == ModaConstants.TOKEN_UID, 'unexpected TOKEN_UID');

		// write MODA address
		moda = _moda;
	}

	/**
	 * @dev Executes ModaERC20.mint(_to, _values)
	 *      on the bound ModaERC20 instance
	 *
	 * @dev Reentrancy safe due to the ModaERC20 design
	 */
	function mintModa(address _to, uint256 _value) internal {
		// just delegate call to the target
		Token(moda).mint(_to, _value);
	}
}

// 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.0;

/**
 * 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);
      }
    }
  }
}

// SPDX-License-Identifier: MIT
pragma solidity 0.8.6;

import '@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol';
import '@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol';
import '@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol';
import '@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol';
import './IMintableToken.sol';
import './ModaConstants.sol';

contract Token is
	Initializable,
	ERC20Upgradeable,
	UUPSUpgradeable,
	AccessControlUpgradeable,
	IMintableToken
{
	uint256 public holderCount;
	address public vestingContract;

	function TOKEN_UID() external pure returns (uint256) {
		return ModaConstants.TOKEN_UID;
	}

	/**
	 * @dev Our constructor (with UUPS upgrades we need to use initialize(), but this is only
	 *      able to be called once because of the initializer modifier.
	 */
	function initialize(address[] memory recipients, uint256[] memory amounts) public initializer {
		require(recipients.length == amounts.length, 'Token: recipients and amounts must match');

		__ERC20_init('moda', 'MODA');

		uint256 length = recipients.length;
		for (uint256 i = 0; i < length; i++) {
			_mintWithCount(recipients[i], amounts[i]);
		}

		__AccessControl_init();
		_setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
		_setupRole(ModaConstants.ROLE_UPGRADER, _msgSender());
		_setupRole(ModaConstants.ROLE_TOKEN_CREATOR, _msgSender());
	}

	/**
	 * @dev This function is required by Open Zeppelin's UUPS proxy implementation
	 *      and indicates whether a contract upgrade should go ahead or not.
	 *
	 *      This implementation only allows the contract owner to perform upgrades.
	 */
	function _authorizeUpgrade(address) internal view override onlyRole(ModaConstants.ROLE_UPGRADER) {}

	/**
	 * @dev Internal function to manage the holderCount variable that should be called
	 *      BEFORE transfers alter balances.
	 */
	function _updateCountOnTransfer(
		address from,
		address to,
		uint256 amount
	) private {
		if (from != to) {
			if (balanceOf(to) == 0 && amount > 0) {
				++holderCount;
			}

			if (balanceOf(from) == amount && amount > 0) {
				--holderCount;
			}
		}
	}

	/**
	 * @dev A private function that mints while maintaining the holder count variable.
	 */
	function _mintWithCount(address to, uint256 amount) private {
		_updateCountOnTransfer(address(0), to, amount);
		_mint(to, amount);
	}

	/**
	 * @dev Mints (creates) some tokens to address specified
	 * @dev The value specified is treated as is without taking
	 *      into account what `decimals` value is
	 * @dev Behaves effectively as `mintTo` function, allowing
	 *      to specify an address to mint tokens to
	 * @dev Requires sender to have `ROLE_TOKEN_CREATOR` permission
	 *
	 * @dev Throws on overflow, if totalSupply + _value doesn't fit into uint256
	 *
	 * @param _to an address to mint tokens to
	 * @param _value an amount of tokens to mint (create)
	 */
	function mint(address _to, uint256 _value) external override onlyRole(ModaConstants.ROLE_TOKEN_CREATOR) {
		// non-zero recipient address check
		require(_to != address(0), 'ERC20: mint to the zero address'); // Zeppelin msg
		if (_value == 0) return;

		// non-zero _value and arithmetic overflow check on the total supply
		// this check automatically secures arithmetic overflow on the individual balance
		require(totalSupply() + _value > totalSupply(), 'zero value mint or arithmetic overflow');

		// uint256 overflow check (required by voting delegation)
		require(totalSupply() + _value <= type(uint192).max, 'total supply overflow (uint192)');

		// perform mint with ERC20 transfer event
		_mintWithCount(_to, _value);
	}

	/**
	 * @dev ERC20 transfer function. Overridden to maintain holder count variable.
	 */
	function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
		_updateCountOnTransfer(_msgSender(), recipient, amount);
		return super.transfer(recipient, amount);
	}

	/**
	 * @dev ERC20 transferFrom function. Overridden to maintain holder count variable.
	 */
	function transferFrom(
		address sender,
		address recipient,
		uint256 amount
	) public virtual override returns (bool) {
		_updateCountOnTransfer(sender, recipient, amount);
		return super.transferFrom(sender, recipient, amount);
	}
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/AccessControl.sol)

pragma solidity ^0.8.0;

import "./IAccessControlUpgradeable.sol";
import "../utils/ContextUpgradeable.sol";
import "../utils/StringsUpgradeable.sol";
import "../utils/introspection/ERC165Upgradeable.sol";
import "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms. This is a lightweight version that doesn't allow enumerating role
 * members except through off-chain means by accessing the contract event logs. Some
 * applications may benefit from on-chain enumerability, for those cases see
 * {AccessControlEnumerable}.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it.
 */
abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable {
    function __AccessControl_init() internal onlyInitializing {
        __Context_init_unchained();
        __ERC165_init_unchained();
        __AccessControl_init_unchained();
    }

    function __AccessControl_init_unchained() internal onlyInitializing {
    }
    struct RoleData {
        mapping(address => bool) members;
        bytes32 adminRole;
    }

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with a standardized message including the required role.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     *
     * _Available since v4.1._
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role, _msgSender());
        _;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) public view override returns (bool) {
        return _roles[role].members[account];
    }

    /**
     * @dev Revert with a standard message if `account` is missing `role`.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     */
    function _checkRole(bytes32 role, address account) internal view {
        if (!hasRole(role, account)) {
            revert(
                string(
                    abi.encodePacked(
                        "AccessControl: account ",
                        StringsUpgradeable.toHexString(uint160(account), 20),
                        " is missing role ",
                        StringsUpgradeable.toHexString(uint256(role), 32)
                    )
                )
            );
        }
    }

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) public view override returns (bytes32) {
        return _roles[role].adminRole;
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _grantRole(role, account);
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _revokeRole(role, account);
    }

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been revoked `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) public virtual override {
        require(account == _msgSender(), "AccessControl: can only renounce roles for self");

        _revokeRole(role, account);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event. Note that unlike {grantRole}, this function doesn't perform any
     * checks on the calling account.
     *
     * [WARNING]
     * ====
     * This function should only be called from the constructor when setting
     * up the initial roles for the system.
     *
     * Using this function in any other way is effectively circumventing the admin
     * system imposed by {AccessControl}.
     * ====
     *
     * NOTE: This function is deprecated in favor of {_grantRole}.
     */
    function _setupRole(bytes32 role, address account) internal virtual {
        _grantRole(role, account);
    }

    /**
     * @dev Sets `adminRole` as ``role``'s admin role.
     *
     * Emits a {RoleAdminChanged} event.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
        bytes32 previousAdminRole = getRoleAdmin(role);
        _roles[role].adminRole = adminRole;
        emit RoleAdminChanged(role, previousAdminRole, adminRole);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * Internal function without access restriction.
     */
    function _grantRole(bytes32 role, address account) internal virtual {
        if (!hasRole(role, account)) {
            _roles[role].members[account] = true;
            emit RoleGranted(role, account, _msgSender());
        }
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * Internal function without access restriction.
     */
    function _revokeRole(bytes32 role, address account) internal virtual {
        if (hasRole(role, account)) {
            _roles[role].members[account] = false;
            emit RoleRevoked(role, account, _msgSender());
        }
    }
    uint256[49] private __gap;
}

File 18 of 32 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/utils/Initializable.sol)

pragma solidity ^0.8.0;

import "../../utils/AddressUpgradeable.sol";

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the
 * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() initializer {}
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     */
    bool private _initialized;

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

    /**
     * @dev Modifier to protect an initializer function from being invoked twice.
     */
    modifier initializer() {
        // If the contract is initializing we ignore whether _initialized is set in order to support multiple
        // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the
        // contract may have been reentered.
        require(_initializing ? _isConstructor() : !_initialized, "Initializable: contract is already initialized");

        bool isTopLevelCall = !_initializing;
        if (isTopLevelCall) {
            _initializing = true;
            _initialized = true;
        }

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} modifier, directly or indirectly.
     */
    modifier onlyInitializing() {
        require(_initializing, "Initializable: contract is not initializing");
        _;
    }

    function _isConstructor() private view returns (bool) {
        return !AddressUpgradeable.isContract(address(this));
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/utils/UUPSUpgradeable.sol)

pragma solidity ^0.8.0;

import "../ERC1967/ERC1967UpgradeUpgradeable.sol";
import "./Initializable.sol";

/**
 * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
 * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
 *
 * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
 * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
 * `UUPSUpgradeable` with a custom implementation of upgrades.
 *
 * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
 *
 * _Available since v4.1._
 */
abstract contract UUPSUpgradeable is Initializable, ERC1967UpgradeUpgradeable {
    function __UUPSUpgradeable_init() internal onlyInitializing {
        __ERC1967Upgrade_init_unchained();
        __UUPSUpgradeable_init_unchained();
    }

    function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
    }
    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment
    address private immutable __self = address(this);

    /**
     * @dev Check that the execution is being performed through a delegatecall call and that the execution context is
     * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case
     * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
     * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
     * fail.
     */
    modifier onlyProxy() {
        require(address(this) != __self, "Function must be called through delegatecall");
        require(_getImplementation() == __self, "Function must be called through active proxy");
        _;
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     */
    function upgradeTo(address newImplementation) external virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallSecure(newImplementation, new bytes(0), false);
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
     * encoded in `data`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     */
    function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallSecure(newImplementation, data, true);
    }

    /**
     * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
     * {upgradeTo} and {upgradeToAndCall}.
     *
     * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
     *
     * ```solidity
     * function _authorizeUpgrade(address) internal override onlyOwner {}
     * ```
     */
    function _authorizeUpgrade(address newImplementation) internal virtual;
    uint256[50] private __gap;
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/ERC20.sol)

pragma solidity ^0.8.0;

import "./IERC20Upgradeable.sol";
import "./extensions/IERC20MetadataUpgradeable.sol";
import "../../utils/ContextUpgradeable.sol";
import "../../proxy/utils/Initializable.sol";

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 * For a generic mechanism see {ERC20PresetMinterPauser}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * We have followed general OpenZeppelin 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 ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable {
    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.
     */
    function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing {
        __Context_init_unchained();
        __ERC20_init_unchained(name_, symbol_);
    }

    function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {
        _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 {}
    uint256[45] private __gap;
}

// SPDX-License-Identifier: MIT
pragma solidity 0.8.6;

/**
 * @dev Interface for a token that will allow mints from a vesting contract
 */
interface IMintableToken {
	function mint(address to, uint256 amount) external;
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)

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
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract ContextUpgradeable is Initializable {
    function __Context_init() internal onlyInitializing {
        __Context_init_unchained();
    }

    function __Context_init_unchained() internal onlyInitializing {
    }
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
    uint256[50] private __gap;
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library StringsUpgradeable {
    bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _HEX_SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)

pragma solidity ^0.8.0;

import "./IERC165Upgradeable.sol";
import "../../proxy/utils/Initializable.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {
    function __ERC165_init() internal onlyInitializing {
        __ERC165_init_unchained();
    }

    function __ERC165_init_unchained() internal onlyInitializing {
    }
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165Upgradeable).interfaceId;
    }
    uint256[50] private __gap;
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)

pragma solidity ^0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library AddressUpgradeable {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/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 (proxy/ERC1967/ERC1967Upgrade.sol)

pragma solidity ^0.8.2;

import "../beacon/IBeaconUpgradeable.sol";
import "../../utils/AddressUpgradeable.sol";
import "../../utils/StorageSlotUpgradeable.sol";
import "../utils/Initializable.sol";

/**
 * @dev This abstract contract provides getters and event emitting update functions for
 * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
 *
 * _Available since v4.1._
 *
 * @custom:oz-upgrades-unsafe-allow delegatecall
 */
abstract contract ERC1967UpgradeUpgradeable is Initializable {
    function __ERC1967Upgrade_init() internal onlyInitializing {
        __ERC1967Upgrade_init_unchained();
    }

    function __ERC1967Upgrade_init_unchained() internal onlyInitializing {
    }
    // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
    bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;

    /**
     * @dev Storage slot with the address of the current implementation.
     * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;

    /**
     * @dev Emitted when the implementation is upgraded.
     */
    event Upgraded(address indexed implementation);

    /**
     * @dev Returns the current implementation address.
     */
    function _getImplementation() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 implementation slot.
     */
    function _setImplementation(address newImplementation) private {
        require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract");
        StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
    }

    /**
     * @dev Perform implementation upgrade
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeTo(address newImplementation) internal {
        _setImplementation(newImplementation);
        emit Upgraded(newImplementation);
    }

    /**
     * @dev Perform implementation upgrade with additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCall(
        address newImplementation,
        bytes memory data,
        bool forceCall
    ) internal {
        _upgradeTo(newImplementation);
        if (data.length > 0 || forceCall) {
            _functionDelegateCall(newImplementation, data);
        }
    }

    /**
     * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCallSecure(
        address newImplementation,
        bytes memory data,
        bool forceCall
    ) internal {
        address oldImplementation = _getImplementation();

        // Initial upgrade and setup call
        _setImplementation(newImplementation);
        if (data.length > 0 || forceCall) {
            _functionDelegateCall(newImplementation, data);
        }

        // Perform rollback test if not already in progress
        StorageSlotUpgradeable.BooleanSlot storage rollbackTesting = StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT);
        if (!rollbackTesting.value) {
            // Trigger rollback using upgradeTo from the new implementation
            rollbackTesting.value = true;
            _functionDelegateCall(
                newImplementation,
                abi.encodeWithSignature("upgradeTo(address)", oldImplementation)
            );
            rollbackTesting.value = false;
            // Check rollback was effective
            require(oldImplementation == _getImplementation(), "ERC1967Upgrade: upgrade breaks further upgrades");
            // Finally reset to the new implementation and log the upgrade
            _upgradeTo(newImplementation);
        }
    }

    /**
     * @dev Storage slot with the admin of the contract.
     * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;

    /**
     * @dev Emitted when the admin account has changed.
     */
    event AdminChanged(address previousAdmin, address newAdmin);

    /**
     * @dev Returns the current admin.
     */
    function _getAdmin() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 admin slot.
     */
    function _setAdmin(address newAdmin) private {
        require(newAdmin != address(0), "ERC1967: new admin is the zero address");
        StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
    }

    /**
     * @dev Changes the admin of the proxy.
     *
     * Emits an {AdminChanged} event.
     */
    function _changeAdmin(address newAdmin) internal {
        emit AdminChanged(_getAdmin(), newAdmin);
        _setAdmin(newAdmin);
    }

    /**
     * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
     * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
     */
    bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;

    /**
     * @dev Emitted when the beacon is upgraded.
     */
    event BeaconUpgraded(address indexed beacon);

    /**
     * @dev Returns the current beacon.
     */
    function _getBeacon() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value;
    }

    /**
     * @dev Stores a new beacon in the EIP1967 beacon slot.
     */
    function _setBeacon(address newBeacon) private {
        require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract");
        require(
            AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()),
            "ERC1967: beacon implementation is not a contract"
        );
        StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon;
    }

    /**
     * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
     * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
     *
     * Emits a {BeaconUpgraded} event.
     */
    function _upgradeBeaconToAndCall(
        address newBeacon,
        bytes memory data,
        bool forceCall
    ) internal {
        _setBeacon(newBeacon);
        emit BeaconUpgraded(newBeacon);
        if (data.length > 0 || forceCall) {
            _functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data);
        }
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {
        require(AddressUpgradeable.isContract(target), "Address: delegate call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return AddressUpgradeable.verifyCallResult(success, returndata, "Address: low-level delegate call failed");
    }
    uint256[50] private __gap;
}

File 29 of 32 : IBeaconUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)

pragma solidity ^0.8.0;

/**
 * @dev This is the interface that {BeaconProxy} expects of its beacon.
 */
interface IBeaconUpgradeable {
    /**
     * @dev Must return an address that can be used as a delegate call target.
     *
     * {BeaconProxy} will check that this address is a contract.
     */
    function implementation() external view returns (address);
}

// SPDX-License-Identifier: MIT
// 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 StorageSlotUpgradeable {
    struct AddressSlot {
        address value;
    }

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

    /**
     * @dev Returns an `AddressSlot` with member `value` located at `slot`.
     */
    function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `BooleanSlot` with member `value` located at `slot`.
     */
    function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
     */
    function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Uint256Slot` with member `value` located at `slot`.
     */
    function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
        assembly {
            r.slot := slot
        }
    }
}

// SPDX-License-Identifier: MIT
// 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 IERC20Upgradeable {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) external returns (bool);

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC20Upgradeable.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
interface IERC20MetadataUpgradeable is IERC20Upgradeable {
    /**
     * @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);
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"address","name":"_moda","type":"address"},{"internalType":"address","name":"_modaPoolFactory","type":"address"},{"internalType":"address","name":"_modaPool","type":"address"},{"internalType":"address","name":"_poolToken","type":"address"},{"internalType":"uint32","name":"_weight","type":"uint32"},{"internalType":"uint256","name":"_startTimestamp","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_by","type":"address"},{"indexed":false,"internalType":"uint32","name":"_fromVal","type":"uint32"},{"indexed":false,"internalType":"uint32","name":"_toVal","type":"uint32"}],"name":"PoolWeightUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_from","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_to","type":"uint256"}],"name":"RewardLockingPeriodUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_by","type":"address"},{"indexed":false,"internalType":"uint256","name":"depositId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"lockedFrom","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"lockedUntil","type":"uint256"}],"name":"StakeLockUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_by","type":"address"},{"indexed":true,"internalType":"address","name":"_from","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Staked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_by","type":"address"},{"indexed":true,"internalType":"address","name":"_to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Unstaked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_by","type":"address"},{"indexed":true,"internalType":"address","name":"_to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"YieldClaimed","type":"event"},{"inputs":[],"name":"POOL_UID","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_depositId","type":"uint256"}],"name":"getDeposit","outputs":[{"components":[{"internalType":"uint256","name":"tokenAmount","type":"uint256"},{"internalType":"uint256","name":"weight","type":"uint256"},{"internalType":"uint256","name":"lockedFrom","type":"uint256"},{"internalType":"uint256","name":"lockedUntil","type":"uint256"},{"internalType":"bool","name":"isYield","type":"bool"}],"internalType":"struct IPool.Deposit","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"getDepositsLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"moda","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"modaPoolFactory","outputs":[{"internalType":"contract ModaPoolFactory","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_staker","type":"address"}],"name":"pendingYieldRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"poolToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"poolTokenReserve","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"processRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rewardLockingPeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"newRewardLockingPeriod","type":"uint256"}],"name":"setRewardLockingPeriod","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_weight","type":"uint32"}],"name":"setWeight","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_lockUntil","type":"uint256"}],"name":"stake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_staker","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"stakeAsPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"startTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_depositId","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"unstake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"depositId","type":"uint256"},{"internalType":"uint256","name":"lockedUntil","type":"uint256"}],"name":"updateStakeLock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"users","outputs":[{"internalType":"uint256","name":"tokenAmount","type":"uint256"},{"internalType":"uint256","name":"totalWeight","type":"uint256"},{"internalType":"uint256","name":"lastProcessedRewards","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"usersLockingWeight","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"weight","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"}]

61012060405262c5c1006005553480156200001957600080fd5b5060405162002cc238038062002cc28339810160408190526200003c91620007e7565b858585858585856200004e336200077a565b6001600160a01b038116620000aa5760405162461bcd60e51b815260206004820152601460248201527f4d4f44412061646472657373206e6f742073657400000000000000000000000060448201526064015b60405180910390fd5b60008051602062002ca2833981519152816001600160a01b0316638a114e136040518163ffffffff1660e01b815260040160206040518083038186803b158015620000f457600080fd5b505afa15801562000109573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200012f91906200086b565b146200017e5760405162461bcd60e51b815260206004820152601460248201527f756e657870656374656420544f4b454e5f5549440000000000000000000000006044820152606401620000a1565b60601b6001600160601b031916608052600180556001600160a01b038316620001ea5760405162461bcd60e51b815260206004820152601a60248201527f706f6f6c20746f6b656e2061646472657373206e6f74207365740000000000006044820152606401620000a1565b6001600160a01b038516620002425760405162461bcd60e51b815260206004820152601c60248201527f706f6f6c20666163746f72792061646472657373206e6f7420736574000000006044820152606401620000a1565b60008263ffffffff16116200029a5760405162461bcd60e51b815260206004820152601360248201527f706f6f6c20776569676874206e6f7420736574000000000000000000000000006044820152606401620000a1565b42811015620002ec5760405162461bcd60e51b815260206004820152601460248201527f737461727420616c7265616479207061737365640000000000000000000000006044820152606401620000a1565b846001600160a01b031663a85adeab6040518163ffffffff1660e01b815260040160206040518083038186803b1580156200032657600080fd5b505afa1580156200033b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200036191906200086b565b8110620003bc5760405162461bcd60e51b815260206004820152602260248201527f737461727420746f6f206c61746520636f6d706172656420746f20666163746f604482015261727960f01b6064820152608401620000a1565b6001600160a01b038416620003d3576000620003d6565b60015b866001600160a01b0316846001600160a01b031614620003f8576000620003fb565b60015b1860ff16600114620004765760405162461bcd60e51b815260206004820152603860248201527f4569746865722061204d4f444120706f6f6c206f72206d616e6167652065787460448201527f65726e616c20746f6b656e732c206e6576657220626f746800000000000000006064820152608401620000a1565b60008051602062002ca2833981519152866001600160a01b0316638a114e136040518163ffffffff1660e01b815260040160206040518083038186803b158015620004c057600080fd5b505afa158015620004d5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620004fb91906200086b565b146200054a5760405162461bcd60e51b815260206004820152601660248201527f4d6f646120544f4b454e5f55494420696e76616c6964000000000000000000006044820152606401620000a1565b7f871acfd60315c19d4e011a9b2fe668860c17caf2dea3882043e8270ec8b5696c856001600160a01b031663f70b7fce6040518163ffffffff1660e01b815260040160206040518083038186803b158015620005a557600080fd5b505afa158015620005ba573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620005e091906200086b565b146200062f5760405162461bcd60e51b815260206004820152601860248201527f4d6f646120464143544f52595f55494420696e76616c696400000000000000006044820152606401620000a1565b6001600160a01b0384161562000724577f8ca5f5bb5e4f02345a019a993ce37018dd549b22e88027f4f5c1f614ef6fb3c0846001600160a01b0316635420a8546040518163ffffffff1660e01b815260040160206040518083038186803b1580156200069a57600080fd5b505afa158015620006af573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620006d591906200086b565b14620007245760405162461bcd60e51b815260206004820152601560248201527f4d6f646120504f4f4c5f55494420696e76616c696400000000000000000000006044820152606401620000a1565b606093841b6001600160601b031990811660a05294841b851660e0529190921b90921660c0526003805463ffffffff191663ffffffff909216919091179055610100525050600060065550620008859350505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80516001600160a01b0381168114620007e257600080fd5b919050565b60008060008060008060c087890312156200080157600080fd5b6200080c87620007ca565b95506200081c60208801620007ca565b94506200082c60408801620007ca565b93506200083c60608801620007ca565b9250608087015163ffffffff811681146200085657600080fd5b8092505060a087015190509295509295509295565b6000602082840312156200087e57600080fd5b5051919050565b60805160601c60a05160601c60c05160601c60e05160601c610100516123476200095b600039600081816103d20152818161044001528181610689015281816106c20152611587015260008181610162015281816104810152818161070b015281816107990152818161093d01528181610a210152611be001526000818161037b01528181610e1b015281816112bb015281816116910152818161173801528181611cfa0152611d8701526000818161140a01526114a40152600081816103ab01528181610df101526112de01526123476000f3fe608060405234801561001057600080fd5b50600436106101585760003560e01c80638da5cb5b116100c3578063ce1115411161007c578063ce1115411461039d578063cfddb824146103a6578063e6fd48bc146103cd578063e8d3cad5146103f4578063f2fde38b14610421578063f9fc0d071461043457600080fd5b80638da5cb5b146102da5780639e2c8a5b146102eb578063a1aab33f146102fe578063a87430ba14610323578063beb0ed6c1461036d578063cbdf382c1461037657600080fd5b806345b231581161011557806345b231581461024a5780635420a8541461025d5780635d0e1f8f1461028357806370a0823114610296578063715018a6146102bf5780637b0472f0146102c757600080fd5b806309b30bef1461015d5780631984db99146101a15780631cc05400146101c25780632726b506146101cb5780634087aeb71461022257806344cc892d14610237575b600080fd5b6101847f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020015b60405180910390f35b6101b46101af3660046120be565b61043c565b604051908152602001610198565b6101b460055481565b6101de6101d93660046120d9565b610878565b6040516101989190600060a0820190508251825260208301516020830152604083015160408301526060830151606083015260808301511515608083015292915050565b610235610230366004612179565b610932565b005b6102356102453660046120d9565b610a0c565b610235610258366004612125565b610c6c565b7f8ca5f5bb5e4f02345a019a993ce37018dd549b22e88027f4f5c1f614ef6fb3c06101b4565b610235610291366004612157565b610cdb565b6101b46102a43660046120be565b6001600160a01b031660009081526002602052604090205490565b610235610cf4565b6102356102d5366004612157565b610d2a565b6000546001600160a01b0316610184565b6102356102f9366004612157565b610d37565b60035461030e9063ffffffff1681565b60405163ffffffff9091168152602001610198565b6103526103313660046120be565b60026020526000908152604090208054600182015460039092015490919083565b60408051938452602084019290925290820152606001610198565b6101b460045481565b6101847f000000000000000000000000000000000000000000000000000000000000000081565b6101b460065481565b6101847f000000000000000000000000000000000000000000000000000000000000000081565b6101b47f000000000000000000000000000000000000000000000000000000000000000081565b6101b46104023660046120be565b6001600160a01b03166000908152600260208190526040909120015490565b61023561042f3660046120be565b610d42565b610235610ddd565b60007f000000000000000000000000000000000000000000000000000000000000000042101561046e57506000919050565b60045461047d57506000919050565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663a85adeab6040518163ffffffff1660e01b815260040160206040518083038186803b1580156104d857600080fd5b505afa1580156104ec573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610510919061213e565b905060008142116105215742610523565b815b9050600060026000866001600160a01b03166001600160a01b03168152602001908152602001600020604051806080016040529081600082015481526020016001820154815260200160028201805480602002602001604051908101604052809291908181526020016000905b828210156105f35760008481526020908190206040805160a081018252600586029092018054835260018082015484860152600282015492840192909252600381015460608401526004015460ff16151560808301529083529092019101610590565b5050505081526020016003820154815250509050818160600151111561061e57506000949350505050565b60408101515160018110156106395750600095945050505050565b604082015160009061064c600184612290565b8151811061065c5761065c6122e9565b6020026020010151905060008084606001511161067d578160400151610683565b83606001515b905060007f000000000000000000000000000000000000000000000000000000000000000086106106bd576106b88287612290565b6106e7565b6106e77f000000000000000000000000000000000000000000000000000000000000000087612290565b6040516339e21bad60e01b8152600481018890529091506000906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906339e21bad9060240160206040518083038186803b15801561074d57600080fd5b505afa158015610761573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610785919061213e565b905060006107938383612271565b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166396c82e576040518163ffffffff1660e01b815260040160206040518083038186803b1580156107f057600080fd5b505afa158015610804573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108289190612196565b60035463ffffffff9182169161083f911684612271565b610849919061224f565b905060045488602001518261085e9190612271565b610868919061224f565b9c9b505050505050505050505050565b6108ac6040518060a00160405280600081526020016000815260200160008152602001600081526020016000151581525090565b6001600160a01b0383166000908152600260208190526040909120018054839081106108da576108da6122e9565b60009182526020918290206040805160a0810182526005909302909101805483526001810154938301939093526002830154908201526003820154606082015260049091015460ff1615156080820152905092915050565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146109af5760405162461bcd60e51b815260206004820152601b60248201527f4163636573732064656e6965643a20666163746f7279206f6e6c79000000000060448201526064015b60405180910390fd5b6003805463ffffffff83811663ffffffff19831681179093556040805191909216808252602082019390935233917f06555fe9dc8cbe328585a0c60ae1b7aafe71c28a706c2769d6cb4ee6e3e44e46910160405180910390a25050565b604051631e1c6a0760e01b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690631e1c6a079060240160206040518083038186803b158015610a6b57600080fd5b505afa158015610a7f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aa39190612103565b610ae85760405162461bcd60e51b81526020600482015260166024820152751c1bdbdb081a5cc81b9bdd081c9959da5cdd195c995960521b60448201526064016109a6565b6001600160a01b0382166000908152600260205260409020805415610b1257610b1083610de2565b505b6000610b22620f42406002612271565b610b2c9084612271565b905060006040518060a0016040528085815260200183815260200142815260200160055442610b5b9190612237565b815260200160011515815250905083836000016000828254610b7d9190612237565b9250508190555081836001016000828254610b989190612237565b90915550506002838101805460018082018355600092835260208084208651600590940201928355850151908201556040840151928101929092556060830151600383015560808301516004928301805460ff1916911515919091179055815484929190610c07908490612237565b925050819055508360066000828254610c209190612237565b90915550506040518481526001600160a01b0386169081907f5dac0c1b1112564a045ba943c9d50270893e8e826c49be8e7073adc713ab7bd79060200160405180910390a35050505050565b6000546001600160a01b03163314610c965760405162461bcd60e51b81526004016109a690612202565b600580549082905560408051828152602081018490527f814491b5eba7a1a7bc3593a7464fc8eef3d984302911041a34ed32748331ffb7910160405180910390a15050565b610ce433610de2565b50610cf0338383610e66565b5050565b6000546001600160a01b03163314610d1e5760405162461bcd60e51b81526004016109a690612202565b610d286000611108565b565b610cf03383836000611158565b610cf0338383611181565b6000546001600160a01b03163314610d6c5760405162461bcd60e51b81526004016109a690612202565b6001600160a01b038116610dd15760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016109a6565b610dda81611108565b50565b610dda335b6000610ded8261127f565b90507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03167f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03161415610e61578060066000828254610e5b9190612237565b90915550505b919050565b428111610eb55760405162461bcd60e51b815260206004820152601c60248201527f6c6f636b2073686f756c6420626520696e20746865206675747572650000000060448201526064016109a6565b6001600160a01b03831660009081526002602081905260408220908101805491929185908110610ee757610ee76122e9565b9060005260206000209060050201905080600301548311610f3d5760405162461bcd60e51b815260206004820152601060248201526f696e76616c6964206e6577206c6f636b60801b60448201526064016109a6565b6002810154610fae576301e13380610f554285612290565b1115610fa35760405162461bcd60e51b815260206004820152601b60248201527f6d6178206c6f636b20706572696f64206973203336352064617973000000000060448201526064016109a6565b426002820155611011565b6301e13380816002015484610fc39190612290565b11156110115760405162461bcd60e51b815260206004820152601b60248201527f6d6178206c6f636b20706572696f64206973203336352064617973000000000060448201526064016109a6565b600381018390558054600282015460009190620f4240906301e1338090829061103a9089612290565b6110449190612271565b61104e919061224f565b6110589190612237565b6110629190612271565b600180840180549083905590850154919250908290611082908390612290565b61108c9190612237565b600185015560045482906110a1908390612290565b6110ab9190612237565b600455600283015460408051888152602081019290925281018690526001600160a01b038816907f790686c73b4b8be3ff3b3a3a881cf875be2b60b24e2a6dd42eef3e7fe6e650ef9060600160405180910390a250505050505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b61116484848484611547565b82600660008282546111769190612237565b909155505050505050565b6001600160a01b038316600090815260026020819052604082209081018054919291859081106111b3576111b36122e9565b60009182526020918290206040805160a08101825260059093029091018054835260018101549383019390935260028301549082015260038201546060820181905260049092015460ff1615156080820152915042116112555760405162461bcd60e51b815260206004820152601860248201527f6465706f736974206e6f742079657420756e6c6f636b6564000000000000000060448201526064016109a6565b82600660008282546112679190612290565b909155506112789050858585611984565b5050505050565b600061128a8261043c565b90508061129957506000919050565b6001600160a01b038083166000908152600260205260409020426003820155907f000000000000000000000000000000000000000000000000000000000000000081167f00000000000000000000000000000000000000000000000000000000000000009091161415611408576000611316620f42406002612271565b6113209084612271565b905060006040518060a001604052808581526020018381526020014281526020016005544261134f9190612237565b8152600160209182018190526002868101805480840182556000918252848220865160059092020190815593850151928401929092556040840151908301556060830151600383015560808301516004909201805460ff191692151592909217909155845491925085918591906113c7908490612237565b92505081905550818360010160008282546113e29190612237565b9250508190555081600460008282546113fb9190612237565b9091555061150192505050565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031661147e5760405162461bcd60e51b815260206004820152601860248201527f6d6f6461506f6f6c2061646472657373206973207a65726f000000000000000060448201526064016109a6565b6040516344cc892d60e01b81526001600160a01b038481166004830152602482018490527f000000000000000000000000000000000000000000000000000000000000000016906344cc892d90604401600060405180830381600087803b1580156114e857600080fd5b505af11580156114fc573d6000803e3d6000fd5b505050505b6040518281526001600160a01b0384169033907ff3055bc8d92d9c8d2f12b45d112dd345cd2cfd17292b8d65c5642ac6f912dfd79060200160405180910390a350919050565b600083116115855760405162461bcd60e51b815260206004820152600b60248201526a1e995c9bc8185b5bdd5b9d60aa1b60448201526064016109a6565b7f00000000000000000000000000000000000000000000000000000000000000004210156115e75760405162461bcd60e51b815260206004820152600f60248201526e706f6f6c206e6f742061637469766560881b60448201526064016109a6565b81158061160b5750428211801561160b57506301e133806116084284612290565b11155b61164f5760405162461bcd60e51b81526020600482015260156024820152741a5b9d985b1a59081b1bd8dac81a5b9d195c9d985b605a1b60448201526064016109a6565b6001600160a01b03841660009081526002602052604090208054156116795761167785610de2565b505b6040516370a0823160e01b81523060048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a082319060240160206040518083038186803b1580156116db57600080fd5b505afa1580156116ef573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611713919061213e565b9050611720333087611c9d565b6040516370a0823160e01b81523060048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a082319060240160206040518083038186803b15801561178257600080fd5b505afa158015611796573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117ba919061213e565b905060006117c88383612290565b90504286600081156118185783620f42406301e133806117e88686612290565b6117f590620f4240612271565b6117ff919061224f565b6118099190612237565b6118139190612271565b611825565b61182584620f4240612271565b90506000811161186e5760405162461bcd60e51b81526020600482015260146024820152735374616b6520776569676874206973207a65726f60601b60448201526064016109a6565b6040805160a0810182528581526020808201848152928201868152606083018681528c15156080850190815260028d810180546001808201835560009283529682208851600590920201908155975195880195909555925192860192909255516003850155516004909301805460ff1916931515939093179092558854909186918a91906118fd908490612237565b92505081905550818860010160008282546119189190612237565b9250508190555081600460008282546119319190612237565b90915550506040518b81526001600160a01b038d169033907f5dac0c1b1112564a045ba943c9d50270893e8e826c49be8e7073adc713ab7bd79060200160405180910390a3505050505050505050505050565b600081116119c25760405162461bcd60e51b815260206004820152600b60248201526a1e995c9bc8185b5bdd5b9d60aa1b60448201526064016109a6565b6001600160a01b038316600090815260026020819052604082209081018054919291859081106119f4576119f46122e9565b600091825260209091206005909102016004810154815491925060ff1690841115611a585760405162461bcd60e51b8152602060048201526014602482015273616d6f756e742065786365656473207374616b6560601b60448201526064016109a6565b611a6186610de2565b506001820154600383015460009015611acb578354611a81908790612290565b611a8e90620f4240612271565b6301e1338085600201548660030154611aa79190612290565b611ab1919061224f565b611abc906001612237565b611ac69190612271565b611ae5565b8354611ad8908790612290565b611ae590620f4240612271565b8454909150611af5908790612290565b611b4657846002018781548110611b0e57611b0e6122e9565b60009182526020822060059091020181815560018101829055600281018290556003810191909155600401805460ff19169055611b67565b85846000016000828254611b5a9190612290565b9091555050600184018190555b85856000016000828254611b7b9190612290565b909155505060018501548190611b92908490612290565b611b9c9190612237565b60018601556004548190611bb1908490612290565b611bbb9190612237565b6004558215611c495760405163e14bdb7160e01b8152336004820152602481018790527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063e14bdb7190604401600060405180830381600087803b158015611c2c57600080fd5b505af1158015611c40573d6000803e3d6000fd5b50505050611c53565b611c533387611d2a565b6040518681526001600160a01b0389169033907fd8654fcc8cf5b36d30b3f5e4688fc78118e6d68de60b9994e09902268b57c3e39060200160405180910390a35050505050505050565b60026001541415611cf05760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016109a6565b6002600155611d217f0000000000000000000000000000000000000000000000000000000000000000848484611db5565b50506001805550565b60026001541415611d7d5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016109a6565b6002600155611dad7f00000000000000000000000000000000000000000000000000000000000000008383611e26565b505060018055565b6040516001600160a01b0380851660248301528316604482015260648101829052611e209085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152611e5b565b50505050565b6040516001600160a01b038316602482015260448101829052611e5690849063a9059cbb60e01b90606401611de9565b505050565b6000611eb0826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611f2d9092919063ffffffff16565b805190915015611e565780806020019051810190611ece9190612103565b611e565760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016109a6565b6060611f3c8484600085611f46565b90505b9392505050565b606082471015611fa75760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016109a6565b843b611ff55760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016109a6565b600080866001600160a01b0316858760405161201191906121b3565b60006040518083038185875af1925050503d806000811461204e576040519150601f19603f3d011682016040523d82523d6000602084013e612053565b606091505b509150915061206382828661206e565b979650505050505050565b6060831561207d575081611f3f565b82511561208d5782518084602001fd5b8160405162461bcd60e51b81526004016109a691906121cf565b80356001600160a01b0381168114610e6157600080fd5b6000602082840312156120d057600080fd5b611f3f826120a7565b600080604083850312156120ec57600080fd5b6120f5836120a7565b946020939093013593505050565b60006020828403121561211557600080fd5b81518015158114611f3f57600080fd5b60006020828403121561213757600080fd5b5035919050565b60006020828403121561215057600080fd5b5051919050565b6000806040838503121561216a57600080fd5b50508035926020909101359150565b60006020828403121561218b57600080fd5b8135611f3f816122ff565b6000602082840312156121a857600080fd5b8151611f3f816122ff565b600082516121c58184602087016122a7565b9190910192915050565b60208152600082518060208401526121ee8160408501602087016122a7565b601f01601f19169190910160400192915050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6000821982111561224a5761224a6122d3565b500190565b60008261226c57634e487b7160e01b600052601260045260246000fd5b500490565b600081600019048311821515161561228b5761228b6122d3565b500290565b6000828210156122a2576122a26122d3565b500390565b60005b838110156122c25781810151838201526020016122aa565b83811115611e205750506000910152565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b63ffffffff81168114610dda57600080fdfea26469706673582212203a840e91bdbe3a282d4395a5abdc4c9fca5f47d85c23f50cd94836f69fb22f7064736f6c63430008060033c8de2a18ae1c61538a5f880f5c8eb7ff85aa3996c4363a27b1c6112a190e65b40000000000000000000000001117ac6ad6cdf1a3bc543bad3b133724620522d5000000000000000000000000503154cdd5710c8c26df1051eba183d04401436500000000000000000000000000000000000000000000000000000000000000000000000000000000000000001117ac6ad6cdf1a3bc543bad3b133724620522d500000000000000000000000000000000000000000000000000000000000000280000000000000000000000000000000000000000000000000000000064d2f578

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106101585760003560e01c80638da5cb5b116100c3578063ce1115411161007c578063ce1115411461039d578063cfddb824146103a6578063e6fd48bc146103cd578063e8d3cad5146103f4578063f2fde38b14610421578063f9fc0d071461043457600080fd5b80638da5cb5b146102da5780639e2c8a5b146102eb578063a1aab33f146102fe578063a87430ba14610323578063beb0ed6c1461036d578063cbdf382c1461037657600080fd5b806345b231581161011557806345b231581461024a5780635420a8541461025d5780635d0e1f8f1461028357806370a0823114610296578063715018a6146102bf5780637b0472f0146102c757600080fd5b806309b30bef1461015d5780631984db99146101a15780631cc05400146101c25780632726b506146101cb5780634087aeb71461022257806344cc892d14610237575b600080fd5b6101847f000000000000000000000000503154cdd5710c8c26df1051eba183d04401436581565b6040516001600160a01b0390911681526020015b60405180910390f35b6101b46101af3660046120be565b61043c565b604051908152602001610198565b6101b460055481565b6101de6101d93660046120d9565b610878565b6040516101989190600060a0820190508251825260208301516020830152604083015160408301526060830151606083015260808301511515608083015292915050565b610235610230366004612179565b610932565b005b6102356102453660046120d9565b610a0c565b610235610258366004612125565b610c6c565b7f8ca5f5bb5e4f02345a019a993ce37018dd549b22e88027f4f5c1f614ef6fb3c06101b4565b610235610291366004612157565b610cdb565b6101b46102a43660046120be565b6001600160a01b031660009081526002602052604090205490565b610235610cf4565b6102356102d5366004612157565b610d2a565b6000546001600160a01b0316610184565b6102356102f9366004612157565b610d37565b60035461030e9063ffffffff1681565b60405163ffffffff9091168152602001610198565b6103526103313660046120be565b60026020526000908152604090208054600182015460039092015490919083565b60408051938452602084019290925290820152606001610198565b6101b460045481565b6101847f0000000000000000000000001117ac6ad6cdf1a3bc543bad3b133724620522d581565b6101b460065481565b6101847f0000000000000000000000001117ac6ad6cdf1a3bc543bad3b133724620522d581565b6101b47f0000000000000000000000000000000000000000000000000000000064d2f57881565b6101b46104023660046120be565b6001600160a01b03166000908152600260208190526040909120015490565b61023561042f3660046120be565b610d42565b610235610ddd565b60007f0000000000000000000000000000000000000000000000000000000064d2f57842101561046e57506000919050565b60045461047d57506000919050565b60007f000000000000000000000000503154cdd5710c8c26df1051eba183d0440143656001600160a01b031663a85adeab6040518163ffffffff1660e01b815260040160206040518083038186803b1580156104d857600080fd5b505afa1580156104ec573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610510919061213e565b905060008142116105215742610523565b815b9050600060026000866001600160a01b03166001600160a01b03168152602001908152602001600020604051806080016040529081600082015481526020016001820154815260200160028201805480602002602001604051908101604052809291908181526020016000905b828210156105f35760008481526020908190206040805160a081018252600586029092018054835260018082015484860152600282015492840192909252600381015460608401526004015460ff16151560808301529083529092019101610590565b5050505081526020016003820154815250509050818160600151111561061e57506000949350505050565b60408101515160018110156106395750600095945050505050565b604082015160009061064c600184612290565b8151811061065c5761065c6122e9565b6020026020010151905060008084606001511161067d578160400151610683565b83606001515b905060007f0000000000000000000000000000000000000000000000000000000064d2f57886106106bd576106b88287612290565b6106e7565b6106e77f0000000000000000000000000000000000000000000000000000000064d2f57887612290565b6040516339e21bad60e01b8152600481018890529091506000906001600160a01b037f000000000000000000000000503154cdd5710c8c26df1051eba183d04401436516906339e21bad9060240160206040518083038186803b15801561074d57600080fd5b505afa158015610761573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610785919061213e565b905060006107938383612271565b905060007f000000000000000000000000503154cdd5710c8c26df1051eba183d0440143656001600160a01b03166396c82e576040518163ffffffff1660e01b815260040160206040518083038186803b1580156107f057600080fd5b505afa158015610804573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108289190612196565b60035463ffffffff9182169161083f911684612271565b610849919061224f565b905060045488602001518261085e9190612271565b610868919061224f565b9c9b505050505050505050505050565b6108ac6040518060a00160405280600081526020016000815260200160008152602001600081526020016000151581525090565b6001600160a01b0383166000908152600260208190526040909120018054839081106108da576108da6122e9565b60009182526020918290206040805160a0810182526005909302909101805483526001810154938301939093526002830154908201526003820154606082015260049091015460ff1615156080820152905092915050565b336001600160a01b037f000000000000000000000000503154cdd5710c8c26df1051eba183d04401436516146109af5760405162461bcd60e51b815260206004820152601b60248201527f4163636573732064656e6965643a20666163746f7279206f6e6c79000000000060448201526064015b60405180910390fd5b6003805463ffffffff83811663ffffffff19831681179093556040805191909216808252602082019390935233917f06555fe9dc8cbe328585a0c60ae1b7aafe71c28a706c2769d6cb4ee6e3e44e46910160405180910390a25050565b604051631e1c6a0760e01b81523360048201527f000000000000000000000000503154cdd5710c8c26df1051eba183d0440143656001600160a01b031690631e1c6a079060240160206040518083038186803b158015610a6b57600080fd5b505afa158015610a7f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aa39190612103565b610ae85760405162461bcd60e51b81526020600482015260166024820152751c1bdbdb081a5cc81b9bdd081c9959da5cdd195c995960521b60448201526064016109a6565b6001600160a01b0382166000908152600260205260409020805415610b1257610b1083610de2565b505b6000610b22620f42406002612271565b610b2c9084612271565b905060006040518060a0016040528085815260200183815260200142815260200160055442610b5b9190612237565b815260200160011515815250905083836000016000828254610b7d9190612237565b9250508190555081836001016000828254610b989190612237565b90915550506002838101805460018082018355600092835260208084208651600590940201928355850151908201556040840151928101929092556060830151600383015560808301516004928301805460ff1916911515919091179055815484929190610c07908490612237565b925050819055508360066000828254610c209190612237565b90915550506040518481526001600160a01b0386169081907f5dac0c1b1112564a045ba943c9d50270893e8e826c49be8e7073adc713ab7bd79060200160405180910390a35050505050565b6000546001600160a01b03163314610c965760405162461bcd60e51b81526004016109a690612202565b600580549082905560408051828152602081018490527f814491b5eba7a1a7bc3593a7464fc8eef3d984302911041a34ed32748331ffb7910160405180910390a15050565b610ce433610de2565b50610cf0338383610e66565b5050565b6000546001600160a01b03163314610d1e5760405162461bcd60e51b81526004016109a690612202565b610d286000611108565b565b610cf03383836000611158565b610cf0338383611181565b6000546001600160a01b03163314610d6c5760405162461bcd60e51b81526004016109a690612202565b6001600160a01b038116610dd15760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016109a6565b610dda81611108565b50565b610dda335b6000610ded8261127f565b90507f0000000000000000000000001117ac6ad6cdf1a3bc543bad3b133724620522d56001600160a01b03167f0000000000000000000000001117ac6ad6cdf1a3bc543bad3b133724620522d56001600160a01b03161415610e61578060066000828254610e5b9190612237565b90915550505b919050565b428111610eb55760405162461bcd60e51b815260206004820152601c60248201527f6c6f636b2073686f756c6420626520696e20746865206675747572650000000060448201526064016109a6565b6001600160a01b03831660009081526002602081905260408220908101805491929185908110610ee757610ee76122e9565b9060005260206000209060050201905080600301548311610f3d5760405162461bcd60e51b815260206004820152601060248201526f696e76616c6964206e6577206c6f636b60801b60448201526064016109a6565b6002810154610fae576301e13380610f554285612290565b1115610fa35760405162461bcd60e51b815260206004820152601b60248201527f6d6178206c6f636b20706572696f64206973203336352064617973000000000060448201526064016109a6565b426002820155611011565b6301e13380816002015484610fc39190612290565b11156110115760405162461bcd60e51b815260206004820152601b60248201527f6d6178206c6f636b20706572696f64206973203336352064617973000000000060448201526064016109a6565b600381018390558054600282015460009190620f4240906301e1338090829061103a9089612290565b6110449190612271565b61104e919061224f565b6110589190612237565b6110629190612271565b600180840180549083905590850154919250908290611082908390612290565b61108c9190612237565b600185015560045482906110a1908390612290565b6110ab9190612237565b600455600283015460408051888152602081019290925281018690526001600160a01b038816907f790686c73b4b8be3ff3b3a3a881cf875be2b60b24e2a6dd42eef3e7fe6e650ef9060600160405180910390a250505050505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b61116484848484611547565b82600660008282546111769190612237565b909155505050505050565b6001600160a01b038316600090815260026020819052604082209081018054919291859081106111b3576111b36122e9565b60009182526020918290206040805160a08101825260059093029091018054835260018101549383019390935260028301549082015260038201546060820181905260049092015460ff1615156080820152915042116112555760405162461bcd60e51b815260206004820152601860248201527f6465706f736974206e6f742079657420756e6c6f636b6564000000000000000060448201526064016109a6565b82600660008282546112679190612290565b909155506112789050858585611984565b5050505050565b600061128a8261043c565b90508061129957506000919050565b6001600160a01b038083166000908152600260205260409020426003820155907f0000000000000000000000001117ac6ad6cdf1a3bc543bad3b133724620522d581167f0000000000000000000000001117ac6ad6cdf1a3bc543bad3b133724620522d59091161415611408576000611316620f42406002612271565b6113209084612271565b905060006040518060a001604052808581526020018381526020014281526020016005544261134f9190612237565b8152600160209182018190526002868101805480840182556000918252848220865160059092020190815593850151928401929092556040840151908301556060830151600383015560808301516004909201805460ff191692151592909217909155845491925085918591906113c7908490612237565b92505081905550818360010160008282546113e29190612237565b9250508190555081600460008282546113fb9190612237565b9091555061150192505050565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031661147e5760405162461bcd60e51b815260206004820152601860248201527f6d6f6461506f6f6c2061646472657373206973207a65726f000000000000000060448201526064016109a6565b6040516344cc892d60e01b81526001600160a01b038481166004830152602482018490527f000000000000000000000000000000000000000000000000000000000000000016906344cc892d90604401600060405180830381600087803b1580156114e857600080fd5b505af11580156114fc573d6000803e3d6000fd5b505050505b6040518281526001600160a01b0384169033907ff3055bc8d92d9c8d2f12b45d112dd345cd2cfd17292b8d65c5642ac6f912dfd79060200160405180910390a350919050565b600083116115855760405162461bcd60e51b815260206004820152600b60248201526a1e995c9bc8185b5bdd5b9d60aa1b60448201526064016109a6565b7f0000000000000000000000000000000000000000000000000000000064d2f5784210156115e75760405162461bcd60e51b815260206004820152600f60248201526e706f6f6c206e6f742061637469766560881b60448201526064016109a6565b81158061160b5750428211801561160b57506301e133806116084284612290565b11155b61164f5760405162461bcd60e51b81526020600482015260156024820152741a5b9d985b1a59081b1bd8dac81a5b9d195c9d985b605a1b60448201526064016109a6565b6001600160a01b03841660009081526002602052604090208054156116795761167785610de2565b505b6040516370a0823160e01b81523060048201526000907f0000000000000000000000001117ac6ad6cdf1a3bc543bad3b133724620522d56001600160a01b0316906370a082319060240160206040518083038186803b1580156116db57600080fd5b505afa1580156116ef573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611713919061213e565b9050611720333087611c9d565b6040516370a0823160e01b81523060048201526000907f0000000000000000000000001117ac6ad6cdf1a3bc543bad3b133724620522d56001600160a01b0316906370a082319060240160206040518083038186803b15801561178257600080fd5b505afa158015611796573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117ba919061213e565b905060006117c88383612290565b90504286600081156118185783620f42406301e133806117e88686612290565b6117f590620f4240612271565b6117ff919061224f565b6118099190612237565b6118139190612271565b611825565b61182584620f4240612271565b90506000811161186e5760405162461bcd60e51b81526020600482015260146024820152735374616b6520776569676874206973207a65726f60601b60448201526064016109a6565b6040805160a0810182528581526020808201848152928201868152606083018681528c15156080850190815260028d810180546001808201835560009283529682208851600590920201908155975195880195909555925192860192909255516003850155516004909301805460ff1916931515939093179092558854909186918a91906118fd908490612237565b92505081905550818860010160008282546119189190612237565b9250508190555081600460008282546119319190612237565b90915550506040518b81526001600160a01b038d169033907f5dac0c1b1112564a045ba943c9d50270893e8e826c49be8e7073adc713ab7bd79060200160405180910390a3505050505050505050505050565b600081116119c25760405162461bcd60e51b815260206004820152600b60248201526a1e995c9bc8185b5bdd5b9d60aa1b60448201526064016109a6565b6001600160a01b038316600090815260026020819052604082209081018054919291859081106119f4576119f46122e9565b600091825260209091206005909102016004810154815491925060ff1690841115611a585760405162461bcd60e51b8152602060048201526014602482015273616d6f756e742065786365656473207374616b6560601b60448201526064016109a6565b611a6186610de2565b506001820154600383015460009015611acb578354611a81908790612290565b611a8e90620f4240612271565b6301e1338085600201548660030154611aa79190612290565b611ab1919061224f565b611abc906001612237565b611ac69190612271565b611ae5565b8354611ad8908790612290565b611ae590620f4240612271565b8454909150611af5908790612290565b611b4657846002018781548110611b0e57611b0e6122e9565b60009182526020822060059091020181815560018101829055600281018290556003810191909155600401805460ff19169055611b67565b85846000016000828254611b5a9190612290565b9091555050600184018190555b85856000016000828254611b7b9190612290565b909155505060018501548190611b92908490612290565b611b9c9190612237565b60018601556004548190611bb1908490612290565b611bbb9190612237565b6004558215611c495760405163e14bdb7160e01b8152336004820152602481018790527f000000000000000000000000503154cdd5710c8c26df1051eba183d0440143656001600160a01b03169063e14bdb7190604401600060405180830381600087803b158015611c2c57600080fd5b505af1158015611c40573d6000803e3d6000fd5b50505050611c53565b611c533387611d2a565b6040518681526001600160a01b0389169033907fd8654fcc8cf5b36d30b3f5e4688fc78118e6d68de60b9994e09902268b57c3e39060200160405180910390a35050505050505050565b60026001541415611cf05760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016109a6565b6002600155611d217f0000000000000000000000001117ac6ad6cdf1a3bc543bad3b133724620522d5848484611db5565b50506001805550565b60026001541415611d7d5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016109a6565b6002600155611dad7f0000000000000000000000001117ac6ad6cdf1a3bc543bad3b133724620522d58383611e26565b505060018055565b6040516001600160a01b0380851660248301528316604482015260648101829052611e209085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152611e5b565b50505050565b6040516001600160a01b038316602482015260448101829052611e5690849063a9059cbb60e01b90606401611de9565b505050565b6000611eb0826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611f2d9092919063ffffffff16565b805190915015611e565780806020019051810190611ece9190612103565b611e565760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016109a6565b6060611f3c8484600085611f46565b90505b9392505050565b606082471015611fa75760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016109a6565b843b611ff55760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016109a6565b600080866001600160a01b0316858760405161201191906121b3565b60006040518083038185875af1925050503d806000811461204e576040519150601f19603f3d011682016040523d82523d6000602084013e612053565b606091505b509150915061206382828661206e565b979650505050505050565b6060831561207d575081611f3f565b82511561208d5782518084602001fd5b8160405162461bcd60e51b81526004016109a691906121cf565b80356001600160a01b0381168114610e6157600080fd5b6000602082840312156120d057600080fd5b611f3f826120a7565b600080604083850312156120ec57600080fd5b6120f5836120a7565b946020939093013593505050565b60006020828403121561211557600080fd5b81518015158114611f3f57600080fd5b60006020828403121561213757600080fd5b5035919050565b60006020828403121561215057600080fd5b5051919050565b6000806040838503121561216a57600080fd5b50508035926020909101359150565b60006020828403121561218b57600080fd5b8135611f3f816122ff565b6000602082840312156121a857600080fd5b8151611f3f816122ff565b600082516121c58184602087016122a7565b9190910192915050565b60208152600082518060208401526121ee8160408501602087016122a7565b601f01601f19169190910160400192915050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6000821982111561224a5761224a6122d3565b500190565b60008261226c57634e487b7160e01b600052601260045260246000fd5b500490565b600081600019048311821515161561228b5761228b6122d3565b500290565b6000828210156122a2576122a26122d3565b500390565b60005b838110156122c25781810151838201526020016122aa565b83811115611e205750506000910152565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b63ffffffff81168114610dda57600080fdfea26469706673582212203a840e91bdbe3a282d4395a5abdc4c9fca5f47d85c23f50cd94836f69fb22f7064736f6c63430008060033

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

0000000000000000000000001117ac6ad6cdf1a3bc543bad3b133724620522d5000000000000000000000000503154cdd5710c8c26df1051eba183d04401436500000000000000000000000000000000000000000000000000000000000000000000000000000000000000001117ac6ad6cdf1a3bc543bad3b133724620522d500000000000000000000000000000000000000000000000000000000000000280000000000000000000000000000000000000000000000000000000064d2f578

-----Decoded View---------------
Arg [0] : _moda (address): 0x1117aC6Ad6Cdf1A3BC543baD3B133724620522d5
Arg [1] : _modaPoolFactory (address): 0x503154cdD5710C8c26DF1051eBA183D044014365
Arg [2] : _modaPool (address): 0x0000000000000000000000000000000000000000
Arg [3] : _poolToken (address): 0x1117aC6Ad6Cdf1A3BC543baD3B133724620522d5
Arg [4] : _weight (uint32): 40
Arg [5] : _startTimestamp (uint256): 1691547000

-----Encoded View---------------
6 Constructor Arguments found :
Arg [0] : 0000000000000000000000001117ac6ad6cdf1a3bc543bad3b133724620522d5
Arg [1] : 000000000000000000000000503154cdd5710c8c26df1051eba183d044014365
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [3] : 0000000000000000000000001117ac6ad6cdf1a3bc543bad3b133724620522d5
Arg [4] : 0000000000000000000000000000000000000000000000000000000000000028
Arg [5] : 0000000000000000000000000000000000000000000000000000000064d2f578


Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.