Overview
ETH Balance
0 ETH
Eth Value
$0.00Token Holdings
Transaction Hash |
Method
|
Block
|
From
|
To
|
Value | ||||
---|---|---|---|---|---|---|---|---|---|
0xc7713774d98dc5ec94bb80f7ac8e9c6c88f6439d7b207e23a9211ba0443387cb | Stake | (pending) | 2 days ago | IN | 0 ETH | (Pending) | |||
0x64f48cab2d9aabaf6d72f153de7fbaf75b13849f74738072708e220aed0d2463 | Stake | (pending) | 2 days ago | IN | 0 ETH | (Pending) | |||
Unstake | 20268026 | 3 hrs ago | IN | 0 ETH | 0.00043263 | ||||
Unstake | 20267046 | 6 hrs ago | IN | 0 ETH | 0.00045783 | ||||
Unstake | 20266967 | 7 hrs ago | IN | 0 ETH | 0.00048062 | ||||
Unstake | 20264533 | 15 hrs ago | IN | 0 ETH | 0.00051102 | ||||
Unstake | 20259001 | 33 hrs ago | IN | 0 ETH | 0.00025546 | ||||
Unstake | 20258876 | 34 hrs ago | IN | 0 ETH | 0.00046723 | ||||
Unstake | 20258016 | 37 hrs ago | IN | 0 ETH | 0.00027809 | ||||
Unstake | 20255409 | 45 hrs ago | IN | 0 ETH | 0.00059089 | ||||
Unstake | 20252976 | 2 days ago | IN | 0 ETH | 0.00020465 | ||||
Unstake | 20252009 | 2 days ago | IN | 0 ETH | 0.00020188 | ||||
Unstake | 20252002 | 2 days ago | IN | 0 ETH | 0.00033041 | ||||
Unstake | 20231628 | 5 days ago | IN | 0 ETH | 0.00056002 | ||||
Unstake | 20228396 | 5 days ago | IN | 0 ETH | 0.00177223 | ||||
Unstake | 20227943 | 5 days ago | IN | 0 ETH | 0.00186072 | ||||
Unstake | 20227921 | 5 days ago | IN | 0 ETH | 0.00226883 | ||||
Unstake | 20225216 | 6 days ago | IN | 0 ETH | 0.00083668 | ||||
Unstake | 20215725 | 7 days ago | IN | 0 ETH | 0.00022375 | ||||
Unstake | 20211382 | 8 days ago | IN | 0 ETH | 0.00067095 | ||||
Unstake | 20207486 | 8 days ago | IN | 0 ETH | 0.00069926 | ||||
Unstake | 20206400 | 8 days ago | IN | 0 ETH | 0.00064593 | ||||
Unstake | 20203226 | 9 days ago | IN | 0 ETH | 0.00062203 | ||||
Unstake | 20199385 | 9 days ago | IN | 0 ETH | 0.00026053 | ||||
Unstake | 20194058 | 10 days ago | IN | 0 ETH | 0.00035267 |
Latest 1 internal transaction
Advanced mode:
Parent Transaction Hash | Block | From | To | Value | ||
---|---|---|---|---|---|---|
12736200 | 1104 days ago | Contract Creation | 0 ETH |
Loading...
Loading
Contract Name:
IlluviumCorePool
Compiler Version
v0.8.1+commit.df193b15
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity 0.8.1; import "./IlluviumPoolBase.sol"; /** * @title Illuvium Core Pool * * @notice Core pools represent permanent pools like ILV or ILV/ETH Pair pool, * core pools allow staking for arbitrary periods of time up to 1 year * * @dev See IlluviumPoolBase for more details * * @author Pedro Bergamini, reviewed by Basil Gorin */ contract IlluviumCorePool is IlluviumPoolBase { /// @dev Flag indicating pool type, false means "core pool" bool public constant override isFlashPool = false; /// @dev Link to deployed IlluviumVault instance address public vault; /// @dev Used to calculate vault rewards /// @dev This value is different from "reward per token" used in locked pool /// @dev Note: stakes are different in duration and "weight" reflects that uint256 public vaultRewardsPerWeight; /// @dev Pool tokens value available in the pool; /// pool token examples are ILV (ILV core pool) or ILV/ETH pair (LP core pool) /// @dev For LP core pool this value doesnt' count for ILV tokens received as Vault rewards /// while for ILV core pool it does count for such tokens as well uint256 public poolTokenReserve; /** * @dev Fired in receiveVaultRewards() * * @param _by an address that sent the rewards, always a vault * @param amount amount of tokens received */ event VaultRewardsReceived(address indexed _by, uint256 amount); /** * @dev Fired in _processVaultRewards() and dependent functions, like processRewards() * * @param _by an address which executed the function * @param _to an address which received a reward * @param amount amount of reward received */ event VaultRewardsClaimed(address indexed _by, address indexed _to, uint256 amount); /** * @dev Fired in setVault() * * @param _by an address which executed the function, always a factory owner */ event VaultUpdated(address indexed _by, address _fromVal, address _toVal); /** * @dev Creates/deploys an instance of the core pool * * @param _ilv ILV ERC20 Token IlluviumERC20 address * @param _silv sILV ERC20 Token EscrowedIlluviumERC20 address * @param _factory Pool factory IlluviumPoolFactory instance/address * @param _poolToken token the pool operates on, for example ILV or ILV/ETH pair * @param _initBlock initial block used to calculate the rewards * @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 */ constructor( address _ilv, address _silv, IlluviumPoolFactory _factory, address _poolToken, uint64 _initBlock, uint32 _weight ) IlluviumPoolBase(_ilv, _silv, _factory, _poolToken, _initBlock, _weight) {} /** * @notice Calculates current vault rewards value available for address specified * * @dev Performs calculations based on current smart contract state only, * not taking into account any additional time/blocks which might have passed * * @param _staker an address to calculate vault rewards value for * @return pending calculated vault reward value for the given address */ function pendingVaultRewards(address _staker) public view returns (uint256 pending) { User memory user = users[_staker]; return weightToReward(user.totalWeight, vaultRewardsPerWeight) - user.subVaultRewards; } /** * @dev Executed only by the factory owner to Set the vault * * @param _vault an address of deployed IlluviumVault instance */ function setVault(address _vault) external { // verify function is executed by the factory owner require(factory.owner() == msg.sender, "access denied"); // verify input is set require(_vault != address(0), "zero input"); // emit an event emit VaultUpdated(msg.sender, vault, _vault); // update vault address vault = _vault; } /** * @dev Executed by the vault to transfer vault rewards ILV from the vault * into the pool * * @dev This function is executed only for ILV core pools * * @param _rewardsAmount amount of ILV rewards to transfer into the pool */ function receiveVaultRewards(uint256 _rewardsAmount) external { require(msg.sender == vault, "access denied"); // return silently if there is no reward to receive if (_rewardsAmount == 0) { return; } require(usersLockingWeight > 0, "zero locking weight"); transferIlvFrom(msg.sender, address(this), _rewardsAmount); vaultRewardsPerWeight += rewardToWeight(_rewardsAmount, usersLockingWeight); // update `poolTokenReserve` only if this is a ILV Core Pool if (poolToken == ilv) { poolTokenReserve += _rewardsAmount; } emit VaultRewardsReceived(msg.sender, _rewardsAmount); } /** * @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 factory * end block), function doesn't throw and exits silently * * @dev _useSILV flag has a context of yield rewards only * * @param _useSILV flag indicating whether to mint sILV token as a reward or not; * when set to true - sILV reward is minted immediately and sent to sender, * when set to false - new ILV reward deposit gets created if pool is an ILV pool * (poolToken is ILV token), or new pool deposit gets created together with sILV minted * when pool is not an ILV pool (poolToken is not an ILV token) */ function processRewards(bool _useSILV) external override { _processRewards(msg.sender, _useSILV, true); } /** * @dev Executed internally by the pool itself (from the parent `IlluviumPoolBase` smart contract) * as part of yield rewards processing logic (`IlluviumPoolBase._processRewards` function) * @dev Executed when _useSILV is false and pool is not an ILV pool - see `IlluviumPoolBase._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(factory.poolExists(msg.sender), "access denied"); _sync(); User storage user = users[_staker]; if (user.tokenAmount > 0) { _processRewards(_staker, true, false); } uint256 depositWeight = _amount * YEAR_STAKE_WEIGHT_MULTIPLIER; Deposit memory newDeposit = Deposit({ tokenAmount: _amount, lockedFrom: uint64(now256()), lockedUntil: uint64(now256() + 365 days), weight: depositWeight, isYield: true }); user.tokenAmount += _amount; user.totalWeight += depositWeight; user.deposits.push(newDeposit); usersLockingWeight += depositWeight; user.subYieldRewards = weightToReward(user.totalWeight, yieldRewardsPerWeight); user.subVaultRewards = weightToReward(user.totalWeight, vaultRewardsPerWeight); // update `poolTokenReserve` only if this is a LP Core Pool (stakeAsPool can be executed only for LP pool) poolTokenReserve += _amount; } /** * @inheritdoc IlluviumPoolBase * * @dev Additionally to the parent smart contract, updates vault rewards of the holder, * and updates (increases) pool token reserve (pool tokens value available in the pool) */ function _stake( address _staker, uint256 _amount, uint64 _lockedUntil, bool _useSILV, bool _isYield ) internal override { super._stake(_staker, _amount, _lockedUntil, _useSILV, _isYield); User storage user = users[_staker]; user.subVaultRewards = weightToReward(user.totalWeight, vaultRewardsPerWeight); poolTokenReserve += _amount; } /** * @inheritdoc IlluviumPoolBase * * @dev Additionally to the parent smart contract, updates vault rewards of the holder, * and updates (decreases) pool token reserve (pool tokens value available in the pool) */ function _unstake( address _staker, uint256 _depositId, uint256 _amount, bool _useSILV ) internal override { User storage user = users[_staker]; Deposit memory stakeDeposit = user.deposits[_depositId]; require(stakeDeposit.lockedFrom == 0 || now256() > stakeDeposit.lockedUntil, "deposit not yet unlocked"); poolTokenReserve -= _amount; super._unstake(_staker, _depositId, _amount, _useSILV); user.subVaultRewards = weightToReward(user.totalWeight, vaultRewardsPerWeight); } /** * @inheritdoc IlluviumPoolBase * * @dev Additionally to the parent smart contract, processes vault rewards of the holder, * and for ILV pool updates (increases) pool token reserve (pool tokens value available in the pool) */ function _processRewards( address _staker, bool _useSILV, bool _withUpdate ) internal override returns (uint256 pendingYield) { _processVaultRewards(_staker); pendingYield = super._processRewards(_staker, _useSILV, _withUpdate); // update `poolTokenReserve` only if this is a ILV Core Pool if (poolToken == ilv && !_useSILV) { poolTokenReserve += pendingYield; } } /** * @dev Used internally to process vault rewards for the staker * * @param _staker address of the user (staker) to process rewards for */ function _processVaultRewards(address _staker) private { User storage user = users[_staker]; uint256 pendingVaultClaim = pendingVaultRewards(_staker); if (pendingVaultClaim == 0) return; // read ILV token balance of the pool via standard ERC20 interface uint256 ilvBalance = IERC20(ilv).balanceOf(address(this)); require(ilvBalance >= pendingVaultClaim, "contract ILV balance too low"); // update `poolTokenReserve` only if this is a ILV Core Pool if (poolToken == ilv) { // protects against rounding errors poolTokenReserve -= pendingVaultClaim > poolTokenReserve ? poolTokenReserve : pendingVaultClaim; } user.subVaultRewards = weightToReward(user.totalWeight, vaultRewardsPerWeight); // transfer fails if pool ILV balance is not enough - which is a desired behavior transferIlv(_staker, pendingVaultClaim); emit VaultRewardsClaimed(msg.sender, _staker, pendingVaultClaim); } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.1; import "../interfaces/IPool.sol"; import "../interfaces/ICorePool.sol"; import "./ReentrancyGuard.sol"; import "./IlluviumPoolFactory.sol"; import "../utils/SafeERC20.sol"; import "../token/EscrowedIlluviumERC20.sol"; /** * @title Illuvium Pool Base * * @notice An abstract contract containing common logic for any pool, * be it a flash pool (temporary pool like SNX) or a core pool (permanent pool like ILV/ETH or ILV pool) * * @dev Deployment and initialization. * Any pool deployed must be bound to the deployed pool factory (IlluviumPoolFactory) * Additionally, 3 token instance addresses must be defined on deployment: * - ILV token address * - sILV token address, used to mint sILV rewards * - pool token address, it can be ILV token address, ILV/ETH pair address, and others * * @dev Pool weight defines the fraction of the yield current pool receives among the other pools, * pool factory is responsible for the weight synchronization between the pools. * @dev The weight is logically 10% for ILV pool and 90% for ILV/ETH pool. * Since Solidity doesn't support fractions the weight is defined by the division of * pool weight by total pools weight (sum of all registered pools within the factory) * @dev For ILV Pool we use 100 as weight and for ILV/ETH pool - 900. * * @author Pedro Bergamini, reviewed by Basil Gorin */ abstract contract IlluviumPoolBase is IPool, IlluviumAware, ReentrancyGuard { /// @dev Data structure representing token holder using a pool struct User { // @dev Total staked amount uint256 tokenAmount; // @dev Total weight uint256 totalWeight; // @dev Auxiliary variable for yield calculation uint256 subYieldRewards; // @dev Auxiliary variable for vault rewards calculation uint256 subVaultRewards; // @dev An array of holder's deposits Deposit[] deposits; } /// @dev Token holder storage, maps token holder address to their data record mapping(address => User) public users; /// @dev Link to sILV ERC20 Token EscrowedIlluviumERC20 instance address public immutable override silv; /// @dev Link to the pool factory IlluviumPoolFactory instance IlluviumPoolFactory public immutable factory; /// @dev Link to the pool token instance, for example ILV or ILV/ETH pair address public immutable override poolToken; /// @dev Pool weight, 100 for ILV pool or 900 for ILV/ETH uint32 public override weight; /// @dev Block number of the last yield distribution event uint64 public override lastYieldDistribution; /// @dev Used to calculate yield rewards /// @dev This value is different from "reward per token" used in locked pool /// @dev Note: stakes are different in duration and "weight" reflects that uint256 public override yieldRewardsPerWeight; /// @dev Used to calculate yield rewards, keeps track of the tokens weight locked in staking uint256 public override usersLockingWeight; /** * @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 previos one */ uint256 internal constant YEAR_STAKE_WEIGHT_MULTIPLIER = 2 * WEIGHT_MULTIPLIER; /** * @dev Rewards per weight are stored multiplied by 1e12, as integers. */ uint256 internal constant REWARD_PER_WEIGHT_MULTIPLIER = 1e12; /** * @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, uint64 lockedFrom, uint64 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 _sync(), sync() and dependent functions (stake, unstake, etc.) * * @param _by an address which performed an operation * @param yieldRewardsPerWeight updated yield rewards per weight value * @param lastYieldDistribution usually, current block number */ event Synchronized(address indexed _by, uint256 yieldRewardsPerWeight, uint64 lastYieldDistribution); /** * @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 sIlv flag indicating if reward was paid (minted) in sILV * @param amount amount of yield paid */ event YieldClaimed(address indexed _by, address indexed _to, bool sIlv, 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 Overridden in sub-contracts to construct the pool * * @param _ilv ILV ERC20 Token IlluviumERC20 address * @param _silv sILV ERC20 Token EscrowedIlluviumERC20 address * @param _factory Pool factory IlluviumPoolFactory instance/address * @param _poolToken token the pool operates on, for example ILV or ILV/ETH pair * @param _initBlock initial block used to calculate the rewards * note: _initBlock can be set to the future effectively meaning _sync() calls will do nothing * @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 */ constructor( address _ilv, address _silv, IlluviumPoolFactory _factory, address _poolToken, uint64 _initBlock, uint32 _weight ) IlluviumAware(_ilv) { // verify the inputs are set require(_silv != address(0), "sILV address not set"); require(address(_factory) != address(0), "ILV Pool fct address not set"); require(_poolToken != address(0), "pool token address not set"); require(_initBlock > 0, "init block not set"); require(_weight > 0, "pool weight not set"); // verify sILV instance supplied require( EscrowedIlluviumERC20(_silv).TOKEN_UID() == 0xac3051b8d4f50966afb632468a4f61483ae6a953b74e387a01ef94316d6b7d62, "unexpected sILV TOKEN_UID" ); // verify IlluviumPoolFactory instance supplied require( _factory.FACTORY_UID() == 0xc5cfd88c6e4d7e5c8a03c255f03af23c0918d8e82cac196f57466af3fd4a5ec7, "unexpected FACTORY_UID" ); // save the inputs into internal state variables silv = _silv; factory = _factory; poolToken = _poolToken; weight = _weight; // init the dependent internal state variables lastYieldDistribution = _initBlock; } /** * @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) external view override returns (uint256) { // `newYieldRewardsPerWeight` will store stored or recalculated value for `yieldRewardsPerWeight` uint256 newYieldRewardsPerWeight; // if smart contract state was not updated recently, `yieldRewardsPerWeight` value // is outdated and we need to recalculate it in order to calculate pending rewards correctly if (blockNumber() > lastYieldDistribution && usersLockingWeight != 0) { uint256 endBlock = factory.endBlock(); uint256 multiplier = blockNumber() > endBlock ? endBlock - lastYieldDistribution : blockNumber() - lastYieldDistribution; uint256 ilvRewards = (multiplier * weight * factory.ilvPerBlock()) / factory.totalWeight(); // recalculated value for `yieldRewardsPerWeight` newYieldRewardsPerWeight = rewardToWeight(ilvRewards, usersLockingWeight) + yieldRewardsPerWeight; } else { // if smart contract state is up to date, we don't recalculate newYieldRewardsPerWeight = yieldRewardsPerWeight; } // based on the rewards per weight value, calculate pending rewards; User memory user = users[_staker]; uint256 pending = weightToReward(user.totalWeight, newYieldRewardsPerWeight) - user.subYieldRewards; return pending; } /** * @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) { // read specified user token amount and return 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) { // read deposit at specified index and return 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) { // read deposits array length and return 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 * @param _useSILV a flag indicating if previous reward to be paid as sILV */ function stake( uint256 _amount, uint64 _lockUntil, bool _useSILV ) external override { // delegate call to an internal function _stake(msg.sender, _amount, _lockUntil, _useSILV, false); } /** * @notice Unstakes 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 * @param _useSILV a flag indicating if reward to be paid as sILV */ function unstake( uint256 _depositId, uint256 _amount, bool _useSILV ) external override { // delegate call to an internal function _unstake(msg.sender, _depositId, _amount, _useSILV); } /** * @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 * @param useSILV used for _processRewards check if it should use ILV or sILV */ function updateStakeLock( uint256 depositId, uint64 lockedUntil, bool useSILV ) external { // sync and call processRewards _sync(); _processRewards(msg.sender, useSILV, false); // delegate call to an internal function _updateStakeLock(msg.sender, depositId, lockedUntil); } /** * @notice Service function to synchronize pool state with current time * * @dev Can be executed by anyone at any time, but has an effect only when * at least one block passes between synchronizations * @dev Executed internally when staking, unstaking, processing rewards in order * for calculations to be correct and to reflect state progress of the contract * @dev When timing conditions are not met (executed too frequently, or after factory * end block), function doesn't throw and exits silently */ function sync() external override { // delegate call to an internal function _sync(); } /** * @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 Executed internally when staking and unstaking, executes sync() under the hood * before making further calculations and payouts * @dev When timing conditions are not met (executed too frequently, or after factory * end block), function doesn't throw and exits silently * * @param _useSILV flag indicating whether to mint sILV token as a reward or not; * when set to true - sILV reward is minted immediately and sent to sender, * when set to false - new ILV reward deposit gets created if pool is an ILV pool * (poolToken is ILV token), or new pool deposit gets created together with sILV minted * when pool is not an ILV pool (poolToken is not an ILV token) */ function processRewards(bool _useSILV) external virtual override { // delegate call to an internal function _processRewards(msg.sender, _useSILV, true); } /** * @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 { // verify function is executed by the factory require(msg.sender == address(factory), "access denied"); // emit an event logging old and new weight values emit PoolWeightUpdated(msg.sender, weight, _weight); // set the new weight value weight = _weight; } /** * @dev Similar to public pendingYieldRewards, but performs calculations based on * current smart contract state only, not taking into account any additional * time/blocks which might have passed * * @param _staker an address to calculate yield rewards value for * @return pending calculated yield reward value for the given address */ function _pendingYieldRewards(address _staker) internal view returns (uint256 pending) { // read user data structure into memory User memory user = users[_staker]; // and perform the calculation using the values read return weightToReward(user.totalWeight, yieldRewardsPerWeight) - user.subYieldRewards; } /** * @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 _useSILV a flag indicating if previous reward to be paid as sILV * @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, uint64 _lockUntil, bool _useSILV, bool _isYield ) internal virtual { // validate the inputs require(_amount > 0, "zero amount"); require( _lockUntil == 0 || (_lockUntil > now256() && _lockUntil - now256() <= 365 days), "invalid lock interval" ); // update smart contract state _sync(); // get a link to user data struct, we will write to it later User storage user = users[_staker]; // process current pending rewards if any if (user.tokenAmount > 0) { _processRewards(_staker, _useSILV, false); } // in most of the cases added amount `addedAmount` is simply `_amount` // however for deflationary tokens this can be different // read the current balance uint256 previousBalance = IERC20(poolToken).balanceOf(address(this)); // transfer `_amount`; note: some tokens may get burnt here transferPoolTokenFrom(address(msg.sender), address(this), _amount); // read new 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` uint64 lockFrom = _lockUntil > 0 ? uint64(now256()) : 0; uint64 lockUntil = _lockUntil; // stake weight formula rewards for locking uint256 stakeWeight = (((lockUntil - lockFrom) * WEIGHT_MULTIPLIER) / 365 days + WEIGHT_MULTIPLIER) * addedAmount; // makes sure stakeWeight is valid assert(stakeWeight > 0); // create and save the deposit (append it to deposits array) Deposit memory deposit = Deposit({ tokenAmount: addedAmount, weight: stakeWeight, lockedFrom: lockFrom, lockedUntil: lockUntil, isYield: _isYield }); // deposit ID is an index of the deposit in `deposits` array user.deposits.push(deposit); // update user record user.tokenAmount += addedAmount; user.totalWeight += stakeWeight; user.subYieldRewards = weightToReward(user.totalWeight, yieldRewardsPerWeight); // update global variable usersLockingWeight += stakeWeight; // emit an event emit Staked(msg.sender, _staker, _amount); } /** * @dev Used internally, mostly by children implementations, see unstake() * * @param _staker an address which unstakes tokens (which previously staked them) * @param _depositId deposit ID to unstake from, zero-indexed * @param _amount amount of tokens to unstake * @param _useSILV a flag indicating if reward to be paid as sILV */ function _unstake( address _staker, uint256 _depositId, uint256 _amount, bool _useSILV ) internal virtual { // verify an amount is set require(_amount > 0, "zero amount"); // get a link to user data struct, we will write to it later User storage user = users[_staker]; // get a link to the corresponding deposit, we may write to it later Deposit storage stakeDeposit = user.deposits[_depositId]; // deposit structure may get deleted, so we save isYield flag to be able to use it bool isYield = stakeDeposit.isYield; // verify available balance // if staker address ot deposit doesn't exist this check will fail as well require(stakeDeposit.tokenAmount >= _amount, "amount exceeds stake"); // update smart contract state _sync(); // and process current pending rewards if any _processRewards(_staker, _useSILV, false); // recalculate deposit weight uint256 previousWeight = stakeDeposit.weight; uint256 newWeight = (((stakeDeposit.lockedUntil - stakeDeposit.lockedFrom) * WEIGHT_MULTIPLIER) / 365 days + WEIGHT_MULTIPLIER) * (stakeDeposit.tokenAmount - _amount); // update the deposit, or delete it if its depleted if (stakeDeposit.tokenAmount - _amount == 0) { delete user.deposits[_depositId]; } else { stakeDeposit.tokenAmount -= _amount; stakeDeposit.weight = newWeight; } // update user record user.tokenAmount -= _amount; user.totalWeight = user.totalWeight - previousWeight + newWeight; user.subYieldRewards = weightToReward(user.totalWeight, yieldRewardsPerWeight); // update global variable usersLockingWeight = usersLockingWeight - previousWeight + newWeight; // if the deposit was created by the pool itself as a yield reward if (isYield) { // mint the yield via the factory factory.mintYieldTo(msg.sender, _amount); } else { // otherwise just return tokens back to holder transferPoolToken(msg.sender, _amount); } // emit an event emit Unstaked(msg.sender, _staker, _amount); } /** * @dev Used internally, mostly by children implementations, see sync() * * @dev Updates smart contract state (`yieldRewardsPerWeight`, `lastYieldDistribution`), * updates factory state via `updateILVPerBlock` */ function _sync() internal virtual { // update ILV per block value in factory if required if (factory.shouldUpdateRatio()) { factory.updateILVPerBlock(); } // check bound conditions and if these are not met - // exit silently, without emitting an event uint256 endBlock = factory.endBlock(); if (lastYieldDistribution >= endBlock) { return; } if (blockNumber() <= lastYieldDistribution) { return; } // if locking weight is zero - update only `lastYieldDistribution` and exit if (usersLockingWeight == 0) { lastYieldDistribution = uint64(blockNumber()); return; } // to calculate the reward we need to know how many blocks passed, and reward per block uint256 currentBlock = blockNumber() > endBlock ? endBlock : blockNumber(); uint256 blocksPassed = currentBlock - lastYieldDistribution; uint256 ilvPerBlock = factory.ilvPerBlock(); // calculate the reward uint256 ilvReward = (blocksPassed * ilvPerBlock * weight) / factory.totalWeight(); // update rewards per weight and `lastYieldDistribution` yieldRewardsPerWeight += rewardToWeight(ilvReward, usersLockingWeight); lastYieldDistribution = uint64(currentBlock); // emit an event emit Synchronized(msg.sender, yieldRewardsPerWeight, lastYieldDistribution); } /** * @dev Used internally, mostly by children implementations, see processRewards() * * @param _staker an address which receives the reward (which has staked some tokens earlier) * @param _useSILV flag indicating whether to mint sILV token as a reward or not, see processRewards() * @param _withUpdate flag allowing to disable synchronization (see sync()) if set to false * @return pendingYield the rewards calculated and optionally re-staked */ function _processRewards( address _staker, bool _useSILV, bool _withUpdate ) internal virtual returns (uint256 pendingYield) { // update smart contract state if required if (_withUpdate) { _sync(); } // calculate pending yield rewards, this value will be returned pendingYield = _pendingYieldRewards(_staker); // if pending yield is zero - just return silently if (pendingYield == 0) return 0; // get link to a user data structure, we will write into it later User storage user = users[_staker]; // if sILV is requested if (_useSILV) { // - mint sILV mintSIlv(_staker, pendingYield); } else if (poolToken == ilv) { // calculate pending yield weight, // 2e6 is the bonus weight when staking for 1 year uint256 depositWeight = pendingYield * YEAR_STAKE_WEIGHT_MULTIPLIER; // if the pool is ILV Pool - create new ILV deposit // and save it - push it into deposits array Deposit memory newDeposit = Deposit({ tokenAmount: pendingYield, lockedFrom: uint64(now256()), lockedUntil: uint64(now256() + 365 days), // staking yield for 1 year weight: depositWeight, isYield: true }); user.deposits.push(newDeposit); // update user record user.tokenAmount += pendingYield; user.totalWeight += depositWeight; // update global variable usersLockingWeight += depositWeight; } else { // for other pools - stake as pool address ilvPool = factory.getPoolAddress(ilv); ICorePool(ilvPool).stakeAsPool(_staker, pendingYield); } // update users's record for `subYieldRewards` if requested if (_withUpdate) { user.subYieldRewards = weightToReward(user.totalWeight, yieldRewardsPerWeight); } // emit an event emit YieldClaimed(msg.sender, _staker, _useSILV, 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, uint64 _lockedUntil ) internal { // validate the input time require(_lockedUntil > now256(), "lock should be in the future"); // get a link to user data struct, we will write to it later User storage user = users[_staker]; // get a link to the corresponding deposit, we may write to it later Deposit storage stakeDeposit = user.deposits[_depositId]; // validate the input against deposit structure require(_lockedUntil > stakeDeposit.lockedUntil, "invalid new lock"); // verify locked from and locked until values if (stakeDeposit.lockedFrom == 0) { require(_lockedUntil - now256() <= 365 days, "max lock period is 365 days"); stakeDeposit.lockedFrom = uint64(now256()); } else { require(_lockedUntil - stakeDeposit.lockedFrom <= 365 days, "max lock period is 365 days"); } // update locked until value, calculate new weight stakeDeposit.lockedUntil = _lockedUntil; uint256 newWeight = (((stakeDeposit.lockedUntil - stakeDeposit.lockedFrom) * WEIGHT_MULTIPLIER) / 365 days + WEIGHT_MULTIPLIER) * stakeDeposit.tokenAmount; // save previous weight uint256 previousWeight = stakeDeposit.weight; // update weight stakeDeposit.weight = newWeight; // update user total weight and global locking weight user.totalWeight = user.totalWeight - previousWeight + newWeight; usersLockingWeight = usersLockingWeight - previousWeight + newWeight; // emit an event emit StakeLockUpdated(_staker, _depositId, stakeDeposit.lockedFrom, _lockedUntil); } /** * @dev Converts stake weight (not to be mixed with the pool weight) to * ILV reward value, applying the 10^12 division on weight * * @param _weight stake weight * @param rewardPerWeight ILV reward per weight * @return reward value normalized to 10^12 */ function weightToReward(uint256 _weight, uint256 rewardPerWeight) public pure returns (uint256) { // apply the formula and return return (_weight * rewardPerWeight) / REWARD_PER_WEIGHT_MULTIPLIER; } /** * @dev Converts reward ILV value to stake weight (not to be mixed with the pool weight), * applying the 10^12 multiplication on the reward * - OR - * @dev Converts reward ILV value to reward/weight if stake weight is supplied as second * function parameter instead of reward/weight * * @param reward yield reward * @param rewardPerWeight reward/weight (or stake weight) * @return stake weight (or reward/weight) */ function rewardToWeight(uint256 reward, uint256 rewardPerWeight) public pure returns (uint256) { // apply the reverse formula and return return (reward * REWARD_PER_WEIGHT_MULTIPLIER) / rewardPerWeight; } /** * @dev Testing time-dependent functionality is difficult and the best way of * doing it is to override block number in helper test smart contracts * * @return `block.number` in mainnet, custom values in testnets (if overridden) */ function blockNumber() public view virtual returns (uint256) { // return current block number return block.number; } /** * @dev Testing time-dependent functionality is difficult and the best way of * doing it is to override time in helper test smart contracts * * @return `block.timestamp` in mainnet, custom values in testnets (if overridden) */ function now256() public view virtual returns (uint256) { // return current block timestamp return block.timestamp; } /** * @dev Executes EscrowedIlluviumERC20.mint(_to, _values) * on the bound EscrowedIlluviumERC20 instance * * @dev Reentrancy safe due to the EscrowedIlluviumERC20 design */ function mintSIlv(address _to, uint256 _value) private { // just delegate call to the target EscrowedIlluviumERC20(silv).mint(_to, _value); } /** * @dev Executes SafeERC20.safeTransfer on a pool token * * @dev Reentrancy safety enforced via `ReentrancyGuard.nonReentrant` */ function transferPoolToken(address _to, uint256 _value) internal nonReentrant { // just delegate call to the target 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 { // just delegate call to the target SafeERC20.safeTransferFrom(IERC20(poolToken), _from, _to, _value); } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.1; import "./ILinkedToILV.sol"; /** * @title Illuvium Pool * * @notice An abstraction representing a pool, see IlluviumPoolBase for details * * @author Pedro Bergamini, reviewed by Basil Gorin */ interface IPool is ILinkedToILV { /** * @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 uint64 lockedFrom; // @dev locking period - until uint64 lockedUntil; // @dev indicates if the stake was created as a yield reward bool isYield; } // for the rest of the functions see Soldoc in IlluviumPoolBase function silv() external view returns (address); function poolToken() external view returns (address); function isFlashPool() external view returns (bool); function weight() external view returns (uint32); function lastYieldDistribution() external view returns (uint64); function yieldRewardsPerWeight() external view returns (uint256); function usersLockingWeight() 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, uint64 _lockedUntil, bool useSILV ) external; function unstake( uint256 _depositId, uint256 _amount, bool useSILV ) external; function sync() external; function processRewards(bool useSILV) external; function setWeight(uint32 _weight) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.1; 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; function receiveVaultRewards(uint256 _amount) external; }
// https://raw.githubusercontent.com/OpenZeppelin/openzeppelin-contracts/master/contracts/security/ReentrancyGuard.sol // #24a0bc23cfe3fbc76f8f2510b78af1e948ae6651 // SPDX-License-Identifier: MIT pragma solidity 0.8.1; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor () { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.1; import "../interfaces/IPool.sol"; import "./IlluviumAware.sol"; import "./IlluviumCorePool.sol"; import "../token/EscrowedIlluviumERC20.sol"; import "../utils/Ownable.sol"; /** * @title Illuvium Pool Factory * * @notice ILV Pool Factory manages Illuvium 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 ILV token to mint yield * (see `mintYieldTo` function) * * @author Pedro Bergamini, reviewed by Basil Gorin */ contract IlluviumPoolFactory is Ownable, IlluviumAware { /** * @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 = 0xc5cfd88c6e4d7e5c8a03c255f03af23c0918d8e82cac196f57466af3fd4a5ec7; /// @dev Auxiliary data structure used only in getPoolData() view function struct PoolData { // @dev pool token address (like ILV) address poolToken; // @dev pool address (like deployed core pool instance) address poolAddress; // @dev pool weight (200 for ILV pools, 800 for ILV/ETH pools - set during deployment) uint32 weight; // @dev flash pool flag bool isFlashPool; } /** * @dev ILV/block determines yield farming reward base * used by the yield pools controlled by the factory */ uint192 public ilvPerBlock; /** * @dev The yield is distributed proportionally to pool weights; * total weight is here to help in determining the proportion */ uint32 public totalWeight; /** * @dev ILV/block decreases by 3% every blocks/update (set to 91252 blocks during deployment); * an update is triggered by executing `updateILVPerBlock` public function */ uint32 public immutable blocksPerUpdate; /** * @dev End block is the last block when ILV/block can be decreased; * it is implied that yield farming stops after that block */ uint32 public endBlock; /** * @dev Each time the ILV/block ratio gets updated, the block number * when the operation has occurred gets recorded into `lastRatioUpdate` * @dev This block number is then used to check if blocks/update `blocksPerUpdate` * has passed when decreasing yield reward by 3% */ uint32 public lastRatioUpdate; /// @dev sILV token address is used to create ILV core pool(s) address public immutable silv; /// @dev Maps pool token address (like ILV) -> 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 ILV) * @param poolAddress deployed pool instance address * @param weight pool weight * @param isFlashPool flag indicating if pool is a flash pool */ event PoolRegistered( address indexed _by, address indexed poolToken, address indexed poolAddress, uint64 weight, bool isFlashPool ); /** * @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 updateILVPerBlock() * * @param _by an address which executed an action * @param newIlvPerBlock new ILV/block value */ event IlvRatioUpdated(address indexed _by, uint256 newIlvPerBlock); /** * @dev Creates/deploys a factory instance * * @param _ilv ILV ERC20 token address * @param _silv sILV ERC20 token address * @param _ilvPerBlock initial ILV/block value for rewards * @param _blocksPerUpdate how frequently the rewards gets updated (decreased by 3%), blocks * @param _initBlock block number to measure _blocksPerUpdate from * @param _endBlock block number when farming stops and rewards cannot be updated anymore */ constructor( address _ilv, address _silv, uint192 _ilvPerBlock, uint32 _blocksPerUpdate, uint32 _initBlock, uint32 _endBlock ) IlluviumAware(_ilv) { // verify the inputs are set require(_silv != address(0), "sILV address not set"); require(_ilvPerBlock > 0, "ILV/block not set"); require(_blocksPerUpdate > 0, "blocks/update not set"); require(_initBlock > 0, "init block not set"); require(_endBlock > _initBlock, "invalid end block: must be greater than init block"); // verify sILV instance supplied require( EscrowedIlluviumERC20(_silv).TOKEN_UID() == 0xac3051b8d4f50966afb632468a4f61483ae6a953b74e387a01ef94316d6b7d62, "unexpected sILV TOKEN_UID" ); // save the inputs into internal state variables silv = _silv; ilvPerBlock = _ilvPerBlock; blocksPerUpdate = _blocksPerUpdate; lastRatioUpdate = _initBlock; endBlock = _endBlock; } /** * @notice Given a pool token retrieves corresponding pool address * * @dev A shortcut for `pools` mapping * * @param poolToken pool token address (like ILV) 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) public 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(); bool isFlashPool = IPool(poolAddr).isFlashPool(); uint32 weight = IPool(poolAddr).weight(); // create the in-memory structure and return it return PoolData({ poolToken: poolToken, poolAddress: poolAddr, weight: weight, isFlashPool: isFlashPool }); } /** * @dev Verifies if `blocksPerUpdate` has passed since last ILV/block * ratio update and if ILV/block reward can be decreased by 3% * * @return true if enough time has passed and `updateILVPerBlock` can be executed */ function shouldUpdateRatio() public view returns (bool) { // if yield farming period has ended if (blockNumber() > endBlock) { // ILV/block reward cannot be updated anymore return false; } // check if blocks/update (91252 blocks) have passed since last update return blockNumber() >= lastRatioUpdate + blocksPerUpdate; } /** * @dev Creates a core pool (IlluviumCorePool) and registers it within the factory * * @dev Can be executed by the pool factory owner only * * @param poolToken pool token address (like ILV, or ILV/ETH pair) * @param initBlock init block to be used for the pool created * @param weight weight of the pool to be created */ function createPool( address poolToken, uint64 initBlock, uint32 weight ) external virtual onlyOwner { // create/deploy new core pool instance IPool pool = new IlluviumCorePool(ilv, silv, this, poolToken, initBlock, weight); // register it within a factory registerPool(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(); bool isFlashPool = IPool(poolAddr).isFlashPool(); 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, isFlashPool); } /** * @notice Decreases ILV/block reward by 3%, can be executed * no more than once per `blocksPerUpdate` blocks */ function updateILVPerBlock() external { // checks if ratio can be updated i.e. if blocks/update (91252 blocks) have passed require(shouldUpdateRatio(), "too frequent"); // decreases ILV/block reward by 3% ilvPerBlock = (ilvPerBlock * 97) / 100; // set current block as the last ratio update block lastRatioUpdate = uint32(blockNumber()); // emit an event emit IlvRatioUpdated(msg.sender, ilvPerBlock); } /** * @dev Mints ILV tokens; executed by ILV Pool only * * @dev Requires factory to have ROLE_TOKEN_CREATOR permission * on the ILV ERC20 token instance * * @param _to an address to mint tokens to * @param _amount amount of ILV tokens to mint */ function mintYieldTo(address _to, uint256 _amount) external { // verify that sender is a pool registered withing the factory require(poolExists[msg.sender], "access denied"); // mint ILV tokens as required mintIlv(_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() || poolExists[msg.sender]); // 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); } /** * @dev Testing time-dependent functionality is difficult and the best way of * doing it is to override block number in helper test smart contracts * * @return `block.number` in mainnet, custom values in testnets (if overridden) */ function blockNumber() public view virtual returns (uint256) { // return current block number return block.number; } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.1; import "../interfaces/IERC20.sol"; import "./Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.1; import "../utils/ERC20.sol"; import "../utils/AccessControl.sol"; contract EscrowedIlluviumERC20 is ERC20("Escrowed Illuvium", "sILV"), AccessControl { /** * @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 = 0xac3051b8d4f50966afb632468a4f61483ae6a953b74e387a01ef94316d6b7d62; /** * @notice Must be called by ROLE_TOKEN_CREATOR addresses. * * @param recipient address to receive the tokens. * @param amount number of tokens to be minted. */ function mint(address recipient, uint256 amount) external { require(isSenderInRole(ROLE_TOKEN_CREATOR), "insufficient privileges (ROLE_TOKEN_CREATOR required)"); _mint(recipient, amount); } /** * @param amount number of tokens to be burned. */ function burn(uint256 amount) external { _burn(msg.sender, amount); } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.1; /** * @title Linked to ILV Marker Interface * * @notice Marks smart contracts which are linked to IlluviumERC20 token instance upon construction, * all these smart contracts share a common ilv() address getter * * @notice Implementing smart contracts MUST verify that they get linked to real IlluviumERC20 instance * and that ilv() getter returns this very same instance address * * @author Basil Gorin */ interface ILinkedToILV { /** * @notice Getter for a verified IlluviumERC20 instance address * * @return IlluviumERC20 token instance address smart contract is linked to */ function ilv() external view returns (address); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.1; import "../token/IlluviumERC20.sol"; import "../interfaces/ILinkedToILV.sol"; /** * @title Illuvium Aware * * @notice Helper smart contract to be inherited by other smart contracts requiring to * be linked to verified IlluviumERC20 instance and performing some basic tasks on it * * @author Basil Gorin */ abstract contract IlluviumAware is ILinkedToILV { /// @dev Link to ILV ERC20 Token IlluviumERC20 instance address public immutable override ilv; /** * @dev Creates IlluviumAware instance, requiring to supply deployed IlluviumERC20 instance address * * @param _ilv deployed IlluviumERC20 instance address */ constructor(address _ilv) { // verify ILV address is set and is correct require(_ilv != address(0), "ILV address not set"); require(IlluviumERC20(_ilv).TOKEN_UID() == 0x83ecb176af7c4f35a45ff0018282e3a05a1018065da866182df12285866f5a2c, "unexpected TOKEN_UID"); // write ILV address ilv = _ilv; } /** * @dev Executes IlluviumERC20.safeTransferFrom(address(this), _to, _value, "") * on the bound IlluviumERC20 instance * * @dev Reentrancy safe due to the IlluviumERC20 design */ function transferIlv(address _to, uint256 _value) internal { // just delegate call to the target transferIlvFrom(address(this), _to, _value); } /** * @dev Executes IlluviumERC20.transferFrom(_from, _to, _value) * on the bound IlluviumERC20 instance * * @dev Reentrancy safe due to the IlluviumERC20 design */ function transferIlvFrom(address _from, address _to, uint256 _value) internal { // just delegate call to the target IlluviumERC20(ilv).transferFrom(_from, _to, _value); } /** * @dev Executes IlluviumERC20.mint(_to, _values) * on the bound IlluviumERC20 instance * * @dev Reentrancy safe due to the IlluviumERC20 design */ function mintIlv(address _to, uint256 _value) internal { // just delegate call to the target IlluviumERC20(ilv).mint(_to, _value); } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.1; /** * @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 { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { address msgSender = msg.sender; _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == msg.sender, "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.1; import "../utils/AddressUtils.sol"; import "../utils/AccessControl.sol"; import "./ERC20Receiver.sol"; /** * @title Illuvium (ILV) ERC20 token * * @notice Illuvium is a core ERC20 token powering the game. * It serves as an in-game currency, is tradable on exchanges, * it powers up the governance protocol (Illuvium DAO) and participates in Yield Farming. * * @dev Token Summary: * - Symbol: ILV * - Name: Illuvium * - Decimals: 18 * - Initial token supply: 7,000,000 ILV * - Maximum final token supply: 10,000,000 ILV * - Up to 3,000,000 ILV may get minted in 3 years period via yield farming * - Mintable: total supply may increase * - Burnable: total supply may decrease * * @dev Token balances and total supply are effectively 192 bits long, meaning that maximum * possible total supply smart contract is able to track is 2^192 (close to 10^40 tokens) * * @dev Smart contract doesn't use safe math. All arithmetic operations are overflow/underflow safe. * Additionally, Solidity 0.8.1 enforces overflow/underflow safety. * * @dev ERC20: reviewed according to https://eips.ethereum.org/EIPS/eip-20 * * @dev ERC20: contract has passed OpenZeppelin ERC20 tests, * see https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/test/token/ERC20/ERC20.behavior.js * see https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/test/token/ERC20/ERC20.test.js * see adopted copies of these tests in the `test` folder * * @dev ERC223/ERC777: not supported; * send tokens via `safeTransferFrom` and implement `ERC20Receiver.onERC20Received` on the receiver instead * * @dev Multiple Withdrawal Attack on ERC20 Tokens (ISBN:978-1-7281-3027-9) - resolved * Related events and functions are marked with "ISBN:978-1-7281-3027-9" tag: * - event Transferred(address indexed _by, address indexed _from, address indexed _to, uint256 _value) * - event Approved(address indexed _owner, address indexed _spender, uint256 _oldValue, uint256 _value) * - function increaseAllowance(address _spender, uint256 _value) public returns (bool) * - function decreaseAllowance(address _spender, uint256 _value) public returns (bool) * See: https://ieeexplore.ieee.org/document/8802438 * See: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * @author Basil Gorin */ contract IlluviumERC20 is AccessControl { /** * @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 = 0x83ecb176af7c4f35a45ff0018282e3a05a1018065da866182df12285866f5a2c; /** * @notice Name of the token: Illuvium * * @notice ERC20 name of the token (long name) * * @dev ERC20 `function name() public view returns (string)` * * @dev Field is declared public: getter name() is created when compiled, * it returns the name of the token. */ string public constant name = "Illuvium"; /** * @notice Symbol of the token: ILV * * @notice ERC20 symbol of that token (short name) * * @dev ERC20 `function symbol() public view returns (string)` * * @dev Field is declared public: getter symbol() is created when compiled, * it returns the symbol of the token */ string public constant symbol = "ILV"; /** * @notice Decimals of the token: 18 * * @dev ERC20 `function decimals() public view returns (uint8)` * * @dev Field is declared public: getter decimals() is created when compiled, * it returns the number of decimals used to get its user representation. * For example, if `decimals` equals `6`, a balance of `1,500,000` tokens should * be displayed to a user as `1,5` (`1,500,000 / 10 ** 6`). * * @dev NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including balanceOf() and transfer(). */ uint8 public constant decimals = 18; /** * @notice Total supply of the token: initially 7,000,000, * with the potential to grow up to 10,000,000 during yield farming period (3 years) * * @dev ERC20 `function totalSupply() public view returns (uint256)` * * @dev Field is declared public: getter totalSupply() is created when compiled, * it returns the amount of tokens in existence. */ uint256 public totalSupply; // is set to 7 million * 10^18 in the constructor /** * @dev A record of all the token balances * @dev This mapping keeps record of all token owners: * owner => balance */ mapping(address => uint256) public tokenBalances; /** * @notice A record of each account's voting delegate * * @dev Auxiliary data structure used to sum up an account's voting power * * @dev This mapping keeps record of all voting power delegations: * voting delegator (token owner) => voting delegate */ mapping(address => address) public votingDelegates; /** * @notice A voting power record binds voting power of a delegate to a particular * block when the voting power delegation change happened */ struct VotingPowerRecord { /* * @dev block.number when delegation has changed; starting from * that block voting power value is in effect */ uint64 blockNumber; /* * @dev cumulative voting power a delegate has obtained starting * from the block stored in blockNumber */ uint192 votingPower; } /** * @notice A record of each account's voting power * * @dev Primarily data structure to store voting power for each account. * Voting power sums up from the account's token balance and delegated * balances. * * @dev Stores current value and entire history of its changes. * The changes are stored as an array of checkpoints. * Checkpoint is an auxiliary data structure containing voting * power (number of votes) and block number when the checkpoint is saved * * @dev Maps voting delegate => voting power record */ mapping(address => VotingPowerRecord[]) public votingPowerHistory; /** * @dev A record of nonces for signing/validating signatures in `delegateWithSig` * for every delegate, increases after successful validation * * @dev Maps delegate address => delegate nonce */ mapping(address => uint256) public nonces; /** * @notice A record of all the allowances to spend tokens on behalf * @dev Maps token owner address to an address approved to spend * some tokens on behalf, maps approved address to that amount * @dev owner => spender => value */ mapping(address => mapping(address => uint256)) public transferAllowances; /** * @notice Enables ERC20 transfers of the tokens * (transfer by the token owner himself) * @dev Feature FEATURE_TRANSFERS must be enabled in order for * `transfer()` function to succeed */ uint32 public constant FEATURE_TRANSFERS = 0x0000_0001; /** * @notice Enables ERC20 transfers on behalf * (transfer by someone else on behalf of token owner) * @dev Feature FEATURE_TRANSFERS_ON_BEHALF must be enabled in order for * `transferFrom()` function to succeed * @dev Token owner must call `approve()` first to authorize * the transfer on behalf */ uint32 public constant FEATURE_TRANSFERS_ON_BEHALF = 0x0000_0002; /** * @dev Defines if the default behavior of `transfer` and `transferFrom` * checks if the receiver smart contract supports ERC20 tokens * @dev When feature FEATURE_UNSAFE_TRANSFERS is enabled the transfers do not * check if the receiver smart contract supports ERC20 tokens, * i.e. `transfer` and `transferFrom` behave like `unsafeTransferFrom` * @dev When feature FEATURE_UNSAFE_TRANSFERS is disabled (default) the transfers * check if the receiver smart contract supports ERC20 tokens, * i.e. `transfer` and `transferFrom` behave like `safeTransferFrom` */ uint32 public constant FEATURE_UNSAFE_TRANSFERS = 0x0000_0004; /** * @notice Enables token owners to burn their own tokens, * including locked tokens which are burnt first * @dev Feature FEATURE_OWN_BURNS must be enabled in order for * `burn()` function to succeed when called by token owner */ uint32 public constant FEATURE_OWN_BURNS = 0x0000_0008; /** * @notice Enables approved operators to burn tokens on behalf of their owners, * including locked tokens which are burnt first * @dev Feature FEATURE_OWN_BURNS must be enabled in order for * `burn()` function to succeed when called by approved operator */ uint32 public constant FEATURE_BURNS_ON_BEHALF = 0x0000_0010; /** * @notice Enables delegators to elect delegates * @dev Feature FEATURE_DELEGATIONS must be enabled in order for * `delegate()` function to succeed */ uint32 public constant FEATURE_DELEGATIONS = 0x0000_0020; /** * @notice Enables delegators to elect delegates on behalf * (via an EIP712 signature) * @dev Feature FEATURE_DELEGATIONS must be enabled in order for * `delegateWithSig()` function to succeed */ uint32 public constant FEATURE_DELEGATIONS_ON_BEHALF = 0x0000_0040; /** * @notice Token creator is responsible for creating (minting) * tokens to an arbitrary address * @dev Role ROLE_TOKEN_CREATOR allows minting tokens * (calling `mint` function) */ uint32 public constant ROLE_TOKEN_CREATOR = 0x0001_0000; /** * @notice Token destroyer is responsible for destroying (burning) * tokens owned by an arbitrary address * @dev Role ROLE_TOKEN_DESTROYER allows burning tokens * (calling `burn` function) */ uint32 public constant ROLE_TOKEN_DESTROYER = 0x0002_0000; /** * @notice ERC20 receivers are allowed to receive tokens without ERC20 safety checks, * which may be useful to simplify tokens transfers into "legacy" smart contracts * @dev When `FEATURE_UNSAFE_TRANSFERS` is not enabled addresses having * `ROLE_ERC20_RECEIVER` permission are allowed to receive tokens * via `transfer` and `transferFrom` functions in the same way they * would via `unsafeTransferFrom` function * @dev When `FEATURE_UNSAFE_TRANSFERS` is enabled `ROLE_ERC20_RECEIVER` permission * doesn't affect the transfer behaviour since * `transfer` and `transferFrom` behave like `unsafeTransferFrom` for any receiver * @dev ROLE_ERC20_RECEIVER is a shortening for ROLE_UNSAFE_ERC20_RECEIVER */ uint32 public constant ROLE_ERC20_RECEIVER = 0x0004_0000; /** * @notice ERC20 senders are allowed to send tokens without ERC20 safety checks, * which may be useful to simplify tokens transfers into "legacy" smart contracts * @dev When `FEATURE_UNSAFE_TRANSFERS` is not enabled senders having * `ROLE_ERC20_SENDER` permission are allowed to send tokens * via `transfer` and `transferFrom` functions in the same way they * would via `unsafeTransferFrom` function * @dev When `FEATURE_UNSAFE_TRANSFERS` is enabled `ROLE_ERC20_SENDER` permission * doesn't affect the transfer behaviour since * `transfer` and `transferFrom` behave like `unsafeTransferFrom` for any receiver * @dev ROLE_ERC20_SENDER is a shortening for ROLE_UNSAFE_ERC20_SENDER */ uint32 public constant ROLE_ERC20_SENDER = 0x0008_0000; /** * @dev Magic value to be returned by ERC20Receiver upon successful reception of token(s) * @dev Equal to `bytes4(keccak256("onERC20Received(address,address,uint256,bytes)"))`, * which can be also obtained as `ERC20Receiver(address(0)).onERC20Received.selector` */ bytes4 private constant ERC20_RECEIVED = 0x4fc35859; /** * @notice EIP-712 contract's domain typeHash, see https://eips.ethereum.org/EIPS/eip-712#rationale-for-typehash */ bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)"); /** * @notice EIP-712 delegation struct typeHash, see https://eips.ethereum.org/EIPS/eip-712#rationale-for-typehash */ bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegate,uint256 nonce,uint256 expiry)"); /** * @dev Fired in transfer(), transferFrom() and some other (non-ERC20) functions * * @dev ERC20 `event Transfer(address indexed _from, address indexed _to, uint256 _value)` * * @param _from an address tokens were consumed from * @param _to an address tokens were sent to * @param _value number of tokens transferred */ event Transfer(address indexed _from, address indexed _to, uint256 _value); /** * @dev Fired in approve() and approveAtomic() functions * * @dev ERC20 `event Approval(address indexed _owner, address indexed _spender, uint256 _value)` * * @param _owner an address which granted a permission to transfer * tokens on its behalf * @param _spender an address which received a permission to transfer * tokens on behalf of the owner `_owner` * @param _value amount of tokens granted to transfer on behalf */ event Approval(address indexed _owner, address indexed _spender, uint256 _value); /** * @dev Fired in mint() function * * @param _by an address which minted some tokens (transaction sender) * @param _to an address the tokens were minted to * @param _value an amount of tokens minted */ event Minted(address indexed _by, address indexed _to, uint256 _value); /** * @dev Fired in burn() function * * @param _by an address which burned some tokens (transaction sender) * @param _from an address the tokens were burnt from * @param _value an amount of tokens burnt */ event Burnt(address indexed _by, address indexed _from, uint256 _value); /** * @dev Resolution for the Multiple Withdrawal Attack on ERC20 Tokens (ISBN:978-1-7281-3027-9) * * @dev Similar to ERC20 Transfer event, but also logs an address which executed transfer * * @dev Fired in transfer(), transferFrom() and some other (non-ERC20) functions * * @param _by an address which performed the transfer * @param _from an address tokens were consumed from * @param _to an address tokens were sent to * @param _value number of tokens transferred */ event Transferred(address indexed _by, address indexed _from, address indexed _to, uint256 _value); /** * @dev Resolution for the Multiple Withdrawal Attack on ERC20 Tokens (ISBN:978-1-7281-3027-9) * * @dev Similar to ERC20 Approve event, but also logs old approval value * * @dev Fired in approve() and approveAtomic() functions * * @param _owner an address which granted a permission to transfer * tokens on its behalf * @param _spender an address which received a permission to transfer * tokens on behalf of the owner `_owner` * @param _oldValue previously granted amount of tokens to transfer on behalf * @param _value new granted amount of tokens to transfer on behalf */ event Approved(address indexed _owner, address indexed _spender, uint256 _oldValue, uint256 _value); /** * @dev Notifies that a key-value pair in `votingDelegates` mapping has changed, * i.e. a delegator address has changed its delegate address * * @param _of delegator address, a token owner * @param _from old delegate, an address which delegate right is revoked * @param _to new delegate, an address which received the voting power */ event DelegateChanged(address indexed _of, address indexed _from, address indexed _to); /** * @dev Notifies that a key-value pair in `votingPowerHistory` mapping has changed, * i.e. a delegate's voting power has changed. * * @param _of delegate whose voting power has changed * @param _fromVal previous number of votes delegate had * @param _toVal new number of votes delegate has */ event VotingPowerChanged(address indexed _of, uint256 _fromVal, uint256 _toVal); /** * @dev Deploys the token smart contract, * assigns initial token supply to the address specified * * @param _initialHolder owner of the initial token supply */ constructor(address _initialHolder) { // verify initial holder address non-zero (is set) require(_initialHolder != address(0), "_initialHolder not set (zero address)"); // mint initial supply mint(_initialHolder, 7_000_000e18); } // ===== Start: ERC20/ERC223/ERC777 functions ===== /** * @notice Gets the balance of a particular address * * @dev ERC20 `function balanceOf(address _owner) public view returns (uint256 balance)` * * @param _owner the address to query the the balance for * @return balance an amount of tokens owned by the address specified */ function balanceOf(address _owner) public view returns (uint256 balance) { // read the balance and return return tokenBalances[_owner]; } /** * @notice Transfers some tokens to an external address or a smart contract * * @dev ERC20 `function transfer(address _to, uint256 _value) public returns (bool success)` * * @dev Called by token owner (an address which has a * positive token balance tracked by this smart contract) * @dev Throws on any error like * * insufficient token balance or * * incorrect `_to` address: * * zero address or * * self address or * * smart contract which doesn't support ERC20 * * @param _to an address to transfer tokens to, * must be either an external address or a smart contract, * compliant with the ERC20 standard * @param _value amount of tokens to be transferred, must * be greater than zero * @return success true on success, throws otherwise */ function transfer(address _to, uint256 _value) public returns (bool success) { // just delegate call to `transferFrom`, // `FEATURE_TRANSFERS` is verified inside it return transferFrom(msg.sender, _to, _value); } /** * @notice Transfers some tokens on behalf of address `_from' (token owner) * to some other address `_to` * * @dev ERC20 `function transferFrom(address _from, address _to, uint256 _value) public returns (bool success)` * * @dev Called by token owner on his own or approved address, * an address approved earlier by token owner to * transfer some amount of tokens on its behalf * @dev Throws on any error like * * insufficient token balance or * * incorrect `_to` address: * * zero address or * * same as `_from` address (self transfer) * * smart contract which doesn't support ERC20 * * @param _from token owner which approved caller (transaction sender) * to transfer `_value` of tokens on its behalf * @param _to an address to transfer tokens to, * must be either an external address or a smart contract, * compliant with the ERC20 standard * @param _value amount of tokens to be transferred, must * be greater than zero * @return success true on success, throws otherwise */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { // depending on `FEATURE_UNSAFE_TRANSFERS` we execute either safe (default) // or unsafe transfer // if `FEATURE_UNSAFE_TRANSFERS` is enabled // or receiver has `ROLE_ERC20_RECEIVER` permission // or sender has `ROLE_ERC20_SENDER` permission if(isFeatureEnabled(FEATURE_UNSAFE_TRANSFERS) || isOperatorInRole(_to, ROLE_ERC20_RECEIVER) || isSenderInRole(ROLE_ERC20_SENDER)) { // we execute unsafe transfer - delegate call to `unsafeTransferFrom`, // `FEATURE_TRANSFERS` is verified inside it unsafeTransferFrom(_from, _to, _value); } // otherwise - if `FEATURE_UNSAFE_TRANSFERS` is disabled // and receiver doesn't have `ROLE_ERC20_RECEIVER` permission else { // we execute safe transfer - delegate call to `safeTransferFrom`, passing empty `_data`, // `FEATURE_TRANSFERS` is verified inside it safeTransferFrom(_from, _to, _value, ""); } // both `unsafeTransferFrom` and `safeTransferFrom` throw on any error, so // if we're here - it means operation successful, // just return true return true; } /** * @notice Transfers some tokens on behalf of address `_from' (token owner) * to some other address `_to` * * @dev Inspired by ERC721 safeTransferFrom, this function allows to * send arbitrary data to the receiver on successful token transfer * @dev Called by token owner on his own or approved address, * an address approved earlier by token owner to * transfer some amount of tokens on its behalf * @dev Throws on any error like * * insufficient token balance or * * incorrect `_to` address: * * zero address or * * same as `_from` address (self transfer) * * smart contract which doesn't support ERC20Receiver interface * @dev Returns silently on success, throws otherwise * * @param _from token owner which approved caller (transaction sender) * to transfer `_value` of tokens on its behalf * @param _to an address to transfer tokens to, * must be either an external address or a smart contract, * compliant with the ERC20 standard * @param _value amount of tokens to be transferred, must * be greater than zero * @param _data [optional] additional data with no specified format, * sent in onERC20Received call to `_to` in case if its a smart contract */ function safeTransferFrom(address _from, address _to, uint256 _value, bytes memory _data) public { // first delegate call to `unsafeTransferFrom` // to perform the unsafe token(s) transfer unsafeTransferFrom(_from, _to, _value); // after the successful transfer - check if receiver supports // ERC20Receiver and execute a callback handler `onERC20Received`, // reverting whole transaction on any error: // check if receiver `_to` supports ERC20Receiver interface if(AddressUtils.isContract(_to)) { // if `_to` is a contract - execute onERC20Received bytes4 response = ERC20Receiver(_to).onERC20Received(msg.sender, _from, _value, _data); // expected response is ERC20_RECEIVED require(response == ERC20_RECEIVED, "invalid onERC20Received response"); } } /** * @notice Transfers some tokens on behalf of address `_from' (token owner) * to some other address `_to` * * @dev In contrast to `safeTransferFrom` doesn't check recipient * smart contract to support ERC20 tokens (ERC20Receiver) * @dev Designed to be used by developers when the receiver is known * to support ERC20 tokens but doesn't implement ERC20Receiver interface * @dev Called by token owner on his own or approved address, * an address approved earlier by token owner to * transfer some amount of tokens on its behalf * @dev Throws on any error like * * insufficient token balance or * * incorrect `_to` address: * * zero address or * * same as `_from` address (self transfer) * @dev Returns silently on success, throws otherwise * * @param _from token owner which approved caller (transaction sender) * to transfer `_value` of tokens on its behalf * @param _to an address to transfer tokens to, * must be either an external address or a smart contract, * compliant with the ERC20 standard * @param _value amount of tokens to be transferred, must * be greater than zero */ function unsafeTransferFrom(address _from, address _to, uint256 _value) public { // if `_from` is equal to sender, require transfers feature to be enabled // otherwise require transfers on behalf feature to be enabled require(_from == msg.sender && isFeatureEnabled(FEATURE_TRANSFERS) || _from != msg.sender && isFeatureEnabled(FEATURE_TRANSFERS_ON_BEHALF), _from == msg.sender? "transfers are disabled": "transfers on behalf are disabled"); // non-zero source address check - Zeppelin // obviously, zero source address is a client mistake // it's not part of ERC20 standard but it's reasonable to fail fast // since for zero value transfer transaction succeeds otherwise require(_from != address(0), "ERC20: transfer from the zero address"); // Zeppelin msg // non-zero recipient address check require(_to != address(0), "ERC20: transfer to the zero address"); // Zeppelin msg // sender and recipient cannot be the same require(_from != _to, "sender and recipient are the same (_from = _to)"); // sending tokens to the token smart contract itself is a client mistake require(_to != address(this), "invalid recipient (transfer to the token smart contract itself)"); // according to ERC-20 Token Standard, https://eips.ethereum.org/EIPS/eip-20 // "Transfers of 0 values MUST be treated as normal transfers and fire the Transfer event." if(_value == 0) { // emit an ERC20 transfer event emit Transfer(_from, _to, _value); // don't forget to return - we're done return; } // no need to make arithmetic overflow check on the _value - by design of mint() // in case of transfer on behalf if(_from != msg.sender) { // read allowance value - the amount of tokens allowed to transfer - into the stack uint256 _allowance = transferAllowances[_from][msg.sender]; // verify sender has an allowance to transfer amount of tokens requested require(_allowance >= _value, "ERC20: transfer amount exceeds allowance"); // Zeppelin msg // update allowance value on the stack _allowance -= _value; // update the allowance value in storage transferAllowances[_from][msg.sender] = _allowance; // emit an improved atomic approve event emit Approved(_from, msg.sender, _allowance + _value, _allowance); // emit an ERC20 approval event to reflect the decrease emit Approval(_from, msg.sender, _allowance); } // verify sender has enough tokens to transfer on behalf require(tokenBalances[_from] >= _value, "ERC20: transfer amount exceeds balance"); // Zeppelin msg // perform the transfer: // decrease token owner (sender) balance tokenBalances[_from] -= _value; // increase `_to` address (receiver) balance tokenBalances[_to] += _value; // move voting power associated with the tokens transferred __moveVotingPower(votingDelegates[_from], votingDelegates[_to], _value); // emit an improved transfer event emit Transferred(msg.sender, _from, _to, _value); // emit an ERC20 transfer event emit Transfer(_from, _to, _value); } /** * @notice Approves address called `_spender` to transfer some amount * of tokens on behalf of the owner * * @dev ERC20 `function approve(address _spender, uint256 _value) public returns (bool success)` * * @dev Caller must not necessarily own any tokens to grant the permission * * @param _spender an address approved by the caller (token owner) * to spend some tokens on its behalf * @param _value an amount of tokens spender `_spender` is allowed to * transfer on behalf of the token owner * @return success true on success, throws otherwise */ function approve(address _spender, uint256 _value) public returns (bool success) { // non-zero spender address check - Zeppelin // obviously, zero spender address is a client mistake // it's not part of ERC20 standard but it's reasonable to fail fast require(_spender != address(0), "ERC20: approve to the zero address"); // Zeppelin msg // read old approval value to emmit an improved event (ISBN:978-1-7281-3027-9) uint256 _oldValue = transferAllowances[msg.sender][_spender]; // perform an operation: write value requested into the storage transferAllowances[msg.sender][_spender] = _value; // emit an improved atomic approve event (ISBN:978-1-7281-3027-9) emit Approved(msg.sender, _spender, _oldValue, _value); // emit an ERC20 approval event emit Approval(msg.sender, _spender, _value); // operation successful, return true return true; } /** * @notice Returns the amount which _spender is still allowed to withdraw from _owner. * * @dev ERC20 `function allowance(address _owner, address _spender) public view returns (uint256 remaining)` * * @dev A function to check an amount of tokens owner approved * to transfer on its behalf by some other address called "spender" * * @param _owner an address which approves transferring some tokens on its behalf * @param _spender an address approved to transfer some tokens on behalf * @return remaining an amount of tokens approved address `_spender` can transfer on behalf * of token owner `_owner` */ function allowance(address _owner, address _spender) public view returns (uint256 remaining) { // read the value from storage and return return transferAllowances[_owner][_spender]; } // ===== End: ERC20/ERC223/ERC777 functions ===== // ===== Start: Resolution for the Multiple Withdrawal Attack on ERC20 Tokens (ISBN:978-1-7281-3027-9) ===== /** * @notice Increases the allowance granted to `spender` by the transaction sender * * @dev Resolution for the Multiple Withdrawal Attack on ERC20 Tokens (ISBN:978-1-7281-3027-9) * * @dev Throws if value to increase by is zero or too big and causes arithmetic overflow * * @param _spender an address approved by the caller (token owner) * to spend some tokens on its behalf * @param _value an amount of tokens to increase by * @return success true on success, throws otherwise */ function increaseAllowance(address _spender, uint256 _value) public virtual returns (bool) { // read current allowance value uint256 currentVal = transferAllowances[msg.sender][_spender]; // non-zero _value and arithmetic overflow check on the allowance require(currentVal + _value > currentVal, "zero value approval increase or arithmetic overflow"); // delegate call to `approve` with the new value return approve(_spender, currentVal + _value); } /** * @notice Decreases the allowance granted to `spender` by the caller. * * @dev Resolution for the Multiple Withdrawal Attack on ERC20 Tokens (ISBN:978-1-7281-3027-9) * * @dev Throws if value to decrease by is zero or is bigger than currently allowed value * * @param _spender an address approved by the caller (token owner) * to spend some tokens on its behalf * @param _value an amount of tokens to decrease by * @return success true on success, throws otherwise */ function decreaseAllowance(address _spender, uint256 _value) public virtual returns (bool) { // read current allowance value uint256 currentVal = transferAllowances[msg.sender][_spender]; // non-zero _value check on the allowance require(_value > 0, "zero value approval decrease"); // verify allowance decrease doesn't underflow require(currentVal >= _value, "ERC20: decreased allowance below zero"); // delegate call to `approve` with the new value return approve(_spender, currentVal - _value); } // ===== End: Resolution for the Multiple Withdrawal Attack on ERC20 Tokens (ISBN:978-1-7281-3027-9) ===== // ===== Start: Minting/burning extension ===== /** * @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) public { // check if caller has sufficient permissions to mint tokens require(isSenderInRole(ROLE_TOKEN_CREATOR), "insufficient privileges (ROLE_TOKEN_CREATOR required)"); // non-zero recipient address check require(_to != address(0), "ERC20: mint to the zero address"); // Zeppelin msg // 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"); // uint192 overflow check (required by voting delegation) require(totalSupply + _value <= type(uint192).max, "total supply overflow (uint192)"); // perform mint: // increase total amount of tokens value totalSupply += _value; // increase `_to` address balance tokenBalances[_to] += _value; // create voting power associated with the tokens minted __moveVotingPower(address(0), votingDelegates[_to], _value); // fire a minted event emit Minted(msg.sender, _to, _value); // emit an improved transfer event emit Transferred(msg.sender, address(0), _to, _value); // fire ERC20 compliant transfer event emit Transfer(address(0), _to, _value); } /** * @dev Burns (destroys) some tokens from the address specified * @dev The value specified is treated as is without taking * into account what `decimals` value is * @dev Behaves effectively as `burnFrom` function, allowing * to specify an address to burn tokens from * @dev Requires sender to have `ROLE_TOKEN_DESTROYER` permission * * @param _from an address to burn some tokens from * @param _value an amount of tokens to burn (destroy) */ function burn(address _from, uint256 _value) public { // check if caller has sufficient permissions to burn tokens // and if not - check for possibility to burn own tokens or to burn on behalf if(!isSenderInRole(ROLE_TOKEN_DESTROYER)) { // if `_from` is equal to sender, require own burns feature to be enabled // otherwise require burns on behalf feature to be enabled require(_from == msg.sender && isFeatureEnabled(FEATURE_OWN_BURNS) || _from != msg.sender && isFeatureEnabled(FEATURE_BURNS_ON_BEHALF), _from == msg.sender? "burns are disabled": "burns on behalf are disabled"); // in case of burn on behalf if(_from != msg.sender) { // read allowance value - the amount of tokens allowed to be burnt - into the stack uint256 _allowance = transferAllowances[_from][msg.sender]; // verify sender has an allowance to burn amount of tokens requested require(_allowance >= _value, "ERC20: burn amount exceeds allowance"); // Zeppelin msg // update allowance value on the stack _allowance -= _value; // update the allowance value in storage transferAllowances[_from][msg.sender] = _allowance; // emit an improved atomic approve event emit Approved(msg.sender, _from, _allowance + _value, _allowance); // emit an ERC20 approval event to reflect the decrease emit Approval(_from, msg.sender, _allowance); } } // at this point we know that either sender is ROLE_TOKEN_DESTROYER or // we burn own tokens or on behalf (in latest case we already checked and updated allowances) // we have left to execute balance checks and burning logic itself // non-zero burn value check require(_value != 0, "zero value burn"); // non-zero source address check - Zeppelin require(_from != address(0), "ERC20: burn from the zero address"); // Zeppelin msg // verify `_from` address has enough tokens to destroy // (basically this is a arithmetic overflow check) require(tokenBalances[_from] >= _value, "ERC20: burn amount exceeds balance"); // Zeppelin msg // perform burn: // decrease `_from` address balance tokenBalances[_from] -= _value; // decrease total amount of tokens value totalSupply -= _value; // destroy voting power associated with the tokens burnt __moveVotingPower(votingDelegates[_from], address(0), _value); // fire a burnt event emit Burnt(msg.sender, _from, _value); // emit an improved transfer event emit Transferred(msg.sender, _from, address(0), _value); // fire ERC20 compliant transfer event emit Transfer(_from, address(0), _value); } // ===== End: Minting/burning extension ===== // ===== Start: DAO Support (Compound-like voting delegation) ===== /** * @notice Gets current voting power of the account `_of` * @param _of the address of account to get voting power of * @return current cumulative voting power of the account, * sum of token balances of all its voting delegators */ function getVotingPower(address _of) public view returns (uint256) { // get a link to an array of voting power history records for an address specified VotingPowerRecord[] storage history = votingPowerHistory[_of]; // lookup the history and return latest element return history.length == 0? 0: history[history.length - 1].votingPower; } /** * @notice Gets past voting power of the account `_of` at some block `_blockNum` * @dev Throws if `_blockNum` is not in the past (not the finalized block) * @param _of the address of account to get voting power of * @param _blockNum block number to get the voting power at * @return past cumulative voting power of the account, * sum of token balances of all its voting delegators at block number `_blockNum` */ function getVotingPowerAt(address _of, uint256 _blockNum) public view returns (uint256) { // make sure block number is not in the past (not the finalized block) require(_blockNum < block.number, "not yet determined"); // Compound msg // get a link to an array of voting power history records for an address specified VotingPowerRecord[] storage history = votingPowerHistory[_of]; // if voting power history for the account provided is empty if(history.length == 0) { // than voting power is zero - return the result return 0; } // check latest voting power history record block number: // if history was not updated after the block of interest if(history[history.length - 1].blockNumber <= _blockNum) { // we're done - return last voting power record return getVotingPower(_of); } // check first voting power history record block number: // if history was never updated before the block of interest if(history[0].blockNumber > _blockNum) { // we're done - voting power at the block num of interest was zero return 0; } // `votingPowerHistory[_of]` is an array ordered by `blockNumber`, ascending; // apply binary search on `votingPowerHistory[_of]` to find such an entry number `i`, that // `votingPowerHistory[_of][i].blockNumber <= _blockNum`, but in the same time // `votingPowerHistory[_of][i + 1].blockNumber > _blockNum` // return the result - voting power found at index `i` return history[__binaryLookup(_of, _blockNum)].votingPower; } /** * @dev Reads an entire voting power history array for the delegate specified * * @param _of delegate to query voting power history for * @return voting power history array for the delegate of interest */ function getVotingPowerHistory(address _of) public view returns(VotingPowerRecord[] memory) { // return an entire array as memory return votingPowerHistory[_of]; } /** * @dev Returns length of the voting power history array for the delegate specified; * useful since reading an entire array just to get its length is expensive (gas cost) * * @param _of delegate to query voting power history length for * @return voting power history array length for the delegate of interest */ function getVotingPowerHistoryLength(address _of) public view returns(uint256) { // read array length and return return votingPowerHistory[_of].length; } /** * @notice Delegates voting power of the delegator `msg.sender` to the delegate `_to` * * @dev Accepts zero value address to delegate voting power to, effectively * removing the delegate in that case * * @param _to address to delegate voting power to */ function delegate(address _to) public { // verify delegations are enabled require(isFeatureEnabled(FEATURE_DELEGATIONS), "delegations are disabled"); // delegate call to `__delegate` __delegate(msg.sender, _to); } /** * @notice Delegates voting power of the delegator (represented by its signature) to the delegate `_to` * * @dev Accepts zero value address to delegate voting power to, effectively * removing the delegate in that case * * @dev Compliant with EIP-712: Ethereum typed structured data hashing and signing, * see https://eips.ethereum.org/EIPS/eip-712 * * @param _to address to delegate voting power to * @param _nonce nonce used to construct the signature, and used to validate it; * nonce is increased by one after successful signature validation and vote delegation * @param _exp signature expiration time * @param v the recovery byte of the signature * @param r half of the ECDSA signature pair * @param s half of the ECDSA signature pair */ function delegateWithSig(address _to, uint256 _nonce, uint256 _exp, uint8 v, bytes32 r, bytes32 s) public { // verify delegations on behalf are enabled require(isFeatureEnabled(FEATURE_DELEGATIONS_ON_BEHALF), "delegations on behalf are disabled"); // build the EIP-712 contract domain separator bytes32 domainSeparator = keccak256(abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name)), block.chainid, address(this))); // build the EIP-712 hashStruct of the delegation message bytes32 hashStruct = keccak256(abi.encode(DELEGATION_TYPEHASH, _to, _nonce, _exp)); // calculate the EIP-712 digest "\x19\x01" ‖ domainSeparator ‖ hashStruct(message) bytes32 digest = keccak256(abi.encodePacked("\x19\x01", domainSeparator, hashStruct)); // recover the address who signed the message with v, r, s address signer = ecrecover(digest, v, r, s); // perform message integrity and security validations require(signer != address(0), "invalid signature"); // Compound msg require(_nonce == nonces[signer], "invalid nonce"); // Compound msg require(block.timestamp < _exp, "signature expired"); // Compound msg // update the nonce for that particular signer to avoid replay attack nonces[signer]++; // delegate call to `__delegate` - execute the logic required __delegate(signer, _to); } /** * @dev Auxiliary function to delegate delegator's `_from` voting power to the delegate `_to` * @dev Writes to `votingDelegates` and `votingPowerHistory` mappings * * @param _from delegator who delegates his voting power * @param _to delegate who receives the voting power */ function __delegate(address _from, address _to) private { // read current delegate to be replaced by a new one address _fromDelegate = votingDelegates[_from]; // read current voting power (it is equal to token balance) uint256 _value = tokenBalances[_from]; // reassign voting delegate to `_to` votingDelegates[_from] = _to; // update voting power for `_fromDelegate` and `_to` __moveVotingPower(_fromDelegate, _to, _value); // emit an event emit DelegateChanged(_from, _fromDelegate, _to); } /** * @dev Auxiliary function to move voting power `_value` * from delegate `_from` to the delegate `_to` * * @dev Doesn't have any effect if `_from == _to`, or if `_value == 0` * * @param _from delegate to move voting power from * @param _to delegate to move voting power to * @param _value voting power to move from `_from` to `_to` */ function __moveVotingPower(address _from, address _to, uint256 _value) private { // if there is no move (`_from == _to`) or there is nothing to move (`_value == 0`) if(_from == _to || _value == 0) { // return silently with no action return; } // if source address is not zero - decrease its voting power if(_from != address(0)) { // read current source address voting power uint256 _fromVal = getVotingPower(_from); // calculate decreased voting power // underflow is not possible by design: // voting power is limited by token balance which is checked by the callee uint256 _toVal = _fromVal - _value; // update source voting power from `_fromVal` to `_toVal` __updateVotingPower(_from, _fromVal, _toVal); } // if destination address is not zero - increase its voting power if(_to != address(0)) { // read current destination address voting power uint256 _fromVal = getVotingPower(_to); // calculate increased voting power // overflow is not possible by design: // max token supply limits the cumulative voting power uint256 _toVal = _fromVal + _value; // update destination voting power from `_fromVal` to `_toVal` __updateVotingPower(_to, _fromVal, _toVal); } } /** * @dev Auxiliary function to update voting power of the delegate `_of` * from value `_fromVal` to value `_toVal` * * @param _of delegate to update its voting power * @param _fromVal old voting power of the delegate * @param _toVal new voting power of the delegate */ function __updateVotingPower(address _of, uint256 _fromVal, uint256 _toVal) private { // get a link to an array of voting power history records for an address specified VotingPowerRecord[] storage history = votingPowerHistory[_of]; // if there is an existing voting power value stored for current block if(history.length != 0 && history[history.length - 1].blockNumber == block.number) { // update voting power which is already stored in the current block history[history.length - 1].votingPower = uint192(_toVal); } // otherwise - if there is no value stored for current block else { // add new element into array representing the value for current block history.push(VotingPowerRecord(uint64(block.number), uint192(_toVal))); } // emit an event emit VotingPowerChanged(_of, _fromVal, _toVal); } /** * @dev Auxiliary function to lookup an element in a sorted (asc) array of elements * * @dev This function finds the closest element in an array to the value * of interest (not exceeding that value) and returns its index within an array * * @dev An array to search in is `votingPowerHistory[_to][i].blockNumber`, * it is sorted in ascending order (blockNumber increases) * * @param _to an address of the delegate to get an array for * @param n value of interest to look for * @return an index of the closest element in an array to the value * of interest (not exceeding that value) */ function __binaryLookup(address _to, uint256 n) private view returns(uint256) { // get a link to an array of voting power history records for an address specified VotingPowerRecord[] storage history = votingPowerHistory[_to]; // left bound of the search interval, originally start of the array uint256 i = 0; // right bound of the search interval, originally end of the array uint256 j = history.length - 1; // the iteration process narrows down the bounds by // splitting the interval in a half oce per each iteration while(j > i) { // get an index in the middle of the interval [i, j] uint256 k = j - (j - i) / 2; // read an element to compare it with the value of interest VotingPowerRecord memory cp = history[k]; // if we've got a strict equal - we're lucky and done if(cp.blockNumber == n) { // just return the result - index `k` return k; } // if the value of interest is bigger - move left bound to the middle else if (cp.blockNumber < n) { // move left bound `i` to the middle position `k` i = k; } // otherwise, when the value of interest is smaller - move right bound to the middle else { // move right bound `j` to the middle position `k - 1`: // element at position `k` is bigger and cannot be the result j = k - 1; } } // reaching that point means no exact match found // since we're interested in the element which is not bigger than the // element of interest, we return the lower bound `i` return i; } } // ===== End: DAO Support (Compound-like voting delegation) =====
// SPDX-License-Identifier: MIT pragma solidity 0.8.1; /** * @title Address Utils * * @dev Utility library of inline functions on addresses * * @author Basil Gorin */ library AddressUtils { /** * @notice Checks if the target address is a contract * @dev This function will return false if invoked during the constructor of a contract, * as the code is not actually created until after the constructor finishes. * @param addr address to check * @return whether the target address is a contract */ function isContract(address addr) internal view returns (bool) { // a variable to load `extcodesize` to uint256 size = 0; // XXX Currently there is no better way to check if there is a contract in an address // than to check the size of the code at that address. // See https://ethereum.stackexchange.com/a/14016/36603 for more details about how this works. // TODO: Check this again before the Serenity release, because all addresses will be contracts. // solium-disable-next-line security/no-inline-assembly assembly { // retrieve the size of the code at address `addr` size := extcodesize(addr) } // positive size indicates a smart contract address return size > 0; } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.1; /** * @title Access Control List * * @notice Access control smart contract provides an API to check * if specific operation is permitted globally and/or * if particular user has a permission to execute it. * * @notice It deals with two main entities: features and roles. * * @notice Features are designed to be used to enable/disable specific * functions (public functions) of the smart contract for everyone. * @notice User roles are designed to restrict access to specific * functions (restricted functions) of the smart contract to some users. * * @notice Terms "role", "permissions" and "set of permissions" have equal meaning * in the documentation text and may be used interchangeably. * @notice Terms "permission", "single permission" implies only one permission bit set. * * @dev This smart contract is designed to be inherited by other * smart contracts which require access control management capabilities. * * @author Basil Gorin */ contract AccessControl { /** * @notice Access manager is responsible for assigning the roles to users, * enabling/disabling global features of the smart contract * @notice Access manager can add, remove and update user roles, * remove and update global features * * @dev Role ROLE_ACCESS_MANAGER allows modifying user roles and global features * @dev Role ROLE_ACCESS_MANAGER has single bit at position 255 enabled */ uint256 public constant ROLE_ACCESS_MANAGER = 0x8000000000000000000000000000000000000000000000000000000000000000; /** * @dev Bitmask representing all the possible permissions (super admin role) * @dev Has all the bits are enabled (2^256 - 1 value) */ uint256 private constant FULL_PRIVILEGES_MASK = type(uint256).max; // before 0.8.0: uint256(-1) overflows to 0xFFFF... /** * @notice Privileged addresses with defined roles/permissions * @notice In the context of ERC20/ERC721 tokens these can be permissions to * allow minting or burning tokens, transferring on behalf and so on * * @dev Maps user address to the permissions bitmask (role), where each bit * represents a permission * @dev Bitmask 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF * represents all possible permissions * @dev Zero address mapping represents global features of the smart contract */ mapping(address => uint256) public userRoles; /** * @dev Fired in updateRole() and updateFeatures() * * @param _by operator which called the function * @param _to address which was granted/revoked permissions * @param _requested permissions requested * @param _actual permissions effectively set */ event RoleUpdated(address indexed _by, address indexed _to, uint256 _requested, uint256 _actual); /** * @notice Creates an access control instance, * setting contract creator to have full privileges */ constructor() { // contract creator has full privileges userRoles[msg.sender] = FULL_PRIVILEGES_MASK; } /** * @notice Retrieves globally set of features enabled * * @dev Auxiliary getter function to maintain compatibility with previous * versions of the Access Control List smart contract, where * features was a separate uint256 public field * * @return 256-bit bitmask of the features enabled */ function features() public view returns(uint256) { // according to new design features are stored in zero address // mapping of `userRoles` structure return userRoles[address(0)]; } /** * @notice Updates set of the globally enabled features (`features`), * taking into account sender's permissions * * @dev Requires transaction sender to have `ROLE_ACCESS_MANAGER` permission * @dev Function is left for backward compatibility with older versions * * @param _mask bitmask representing a set of features to enable/disable */ function updateFeatures(uint256 _mask) public { // delegate call to `updateRole` updateRole(address(0), _mask); } /** * @notice Updates set of permissions (role) for a given user, * taking into account sender's permissions. * * @dev Setting role to zero is equivalent to removing an all permissions * @dev Setting role to `FULL_PRIVILEGES_MASK` is equivalent to * copying senders' permissions (role) to the user * @dev Requires transaction sender to have `ROLE_ACCESS_MANAGER` permission * * @param operator address of a user to alter permissions for or zero * to alter global features of the smart contract * @param role bitmask representing a set of permissions to * enable/disable for a user specified */ function updateRole(address operator, uint256 role) public { // caller must have a permission to update user roles require(isSenderInRole(ROLE_ACCESS_MANAGER), "insufficient privileges (ROLE_ACCESS_MANAGER required)"); // evaluate the role and reassign it userRoles[operator] = evaluateBy(msg.sender, userRoles[operator], role); // fire an event emit RoleUpdated(msg.sender, operator, role, userRoles[operator]); } /** * @notice Determines the permission bitmask an operator can set on the * target permission set * @notice Used to calculate the permission bitmask to be set when requested * in `updateRole` and `updateFeatures` functions * * @dev Calculated based on: * 1) operator's own permission set read from userRoles[operator] * 2) target permission set - what is already set on the target * 3) desired permission set - what do we want set target to * * @dev Corner cases: * 1) Operator is super admin and its permission set is `FULL_PRIVILEGES_MASK`: * `desired` bitset is returned regardless of the `target` permission set value * (what operator sets is what they get) * 2) Operator with no permissions (zero bitset): * `target` bitset is returned regardless of the `desired` value * (operator has no authority and cannot modify anything) * * @dev Example: * Consider an operator with the permissions bitmask 00001111 * is about to modify the target permission set 01010101 * Operator wants to set that permission set to 00110011 * Based on their role, an operator has the permissions * to update only lowest 4 bits on the target, meaning that * high 4 bits of the target set in this example is left * unchanged and low 4 bits get changed as desired: 01010011 * * @param operator address of the contract operator which is about to set the permissions * @param target input set of permissions to operator is going to modify * @param desired desired set of permissions operator would like to set * @return resulting set of permissions given operator will set */ function evaluateBy(address operator, uint256 target, uint256 desired) public view returns(uint256) { // read operator's permissions uint256 p = userRoles[operator]; // taking into account operator's permissions, // 1) enable the permissions desired on the `target` target |= p & desired; // 2) disable the permissions desired on the `target` target &= FULL_PRIVILEGES_MASK ^ (p & (FULL_PRIVILEGES_MASK ^ desired)); // return calculated result return target; } /** * @notice Checks if requested set of features is enabled globally on the contract * * @param required set of features to check against * @return true if all the features requested are enabled, false otherwise */ function isFeatureEnabled(uint256 required) public view returns(bool) { // delegate call to `__hasRole`, passing `features` property return __hasRole(features(), required); } /** * @notice Checks if transaction sender `msg.sender` has all the permissions required * * @param required set of permissions (role) to check against * @return true if all the permissions requested are enabled, false otherwise */ function isSenderInRole(uint256 required) public view returns(bool) { // delegate call to `isOperatorInRole`, passing transaction sender return isOperatorInRole(msg.sender, required); } /** * @notice Checks if operator has all the permissions (role) required * * @param operator address of the user to check role for * @param required set of permissions (role) to check * @return true if all the permissions requested are enabled, false otherwise */ function isOperatorInRole(address operator, uint256 required) public view returns(bool) { // delegate call to `__hasRole`, passing operator's permissions (role) return __hasRole(userRoles[operator], required); } /** * @dev Checks if role `actual` contains all the permissions required `required` * * @param actual existent role * @param required required role * @return true if actual has required role (all permissions), false otherwise */ function __hasRole(uint256 actual, uint256 required) internal pure returns(bool) { // check the bitmask for the role required and return the result return actual & required == required; } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.1; /** * @title ERC20 token receiver interface * * @dev Interface for any contract that wants to support safe transfers * from ERC20 token smart contracts. * @dev Inspired by ERC721 and ERC223 token standards * * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md * @dev See https://github.com/ethereum/EIPs/issues/223 * * @author Basil Gorin */ interface ERC20Receiver { /** * @notice Handle the receipt of a ERC20 token(s) * @dev The ERC20 smart contract calls this function on the recipient * after a successful transfer (`safeTransferFrom`). * This function MAY throw to revert and reject the transfer. * Return of other than the magic value MUST result in the transaction being reverted. * @notice The contract address is always the message sender. * A wallet/broker/auction application MUST implement the wallet interface * if it will accept safe transfers. * @param _operator The address which called `safeTransferFrom` function * @param _from The address which previously owned the token * @param _value amount of tokens which is being transferred * @param _data additional data with no specified format * @return `bytes4(keccak256("onERC20Received(address,address,uint256,bytes)"))` unless throwing */ function onERC20Received(address _operator, address _from, uint256 _value, bytes calldata _data) external returns(bytes4); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.1; import "../interfaces/IERC20.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ // Copied from Open Zeppelin contract ERC20 is IERC20 { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @notice Token creator is responsible for creating (minting) * tokens to an arbitrary address * @dev Role ROLE_TOKEN_CREATOR allows minting tokens * (calling `mint` function) */ uint32 public constant ROLE_TOKEN_CREATOR = 0x0001_0000; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view virtual returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(msg.sender, recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(msg.sender, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, msg.sender, _allowances[sender][msg.sender] - 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(msg.sender, spender, _allowances[msg.sender][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) { _approve(msg.sender, spender, _allowances[msg.sender][spender] - subtractedValue); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender] - amount; _balances[recipient] = _balances[recipient] + amount; emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply + amount; _balances[account] = _balances[account] + amount; emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account] - amount; _totalSupply = _totalSupply - amount; emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal virtual { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
// SPDX-License-Identifier: MIT pragma solidity 0.8.1; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.3._ */ 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.3._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) private pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_ilv","type":"address"},{"internalType":"address","name":"_silv","type":"address"},{"internalType":"contract IlluviumPoolFactory","name":"_factory","type":"address"},{"internalType":"address","name":"_poolToken","type":"address"},{"internalType":"uint64","name":"_initBlock","type":"uint64"},{"internalType":"uint32","name":"_weight","type":"uint32"}],"stateMutability":"nonpayable","type":"constructor"},{"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":true,"internalType":"address","name":"_by","type":"address"},{"indexed":false,"internalType":"uint256","name":"depositId","type":"uint256"},{"indexed":false,"internalType":"uint64","name":"lockedFrom","type":"uint64"},{"indexed":false,"internalType":"uint64","name":"lockedUntil","type":"uint64"}],"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":false,"internalType":"uint256","name":"yieldRewardsPerWeight","type":"uint256"},{"indexed":false,"internalType":"uint64","name":"lastYieldDistribution","type":"uint64"}],"name":"Synchronized","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":"VaultRewardsClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_by","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"VaultRewardsReceived","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_by","type":"address"},{"indexed":false,"internalType":"address","name":"_fromVal","type":"address"},{"indexed":false,"internalType":"address","name":"_toVal","type":"address"}],"name":"VaultUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_by","type":"address"},{"indexed":true,"internalType":"address","name":"_to","type":"address"},{"indexed":false,"internalType":"bool","name":"sIlv","type":"bool"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"YieldClaimed","type":"event"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"blockNumber","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"factory","outputs":[{"internalType":"contract IlluviumPoolFactory","name":"","type":"address"}],"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":"uint64","name":"lockedFrom","type":"uint64"},{"internalType":"uint64","name":"lockedUntil","type":"uint64"},{"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":"ilv","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isFlashPool","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastYieldDistribution","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"now256","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_staker","type":"address"}],"name":"pendingVaultRewards","outputs":[{"internalType":"uint256","name":"pending","type":"uint256"}],"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":[{"internalType":"bool","name":"_useSILV","type":"bool"}],"name":"processRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_rewardsAmount","type":"uint256"}],"name":"receiveVaultRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"reward","type":"uint256"},{"internalType":"uint256","name":"rewardPerWeight","type":"uint256"}],"name":"rewardToWeight","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"_vault","type":"address"}],"name":"setVault","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_weight","type":"uint32"}],"name":"setWeight","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"silv","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint64","name":"_lockUntil","type":"uint64"},{"internalType":"bool","name":"_useSILV","type":"bool"}],"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":"sync","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_depositId","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"bool","name":"_useSILV","type":"bool"}],"name":"unstake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"depositId","type":"uint256"},{"internalType":"uint64","name":"lockedUntil","type":"uint64"},{"internalType":"bool","name":"useSILV","type":"bool"}],"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":"subYieldRewards","type":"uint256"},{"internalType":"uint256","name":"subVaultRewards","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"usersLockingWeight","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vault","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vaultRewardsPerWeight","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"weight","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_weight","type":"uint256"},{"internalType":"uint256","name":"rewardPerWeight","type":"uint256"}],"name":"weightToReward","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"yieldRewardsPerWeight","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
6101006040523480156200001257600080fd5b5060405162003bad38038062003bad8339810160408190526200003591620003e8565b858585858585856001600160a01b0381166200006e5760405162461bcd60e51b81526004016200006590620005ad565b60405180910390fd5b806001600160a01b0316638a114e136040518163ffffffff1660e01b815260040160206040518083038186803b158015620000a857600080fd5b505afa158015620000bd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620000e391906200048c565b7f83ecb176af7c4f35a45ff0018282e3a05a1018065da866182df12285866f5a2c14620001245760405162461bcd60e51b8152600401620000659062000576565b60601b6001600160601b03191660805260016000556001600160a01b038516620001625760405162461bcd60e51b81526004016200006590620005e4565b6001600160a01b0384166200018b5760405162461bcd60e51b8152600401620000659062000513565b6001600160a01b038316620001b45760405162461bcd60e51b81526004016200006590620004dc565b6000826001600160401b031611620001e05760405162461bcd60e51b815260040162000065906200054a565b60008163ffffffff1611620002095760405162461bcd60e51b815260040162000065906200061b565b846001600160a01b0316638a114e136040518163ffffffff1660e01b815260040160206040518083038186803b1580156200024357600080fd5b505afa15801562000258573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200027e91906200048c565b7fac3051b8d4f50966afb632468a4f61483ae6a953b74e387a01ef94316d6b7d6214620002bf5760405162461bcd60e51b8152600401620000659062000652565b836001600160a01b031663f70b7fce6040518163ffffffff1660e01b815260040160206040518083038186803b158015620002f957600080fd5b505afa1580156200030e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200033491906200048c565b7fc5cfd88c6e4d7e5c8a03c255f03af23c0918d8e82cac196f57466af3fd4a5ec714620003755760405162461bcd60e51b81526004016200006590620004a5565b606094851b6001600160601b031990811660a05293851b841660c0529190931b90911660e0526002805463ffffffff191663ffffffff90921691909117600160201b600160601b0319166401000000006001600160401b039093169290920291909117905550620006a295505050505050565b60008060008060008060c0878903121562000401578182fd5b86516200040e8162000689565b6020880151909650620004218162000689565b6040880151909550620004348162000689565b6060880151909450620004478162000689565b60808801519093506001600160401b038116811462000464578283fd5b60a088015190925063ffffffff811681146200047e578182fd5b809150509295509295509295565b6000602082840312156200049e578081fd5b5051919050565b60208082526016908201527f756e657870656374656420464143544f52595f55494400000000000000000000604082015260600190565b6020808252601a908201527f706f6f6c20746f6b656e2061646472657373206e6f7420736574000000000000604082015260600190565b6020808252601c908201527f494c5620506f6f6c206663742061646472657373206e6f742073657400000000604082015260600190565b6020808252601290820152711a5b9a5d08189b1bd8dac81b9bdd081cd95d60721b604082015260600190565b60208082526014908201527f756e657870656374656420544f4b454e5f554944000000000000000000000000604082015260600190565b60208082526013908201527f494c562061646472657373206e6f742073657400000000000000000000000000604082015260600190565b60208082526014908201527f73494c562061646472657373206e6f7420736574000000000000000000000000604082015260600190565b60208082526013908201527f706f6f6c20776569676874206e6f742073657400000000000000000000000000604082015260600190565b60208082526019908201527f756e65787065637465642073494c5620544f4b454e5f55494400000000000000604082015260600190565b6001600160a01b03811681146200069f57600080fd5b50565b60805160601c60a05160601c60c05160601c60e05160601c6133fa620007b3600039600081816109b201528181610fa6015281816115ba01528181611c1001528181611d590152818161214e015281816121fa0152818161296801526129c6015260008181610481015281816105750152818161060c01528181610a4801528181610afc01528181610da601528181610f8201528181611118015281816111ae01528181611224015281816113860152818161142401528181611efa01526126dd01526000818161080f01526128ce0152600081816104030152818161098801528181611590015281816118df01528181611b3d01528181611be601528181611d2f0152611f2701526133fa6000f3fe608060405234801561001057600080fd5b50600436106101e55760003560e01c80636817031b1161010f578063c45a0155116100a2578063fa213bd611610071578063fa213bd6146103d0578063fbfa77cf146103d8578063fc27076f146103e0578063fff6cae9146103f3576101e5565b8063c45a0155146103a5578063cbdf382c146103ad578063ce111541146103b5578063e8d3cad5146103bd576101e5565b8063a156dc28116100de578063a156dc2814610352578063a1aab33f14610365578063a87430ba1461037a578063beb0ed6c1461039d576101e5565b80636817031b1461030657806370a082311461031957806379b91d691461032c5780638e169d471461033f576101e5565b806329eb5f2c116101875780634ce0f9a6116101565780634ce0f9a6146102d057806351c547f8146102d857806352044ec9146102eb57806357e871e7146102fe576101e5565b806329eb5f2c146102825780633021a560146102975780634087aeb7146102aa57806344cc892d146102bd576101e5565b80631984db99116101c35780631984db99146102325780631da10d91146102455780631fffab221461025a5780632726b50614610262576101e5565b806305472358146101ea578063084ff3c91461020857806315e4b1ae1461021d575b600080fd5b6101f26103fb565b6040516101ff9190613221565b60405180910390f35b610210610401565b6040516101ff9190612e1f565b61023061022b366004612d8a565b610425565b005b6101f2610240366004612c3f565b61044a565b61024d610808565b6040516101ff9190612e8a565b61021061080d565b610275610270366004612c77565b610831565b6040516101ff91906131d6565b61028a6108e2565b6040516101ff91906132a3565b6102306102a5366004612d01565b6108f8565b6102306102b8366004612dcb565b610a3d565b6102306102cb366004612c77565b610ae5565b6101f2610d74565b6102306102e6366004612ca2565b610d78565b6102306102f9366004612d8a565b610d88565b6101f2610d96565b610230610314366004612c3f565b610d9a565b6101f2610327366004612c3f565b610eea565b61023061033a366004612d52565b610f05565b6101f261034d366004612d31565b610f11565b6101f2610360366004612d31565b610f34565b61036d610f46565b6040516101ff919061327b565b61038d610388366004612c3f565b610f52565b6040516101ff949392919061322a565b6101f2610f7a565b610210610f80565b610210610fa4565b6101f2610fc8565b6101f26103cb366004612c3f565b610fce565b6101f2610fec565b610210610ff2565b6101f26103ee366004612c3f565b611001565b61023061110c565b60065481565b7f000000000000000000000000000000000000000000000000000000000000000081565b61042d611116565b61043933826000611576565b50610445338484611610565b505050565b6002546000908190600160201b90046001600160401b031661046a610d96565b118015610478575060045415155b156106f45760007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663083c63236040518163ffffffff1660e01b815260040160206040518083038186803b1580156104d857600080fd5b505afa1580156104ec573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105109190612de7565b63ffffffff169050600081610523610d96565b1161055257600254600160201b90046001600160401b0316610543610d96565b61054d919061330e565b61056f565b60025461056f90600160201b90046001600160401b03168361330e565b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166396c82e576040518163ffffffff1660e01b815260040160206040518083038186803b1580156105cc57600080fd5b505afa1580156105e0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106049190612de7565b63ffffffff167f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316634f5cc8026040518163ffffffff1660e01b815260040160206040518083038186803b15801561066357600080fd5b505afa158015610677573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061069b9190612cda565b6002546001600160c01b0391909116906106bb9063ffffffff16856132ef565b6106c591906132ef565b6106cf91906132cf565b90506003546106e082600454610f34565b6106ea91906132b7565b93505050506106f9565b506003545b6001600160a01b0383166000908152600160208181526040808420815160a08101835281548152938101548484015260028101548483015260038101546060850152600481018054835181860281018601909452808452919360808601939290879084015b828210156107d65760008481526020908190206040805160a0810182526003860290920180548352600180820154848601526002909101546001600160401b0380821693850193909352600160401b81049092166060840152600160801b90910460ff1615156080830152908352909201910161075e565b50505050815250509050600081604001516107f5836020015185610f11565b6107ff919061330e565b95945050505050565b600081565b7f000000000000000000000000000000000000000000000000000000000000000081565b610839612c11565b6001600160a01b038316600090815260016020526040902060040180548390811061087457634e487b7160e01b600052603260045260246000fd5b60009182526020918290206040805160a081018252600393909302909101805483526001810154938301939093526002909201546001600160401b0380821693830193909352600160401b81049092166060820152600160801b90910460ff16151560808201529392505050565b600254600160201b90046001600160401b031681565b6005546001600160a01b0316331461092b5760405162461bcd60e51b81526004016109229061306e565b60405180910390fd5b8061093557610a3a565b6000600454116109575760405162461bcd60e51b815260040161092290613017565b6109623330836118c8565b61096e81600454610f34565b6006600082825461097f91906132b7565b925050819055507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03167f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031614156109f85780600760008282546109f291906132b7565b90915550505b336001600160a01b03167fe1745dfad8f400852fcec0e4b23dabb3b55a98c67df52ee99c5385887277d72f82604051610a319190613221565b60405180910390a25b50565b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610a855760405162461bcd60e51b81526004016109229061306e565b60025460405133917f06555fe9dc8cbe328585a0c60ae1b7aafe71c28a706c2769d6cb4ee6e3e44e4691610ac19163ffffffff1690859061328c565b60405180910390a26002805463ffffffff191663ffffffff92909216919091179055565b604051631e1c6a0760e01b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690631e1c6a0790610b31903390600401612e1f565b60206040518083038186803b158015610b4957600080fd5b505afa158015610b5d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b819190612cbe565b610b9d5760405162461bcd60e51b81526004016109229061306e565b610ba5611116565b6001600160a01b0382166000908152600160205260409020805415610bd357610bd18360016000611576565b505b6000610be3620f424060026132ef565b610bed90846132ef565b905060006040518060a00160405280858152602001838152602001610c10610d74565b6001600160401b03168152602001610c26610d74565b610c34906301e133806132b7565b6001600160401b0316815260200160011515815250905083836000016000828254610c5f91906132b7565b9250508190555081836001016000828254610c7a91906132b7565b9091555050600480840180546001818101835560009283526020808420865160039094020192835585015190820155604084015160029091018054606086015160808701511515600160801b0260ff60801b196001600160401b03928316600160401b0267ffffffffffffffff60401b199390961667ffffffffffffffff1990941693909317919091169390931716919091179055815484929190610d209084906132b7565b92505081905550610d378360010154600354610f11565b60028401556001830154600654610d4e9190610f11565b83600301819055508360076000828254610d6891906132b7565b90915550505050505050565b4290565b610d8433826001611576565b5050565b610445338484846000611970565b4390565b336001600160a01b03167f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b158015610dfd57600080fd5b505afa158015610e11573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e359190612c5b565b6001600160a01b031614610e5b5760405162461bcd60e51b81526004016109229061306e565b6001600160a01b038116610e815760405162461bcd60e51b8152600401610922906130cc565b60055460405133917f2afec66505e0ceed692012e3833f6609d4933ded34732135bc05f2842374406591610ec0916001600160a01b0316908590612e33565b60405180910390a2600580546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b031660009081526001602052604090205490565b610445338484846119d0565b600064e8d4a51000610f2383856132ef565b610f2d91906132cf565b9392505050565b600081610f2364e8d4a51000856132ef565b60025463ffffffff1681565b6001602081905260009182526040909120805491810154600282015460039092015490919084565b60045481565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b60075481565b6001600160a01b031660009081526001602052604090206004015490565b60035481565b6005546001600160a01b031681565b6001600160a01b0381166000908152600160208181526040808420815160a081018352815481529381015484840152600281015484830152600381015460608501526004810180548351818602810186019094528084528695949293608086019390929190879084015b828210156110e35760008481526020908190206040805160a0810182526003860290920180548352600180820154848601526002909101546001600160401b0380821693850193909352600160401b81049092166060840152600160801b90910460ff1615156080830152908352909201910161106b565b5050505081525050905080606001516111028260200151600654610f11565b610f2d919061330e565b611114611116565b565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316639f1dc9bd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561116f57600080fd5b505afa158015611183573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111a79190612cbe565b15611220577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d0c71b436040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561120757600080fd5b505af115801561121b573d6000803e3d6000fd5b505050505b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663083c63236040518163ffffffff1660e01b815260040160206040518083038186803b15801561127b57600080fd5b505afa15801561128f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112b39190612de7565b60025463ffffffff919091169150600160201b90046001600160401b031681116112dd5750611114565b600254600160201b90046001600160401b03166112f8610d96565b116113035750611114565b60045461133e57611312610d96565b600260046101000a8154816001600160401b0302191690836001600160401b0316021790555050611114565b600081611349610d96565b1161135b57611356610d96565b61135d565b815b60025490915060009061138090600160201b90046001600160401b03168361330e565b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316634f5cc8026040518163ffffffff1660e01b815260040160206040518083038186803b1580156113dd57600080fd5b505afa1580156113f1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114159190612cda565b6001600160c01b0316905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166396c82e576040518163ffffffff1660e01b815260040160206040518083038186803b15801561147b57600080fd5b505afa15801561148f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114b39190612de7565b60025463ffffffff91821691166114ca84866132ef565b6114d491906132ef565b6114de91906132cf565b90506114ec81600454610f34565b600360008282546114fd91906132b7565b9091555050600280546bffffffffffffffff000000001916600160201b6001600160401b038781168202929092179283905560035460405133947f5ffbf9ce09d035b92503aad17a31b3d37ca5cd887b63701ddc2200be77d9ccc794611567949091041690613245565b60405180910390a25050505050565b600061158184611af3565b61158c848484611cd8565b90507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03167f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03161480156115ed575082155b15610f2d57806007600082825461160491906132b7565b90915550509392505050565b611618610d74565b816001600160401b03161161163f5760405162461bcd60e51b815260040161092290612fb1565b6001600160a01b03831660009081526001602052604081206004810180549192918590811061167e57634e487b7160e01b600052603260045260246000fd5b906000526020600020906003020190508060020160089054906101000a90046001600160401b03166001600160401b0316836001600160401b0316116116d65760405162461bcd60e51b815260040161092290613044565b60028101546001600160401b0316611756576301e133806116f5610d74565b611708906001600160401b03861661330e565b11156117265760405162461bcd60e51b815260040161092290612ed8565b61172e610d74565b60028201805467ffffffffffffffff19166001600160401b039290921691909117905561179b565b60028101546301e1338090611774906001600160401b031685613325565b6001600160401b0316111561179b5760405162461bcd60e51b815260040161092290612ed8565b60028101805467ffffffffffffffff60401b1916600160401b6001600160401b038681168202929092179283905583546000939092620f4240926301e133809284926117ec92828216920416613325565b6001600160401b03166117ff91906132ef565b61180991906132cf565b61181391906132b7565b61181d91906132ef565b60018084018054908390559085015491925090829061183d90839061330e565b61184791906132b7565b6001850155600454829061185c90839061330e565b61186691906132b7565b60045560028301546040516001600160a01b038916917f85daa0d8a4afa74e5bd57c0f5d2cddf52920ec882a02b8d3f646c972b4cfb6b4916118b7918a916001600160401b03909116908a9061325c565b60405180910390a250505050505050565b6040516323b872dd60e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906323b872dd9061191890869086908690600401612e4d565b602060405180830381600087803b15801561193257600080fd5b505af1158015611946573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061196a9190612cbe565b50505050565b61197d8585858585612075565b6001600160a01b0385166000908152600160208190526040909120908101546006546119a99190610f11565b816003018190555084600760008282546119c391906132b7565b9091555050505050505050565b6001600160a01b038416600090815260016020526040812060048101805491929186908110611a0f57634e487b7160e01b600052603260045260246000fd5b60009182526020918290206040805160a0810182526003909302909101805483526001810154938301939093526002909201546001600160401b03808216938301849052600160401b820416606083015260ff600160801b909104161515608082015291501580611a93575080606001516001600160401b0316611a91610d74565b115b611aaf5760405162461bcd60e51b815260040161092290612f34565b8360076000828254611ac1919061330e565b90915550611ad3905086868686612496565b611ae38260010154600654610f11565b8260030181905550505050505050565b6001600160a01b038116600090815260016020526040812090611b1583611001565b905080611b23575050610a3a565b6040516370a0823160e01b81526000906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906370a0823190611b72903090600401612e1f565b60206040518083038186803b158015611b8a57600080fd5b505afa158015611b9e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bc29190612d19565b905081811015611be45760405162461bcd60e51b81526004016109229061313a565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03167f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03161415611c68576007548211611c4d5781611c51565b6007545b60076000828254611c62919061330e565b90915550505b611c788360010154600654610f11565b6003840155611c8784836127ab565b836001600160a01b0316336001600160a01b03167f291d65ce1109b491b8b6540dabe662b3478f4c808f76bb4130c3f7afa2fab59c84604051611cca9190613221565b60405180910390a350505050565b60008115611ce857611ce8611116565b611cf1846127b6565b905080611d0057506000610f2d565b6001600160a01b03841660009081526001602052604090208315611d2d57611d2885836128b7565b612004565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03167f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03161415611ee0576000611d97620f424060026132ef565b611da190846132ef565b905060006040518060a00160405280858152602001838152602001611dc4610d74565b6001600160401b03168152602001611dda610d74565b611de8906301e133806132b7565b6001600160401b039081168252600160209283018190526004870180548083018255600091825284822086516003909202019081559385015191840191909155604084015160029093018054606086015160808701511515600160801b0260ff60801b19918616600160401b0267ffffffffffffffff60401b199790961667ffffffffffffffff19909316929092179590951693909317939093169190911790915584549192508591859190611e9f9084906132b7565b9250508190555081836001016000828254611eba91906132b7565b925050819055508160046000828254611ed391906132b7565b9091555061200492505050565b60405163091465f760e11b81526000906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690631228cbee90611f4f907f000000000000000000000000000000000000000000000000000000000000000090600401612e1f565b60206040518083038186803b158015611f6757600080fd5b505afa158015611f7b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f9f9190612c5b565b6040516344cc892d60e01b81529091506001600160a01b038216906344cc892d90611fd09089908790600401612e71565b600060405180830381600087803b158015611fea57600080fd5b505af1158015611ffe573d6000803e3d6000fd5b50505050505b82156120205761201a8160010154600354610f11565b60028201555b846001600160a01b0316336001600160a01b03167f5033fdcf01566fb38fe1493114b856ff2a5d1c7875a6fafdacd1d320a012806a8685604051612065929190612e95565b60405180910390a3509392505050565b600084116120955760405162461bcd60e51b815260040161092290612f0f565b6001600160401b03831615806120e357506120ae610d74565b836001600160401b03161180156120e357506301e133806120cd610d74565b6120e0906001600160401b03861661330e565b11155b6120ff5760405162461bcd60e51b815260040161092290612fe8565b612107611116565b6001600160a01b03851660009081526001602052604090208054156121345761213286846000611576565b505b6040516370a0823160e01b81526000906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906370a0823190612183903090600401612e1f565b60206040518083038186803b15801561219b57600080fd5b505afa1580156121af573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121d39190612d19565b90506121e033308861293b565b6040516370a0823160e01b81526000906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906370a082319061222f903090600401612e1f565b60206040518083038186803b15801561224757600080fd5b505afa15801561225b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061227f9190612d19565b9050600061228d838361330e565b9050600080886001600160401b0316116122a85760006122b0565b6122b0610d74565b905087600083620f42406301e13380816122ca8787613325565b6001600160401b03166122dd91906132ef565b6122e791906132cf565b6122f191906132b7565b6122fb91906132ef565b90506000811161231b57634e487b7160e01b600052600160045260246000fd5b6040805160a08101825285815260208082018481526001600160401b03878116948401948552868116606085019081528d15156080860190815260048e01805460018082018355600092835296822088516003909202019081559451958501959095559551600290930180549151965167ffffffffffffffff199092169383169390931767ffffffffffffffff60401b1916600160401b96909216959095021760ff60801b1916600160801b94151594909402939093179092558854909186918a91906123e99084906132b7565b925050819055508188600101600082825461240491906132b7565b9250508190555061241b8860010154600354610f11565b8860020181905550816004600082825461243591906132b7565b925050819055508c6001600160a01b0316336001600160a01b03167f5dac0c1b1112564a045ba943c9d50270893e8e826c49be8e7073adc713ab7bd78e60405161247f9190613221565b60405180910390a350505050505050505050505050565b600082116124b65760405162461bcd60e51b815260040161092290612f0f565b6001600160a01b0384166000908152600160205260408120600481018054919291869081106124f557634e487b7160e01b600052603260045260246000fd5b6000918252602090912060039091020160028101548154919250600160801b900460ff16908511156125395760405162461bcd60e51b8152600401610922906131a8565b612541611116565b61254d87856000611576565b506001820154825460009061256390889061330e565b6002850154620f4240906301e13380908290612592906001600160401b0380821691600160401b900416613325565b6001600160401b03166125a591906132ef565b6125af91906132cf565b6125b991906132b7565b6125c391906132ef565b84549091506125d390889061330e565b612634578460040188815481106125fa57634e487b7160e01b600052603260045260246000fd5b6000918252602082206003909102018181556001810191909155600201805470ffffffffffffffffffffffffffffffffff19169055612655565b86846000016000828254612648919061330e565b9091555050600184018190555b86856000016000828254612669919061330e565b90915550506001850154819061268090849061330e565b61268a91906132b7565b6001860181905560035461269e9190610f11565b600286015560045481906126b390849061330e565b6126bd91906132b7565b600455821561274b5760405163e14bdb7160e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063e14bdb71906127149033908b90600401612e71565b600060405180830381600087803b15801561272e57600080fd5b505af1158015612742573d6000803e3d6000fd5b50505050612755565b6127553388612999565b886001600160a01b0316336001600160a01b03167fd8654fcc8cf5b36d30b3f5e4688fc78118e6d68de60b9994e09902268b57c3e3896040516127989190613221565b60405180910390a3505050505050505050565b610d843083836118c8565b6001600160a01b0381166000908152600160208181526040808420815160a081018352815481529381015484840152600281015484830152600381015460608501526004810180548351818602810186019094528084528695949293608086019390929190879084015b828210156128985760008481526020908190206040805160a0810182526003860290920180548352600180820154848601526002909101546001600160401b0380821693850193909352600160401b81049092166060840152600160801b90910460ff16151560808301529083529092019101612820565b5050505081525050905080604001516111028260200151600354610f11565b6040516340c10f1960e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906340c10f19906129059085908590600401612e71565b600060405180830381600087803b15801561291f57600080fd5b505af1158015612933573d6000803e3d6000fd5b505050505050565b6002600054141561295e5760405162461bcd60e51b815260040161092290613171565b600260005561298f7f00000000000000000000000000000000000000000000000000000000000000008484846129f5565b5050600160005550565b600260005414156129bc5760405162461bcd60e51b815260040161092290613171565b60026000556129ec7f00000000000000000000000000000000000000000000000000000000000000008383612a4d565b50506001600055565b61196a846323b872dd60e01b858585604051602401612a1693929190612e4d565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612a6c565b6104458363a9059cbb60e01b8484604051602401612a16929190612e71565b6000612ac1826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612afb9092919063ffffffff16565b8051909150156104455780806020019051810190612adf9190612cbe565b6104455760405162461bcd60e51b8152600401610922906130f0565b6060612b0a8484600085612b12565b949350505050565b606082471015612b345760405162461bcd60e51b815260040161092290612f6b565b612b3d85612bd2565b612b595760405162461bcd60e51b815260040161092290613095565b600080866001600160a01b03168587604051612b759190612e03565b60006040518083038185875af1925050503d8060008114612bb2576040519150601f19603f3d011682016040523d82523d6000602084013e612bb7565b606091505b5091509150612bc7828286612bd8565b979650505050505050565b3b151590565b60608315612be7575081610f2d565b825115612bf75782518084602001fd5b8160405162461bcd60e51b81526004016109229190612ea5565b6040805160a08101825260008082526020820181905291810182905260608101829052608081019190915290565b600060208284031215612c50578081fd5b8135610f2d8161338f565b600060208284031215612c6c578081fd5b8151610f2d8161338f565b60008060408385031215612c89578081fd5b8235612c948161338f565b946020939093013593505050565b600060208284031215612cb3578081fd5b8135610f2d816133a4565b600060208284031215612ccf578081fd5b8151610f2d816133a4565b600060208284031215612ceb578081fd5b81516001600160c01b0381168114610f2d578182fd5b600060208284031215612d12578081fd5b5035919050565b600060208284031215612d2a578081fd5b5051919050565b60008060408385031215612d43578182fd5b50508035926020909101359150565b600080600060608486031215612d66578081fd5b83359250602084013591506040840135612d7f816133a4565b809150509250925092565b600080600060608486031215612d9e578283fd5b8335925060208401356001600160401b0381168114612dbb578283fd5b91506040840135612d7f816133a4565b600060208284031215612ddc578081fd5b8135610f2d816133b2565b600060208284031215612df8578081fd5b8151610f2d816133b2565b60008251612e1581846020870161334d565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03929092168252602082015260400190565b901515815260200190565b9115158252602082015260400190565b6000602082528251806020840152612ec481604085016020870161334d565b601f01601f19169190910160400192915050565b6020808252601b908201527f6d6178206c6f636b20706572696f642069732033363520646179730000000000604082015260600190565b6020808252600b908201526a1e995c9bc8185b5bdd5b9d60aa1b604082015260600190565b60208082526018908201527f6465706f736974206e6f742079657420756e6c6f636b65640000000000000000604082015260600190565b60208082526026908201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6040820152651c8818d85b1b60d21b606082015260800190565b6020808252601c908201527f6c6f636b2073686f756c6420626520696e207468652066757475726500000000604082015260600190565b6020808252601590820152741a5b9d985b1a59081b1bd8dac81a5b9d195c9d985b605a1b604082015260600190565b6020808252601390820152721e995c9bc81b1bd8dada5b99c81dd95a59da1d606a1b604082015260600190565b60208082526010908201526f696e76616c6964206e6577206c6f636b60801b604082015260600190565b6020808252600d908201526c1858d8d95cdcc819195b9a5959609a1b604082015260600190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252600a90820152691e995c9bc81a5b9c1d5d60b21b604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b6020808252601c908201527f636f6e747261637420494c562062616c616e636520746f6f206c6f7700000000604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b602080825260149082015273616d6f756e742065786365656473207374616b6560601b604082015260600190565b600060a082019050825182526020830151602083015260408301516001600160401b038082166040850152806060860151166060850152505060808301511515608083015292915050565b90815260200190565b93845260208401929092526040830152606082015260800190565b9182526001600160401b0316602082015260400190565b9283526001600160401b03918216602084015216604082015260600190565b63ffffffff91909116815260200190565b63ffffffff92831681529116602082015260400190565b6001600160401b0391909116815260200190565b600082198211156132ca576132ca613379565b500190565b6000826132ea57634e487b7160e01b81526012600452602481fd5b500490565b600081600019048311821515161561330957613309613379565b500290565b60008282101561332057613320613379565b500390565b60006001600160401b038381169083168181101561334557613345613379565b039392505050565b60005b83811015613368578181015183820152602001613350565b8381111561196a5750506000910152565b634e487b7160e01b600052601160045260246000fd5b6001600160a01b0381168114610a3a57600080fd5b8015158114610a3a57600080fd5b63ffffffff81168114610a3a57600080fdfea2646970667358221220a4e504cfb7a1e1a0045d955188404960e3b015426a7f641815f21efd5829a5a964736f6c63430008010033000000000000000000000000767fe9edc9e0df98e07454847909b5e959d7ca0e000000000000000000000000398aea1c9ceb7de800284bb399a15e0efe5a9ec20000000000000000000000002996222cb2bf3675e5f5f88a5f211736197f03c7000000000000000000000000767fe9edc9e0df98e07454847909b5e959d7ca0e0000000000000000000000000000000000000000000000000000000000c262bc00000000000000000000000000000000000000000000000000000000000000c8
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106101e55760003560e01c80636817031b1161010f578063c45a0155116100a2578063fa213bd611610071578063fa213bd6146103d0578063fbfa77cf146103d8578063fc27076f146103e0578063fff6cae9146103f3576101e5565b8063c45a0155146103a5578063cbdf382c146103ad578063ce111541146103b5578063e8d3cad5146103bd576101e5565b8063a156dc28116100de578063a156dc2814610352578063a1aab33f14610365578063a87430ba1461037a578063beb0ed6c1461039d576101e5565b80636817031b1461030657806370a082311461031957806379b91d691461032c5780638e169d471461033f576101e5565b806329eb5f2c116101875780634ce0f9a6116101565780634ce0f9a6146102d057806351c547f8146102d857806352044ec9146102eb57806357e871e7146102fe576101e5565b806329eb5f2c146102825780633021a560146102975780634087aeb7146102aa57806344cc892d146102bd576101e5565b80631984db99116101c35780631984db99146102325780631da10d91146102455780631fffab221461025a5780632726b50614610262576101e5565b806305472358146101ea578063084ff3c91461020857806315e4b1ae1461021d575b600080fd5b6101f26103fb565b6040516101ff9190613221565b60405180910390f35b610210610401565b6040516101ff9190612e1f565b61023061022b366004612d8a565b610425565b005b6101f2610240366004612c3f565b61044a565b61024d610808565b6040516101ff9190612e8a565b61021061080d565b610275610270366004612c77565b610831565b6040516101ff91906131d6565b61028a6108e2565b6040516101ff91906132a3565b6102306102a5366004612d01565b6108f8565b6102306102b8366004612dcb565b610a3d565b6102306102cb366004612c77565b610ae5565b6101f2610d74565b6102306102e6366004612ca2565b610d78565b6102306102f9366004612d8a565b610d88565b6101f2610d96565b610230610314366004612c3f565b610d9a565b6101f2610327366004612c3f565b610eea565b61023061033a366004612d52565b610f05565b6101f261034d366004612d31565b610f11565b6101f2610360366004612d31565b610f34565b61036d610f46565b6040516101ff919061327b565b61038d610388366004612c3f565b610f52565b6040516101ff949392919061322a565b6101f2610f7a565b610210610f80565b610210610fa4565b6101f2610fc8565b6101f26103cb366004612c3f565b610fce565b6101f2610fec565b610210610ff2565b6101f26103ee366004612c3f565b611001565b61023061110c565b60065481565b7f000000000000000000000000767fe9edc9e0df98e07454847909b5e959d7ca0e81565b61042d611116565b61043933826000611576565b50610445338484611610565b505050565b6002546000908190600160201b90046001600160401b031661046a610d96565b118015610478575060045415155b156106f45760007f0000000000000000000000002996222cb2bf3675e5f5f88a5f211736197f03c76001600160a01b031663083c63236040518163ffffffff1660e01b815260040160206040518083038186803b1580156104d857600080fd5b505afa1580156104ec573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105109190612de7565b63ffffffff169050600081610523610d96565b1161055257600254600160201b90046001600160401b0316610543610d96565b61054d919061330e565b61056f565b60025461056f90600160201b90046001600160401b03168361330e565b905060007f0000000000000000000000002996222cb2bf3675e5f5f88a5f211736197f03c76001600160a01b03166396c82e576040518163ffffffff1660e01b815260040160206040518083038186803b1580156105cc57600080fd5b505afa1580156105e0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106049190612de7565b63ffffffff167f0000000000000000000000002996222cb2bf3675e5f5f88a5f211736197f03c76001600160a01b0316634f5cc8026040518163ffffffff1660e01b815260040160206040518083038186803b15801561066357600080fd5b505afa158015610677573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061069b9190612cda565b6002546001600160c01b0391909116906106bb9063ffffffff16856132ef565b6106c591906132ef565b6106cf91906132cf565b90506003546106e082600454610f34565b6106ea91906132b7565b93505050506106f9565b506003545b6001600160a01b0383166000908152600160208181526040808420815160a08101835281548152938101548484015260028101548483015260038101546060850152600481018054835181860281018601909452808452919360808601939290879084015b828210156107d65760008481526020908190206040805160a0810182526003860290920180548352600180820154848601526002909101546001600160401b0380821693850193909352600160401b81049092166060840152600160801b90910460ff1615156080830152908352909201910161075e565b50505050815250509050600081604001516107f5836020015185610f11565b6107ff919061330e565b95945050505050565b600081565b7f000000000000000000000000398aea1c9ceb7de800284bb399a15e0efe5a9ec281565b610839612c11565b6001600160a01b038316600090815260016020526040902060040180548390811061087457634e487b7160e01b600052603260045260246000fd5b60009182526020918290206040805160a081018252600393909302909101805483526001810154938301939093526002909201546001600160401b0380821693830193909352600160401b81049092166060820152600160801b90910460ff16151560808201529392505050565b600254600160201b90046001600160401b031681565b6005546001600160a01b0316331461092b5760405162461bcd60e51b81526004016109229061306e565b60405180910390fd5b8061093557610a3a565b6000600454116109575760405162461bcd60e51b815260040161092290613017565b6109623330836118c8565b61096e81600454610f34565b6006600082825461097f91906132b7565b925050819055507f000000000000000000000000767fe9edc9e0df98e07454847909b5e959d7ca0e6001600160a01b03167f000000000000000000000000767fe9edc9e0df98e07454847909b5e959d7ca0e6001600160a01b031614156109f85780600760008282546109f291906132b7565b90915550505b336001600160a01b03167fe1745dfad8f400852fcec0e4b23dabb3b55a98c67df52ee99c5385887277d72f82604051610a319190613221565b60405180910390a25b50565b336001600160a01b037f0000000000000000000000002996222cb2bf3675e5f5f88a5f211736197f03c71614610a855760405162461bcd60e51b81526004016109229061306e565b60025460405133917f06555fe9dc8cbe328585a0c60ae1b7aafe71c28a706c2769d6cb4ee6e3e44e4691610ac19163ffffffff1690859061328c565b60405180910390a26002805463ffffffff191663ffffffff92909216919091179055565b604051631e1c6a0760e01b81526001600160a01b037f0000000000000000000000002996222cb2bf3675e5f5f88a5f211736197f03c71690631e1c6a0790610b31903390600401612e1f565b60206040518083038186803b158015610b4957600080fd5b505afa158015610b5d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b819190612cbe565b610b9d5760405162461bcd60e51b81526004016109229061306e565b610ba5611116565b6001600160a01b0382166000908152600160205260409020805415610bd357610bd18360016000611576565b505b6000610be3620f424060026132ef565b610bed90846132ef565b905060006040518060a00160405280858152602001838152602001610c10610d74565b6001600160401b03168152602001610c26610d74565b610c34906301e133806132b7565b6001600160401b0316815260200160011515815250905083836000016000828254610c5f91906132b7565b9250508190555081836001016000828254610c7a91906132b7565b9091555050600480840180546001818101835560009283526020808420865160039094020192835585015190820155604084015160029091018054606086015160808701511515600160801b0260ff60801b196001600160401b03928316600160401b0267ffffffffffffffff60401b199390961667ffffffffffffffff1990941693909317919091169390931716919091179055815484929190610d209084906132b7565b92505081905550610d378360010154600354610f11565b60028401556001830154600654610d4e9190610f11565b83600301819055508360076000828254610d6891906132b7565b90915550505050505050565b4290565b610d8433826001611576565b5050565b610445338484846000611970565b4390565b336001600160a01b03167f0000000000000000000000002996222cb2bf3675e5f5f88a5f211736197f03c76001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b158015610dfd57600080fd5b505afa158015610e11573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e359190612c5b565b6001600160a01b031614610e5b5760405162461bcd60e51b81526004016109229061306e565b6001600160a01b038116610e815760405162461bcd60e51b8152600401610922906130cc565b60055460405133917f2afec66505e0ceed692012e3833f6609d4933ded34732135bc05f2842374406591610ec0916001600160a01b0316908590612e33565b60405180910390a2600580546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b031660009081526001602052604090205490565b610445338484846119d0565b600064e8d4a51000610f2383856132ef565b610f2d91906132cf565b9392505050565b600081610f2364e8d4a51000856132ef565b60025463ffffffff1681565b6001602081905260009182526040909120805491810154600282015460039092015490919084565b60045481565b7f0000000000000000000000002996222cb2bf3675e5f5f88a5f211736197f03c781565b7f000000000000000000000000767fe9edc9e0df98e07454847909b5e959d7ca0e81565b60075481565b6001600160a01b031660009081526001602052604090206004015490565b60035481565b6005546001600160a01b031681565b6001600160a01b0381166000908152600160208181526040808420815160a081018352815481529381015484840152600281015484830152600381015460608501526004810180548351818602810186019094528084528695949293608086019390929190879084015b828210156110e35760008481526020908190206040805160a0810182526003860290920180548352600180820154848601526002909101546001600160401b0380821693850193909352600160401b81049092166060840152600160801b90910460ff1615156080830152908352909201910161106b565b5050505081525050905080606001516111028260200151600654610f11565b610f2d919061330e565b611114611116565b565b7f0000000000000000000000002996222cb2bf3675e5f5f88a5f211736197f03c76001600160a01b0316639f1dc9bd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561116f57600080fd5b505afa158015611183573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111a79190612cbe565b15611220577f0000000000000000000000002996222cb2bf3675e5f5f88a5f211736197f03c76001600160a01b031663d0c71b436040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561120757600080fd5b505af115801561121b573d6000803e3d6000fd5b505050505b60007f0000000000000000000000002996222cb2bf3675e5f5f88a5f211736197f03c76001600160a01b031663083c63236040518163ffffffff1660e01b815260040160206040518083038186803b15801561127b57600080fd5b505afa15801561128f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112b39190612de7565b60025463ffffffff919091169150600160201b90046001600160401b031681116112dd5750611114565b600254600160201b90046001600160401b03166112f8610d96565b116113035750611114565b60045461133e57611312610d96565b600260046101000a8154816001600160401b0302191690836001600160401b0316021790555050611114565b600081611349610d96565b1161135b57611356610d96565b61135d565b815b60025490915060009061138090600160201b90046001600160401b03168361330e565b905060007f0000000000000000000000002996222cb2bf3675e5f5f88a5f211736197f03c76001600160a01b0316634f5cc8026040518163ffffffff1660e01b815260040160206040518083038186803b1580156113dd57600080fd5b505afa1580156113f1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114159190612cda565b6001600160c01b0316905060007f0000000000000000000000002996222cb2bf3675e5f5f88a5f211736197f03c76001600160a01b03166396c82e576040518163ffffffff1660e01b815260040160206040518083038186803b15801561147b57600080fd5b505afa15801561148f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114b39190612de7565b60025463ffffffff91821691166114ca84866132ef565b6114d491906132ef565b6114de91906132cf565b90506114ec81600454610f34565b600360008282546114fd91906132b7565b9091555050600280546bffffffffffffffff000000001916600160201b6001600160401b038781168202929092179283905560035460405133947f5ffbf9ce09d035b92503aad17a31b3d37ca5cd887b63701ddc2200be77d9ccc794611567949091041690613245565b60405180910390a25050505050565b600061158184611af3565b61158c848484611cd8565b90507f000000000000000000000000767fe9edc9e0df98e07454847909b5e959d7ca0e6001600160a01b03167f000000000000000000000000767fe9edc9e0df98e07454847909b5e959d7ca0e6001600160a01b03161480156115ed575082155b15610f2d57806007600082825461160491906132b7565b90915550509392505050565b611618610d74565b816001600160401b03161161163f5760405162461bcd60e51b815260040161092290612fb1565b6001600160a01b03831660009081526001602052604081206004810180549192918590811061167e57634e487b7160e01b600052603260045260246000fd5b906000526020600020906003020190508060020160089054906101000a90046001600160401b03166001600160401b0316836001600160401b0316116116d65760405162461bcd60e51b815260040161092290613044565b60028101546001600160401b0316611756576301e133806116f5610d74565b611708906001600160401b03861661330e565b11156117265760405162461bcd60e51b815260040161092290612ed8565b61172e610d74565b60028201805467ffffffffffffffff19166001600160401b039290921691909117905561179b565b60028101546301e1338090611774906001600160401b031685613325565b6001600160401b0316111561179b5760405162461bcd60e51b815260040161092290612ed8565b60028101805467ffffffffffffffff60401b1916600160401b6001600160401b038681168202929092179283905583546000939092620f4240926301e133809284926117ec92828216920416613325565b6001600160401b03166117ff91906132ef565b61180991906132cf565b61181391906132b7565b61181d91906132ef565b60018084018054908390559085015491925090829061183d90839061330e565b61184791906132b7565b6001850155600454829061185c90839061330e565b61186691906132b7565b60045560028301546040516001600160a01b038916917f85daa0d8a4afa74e5bd57c0f5d2cddf52920ec882a02b8d3f646c972b4cfb6b4916118b7918a916001600160401b03909116908a9061325c565b60405180910390a250505050505050565b6040516323b872dd60e01b81526001600160a01b037f000000000000000000000000767fe9edc9e0df98e07454847909b5e959d7ca0e16906323b872dd9061191890869086908690600401612e4d565b602060405180830381600087803b15801561193257600080fd5b505af1158015611946573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061196a9190612cbe565b50505050565b61197d8585858585612075565b6001600160a01b0385166000908152600160208190526040909120908101546006546119a99190610f11565b816003018190555084600760008282546119c391906132b7565b9091555050505050505050565b6001600160a01b038416600090815260016020526040812060048101805491929186908110611a0f57634e487b7160e01b600052603260045260246000fd5b60009182526020918290206040805160a0810182526003909302909101805483526001810154938301939093526002909201546001600160401b03808216938301849052600160401b820416606083015260ff600160801b909104161515608082015291501580611a93575080606001516001600160401b0316611a91610d74565b115b611aaf5760405162461bcd60e51b815260040161092290612f34565b8360076000828254611ac1919061330e565b90915550611ad3905086868686612496565b611ae38260010154600654610f11565b8260030181905550505050505050565b6001600160a01b038116600090815260016020526040812090611b1583611001565b905080611b23575050610a3a565b6040516370a0823160e01b81526000906001600160a01b037f000000000000000000000000767fe9edc9e0df98e07454847909b5e959d7ca0e16906370a0823190611b72903090600401612e1f565b60206040518083038186803b158015611b8a57600080fd5b505afa158015611b9e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bc29190612d19565b905081811015611be45760405162461bcd60e51b81526004016109229061313a565b7f000000000000000000000000767fe9edc9e0df98e07454847909b5e959d7ca0e6001600160a01b03167f000000000000000000000000767fe9edc9e0df98e07454847909b5e959d7ca0e6001600160a01b03161415611c68576007548211611c4d5781611c51565b6007545b60076000828254611c62919061330e565b90915550505b611c788360010154600654610f11565b6003840155611c8784836127ab565b836001600160a01b0316336001600160a01b03167f291d65ce1109b491b8b6540dabe662b3478f4c808f76bb4130c3f7afa2fab59c84604051611cca9190613221565b60405180910390a350505050565b60008115611ce857611ce8611116565b611cf1846127b6565b905080611d0057506000610f2d565b6001600160a01b03841660009081526001602052604090208315611d2d57611d2885836128b7565b612004565b7f000000000000000000000000767fe9edc9e0df98e07454847909b5e959d7ca0e6001600160a01b03167f000000000000000000000000767fe9edc9e0df98e07454847909b5e959d7ca0e6001600160a01b03161415611ee0576000611d97620f424060026132ef565b611da190846132ef565b905060006040518060a00160405280858152602001838152602001611dc4610d74565b6001600160401b03168152602001611dda610d74565b611de8906301e133806132b7565b6001600160401b039081168252600160209283018190526004870180548083018255600091825284822086516003909202019081559385015191840191909155604084015160029093018054606086015160808701511515600160801b0260ff60801b19918616600160401b0267ffffffffffffffff60401b199790961667ffffffffffffffff19909316929092179590951693909317939093169190911790915584549192508591859190611e9f9084906132b7565b9250508190555081836001016000828254611eba91906132b7565b925050819055508160046000828254611ed391906132b7565b9091555061200492505050565b60405163091465f760e11b81526000906001600160a01b037f0000000000000000000000002996222cb2bf3675e5f5f88a5f211736197f03c71690631228cbee90611f4f907f000000000000000000000000767fe9edc9e0df98e07454847909b5e959d7ca0e90600401612e1f565b60206040518083038186803b158015611f6757600080fd5b505afa158015611f7b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f9f9190612c5b565b6040516344cc892d60e01b81529091506001600160a01b038216906344cc892d90611fd09089908790600401612e71565b600060405180830381600087803b158015611fea57600080fd5b505af1158015611ffe573d6000803e3d6000fd5b50505050505b82156120205761201a8160010154600354610f11565b60028201555b846001600160a01b0316336001600160a01b03167f5033fdcf01566fb38fe1493114b856ff2a5d1c7875a6fafdacd1d320a012806a8685604051612065929190612e95565b60405180910390a3509392505050565b600084116120955760405162461bcd60e51b815260040161092290612f0f565b6001600160401b03831615806120e357506120ae610d74565b836001600160401b03161180156120e357506301e133806120cd610d74565b6120e0906001600160401b03861661330e565b11155b6120ff5760405162461bcd60e51b815260040161092290612fe8565b612107611116565b6001600160a01b03851660009081526001602052604090208054156121345761213286846000611576565b505b6040516370a0823160e01b81526000906001600160a01b037f000000000000000000000000767fe9edc9e0df98e07454847909b5e959d7ca0e16906370a0823190612183903090600401612e1f565b60206040518083038186803b15801561219b57600080fd5b505afa1580156121af573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121d39190612d19565b90506121e033308861293b565b6040516370a0823160e01b81526000906001600160a01b037f000000000000000000000000767fe9edc9e0df98e07454847909b5e959d7ca0e16906370a082319061222f903090600401612e1f565b60206040518083038186803b15801561224757600080fd5b505afa15801561225b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061227f9190612d19565b9050600061228d838361330e565b9050600080886001600160401b0316116122a85760006122b0565b6122b0610d74565b905087600083620f42406301e13380816122ca8787613325565b6001600160401b03166122dd91906132ef565b6122e791906132cf565b6122f191906132b7565b6122fb91906132ef565b90506000811161231b57634e487b7160e01b600052600160045260246000fd5b6040805160a08101825285815260208082018481526001600160401b03878116948401948552868116606085019081528d15156080860190815260048e01805460018082018355600092835296822088516003909202019081559451958501959095559551600290930180549151965167ffffffffffffffff199092169383169390931767ffffffffffffffff60401b1916600160401b96909216959095021760ff60801b1916600160801b94151594909402939093179092558854909186918a91906123e99084906132b7565b925050819055508188600101600082825461240491906132b7565b9250508190555061241b8860010154600354610f11565b8860020181905550816004600082825461243591906132b7565b925050819055508c6001600160a01b0316336001600160a01b03167f5dac0c1b1112564a045ba943c9d50270893e8e826c49be8e7073adc713ab7bd78e60405161247f9190613221565b60405180910390a350505050505050505050505050565b600082116124b65760405162461bcd60e51b815260040161092290612f0f565b6001600160a01b0384166000908152600160205260408120600481018054919291869081106124f557634e487b7160e01b600052603260045260246000fd5b6000918252602090912060039091020160028101548154919250600160801b900460ff16908511156125395760405162461bcd60e51b8152600401610922906131a8565b612541611116565b61254d87856000611576565b506001820154825460009061256390889061330e565b6002850154620f4240906301e13380908290612592906001600160401b0380821691600160401b900416613325565b6001600160401b03166125a591906132ef565b6125af91906132cf565b6125b991906132b7565b6125c391906132ef565b84549091506125d390889061330e565b612634578460040188815481106125fa57634e487b7160e01b600052603260045260246000fd5b6000918252602082206003909102018181556001810191909155600201805470ffffffffffffffffffffffffffffffffff19169055612655565b86846000016000828254612648919061330e565b9091555050600184018190555b86856000016000828254612669919061330e565b90915550506001850154819061268090849061330e565b61268a91906132b7565b6001860181905560035461269e9190610f11565b600286015560045481906126b390849061330e565b6126bd91906132b7565b600455821561274b5760405163e14bdb7160e01b81526001600160a01b037f0000000000000000000000002996222cb2bf3675e5f5f88a5f211736197f03c7169063e14bdb71906127149033908b90600401612e71565b600060405180830381600087803b15801561272e57600080fd5b505af1158015612742573d6000803e3d6000fd5b50505050612755565b6127553388612999565b886001600160a01b0316336001600160a01b03167fd8654fcc8cf5b36d30b3f5e4688fc78118e6d68de60b9994e09902268b57c3e3896040516127989190613221565b60405180910390a3505050505050505050565b610d843083836118c8565b6001600160a01b0381166000908152600160208181526040808420815160a081018352815481529381015484840152600281015484830152600381015460608501526004810180548351818602810186019094528084528695949293608086019390929190879084015b828210156128985760008481526020908190206040805160a0810182526003860290920180548352600180820154848601526002909101546001600160401b0380821693850193909352600160401b81049092166060840152600160801b90910460ff16151560808301529083529092019101612820565b5050505081525050905080604001516111028260200151600354610f11565b6040516340c10f1960e01b81526001600160a01b037f000000000000000000000000398aea1c9ceb7de800284bb399a15e0efe5a9ec216906340c10f19906129059085908590600401612e71565b600060405180830381600087803b15801561291f57600080fd5b505af1158015612933573d6000803e3d6000fd5b505050505050565b6002600054141561295e5760405162461bcd60e51b815260040161092290613171565b600260005561298f7f000000000000000000000000767fe9edc9e0df98e07454847909b5e959d7ca0e8484846129f5565b5050600160005550565b600260005414156129bc5760405162461bcd60e51b815260040161092290613171565b60026000556129ec7f000000000000000000000000767fe9edc9e0df98e07454847909b5e959d7ca0e8383612a4d565b50506001600055565b61196a846323b872dd60e01b858585604051602401612a1693929190612e4d565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612a6c565b6104458363a9059cbb60e01b8484604051602401612a16929190612e71565b6000612ac1826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612afb9092919063ffffffff16565b8051909150156104455780806020019051810190612adf9190612cbe565b6104455760405162461bcd60e51b8152600401610922906130f0565b6060612b0a8484600085612b12565b949350505050565b606082471015612b345760405162461bcd60e51b815260040161092290612f6b565b612b3d85612bd2565b612b595760405162461bcd60e51b815260040161092290613095565b600080866001600160a01b03168587604051612b759190612e03565b60006040518083038185875af1925050503d8060008114612bb2576040519150601f19603f3d011682016040523d82523d6000602084013e612bb7565b606091505b5091509150612bc7828286612bd8565b979650505050505050565b3b151590565b60608315612be7575081610f2d565b825115612bf75782518084602001fd5b8160405162461bcd60e51b81526004016109229190612ea5565b6040805160a08101825260008082526020820181905291810182905260608101829052608081019190915290565b600060208284031215612c50578081fd5b8135610f2d8161338f565b600060208284031215612c6c578081fd5b8151610f2d8161338f565b60008060408385031215612c89578081fd5b8235612c948161338f565b946020939093013593505050565b600060208284031215612cb3578081fd5b8135610f2d816133a4565b600060208284031215612ccf578081fd5b8151610f2d816133a4565b600060208284031215612ceb578081fd5b81516001600160c01b0381168114610f2d578182fd5b600060208284031215612d12578081fd5b5035919050565b600060208284031215612d2a578081fd5b5051919050565b60008060408385031215612d43578182fd5b50508035926020909101359150565b600080600060608486031215612d66578081fd5b83359250602084013591506040840135612d7f816133a4565b809150509250925092565b600080600060608486031215612d9e578283fd5b8335925060208401356001600160401b0381168114612dbb578283fd5b91506040840135612d7f816133a4565b600060208284031215612ddc578081fd5b8135610f2d816133b2565b600060208284031215612df8578081fd5b8151610f2d816133b2565b60008251612e1581846020870161334d565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03929092168252602082015260400190565b901515815260200190565b9115158252602082015260400190565b6000602082528251806020840152612ec481604085016020870161334d565b601f01601f19169190910160400192915050565b6020808252601b908201527f6d6178206c6f636b20706572696f642069732033363520646179730000000000604082015260600190565b6020808252600b908201526a1e995c9bc8185b5bdd5b9d60aa1b604082015260600190565b60208082526018908201527f6465706f736974206e6f742079657420756e6c6f636b65640000000000000000604082015260600190565b60208082526026908201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6040820152651c8818d85b1b60d21b606082015260800190565b6020808252601c908201527f6c6f636b2073686f756c6420626520696e207468652066757475726500000000604082015260600190565b6020808252601590820152741a5b9d985b1a59081b1bd8dac81a5b9d195c9d985b605a1b604082015260600190565b6020808252601390820152721e995c9bc81b1bd8dada5b99c81dd95a59da1d606a1b604082015260600190565b60208082526010908201526f696e76616c6964206e6577206c6f636b60801b604082015260600190565b6020808252600d908201526c1858d8d95cdcc819195b9a5959609a1b604082015260600190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252600a90820152691e995c9bc81a5b9c1d5d60b21b604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b6020808252601c908201527f636f6e747261637420494c562062616c616e636520746f6f206c6f7700000000604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b602080825260149082015273616d6f756e742065786365656473207374616b6560601b604082015260600190565b600060a082019050825182526020830151602083015260408301516001600160401b038082166040850152806060860151166060850152505060808301511515608083015292915050565b90815260200190565b93845260208401929092526040830152606082015260800190565b9182526001600160401b0316602082015260400190565b9283526001600160401b03918216602084015216604082015260600190565b63ffffffff91909116815260200190565b63ffffffff92831681529116602082015260400190565b6001600160401b0391909116815260200190565b600082198211156132ca576132ca613379565b500190565b6000826132ea57634e487b7160e01b81526012600452602481fd5b500490565b600081600019048311821515161561330957613309613379565b500290565b60008282101561332057613320613379565b500390565b60006001600160401b038381169083168181101561334557613345613379565b039392505050565b60005b83811015613368578181015183820152602001613350565b8381111561196a5750506000910152565b634e487b7160e01b600052601160045260246000fd5b6001600160a01b0381168114610a3a57600080fd5b8015158114610a3a57600080fd5b63ffffffff81168114610a3a57600080fdfea2646970667358221220a4e504cfb7a1e1a0045d955188404960e3b015426a7f641815f21efd5829a5a964736f6c63430008010033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000767fe9edc9e0df98e07454847909b5e959d7ca0e000000000000000000000000398aea1c9ceb7de800284bb399a15e0efe5a9ec20000000000000000000000002996222cb2bf3675e5f5f88a5f211736197f03c7000000000000000000000000767fe9edc9e0df98e07454847909b5e959d7ca0e0000000000000000000000000000000000000000000000000000000000c262bc00000000000000000000000000000000000000000000000000000000000000c8
-----Decoded View---------------
Arg [0] : _ilv (address): 0x767FE9EDC9E0dF98E07454847909b5E959D7ca0E
Arg [1] : _silv (address): 0x398AeA1c9ceb7dE800284bb399A15e0Efe5A9EC2
Arg [2] : _factory (address): 0x2996222cb2bF3675e5f5f88A5F211736197F03C7
Arg [3] : _poolToken (address): 0x767FE9EDC9E0dF98E07454847909b5E959D7ca0E
Arg [4] : _initBlock (uint64): 12739260
Arg [5] : _weight (uint32): 200
-----Encoded View---------------
6 Constructor Arguments found :
Arg [0] : 000000000000000000000000767fe9edc9e0df98e07454847909b5e959d7ca0e
Arg [1] : 000000000000000000000000398aea1c9ceb7de800284bb399a15e0efe5a9ec2
Arg [2] : 0000000000000000000000002996222cb2bf3675e5f5f88a5f211736197f03c7
Arg [3] : 000000000000000000000000767fe9edc9e0df98e07454847909b5e959d7ca0e
Arg [4] : 0000000000000000000000000000000000000000000000000000000000c262bc
Arg [5] : 00000000000000000000000000000000000000000000000000000000000000c8
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.