ETH Price: $2,059.72 (-0.46%)
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Unstake Query113997532020-12-06 14:34:491569 days ago1607265289IN
0x495074B5...Ff1DefF4F
0 ETH0.0051748326
Reward Rebase113964992020-12-06 2:46:591570 days ago1607222819IN
0x495074B5...Ff1DefF4F
0 ETH0.002076728
Unstake Query113906612020-12-05 5:11:191571 days ago1607145079IN
0x495074B5...Ff1DefF4F
0 ETH0.0053738627
Reward Rebase113897972020-12-05 2:02:221571 days ago1607133742IN
0x495074B5...Ff1DefF4F
0 ETH0.0027442137
Unstake Query113896032020-12-05 1:20:331571 days ago1607131233IN
0x495074B5...Ff1DefF4F
0 ETH0.005351125
Reward Rebase113834172020-12-04 2:23:191572 days ago1607048599IN
0x495074B5...Ff1DefF4F
0 ETH0.0034858947
Unstake Query113803532020-12-03 15:05:261572 days ago1607007926IN
0x495074B5...Ff1DefF4F
0 ETH0.0079196237.00000145
Unstake Query113776072020-12-03 5:02:191573 days ago1606971739IN
0x495074B5...Ff1DefF4F
0 ETH0.0074915435
Unstake Query113774372020-12-03 4:24:501573 days ago1606969490IN
0x495074B5...Ff1DefF4F
0 ETH0.006587135
Unstake Query113773962020-12-03 4:16:421573 days ago1606969002IN
0x495074B5...Ff1DefF4F
0 ETH0.0039607319.9
Unstake Query113769812020-12-03 2:44:161573 days ago1606963456IN
0x495074B5...Ff1DefF4F
0 ETH0.0072770834
Reward Rebase113767942020-12-03 2:02:231573 days ago1606960943IN
0x495074B5...Ff1DefF4F
0 ETH0.0025958835
Unstake Query113766422020-12-03 1:29:341573 days ago1606958974IN
0x495074B5...Ff1DefF4F
0 ETH0.0073646237
Unstake Query113764552020-12-03 0:50:381573 days ago1606956638IN
0x495074B5...Ff1DefF4F
0 ETH0.0073646237
Unstake Query113763232020-12-03 0:21:321573 days ago1606954892IN
0x495074B5...Ff1DefF4F
0 ETH0.0071655836
Unstake Query113762752020-12-03 0:10:221573 days ago1606954222IN
0x495074B5...Ff1DefF4F
0 ETH0.0046977833
Unstake Query113762742020-12-03 0:10:181573 days ago1606954218IN
0x495074B5...Ff1DefF4F
0 ETH0.0067056933
Unstake Query113762242020-12-02 23:58:261573 days ago1606953506IN
0x495074B5...Ff1DefF4F
0 ETH0.0059713230
Unstake Query113762092020-12-02 23:53:581573 days ago1606953238IN
0x495074B5...Ff1DefF4F
0 ETH0.0080907630
Unstake Query113761532020-12-02 23:37:431573 days ago1606952263IN
0x495074B5...Ff1DefF4F
0 ETH0.0061703631
Unstake Query113759762020-12-02 23:04:001573 days ago1606950240IN
0x495074B5...Ff1DefF4F
0 ETH0.0078941831
Unstake Query113759032020-12-02 22:46:491573 days ago1606949209IN
0x495074B5...Ff1DefF4F
0 ETH0.0069635137
Unstake Query113757962020-12-02 22:23:061573 days ago1606947786IN
0x495074B5...Ff1DefF4F
0 ETH0.0069665435
Unstake Query113755942020-12-02 21:35:331573 days ago1606944933IN
0x495074B5...Ff1DefF4F
0 ETH0.0069665435
Unstake Query113755392020-12-02 21:25:531573 days ago1606944353IN
0x495074B5...Ff1DefF4F
0 ETH0.0046939823.1
View all transactions

Latest 4 internal transactions

Advanced mode:
Parent Transaction Hash Method Block
From
To
-112773872020-11-17 19:35:131588 days ago1605641713
0x495074B5...Ff1DefF4F
 Contract Creation0 ETH
-112773872020-11-17 19:35:131588 days ago1605641713
0x495074B5...Ff1DefF4F
 Contract Creation0 ETH
-112773872020-11-17 19:35:131588 days ago1605641713
0x495074B5...Ff1DefF4F
 Contract Creation0 ETH
-112773872020-11-17 19:35:131588 days ago1605641713
0x495074B5...Ff1DefF4F
 Contract Creation0 ETH
Loading...
Loading

Similar Match Source Code
This contract matches the deployed Bytecode of the Source Code for Contract 0xf30e88C9...c2fBfCB90
The constructor portion of the code might be different and could alter the actual behaviour of the contract

Contract Name:
AmpleSenseGeyser

Compiler Version
v0.5.0+commit.1d4f565a

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity)

/**
 *Submitted for verification at Etherscan.io on 2020-11-01
*/

pragma solidity 0.5.0;


/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");

        return c;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     * - Subtraction cannot overflow.
     *
     * _Available since v2.4.0._
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;

        return c;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }

        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");

        return c;
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     *
     * _Available since v2.4.0._
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        // Solidity only automatically asserts when dividing by 0
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold

        return c;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     *
     * _Available since v2.4.0._
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
}

/**
 * @dev Interface of the ERC20 standard as defined in the EIP. Does not include
 * the optional functions; to access them see {ERC20Detailed}.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

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

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

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

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

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

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

/*
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with GSN meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
contract Context {
    // Empty internal constructor, to prevent people from mistakenly deploying
    // an instance of this contract, which should be used via inheritance.
    constructor () internal { }
    // solhint-disable-previous-line no-empty-blocks

    function _msgSender() internal view returns (address payable) {
        return msg.sender;
    }

    function _msgData() internal view returns (bytes memory) {
        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
        return msg.data;
    }
}

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor () internal {
        _owner = _msgSender();
        emit OwnershipTransferred(address(0), _owner);
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(isOwner(), "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Returns true if the caller is the current owner.
     */
    function isOwner() public view returns (bool) {
        return _msgSender() == _owner;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public onlyOwner {
        emit OwnershipTransferred(_owner, address(0));
        _owner = address(0);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public onlyOwner {
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     */
    function _transferOwnership(address newOwner) internal {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
}

/**
 * @title Staking interface, as defined by EIP-900.
 * @dev https://github.com/ethereum/EIPs/blob/master/EIPS/eip-900.md
 */
contract IStaking {
    event Staked(address indexed user, uint256 amount, uint256 total, bytes data);
    event Unstaked(address indexed user, uint256 amount, uint256 total, bytes data);

    function stake(uint256 amount, bytes calldata data) external;
    function stakeFor(address user, uint256 amount, bytes calldata data) external;
    function unstake(uint256 amount, bytes calldata data) external;
    function totalStakedFor(address addr) public view returns (uint256);
    function totalStaked() public view returns (uint256);
    function token() external view returns (address);

    /**
     * @return False. This application does not support staking history.
     */
    function supportsHistory() external pure returns (bool) {
        return false;
    }
}

/**
 * @title A simple holder of tokens.
 * This is a simple contract to hold tokens. It's useful in the case where a separate contract
 * needs to hold multiple distinct pools of the same token.
 */
contract TokenPool is Ownable {
    IERC20 public token;

    constructor(IERC20 _token) public {
        token = _token;
    }

    function balance() public view returns (uint256) {
        return token.balanceOf(address(this));
    }

    function transfer(address to, uint256 value) external onlyOwner returns (bool) {
        return token.transfer(to, value);
    }

    function rescueFunds(address tokenToRescue, address to, uint256 amount) external onlyOwner returns (bool) {
        require(address(token) != tokenToRescue, 'TokenPool: Cannot claim token held by the contract');

        return IERC20(tokenToRescue).transfer(to, amount);
    }
}

/**
 * @title Token Geyser
 * @dev A smart-contract based mechanism to distribute tokens over time, inspired loosely by
 *      Compound and Uniswap.
 *
 *      Distribution tokens are added to a locked pool in the contract and become unlocked over time
 *      according to a once-configurable unlock schedule. Once unlocked, they are available to be
 *      claimed by users.
 *
 *      A user may deposit tokens to accrue ownership share over the unlocked pool. This owner share
 *      is a function of the number of tokens deposited as well as the length of time deposited.
 *      Specifically, a user's share of the currently-unlocked pool equals their "deposit-seconds"
 *      divided by the global "deposit-seconds". This aligns the new token distribution with long
 *      term supporters of the project, addressing one of the major drawbacks of simple airdrops.
 *
 *      More background and motivation available at:
 *      https://github.com/ampleforth/RFCs/blob/master/RFCs/rfc-1.md
 */
contract TokenGeyser is IStaking, Ownable {
    using SafeMath for uint256;

    event Staked(address indexed user, uint256 amount, uint256 total, bytes data);
    event Unstaked(address indexed user, uint256 amount, uint256 total, bytes data);
    event TokensClaimed(address indexed user, uint256 amount);
    event TokensLocked(uint256 amount, uint256 durationSec, uint256 total);
    // amount: Unlocked tokens, total: Total locked tokens
    event TokensUnlocked(uint256 amount, uint256 total);

    TokenPool private _stakingPool;
    TokenPool public _unlockedPool;
    TokenPool private _lockedPool;

    //
    // Time-bonus params
    //
    uint256 public constant BONUS_DECIMALS = 2;
    uint256 public startBonus = 0;
    uint256 public bonusPeriodSec = 0;

    //
    // Global accounting state
    //
    uint256 public totalLockedShares = 0;
    uint256 public totalStakingShares = 0;
    uint256 private _totalStakingShareSeconds = 0;
    uint256 private _lastAccountingTimestampSec = now;
    uint256 private _maxUnlockSchedules = 0;
    uint256 private _initialSharesPerToken = 0;

    //
    // User accounting state
    //
    // Represents a single stake for a user. A user may have multiple.
    struct Stake {
        uint256 stakingShares;
        uint256 timestampSec;
    }

    // Caches aggregated values from the User->Stake[] map to save computation.
    // If lastAccountingTimestampSec is 0, there's no entry for that user.
    struct UserTotals {
        uint256 stakingShares;
        uint256 stakingShareSeconds;
        uint256 lastAccountingTimestampSec;
    }

    // Aggregated staking values per user
    mapping(address => UserTotals) private _userTotals;

    // The collection of stakes for each user. Ordered by timestamp, earliest to latest.
    mapping(address => Stake[]) private _userStakes;

    //
    // Locked/Unlocked Accounting state
    //
    struct UnlockSchedule {
        uint256 initialLockedShares;
        uint256 unlockedShares;
        uint256 lastUnlockTimestampSec;
        uint256 endAtSec;
        uint256 durationSec;
    }

    UnlockSchedule[] public unlockSchedules;

    /**
     * @param stakingToken The token users deposit as stake.
     * @param distributionToken The token users receive as they unstake.
     * @param maxUnlockSchedules Max number of unlock stages, to guard against hitting gas limit.
     * @param startBonus_ Starting time bonus, BONUS_DECIMALS fixed point.
     *                    e.g. 25% means user gets 25% of max distribution tokens.
     * @param bonusPeriodSec_ Length of time for bonus to increase linearly to max.
     * @param initialSharesPerToken Number of shares to mint per staking token on first stake.
     */
    constructor(IERC20 stakingToken, IERC20 distributionToken, uint256 maxUnlockSchedules,
                uint256 startBonus_, uint256 bonusPeriodSec_, uint256 initialSharesPerToken) public {
        // The start bonus must be some fraction of the max. (i.e. <= 100%)
        require(startBonus_ <= 10**BONUS_DECIMALS, 'TokenGeyser: start bonus too high');
        // If no period is desired, instead set startBonus = 100%
        // and bonusPeriod to a small value like 1sec.
        require(bonusPeriodSec_ != 0, 'TokenGeyser: bonus period is zero');
        require(initialSharesPerToken > 0, 'TokenGeyser: initialSharesPerToken is zero');

        _stakingPool = new TokenPool(stakingToken);
        _unlockedPool = new TokenPool(distributionToken);
        _lockedPool = new TokenPool(distributionToken);
        startBonus = startBonus_;
        bonusPeriodSec = bonusPeriodSec_;
        _maxUnlockSchedules = maxUnlockSchedules;
        _initialSharesPerToken = initialSharesPerToken;
    }

    /**
     * @return The token users deposit as stake.
     */
    function getStakingToken() public view returns (IERC20) {
        return _stakingPool.token();
    }

    /**
     * @return The token users receive as they unstake.
     */
    function getDistributionToken() public view returns (IERC20) {
        assert(_unlockedPool.token() == _lockedPool.token());
        return _unlockedPool.token();
    }

    /**
     * @dev Transfers amount of deposit tokens from the user.
     * @param amount Number of deposit tokens to stake.
     * @param data Not used.
     */
    function stake(uint256 amount, bytes calldata data) external {
        _stakeFor(msg.sender, msg.sender, amount);
    }

    /**
     * @dev Transfers amount of deposit tokens from the caller on behalf of user.
     * @param user User address who gains credit for this stake operation.
     * @param amount Number of deposit tokens to stake.
     * @param data Not used.
     */
    function stakeFor(address user, uint256 amount, bytes calldata data) external onlyOwner {
        _stakeFor(msg.sender, user, amount);
    }

    /**
     * @dev Private implementation of staking methods.
     * @param staker User address who deposits tokens to stake.
     * @param beneficiary User address who gains credit for this stake operation.
     * @param amount Number of deposit tokens to stake.
     */
    function _stakeFor(address staker, address beneficiary, uint256 amount) private {
        require(amount > 0, 'TokenGeyser: stake amount is zero');
        require(beneficiary != address(0), 'TokenGeyser: beneficiary is zero address');
        require(totalStakingShares == 0 || totalStaked() > 0,
                'TokenGeyser: Invalid state. Staking shares exist, but no staking tokens do');

        uint256 mintedStakingShares = (totalStakingShares > 0)
            ? totalStakingShares.mul(amount).div(totalStaked())
            : amount.mul(_initialSharesPerToken);
        require(mintedStakingShares > 0, 'TokenGeyser: Stake amount is too small');

        updateAccounting();

        // 1. User Accounting
        UserTotals storage totals = _userTotals[beneficiary];
        totals.stakingShares = totals.stakingShares.add(mintedStakingShares);
        totals.lastAccountingTimestampSec = now;

        Stake memory newStake = Stake(mintedStakingShares, now);
        _userStakes[beneficiary].push(newStake);

        // 2. Global Accounting
        totalStakingShares = totalStakingShares.add(mintedStakingShares);
        // Already set in updateAccounting()
        // _lastAccountingTimestampSec = now;

        // interactions
        require(_stakingPool.token().transferFrom(staker, address(_stakingPool), amount),
            'TokenGeyser: transfer into staking pool failed');

        emit Staked(beneficiary, amount, totalStakedFor(beneficiary), "");
    }

    /**
     * @dev Unstakes a certain amount of previously deposited tokens. User also receives their
     * alotted number of distribution tokens.
     * @param amount Number of deposit tokens to unstake / withdraw.
     * @param data Not used.
     */
    function unstake(uint256 amount, bytes calldata data) external {
        _unstake(amount);
    }

    /**
     * @param amount Number of deposit tokens to unstake / withdraw.
     * @return The total number of distribution tokens that would be rewarded.
     */
    function unstakeQuery(uint256 amount) public returns (uint256) {
        return _unstake(amount);
    }

    /**
     * @dev Unstakes a certain amount of previously deposited tokens. User also receives their
     * alotted number of distribution tokens.
     * @param amount Number of deposit tokens to unstake / withdraw.
     * @return The total number of distribution tokens rewarded.
     */
    function _unstake(uint256 amount) private returns (uint256) {
        updateAccounting();

        // checks
        require(amount > 0, 'TokenGeyser: unstake amount is zero');
        require(totalStakedFor(msg.sender) >= amount,
            'TokenGeyser: unstake amount is greater than total user stakes');
        uint256 stakingSharesToBurn = totalStakingShares.mul(amount).div(totalStaked());
        require(stakingSharesToBurn > 0, 'TokenGeyser: Unable to unstake amount this small');

        // 1. User Accounting
        UserTotals storage totals = _userTotals[msg.sender];
        Stake[] storage accountStakes = _userStakes[msg.sender];

        // Redeem from most recent stake and go backwards in time.
        uint256 stakingShareSecondsToBurn = 0;
        uint256 sharesLeftToBurn = stakingSharesToBurn;
        uint256 rewardAmount = 0;
        while (sharesLeftToBurn > 0) {
            Stake storage lastStake = accountStakes[accountStakes.length - 1];
            uint256 stakeTimeSec = now.sub(lastStake.timestampSec);
            uint256 newStakingShareSecondsToBurn = 0;
            if (lastStake.stakingShares <= sharesLeftToBurn) {
                // fully redeem a past stake
                newStakingShareSecondsToBurn = lastStake.stakingShares.mul(stakeTimeSec);
                rewardAmount = computeNewReward(rewardAmount, newStakingShareSecondsToBurn, stakeTimeSec);
                stakingShareSecondsToBurn = stakingShareSecondsToBurn.add(newStakingShareSecondsToBurn);
                sharesLeftToBurn = sharesLeftToBurn.sub(lastStake.stakingShares);
                accountStakes.length--;
            } else {
                // partially redeem a past stake
                newStakingShareSecondsToBurn = sharesLeftToBurn.mul(stakeTimeSec);
                rewardAmount = computeNewReward(rewardAmount, newStakingShareSecondsToBurn, stakeTimeSec);
                stakingShareSecondsToBurn = stakingShareSecondsToBurn.add(newStakingShareSecondsToBurn);
                lastStake.stakingShares = lastStake.stakingShares.sub(sharesLeftToBurn);
                sharesLeftToBurn = 0;
            }
        }
        totals.stakingShareSeconds = totals.stakingShareSeconds.sub(stakingShareSecondsToBurn);
        totals.stakingShares = totals.stakingShares.sub(stakingSharesToBurn);
        // Already set in updateAccounting
        // totals.lastAccountingTimestampSec = now;

        // 2. Global Accounting
        _totalStakingShareSeconds = _totalStakingShareSeconds.sub(stakingShareSecondsToBurn);
        totalStakingShares = totalStakingShares.sub(stakingSharesToBurn);
        // Already set in updateAccounting
        // _lastAccountingTimestampSec = now;

        // interactions
        require(_stakingPool.transfer(msg.sender, amount),
            'TokenGeyser: transfer out of staking pool failed');
        require(_unlockedPool.transfer(msg.sender, rewardAmount),
            'TokenGeyser: transfer out of unlocked pool failed');

        emit Unstaked(msg.sender, amount, totalStakedFor(msg.sender), "");
        emit TokensClaimed(msg.sender, rewardAmount);

        require(totalStakingShares == 0 || totalStaked() > 0,
                "TokenGeyser: Error unstaking. Staking shares exist, but no staking tokens do");
        return rewardAmount;
    }

    /**
     * @dev Applies an additional time-bonus to a distribution amount. This is necessary to
     *      encourage long-term deposits instead of constant unstake/restakes.
     *      The bonus-multiplier is the result of a linear function that starts at startBonus and
     *      ends at 100% over bonusPeriodSec, then stays at 100% thereafter.
     * @param currentRewardTokens The current number of distribution tokens already alotted for this
     *                            unstake op. Any bonuses are already applied.
     * @param stakingShareSeconds The stakingShare-seconds that are being burned for new
     *                            distribution tokens.
     * @param stakeTimeSec Length of time for which the tokens were staked. Needed to calculate
     *                     the time-bonus.
     * @return Updated amount of distribution tokens to award, with any bonus included on the
     *         newly added tokens.
     */
    function computeNewReward(uint256 currentRewardTokens,
                                uint256 stakingShareSeconds,
                                uint256 stakeTimeSec) private view returns (uint256) {

        uint256 newRewardTokens =
            totalUnlocked()
            .mul(stakingShareSeconds)
            .div(_totalStakingShareSeconds);

        if (stakeTimeSec >= bonusPeriodSec) {
            return currentRewardTokens.add(newRewardTokens);
        }

        uint256 oneHundredPct = 10**BONUS_DECIMALS;
        uint256 bonusedReward =
            startBonus
            .add(oneHundredPct.sub(startBonus).mul(stakeTimeSec).div(bonusPeriodSec))
            .mul(newRewardTokens)
            .div(oneHundredPct);
        return currentRewardTokens.add(bonusedReward);
    }

    /**
     * @param addr The user to look up staking information for.
     * @return The number of staking tokens deposited for addr.
     */
    function totalStakedFor(address addr) public view returns (uint256) {
        return totalStakingShares > 0 ?
            totalStaked().mul(_userTotals[addr].stakingShares).div(totalStakingShares) : 0;
    }

    /**
     * @return The total number of deposit tokens staked globally, by all users.
     */
    function totalStaked() public view returns (uint256) {
        return _stakingPool.balance();
    }

    /**
     * @dev Note that this application has a staking token as well as a distribution token, which
     * may be different. This function is required by EIP-900.
     * @return The deposit token used for staking.
     */
    function token() external view returns (address) {
        return address(getStakingToken());
    }

    /**
     * @dev A globally callable function to update the accounting state of the system.
     *      Global state and state for the caller are updated.
     * @return [0] balance of the locked pool
     * @return [1] balance of the unlocked pool
     * @return [2] caller's staking share seconds
     * @return [3] global staking share seconds
     * @return [4] Rewards caller has accumulated, optimistically assumes max time-bonus.
     * @return [5] block timestamp
     */
    function updateAccounting() public returns (
        uint256, uint256, uint256, uint256, uint256, uint256) {

        unlockTokens();

        // Global accounting
        uint256 newStakingShareSeconds =
            now
            .sub(_lastAccountingTimestampSec)
            .mul(totalStakingShares);
        _totalStakingShareSeconds = _totalStakingShareSeconds.add(newStakingShareSeconds);
        _lastAccountingTimestampSec = now;

        // User Accounting
        UserTotals storage totals = _userTotals[msg.sender];
        uint256 newUserStakingShareSeconds =
            now
            .sub(totals.lastAccountingTimestampSec)
            .mul(totals.stakingShares);
        totals.stakingShareSeconds =
            totals.stakingShareSeconds
            .add(newUserStakingShareSeconds);
        totals.lastAccountingTimestampSec = now;

        uint256 totalUserRewards = (_totalStakingShareSeconds > 0)
            ? totalUnlocked().mul(totals.stakingShareSeconds).div(_totalStakingShareSeconds)
            : 0;

        return (
            totalLocked(),
            totalUnlocked(),
            totals.stakingShareSeconds,
            _totalStakingShareSeconds,
            totalUserRewards,
            now
        );
    }

    /**
     * @return Total number of locked distribution tokens.
     */
    function totalLocked() public view returns (uint256) {
        return _lockedPool.balance();
    }

    /**
     * @return Total number of unlocked distribution tokens.
     */
    function totalUnlocked() public view returns (uint256) {
        return _unlockedPool.balance();
    }

    /**
     * @return Number of unlock schedules.
     */
    function unlockScheduleCount() public view returns (uint256) {
        return unlockSchedules.length;
    }

    /**
     * @dev This funcion allows the contract owner to add more locked distribution tokens, along
     *      with the associated "unlock schedule". These locked tokens immediately begin unlocking
     *      linearly over the duraction of durationSec timeframe.
     * @param amount Number of distribution tokens to lock. These are transferred from the caller.
     * @param durationSec Length of time to linear unlock the tokens.
     */
    function lockTokens(uint256 amount, uint256 durationSec) external onlyOwner {
        require(unlockSchedules.length < _maxUnlockSchedules,
            'TokenGeyser: reached maximum unlock schedules');

        // Update lockedTokens amount before using it in computations after.
        updateAccounting();

        uint256 lockedTokens = totalLocked();
        uint256 mintedLockedShares = (lockedTokens > 0)
            ? totalLockedShares.mul(amount).div(lockedTokens)
            : amount.mul(_initialSharesPerToken);

        UnlockSchedule memory schedule;
        schedule.initialLockedShares = mintedLockedShares;
        schedule.lastUnlockTimestampSec = now;
        schedule.endAtSec = now.add(durationSec);
        schedule.durationSec = durationSec;
        unlockSchedules.push(schedule);

        totalLockedShares = totalLockedShares.add(mintedLockedShares);

        require(_lockedPool.token().transferFrom(msg.sender, address(_lockedPool), amount),
            'TokenGeyser: transfer into locked pool failed');
        emit TokensLocked(amount, durationSec, totalLocked());
    }

    /**
     * @dev Moves distribution tokens from the locked pool to the unlocked pool, according to the
     *      previously defined unlock schedules. Publicly callable.
     * @return Number of newly unlocked distribution tokens.
     */
    function unlockTokens() public returns (uint256) {
        uint256 unlockedTokens = 0;
        uint256 lockedTokens = totalLocked();

        if (totalLockedShares == 0) {
            unlockedTokens = lockedTokens;
        } else {
            uint256 unlockedShares = 0;
            for (uint256 s = 0; s < unlockSchedules.length; s++) {
                unlockedShares = unlockedShares.add(unlockScheduleShares(s));
            }
            unlockedTokens = unlockedShares.mul(lockedTokens).div(totalLockedShares);
            totalLockedShares = totalLockedShares.sub(unlockedShares);
        }

        if (unlockedTokens > 0) {
            require(_lockedPool.transfer(address(_unlockedPool), unlockedTokens),
                'TokenGeyser: transfer out of locked pool failed');
            emit TokensUnlocked(unlockedTokens, totalLocked());
        }

        return unlockedTokens;
    }

    /**
     * @dev Returns the number of unlockable shares from a given schedule. The returned value
     *      depends on the time since the last unlock. This function updates schedule accounting,
     *      but does not actually transfer any tokens.
     * @param s Index of the unlock schedule.
     * @return The number of unlocked shares.
     */
    function unlockScheduleShares(uint256 s) private returns (uint256) {
        UnlockSchedule storage schedule = unlockSchedules[s];

        if(schedule.unlockedShares >= schedule.initialLockedShares) {
            return 0;
        }

        uint256 sharesToUnlock = 0;
        // Special case to handle any leftover dust from integer division
        if (now >= schedule.endAtSec) {
            sharesToUnlock = (schedule.initialLockedShares.sub(schedule.unlockedShares));
            schedule.lastUnlockTimestampSec = schedule.endAtSec;
        } else {
            sharesToUnlock = now.sub(schedule.lastUnlockTimestampSec)
                .mul(schedule.initialLockedShares)
                .div(schedule.durationSec);
            schedule.lastUnlockTimestampSec = now;
        }

        schedule.unlockedShares = schedule.unlockedShares.add(sharesToUnlock);
        return sharesToUnlock;
    }

    /**
     * @dev Lets the owner rescue funds air-dropped to the staking pool.
     * @param tokenToRescue Address of the token to be rescued.
     * @param to Address to which the rescued funds are to be sent.
     * @param amount Amount of tokens to be rescued.
     * @return Transfer success.
     */
    function rescueFundsFromStakingPool(address tokenToRescue, address to, uint256 amount)
        public onlyOwner returns (bool) {

        return _stakingPool.rescueFunds(tokenToRescue, to, amount);
    }
}

contract AmpleSenseGeyser is TokenGeyser {
    using SafeMath for uint256;

    event RebaseReward(uint256 amount, uint256 total);

    TokenPool private _rewardPool;

    //
    // Rebase-bonus params
    //
    uint256 public constant REBASE_BONUS_DECIMALS = 3;
    uint256 public bonusPositiveRebase = 0;
    uint256 public bonusNegativeRebase = 0;

    uint256 public totalRewardTokens = 0;
    
    //
    // Address of the AMPL contract
    //
    IERC20 public AMPLContract;

    //
    // Last AMPL total supply
    //
    uint256 public lastAMPLTotalSupply;

    /**
     * @param stakingToken The token users deposit as stake.
     * @param distributionToken The token users receive as they unstake.
     * @param maxUnlockSchedules Max number of unlock stages, to guard against hitting gas limit.
     * @param startBonus_ Starting time bonus, BONUS_DECIMALS fixed point.
     *                    e.g. 25% means user gets 25% of max distribution tokens.
     * @param bonusPeriodSec_ Length of time for bonus to increase linearly to max.
     * @param initialSharesPerToken Number of shares to mint per staking token on first stake.
     * @param AMPLContractAddress Address of the uFragments Ampleforth ERC20
     * @param bonusPositiveRebase_ Bonus to apply on positive rebase
     * @param bonusNegativeRebase_ Bonus to apply on negative rebase
     */
    constructor(IERC20 stakingToken, IERC20 distributionToken, uint256 maxUnlockSchedules,
                uint256 startBonus_, uint256 bonusPeriodSec_, uint256 initialSharesPerToken,
                address AMPLContractAddress, uint256 bonusPositiveRebase_, uint256 bonusNegativeRebase_) public
        TokenGeyser(stakingToken, distributionToken, maxUnlockSchedules,
        startBonus_, bonusPeriodSec_, initialSharesPerToken) {
        require(bonusPositiveRebase_ <= 10**REBASE_BONUS_DECIMALS, 'TokenGeyser: rebase bonus too high');
        require(bonusNegativeRebase_ <= 10**REBASE_BONUS_DECIMALS, 'TokenGeyser: rebase bonus too high');
        require(AMPLContractAddress != address(0), "AMPLContractAddress cannot be the zero address");

        bonusPositiveRebase = bonusPositiveRebase_;
        bonusNegativeRebase = bonusNegativeRebase_;
        AMPLContract = IERC20(AMPLContractAddress);
        //init the last total supply to the AMPL total supply on creation
        lastAMPLTotalSupply = AMPLContract.totalSupply();
        _rewardPool = new TokenPool(distributionToken);
    }

    /**
    * Allows to add new reward tokens to the reward pool
    * Contract must be allowed to transfer this amount from the caller
    */
    function addRewardRebase(uint256 amount) external onlyOwner {
        totalRewardTokens = totalRewardTokens.add(amount);
        require(getDistributionToken().transferFrom(msg.sender, address(_rewardPool), amount),
            'TokenGeyser: transfer into reward pool failed');
    }

    /**
    * Public function to call after an Ampleforth AMPL token rebase
    * The function throws if the total supply of AMPL hasn't changed since the last call.
    */
    function rewardRebase() public {
        uint256 newTotalSupply = AMPLContract.totalSupply();
        require(newTotalSupply != lastAMPLTotalSupply, "Total supply of AMPL not changed");
        uint256 toTransfer = 0;
        if(newTotalSupply > lastAMPLTotalSupply) {
            toTransfer = totalRewardTokens.mul(bonusPositiveRebase).div(10**REBASE_BONUS_DECIMALS);
            
        } else {
            toTransfer = totalRewardTokens.mul(bonusNegativeRebase).div(10**REBASE_BONUS_DECIMALS);
        }
        //handle the last reward
        if(toTransfer > _rewardPool.balance())
            toTransfer = _rewardPool.balance();
        require(_rewardPool.transfer(address(_unlockedPool), toTransfer), 'TokenGeyser: transfer out of reward pool failed');
        lastAMPLTotalSupply = newTotalSupply;
        emit RebaseReward(toTransfer, _rewardPool.balance());
    }

    function rewardLeft() view public returns (uint256) {
        return _rewardPool.balance();
    }
}

Contract Security Audit

Contract ABI

API
[{"constant":false,"inputs":[{"name":"amount","type":"uint256"},{"name":"data","type":"bytes"}],"name":"stake","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"user","type":"address"},{"name":"amount","type":"uint256"},{"name":"data","type":"bytes"}],"name":"stakeFor","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalRewardTokens","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"BONUS_DECIMALS","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getDistributionToken","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"bonusNegativeRebase","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"amount","type":"uint256"}],"name":"addRewardRebase","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"startBonus","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"rewardLeft","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"updateAccounting","outputs":[{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"addr","type":"address"}],"name":"totalStakedFor","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalLocked","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"tokenToRescue","type":"address"},{"name":"to","type":"address"},{"name":"amount","type":"uint256"}],"name":"rescueFundsFromStakingPool","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"unlockSchedules","outputs":[{"name":"initialLockedShares","type":"uint256"},{"name":"unlockedShares","type":"uint256"},{"name":"lastUnlockTimestampSec","type":"uint256"},{"name":"endAtSec","type":"uint256"},{"name":"durationSec","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"supportsHistory","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[],"name":"totalStakingShares","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"renounceOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"lastAMPLTotalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"bonusPeriodSec","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalStaked","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalLockedShares","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"amount","type":"uint256"}],"name":"unstakeQuery","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"bonusPositiveRebase","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"amount","type":"uint256"},{"name":"durationSec","type":"uint256"}],"name":"lockTokens","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"REBASE_BONUS_DECIMALS","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"isOwner","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getStakingToken","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalUnlocked","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"AMPLContract","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"rewardRebase","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"unlockScheduleCount","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"amount","type":"uint256"},{"name":"data","type":"bytes"}],"name":"unstake","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"_unlockedPool","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"unlockTokens","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"token","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"stakingToken","type":"address"},{"name":"distributionToken","type":"address"},{"name":"maxUnlockSchedules","type":"uint256"},{"name":"startBonus_","type":"uint256"},{"name":"bonusPeriodSec_","type":"uint256"},{"name":"initialSharesPerToken","type":"uint256"},{"name":"AMPLContractAddress","type":"address"},{"name":"bonusPositiveRebase_","type":"uint256"},{"name":"bonusNegativeRebase_","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"total","type":"uint256"}],"name":"RebaseReward","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"user","type":"address"},{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"total","type":"uint256"},{"indexed":false,"name":"data","type":"bytes"}],"name":"Staked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"user","type":"address"},{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"total","type":"uint256"},{"indexed":false,"name":"data","type":"bytes"}],"name":"Unstaked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"user","type":"address"},{"indexed":false,"name":"amount","type":"uint256"}],"name":"TokensClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"durationSec","type":"uint256"},{"indexed":false,"name":"total","type":"uint256"}],"name":"TokensLocked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"total","type":"uint256"}],"name":"TokensUnlocked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"},{"indexed":true,"name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"}]

Deployed Bytecode

0x6080604052600436106101b35763ffffffff60e060020a6000350416630e89439b81146101b85780630ef963561461023e5780631b0875a6146102d05780631dc27fde146102f757806322c12b841461030c5780632865649f1461033d5780632dccb7651461035257806338b45fde1461037c5780633eee042614610391578063494347e7146103a65780634b341aed146103ee57806356891412146104215780635a72bbef146104365780635c94bcb21461048d5780637033e4a6146104e257806370c6a17e146104f7578063715018a61461050c57806373fd551d146105215780637c6aa6f414610536578063817b1cd21461054b57806381c39bec1461056057806386805dd114610575578063888019a31461059f57806389158d8e146105b45780638b3b30bd146105e45780638da5cb5b146105f95780638f32d59b1461060e5780639f9106d114610623578063a779d08014610638578063ac4f26101461064d578063aed1e22c14610662578063c7ae200714610677578063c8fd6ed01461068c578063f2e456c614610710578063f2fde38b14610725578063f968f49314610758578063fc0c546a1461076d575b600080fd5b3480156101c457600080fd5b5061023c600480360360408110156101db57600080fd5b813591908101906040810160208201356401000000008111156101fd57600080fd5b82018360208201111561020f57600080fd5b8035906020019184600183028401116401000000008311171561023157600080fd5b509092509050610782565b005b34801561024a57600080fd5b5061023c6004803603606081101561026157600080fd5b600160a060020a038235169160208101359181019060608101604082013564010000000081111561029157600080fd5b8201836020820111156102a357600080fd5b803590602001918460018302840111640100000000831117156102c557600080fd5b509092509050610792565b3480156102dc57600080fd5b506102e56107ef565b60408051918252519081900360200190f35b34801561030357600080fd5b506102e56107f5565b34801561031857600080fd5b506103216107fa565b60408051600160a060020a039092168252519081900360200190f35b34801561034957600080fd5b506102e5610979565b34801561035e57600080fd5b5061023c6004803603602081101561037557600080fd5b503561097f565b34801561038857600080fd5b506102e5610b0a565b34801561039d57600080fd5b506102e5610b10565b3480156103b257600080fd5b506103bb610b58565b604080519687526020870195909552858501939093526060850191909152608084015260a0830152519081900360c00190f35b3480156103fa57600080fd5b506102e56004803603602081101561041157600080fd5b5035600160a060020a0316610c66565b34801561042d57600080fd5b506102e5610cad565b34801561044257600080fd5b506104796004803603606081101561045957600080fd5b50600160a060020a03813581169160208101359091169060400135610cf5565b604080519115158252519081900360200190f35b34801561049957600080fd5b506104b7600480360360208110156104b057600080fd5b5035610df0565b6040805195865260208601949094528484019290925260608401526080830152519081900360a00190f35b3480156104ee57600080fd5b50610479610e2f565b34801561050357600080fd5b506102e5610e34565b34801561051857600080fd5b5061023c610e3a565b34801561052d57600080fd5b506102e5610edd565b34801561054257600080fd5b506102e5610ee3565b34801561055757600080fd5b506102e5610ee9565b34801561056c57600080fd5b506102e5610f31565b34801561058157600080fd5b506102e56004803603602081101561059857600080fd5b5035610f37565b3480156105ab57600080fd5b506102e5610f42565b3480156105c057600080fd5b5061023c600480360360408110156105d757600080fd5b5080359060200135610f48565b3480156105f057600080fd5b506102e5611367565b34801561060557600080fd5b5061032161136c565b34801561061a57600080fd5b5061047961137b565b34801561062f57600080fd5b5061032161139f565b34801561064457600080fd5b506102e56113e7565b34801561065957600080fd5b5061032161142f565b34801561066e57600080fd5b5061023c61143e565b34801561068357600080fd5b506102e5611840565b34801561069857600080fd5b5061023c600480360360408110156106af57600080fd5b813591908101906040810160208201356401000000008111156106d157600080fd5b8201836020820111156106e357600080fd5b8035906020019184600183028401116401000000008311171561070557600080fd5b509092509050611846565b34801561071c57600080fd5b5061032161184f565b34801561073157600080fd5b5061023c6004803603602081101561074857600080fd5b5035600160a060020a031661185e565b34801561076457600080fd5b506102e56118b3565b34801561077957600080fd5b50610321611a8e565b61078d333385611a9d565b505050565b61079a61137b565b15156107de576040805160e560020a62461bcd0281526020600482018190526024820152600080516020612ba0833981519152604482015290519081900360640190fd5b6107e9338585611a9d565b50505050565b60125481565b600281565b6003546040805160e160020a637e062a350281529051600092600160a060020a03169163fc0c546a916004808301926020929190829003018186803b15801561084257600080fd5b505afa158015610856573d6000803e3d6000fd5b505050506040513d602081101561086c57600080fd5b50516002546040805160e160020a637e062a350281529051600160a060020a03938416939092169163fc0c546a91600480820192602092909190829003018186803b1580156108ba57600080fd5b505afa1580156108ce573d6000803e3d6000fd5b505050506040513d60208110156108e457600080fd5b5051600160a060020a0316146108f657fe5b600260009054906101000a9004600160a060020a0316600160a060020a031663fc0c546a6040518163ffffffff1660e060020a02815260040160206040518083038186803b15801561094757600080fd5b505afa15801561095b573d6000803e3d6000fd5b505050506040513d602081101561097157600080fd5b505190505b90565b60115481565b61098761137b565b15156109cb576040805160e560020a62461bcd0281526020600482018190526024820152600080516020612ba0833981519152604482015290519081900360640190fd5b6012546109de908263ffffffff611fbb16565b6012556109e96107fa565b600f54604080517f23b872dd000000000000000000000000000000000000000000000000000000008152336004820152600160a060020a03928316602482015260448101859052905192909116916323b872dd916064808201926020929091908290030181600087803b158015610a5f57600080fd5b505af1158015610a73573d6000803e3d6000fd5b505050506040513d6020811015610a8957600080fd5b50511515610b07576040805160e560020a62461bcd02815260206004820152602d60248201527f546f6b656e4765797365723a207472616e7366657220696e746f20726577617260448201527f6420706f6f6c206661696c656400000000000000000000000000000000000000606482015290519081900360840190fd5b50565b60045481565b600f546040805160e360020a6316d3df150281529051600092600160a060020a03169163b69ef8a8916004808301926020929190829003018186803b15801561094757600080fd5b600080600080600080610b696118b3565b506000610b93600754610b876009544261202190919063ffffffff16565b9063ffffffff61206316565b600854909150610ba9908263ffffffff611fbb16565b600855426009819055336000908152600c60205260408120805460028201549193610bde92610b87919063ffffffff61202116565b6001830154909150610bf6908263ffffffff611fbb16565b60018301554260028301556008546000908110610c14576000610c36565b610c36600854610c2a8560010154610b876113e7565b9063ffffffff6120ff16565b9050610c40610cad565b610c486113e7565b600190940154600854919c949b509950975095504294509092505050565b60008060075411610c78576000610ca5565b600754600160a060020a0383166000908152600c6020526040902054610ca59190610c2a90610b87610ee9565b90505b919050565b6003546040805160e360020a6316d3df150281529051600092600160a060020a03169163b69ef8a8916004808301926020929190829003018186803b15801561094757600080fd5b6000610cff61137b565b1515610d43576040805160e560020a62461bcd0281526020600482018190526024820152600080516020612ba0833981519152604482015290519081900360640190fd5b600154604080517f6ccae054000000000000000000000000000000000000000000000000000000008152600160a060020a03878116600483015286811660248301526044820186905291519190921691636ccae0549160648083019260209291908290030181600087803b158015610dba57600080fd5b505af1158015610dce573d6000803e3d6000fd5b505050506040513d6020811015610de457600080fd5b505190505b9392505050565b600e805482908110610dfe57fe5b6000918252602090912060059091020180546001820154600283015460038401546004909401549294509092909185565b600090565b60075481565b610e4261137b565b1515610e86576040805160e560020a62461bcd0281526020600482018190526024820152600080516020612ba0833981519152604482015290519081900360640190fd5b60008054604051600160a060020a03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a36000805473ffffffffffffffffffffffffffffffffffffffff19169055565b60145481565b60055481565b6001546040805160e360020a6316d3df150281529051600092600160a060020a03169163b69ef8a8916004808301926020929190829003018186803b15801561094757600080fd5b60065481565b6000610ca582612141565b60105481565b610f5061137b565b1515610f94576040805160e560020a62461bcd0281526020600482018190526024820152600080516020612ba0833981519152604482015290519081900360640190fd5b600a54600e5410611015576040805160e560020a62461bcd02815260206004820152602d60248201527f546f6b656e4765797365723a2072656163686564206d6178696d756d20756e6c60448201527f6f636b207363686564756c657300000000000000000000000000000000000000606482015290519081900360840190fd5b61101d610b58565b505050505050600061102d610cad565b9050600080821161105157600b5461104c90859063ffffffff61206316565b61106a565b61106a82610c2a8660065461206390919063ffffffff16565b9050611074612b10565b818152426040820181905261108f908563ffffffff611fbb16565b6060820190815260808201858152600e805460018101825560009190915283517fbb7b4a454dc3493923482f07822329ed19e8244eff582cc204f8554c3620c3fd60059092029182015560208401517fbb7b4a454dc3493923482f07822329ed19e8244eff582cc204f8554c3620c3fe82015560408401517fbb7b4a454dc3493923482f07822329ed19e8244eff582cc204f8554c3620c3ff82015591517fbb7b4a454dc3493923482f07822329ed19e8244eff582cc204f8554c3620c400830155517fbb7b4a454dc3493923482f07822329ed19e8244eff582cc204f8554c3620c401909101556006546111849083611fbb565b6006556003546040805160e160020a637e062a350281529051600160a060020a039092169163fc0c546a91600480820192602092909190829003018186803b1580156111cf57600080fd5b505afa1580156111e3573d6000803e3d6000fd5b505050506040513d60208110156111f957600080fd5b5051600354604080517f23b872dd000000000000000000000000000000000000000000000000000000008152336004820152600160a060020a03928316602482015260448101899052905191909216916323b872dd9160648083019260209291908290030181600087803b15801561127057600080fd5b505af1158015611284573d6000803e3d6000fd5b505050506040513d602081101561129a57600080fd5b50511515611318576040805160e560020a62461bcd02815260206004820152602d60248201527f546f6b656e4765797365723a207472616e7366657220696e746f206c6f636b6560448201527f6420706f6f6c206661696c656400000000000000000000000000000000000000606482015290519081900360840190fd5b7ff346961af4c52f314df1b45964746280fe409abb959d4a2458d58f79408b1fe88585611343610cad565b60408051938452602084019290925282820152519081900360600190a15050505050565b600381565b600054600160a060020a031690565b60008054600160a060020a03166113906127c1565b600160a060020a031614905090565b6001546040805160e160020a637e062a350281529051600092600160a060020a03169163fc0c546a916004808301926020929190829003018186803b15801561094757600080fd5b6002546040805160e360020a6316d3df150281529051600092600160a060020a03169163b69ef8a8916004808301926020929190829003018186803b15801561094757600080fd5b601354600160a060020a031681565b601354604080517f18160ddd0000000000000000000000000000000000000000000000000000000081529051600092600160a060020a0316916318160ddd916004808301926020929190829003018186803b15801561149c57600080fd5b505afa1580156114b0573d6000803e3d6000fd5b505050506040513d60208110156114c657600080fd5b5051601454909150811415611525576040805160e560020a62461bcd02815260206004820181905260248201527f546f74616c20737570706c79206f6620414d504c206e6f74206368616e676564604482015290519081900360640190fd5b6014546000908211156115565760105460125461154f916103e891610c2a9163ffffffff61206316565b9050611576565b601154601254611573916103e891610c2a9163ffffffff61206316565b90505b600f60009054906101000a9004600160a060020a0316600160a060020a031663b69ef8a86040518163ffffffff1660e060020a02815260040160206040518083038186803b1580156115c757600080fd5b505afa1580156115db573d6000803e3d6000fd5b505050506040513d60208110156115f157600080fd5b505181111561167a57600f60009054906101000a9004600160a060020a0316600160a060020a031663b69ef8a86040518163ffffffff1660e060020a02815260040160206040518083038186803b15801561164b57600080fd5b505afa15801561165f573d6000803e3d6000fd5b505050506040513d602081101561167557600080fd5b505190505b600f546002546040805160e060020a63a9059cbb028152600160a060020a039283166004820152602481018590529051919092169163a9059cbb9160448083019260209291908290030181600087803b1580156116d657600080fd5b505af11580156116ea573d6000803e3d6000fd5b505050506040513d602081101561170057600080fd5b5051151561177e576040805160e560020a62461bcd02815260206004820152602f60248201527f546f6b656e4765797365723a207472616e73666572206f7574206f662072657760448201527f61726420706f6f6c206661696c65640000000000000000000000000000000000606482015290519081900360840190fd5b816014819055507f8cf83b25e4b9a0ebbd3d2f90d9dd4aaa115c5b9382b89fcddce5bd66dc77a29a81600f60009054906101000a9004600160a060020a0316600160a060020a031663b69ef8a86040518163ffffffff1660e060020a02815260040160206040518083038186803b1580156117f857600080fd5b505afa15801561180c573d6000803e3d6000fd5b505050506040513d602081101561182257600080fd5b50516040805192835260208301919091528051918290030190a15050565b600e5490565b6107e983612141565b600254600160a060020a031681565b61186661137b565b15156118aa576040805160e560020a62461bcd0281526020600482018190526024820152600080516020612ba0833981519152604482015290519081900360640190fd5b610b07816127c5565b600080806118bf610cad565b9050600654600014156118d457809150611938565b6000805b600e54811015611905576118fb6118ee826128b3565b839063ffffffff611fbb16565b91506001016118d8565b5060065461191d90610c2a838563ffffffff61206316565b600654909350611933908263ffffffff61202116565b600655505b6000821115611a88576003546002546040805160e060020a63a9059cbb028152600160a060020a039283166004820152602481018690529051919092169163a9059cbb9160448083019260209291908290030181600087803b15801561199d57600080fd5b505af11580156119b1573d6000803e3d6000fd5b505050506040513d60208110156119c757600080fd5b50511515611a45576040805160e560020a62461bcd02815260206004820152602f60248201527f546f6b656e4765797365723a207472616e73666572206f7574206f66206c6f6360448201527f6b656420706f6f6c206661696c65640000000000000000000000000000000000606482015290519081900360840190fd5b7f2e444eb379b177e88ce0649c6110a3b01099f03e297127919dd5e3b63a761a9c82611a6f610cad565b6040805192835260208301919091528051918290030190a15b50905090565b6000611a9861139f565b905090565b60008111611b1b576040805160e560020a62461bcd02815260206004820152602160248201527f546f6b656e4765797365723a207374616b6520616d6f756e74206973207a657260448201527f6f00000000000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b600160a060020a0382161515611ba1576040805160e560020a62461bcd02815260206004820152602860248201527f546f6b656e4765797365723a2062656e6566696369617279206973207a65726f60448201527f2061646472657373000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b6007541580611bb757506000611bb5610ee9565b115b1515611c59576040805160e560020a62461bcd02815260206004820152604a60248201527f546f6b656e4765797365723a20496e76616c69642073746174652e205374616b60448201527f696e67207368617265732065786973742c20627574206e6f207374616b696e6760648201527f20746f6b656e7320646f00000000000000000000000000000000000000000000608482015290519081900360a40190fd5b60008060075411611c7d57600b54611c7890839063ffffffff61206316565b611c9b565b611c9b611c88610ee9565b600754610c2a908563ffffffff61206316565b905060008111611d1b576040805160e560020a62461bcd02815260206004820152602660248201527f546f6b656e4765797365723a205374616b6520616d6f756e7420697320746f6f60448201527f20736d616c6c0000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b611d23610b58565b50505050600160a060020a0385166000908152600c602052604090208054909250611d4f915083611fbb565b8155426002820155611d5f612b40565b50604080518082018252838152426020808301918252600160a060020a0388166000908152600d82529384208054600181810183559186529190942083516002909202019081559051920191909155600754611dc1908463ffffffff611fbb16565b6007556001546040805160e160020a637e062a350281529051600160a060020a039092169163fc0c546a91600480820192602092909190829003018186803b158015611e0c57600080fd5b505afa158015611e20573d6000803e3d6000fd5b505050506040513d6020811015611e3657600080fd5b5051600154604080517f23b872dd000000000000000000000000000000000000000000000000000000008152600160a060020a038a81166004830152928316602482015260448101889052905191909216916323b872dd9160648083019260209291908290030181600087803b158015611eaf57600080fd5b505af1158015611ec3573d6000803e3d6000fd5b505050506040513d6020811015611ed957600080fd5b50511515611f57576040805160e560020a62461bcd02815260206004820152602e60248201527f546f6b656e4765797365723a207472616e7366657220696e746f207374616b6960448201527f6e6720706f6f6c206661696c6564000000000000000000000000000000000000606482015290519081900360840190fd5b84600160a060020a03167fc65e53b88159e7d2c0fc12a0600072e28ae53ff73b4c1715369c30f16093514285611f8c88610c66565b6040805192835260208301919091526060828201819052600090830152519081900360a00190a2505050505050565b600082820183811015612018576040805160e560020a62461bcd02815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b90505b92915050565b600061201883836040805190810160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061297a565b60008215156120745750600061201b565b82820282848281151561208357fe5b0414612018576040805160e560020a62461bcd02815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60448201527f7700000000000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b600061201883836040805190810160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612a14565b600061214b610b58565b5050505050506000821115156121d1576040805160e560020a62461bcd02815260206004820152602360248201527f546f6b656e4765797365723a20756e7374616b6520616d6f756e74206973207a60448201527f65726f0000000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b816121db33610c66565b1015612257576040805160e560020a62461bcd02815260206004820152603d60248201527f546f6b656e4765797365723a20756e7374616b6520616d6f756e74206973206760448201527f726561746572207468616e20746f74616c2075736572207374616b6573000000606482015290519081900360840190fd5b6000612277612264610ee9565b600754610c2a908663ffffffff61206316565b9050600081116122f7576040805160e560020a62461bcd02815260206004820152603060248201527f546f6b656e4765797365723a20556e61626c6520746f20756e7374616b65206160448201527f6d6f756e74207468697320736d616c6c00000000000000000000000000000000606482015290519081900360840190fd5b336000908152600c60209081526040808320600d9092528220909183815b600082111561241d5783546000908590600019810190811061233357fe5b90600052602060002090600202019050600061235c82600101544261202190919063ffffffff16565b825490915060009085106123ca57825461237c908363ffffffff61206316565b9050612389848284612a81565b935061239b868263ffffffff611fbb16565b83549096506123b190869063ffffffff61202116565b87549095506123c4886000198301612b57565b50612415565b6123da858363ffffffff61206316565b90506123e7848284612a81565b93506123f9868263ffffffff611fbb16565b835490965061240e908663ffffffff61202116565b8355600094505b505050612315565b6001850154612432908463ffffffff61202116565b60018601558454612449908763ffffffff61202116565b855560085461245e908463ffffffff61202116565b600855600754612474908763ffffffff61202116565b6007556001546040805160e060020a63a9059cbb028152336004820152602481018b90529051600160a060020a039092169163a9059cbb916044808201926020929091908290030181600087803b1580156124ce57600080fd5b505af11580156124e2573d6000803e3d6000fd5b505050506040513d60208110156124f857600080fd5b50511515612576576040805160e560020a62461bcd02815260206004820152603060248201527f546f6b656e4765797365723a207472616e73666572206f7574206f662073746160448201527f6b696e6720706f6f6c206661696c656400000000000000000000000000000000606482015290519081900360840190fd5b6002546040805160e060020a63a9059cbb028152336004820152602481018490529051600160a060020a039092169163a9059cbb916044808201926020929091908290030181600087803b1580156125cd57600080fd5b505af11580156125e1573d6000803e3d6000fd5b505050506040513d60208110156125f757600080fd5b50511515612675576040805160e560020a62461bcd02815260206004820152603160248201527f546f6b656e4765797365723a207472616e73666572206f7574206f6620756e6c60448201527f6f636b656420706f6f6c206661696c6564000000000000000000000000000000606482015290519081900360840190fd5b337faf01bfc8475df280aca00b578c4a948e6d95700f0db8c13365240f7f973c8754896126a183610c66565b6040805192835260208301919091526060828201819052600090830152519081900360a00190a260408051828152905133917f896e034966eaaf1adc54acc0f257056febbd300c9e47182cf761982cf1f5e430919081900360200190a2600754158061271457506000612712610ee9565b115b15156127b6576040805160e560020a62461bcd02815260206004820152604c60248201527f546f6b656e4765797365723a204572726f7220756e7374616b696e672e20537460448201527f616b696e67207368617265732065786973742c20627574206e6f207374616b6960648201527f6e6720746f6b656e7320646f0000000000000000000000000000000000000000608482015290519081900360a40190fd5b979650505050505050565b3390565b600160a060020a038116151561284b576040805160e560020a62461bcd02815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b60008054604051600160a060020a03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b600080600e838154811015156128c557fe5b90600052602060002090600502019050806000015481600101541015156128f0576000915050610ca8565b6003810154600090421061292557600182015482546129149163ffffffff61202116565b600383015460028401559050612955565b61294c8260040154610c2a8460000154610b8786600201544261202190919063ffffffff16565b42600284015590505b600182015461296a908263ffffffff611fbb16565b6001909201919091559050919050565b60008184841115612a0c5760405160e560020a62461bcd0281526004018080602001828103825283818151815260200191508051906020019080838360005b838110156129d15781810151838201526020016129b9565b50505050905090810190601f1680156129fe5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600081818411612a695760405160e560020a62461bcd028152600401808060200182810382528381815181526020019150805190602001908083836000838110156129d15781810151838201526020016129b9565b5060008385811515612a7757fe5b0495945050505050565b600080612a96600854610c2a86610b876113e7565b6005549091508310612aba57612ab2858263ffffffff611fbb16565b915050610de9565b60006002600a0a90506000612afe82610c2a85610b87612aef600554610c2a8c610b876004548c61202190919063ffffffff16565b6004549063ffffffff611fbb16565b90506127b6878263ffffffff611fbb16565b60a06040519081016040528060008152602001600081526020016000815260200160008152602001600081525090565b604080518082019091526000808252602082015290565b81548183558181111561078d5760008381526020902061078d916109769160029182028101918502015b80821115612b9b5760008082556001820155600201612b81565b509056fe4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572a165627a7a72305820d834d6aa3d24a83de90f7032ec15c4582644c2c3806020a9c70c2f2c0872467e0029

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
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.