Cryo Explorer Ethereum Mainnet

Address Contract Partially Verified

Address 0x41b9E154b099A3e53b88D44004886B31311ECeb8
Balance 0 ETH
Nonce 1
Code Size 5149 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

5149 bytes
0x6080604052600436106102465760003560e01c806364dd48f51161013957806398dca210116100b6578063c3cda5201161007a578063c3cda52014610582578063dd62ed3e146105a2578063e7a324dc146105bd578063ec342ad0146105d2578063f1127ed8146105e7578063fa8f34551461045c57610246565b806398dca2101461045c578063a457c2d7146102c3578063a9059cbb146102c3578063aaa84f651461056d578063b4b5ea57146103ca57610246565b8063782d6fe1116100fd578063782d6fe1146104e85780637af548c1146105085780637ecebe001461052357806395d89b411461054357806397d63f931461055857610246565b806364dd48f5146104915780636fc6407c146104a65780636fcfff45146104bb57806370a08231146103ca57806373f03dff1461045c57610246565b8063313ce567116101c75780634bda2e201161018b5780634bda2e201461040a578063555bcc4014610421578063587cde1e146104415780635c19a95c1461045c5780635c60da1b1461047c57610246565b8063313ce567146103a857806339509351146102c35780633af9e669146103ca57806340c10f19146102c35780634487152f146103ea57610246565b806312d43a511161020e57806312d43a511461033457806318160ddd1461034957806320606b701461035e57806323b872dd14610373578063252408101461039357610246565b806306fdde03146102785780630933c1ed146102a3578063095ea7b3146102c357806311d3e6c4146102f057806311fd8a8314610312575b341561026d5760405162461bcd60e51b815260040161026490611276565b60405180910390fd5b610275610615565b50005b34801561028457600080fd5b5061028d610695565b60405161029a9190611265565b60405180910390f35b3480156102af57600080fd5b5061028d6102be366004610efd565b610722565b3480156102cf57600080fd5b506102e36102de366004610de1565b610741565b60405161029a9190611237565b3480156102fc57600080fd5b50610305610752565b60405161029a9190611245565b34801561031e57600080fd5b50610327610760565b60405161029a919061120e565b34801561034057600080fd5b5061032761076f565b34801561035557600080fd5b50610305610783565b34801561036a57600080fd5b50610305610789565b34801561037f57600080fd5b506102e361038e366004610d39565b6107a0565b34801561039f57600080fd5b506103276107b2565b3480156103b457600080fd5b506103bd6107c1565b60405161029a91906112bf565b3480156103d657600080fd5b506103056103e5366004610ce1565b6107ca565b3480156103f657600080fd5b5061028d610405366004610efd565b6107da565b34801561041657600080fd5b5061041f6108a1565b005b34801561042d57600080fd5b5061041f61043c366004610d86565b6108ac565b34801561044d57600080fd5b506103276103e5366004610ce1565b34801561046857600080fd5b5061041f610477366004610ce1565b6109c6565b34801561048857600080fd5b506103276109d2565b34801561049d57600080fd5b506103056109e1565b3480156104b257600080fd5b506103276109ef565b3480156104c757600080fd5b506104db6104d6366004610ce1565b6109fe565b60405161029a9190611296565b3480156104f457600080fd5b50610305610503366004610de1565b610a16565b34801561051457600080fd5b5061030561038e366004610f32565b34801561052f57600080fd5b5061030561053e366004610ce1565b610a20565b34801561054f57600080fd5b5061028d610a32565b34801561056457600080fd5b50610305610a8a565b34801561057957600080fd5b50610305610a90565b34801561058e57600080fd5b5061041f61059d366004610e11565b610a96565b3480156105ae57600080fd5b50610305610503366004610cff565b3480156105c957600080fd5b50610305610aa7565b3480156105de57600080fd5b50610305610ab3565b3480156105f357600080fd5b50610607610602366004610e98565b610abf565b60405161029a9291906112a4565b6010546040516060916000916001600160a01b039091169061063a90839036906111d8565b600060405180830381855af49150503d8060008114610675576040519150601f19603f3d011682016040523d82523d6000602084013e61067a565b606091505b505090506040513d6000823e818015610691573d82f35b3d82fd5b60018054604080516020600284861615610100026000190190941693909304601f8101849004840282018401909252818152929183018282801561071a5780601f106106ef5761010080835404028352916020019161071a565b820191906000526020600020905b8154815290600101906020018083116106fd57829003601f168201915b505050505081565b60105460609061073b906001600160a01b031683610aec565b92915050565b600061074b610615565b5092915050565b600061075c610b5f565b5090565b6005546001600160a01b031681565b60035461010090046001600160a01b031681565b60075481565b604051610795906111f8565b604051809103902081565b60006107aa610615565b509392505050565b6004546001600160a01b031681565b60035460ff1681565b60006107d4610b5f565b50919050565b606060006060306001600160a01b0316846040516024016107fb9190611265565b60408051601f198184030181529181526020820180516001600160e01b0316630933c1ed60e01b1790525161083091906111e5565b600060405180830381855afa9150503d806000811461086b576040519150601f19603f3d011682016040523d82523d6000602084013e610870565b606091505b50915091506000821415610885573d60208201fd5b808060200190516108999190810190610ec8565b949350505050565b6108a9610615565b50565b60035461010090046001600160a01b031633146108db5760405162461bcd60e51b815260040161026490611286565b8115610915576040805160048152602481019091526020810180516001600160e01b031663153ab50560e01b17905261091390610722565b505b601080546001600160a01b038581166001600160a01b031983161790925560405191169061097a9061094b908490602401611265565b60408051601f198184030181529190526020810180516001600160e01b0316630adccee560e31b179052610722565b506010546040517fd604de94d45953f9138079ec1b82d533cb2160c906d1076d1f7ed54befbca97a916109b89184916001600160a01b03169061121c565b60405180910390a150505050565b6109ce610615565b5050565b6010546001600160a01b031681565b69d3c21bcecceda100000081565b6006546001600160a01b031681565b600e6020526000908152604090205463ffffffff1681565b600061074b610b5f565b600f6020526000908152604090205481565b6002805460408051602060018416156101000260001901909316849004601f8101849004840282018401909252818152929183018282801561071a5780601f106106ef5761010080835404028352916020019161071a565b600b5481565b60085481565b610a9e610615565b50505050505050565b60405161079590611203565b670de0b6b3a764000081565b600d6020908152600092835260408084209091529082529020805460019091015463ffffffff9091169082565b606060006060846001600160a01b031684604051610b0a91906111e5565b600060405180830381855af49150503d8060008114610b45576040519150601f19603f3d011682016040523d82523d6000602084013e610b4a565b606091505b50915091506000821415610899573d60208201fd5b60606000306001600160a01b0316600036604051602401610b81929190611253565b60408051601f198184030181529181526020820180516001600160e01b0316630933c1ed60e01b17905251610bb691906111e5565b600060405180830381855afa9150503d8060008114610bf1576040519150601f19603f3d011682016040523d82523d6000602084013e610bf6565b606091505b505090506040513d6000823e818015610691573d60408301f35b803561073b816113a2565b803561073b816113b6565b803561073b816113bf565b600082601f830112610c4257600080fd5b8151610c55610c50826112f4565b6112cd565b91508082526020830160208301858383011115610c7157600080fd5b610c7c838284611368565b50505092915050565b600082601f830112610c9657600080fd5b8135610ca4610c50826112f4565b91508082526020830160208301858383011115610cc057600080fd5b610c7c83828461135c565b803561073b816113c8565b803561073b816113d1565b600060208284031215610cf357600080fd5b60006108998484610c10565b60008060408385031215610d1257600080fd5b6000610d1e8585610c10565b9250506020610d2f85828601610c10565b9150509250929050565b600080600060608486031215610d4e57600080fd5b6000610d5a8686610c10565b9350506020610d6b86828701610c10565b9250506040610d7c86828701610c26565b9150509250925092565b600080600060608486031215610d9b57600080fd5b6000610da78686610c10565b9350506020610db886828701610c1b565b925050604084013567ffffffffffffffff811115610dd557600080fd5b610d7c86828701610c85565b60008060408385031215610df457600080fd5b6000610e008585610c10565b9250506020610d2f85828601610c26565b60008060008060008060c08789031215610e2a57600080fd5b6000610e368989610c10565b9650506020610e4789828a01610c26565b9550506040610e5889828a01610c26565b9450506060610e6989828a01610cd6565b9350506080610e7a89828a01610c26565b92505060a0610e8b89828a01610c26565b9150509295509295509295565b60008060408385031215610eab57600080fd5b6000610eb78585610c10565b9250506020610d2f85828601610ccb565b600060208284031215610eda57600080fd5b815167ffffffffffffffff811115610ef157600080fd5b61089984828501610c31565b600060208284031215610f0f57600080fd5b813567ffffffffffffffff811115610f2657600080fd5b61089984828501610c85565b600080600060608486031215610f4757600080fd5b6000610f538686610c26565b9350506020610f6486828701610c26565b9250506040610d7c86828701610c1b565b610f7e8161132e565b82525050565b610f7e81611339565b610f7e8161133e565b6000610fa28385611320565b9350610faf83858461135c565b610fb883611398565b9093019392505050565b6000610fce8385611329565b9350610fdb83858461135c565b50500190565b6000610fec8261131c565b610ff68185611320565b9350611006818560208601611368565b610fb881611398565b600061101a8261131c565b6110248185611329565b9350611034818560208601611368565b9290920192915050565b600061104b603b83611320565b7f54494d4554524156454c44656c656761746f723a66616c6c6261636b3a20636181527f6e6e6f742073656e642076616c756520746f2066616c6c6261636b0000000000602082015260400192915050565b60006110aa603b83611320565b7f54494d4554524156454c44656c656761746f723a3a5f736574496d706c656d6581527f6e746174696f6e3a2043616c6c6572206d75737420626520676f760000000000602082015260400192915050565b6000611109604383611329565b7f454950373132446f6d61696e28737472696e67206e616d652c75696e7432353681527f20636861696e49642c6164647265737320766572696679696e67436f6e74726160208201526263742960e81b604082015260430192915050565b6000611174603a83611329565b7f44656c65676174696f6e28616464726573732064656c6567617465652c75696e81527f74323536206e6f6e63652c75696e7432353620657870697279290000000000006020820152603a0192915050565b610f7e8161134d565b610f7e81611356565b6000610899828486610fc2565b60006111f1828461100f565b9392505050565b600061073b826110fc565b600061073b82611167565b6020810161073b8284610f75565b6040810161122a8285610f75565b6111f16020830184610f75565b6020810161073b8284610f84565b6020810161073b8284610f8d565b60208082528101610899818486610f96565b602080825281016111f18184610fe1565b6020808252810161073b8161103e565b6020808252810161073b8161109d565b6020810161073b82846111c6565b604081016112b282856111c6565b6111f16020830184610f8d565b6020810161073b82846111cf565b60405181810167ffffffffffffffff811182821017156112ec57600080fd5b604052919050565b600067ffffffffffffffff82111561130b57600080fd5b506020601f91909101601f19160190565b5190565b90815260200190565b919050565b600061073b82611341565b151590565b90565b6001600160a01b031690565b63ffffffff1690565b60ff1690565b82818337506000910152565b60005b8381101561138357818101518382015260200161136b565b83811115611392576000848401525b50505050565b601f01601f191690565b6113ab8161132e565b81146108a957600080fd5b6113ab81611339565b6113ab8161133e565b6113ab8161134d565b6113ab8161135656fea365627a7a723158205e37a89d7a3015f05d301a7ce969f88a2d6fa1c3651e217b0875c8cd13b408376c6578706572696d656e74616cf564736f6c63430005110040

Verified Source Code Partial Match

Compiler: v0.5.17+commit.d19bba13 EVM: istanbul Optimization: Yes (200 runs)
TIMETRAVELDelegator.sol 1395 lines
pragma solidity 0.5.17;

pragma experimental ABIEncoderV2;

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

        return c;
    }

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

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

        return c;
    }

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

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

        return c;
    }

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

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

        return c;
    }

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

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


// Storage for a TIMETRAVEL token
contract TIMETRAVELTokenStorage {

    using SafeMath for uint256;

    /**
     * @dev Guard variable for re-entrancy checks. Not currently used
     */
    bool internal _notEntered;

    /**
     * @notice EIP-20 token name for this token
     */
    string public name;

    /**
     * @notice EIP-20 token symbol for this token
     */
    string public symbol;

    /**
     * @notice EIP-20 token decimals for this token
     */
    uint8 public decimals;

    /**
     * @notice Governor for this contract
     */
    address public gov;

    /**
     * @notice Pending governance for this contract
     */
    address public pendingGov;

    /**
     * @notice Approved rebaser for this contract
     */
    address public rebaser;

    /**
     * @notice Reserve address of TIMETRAVEL protocol
     */
    address public incentivizer;

    /**
     * @notice Total supply of TIMETRAVELs
     */
    uint256 public totalSupply;

    /**
     * @notice Internal decimals used to handle scaling factor
     */
    uint256 public constant internalDecimals = 10**24;

    /**
     * @notice Used for percentage maths
     */
    uint256 public constant BASE = 10**18;

    /**
     * @notice Scaling factor that adjusts everyone's balances
     */
    uint256 public timetravelsScalingFactor;

    mapping (address => uint256) internal _timetravelBalances;

    mapping (address => mapping (address => uint256)) internal _allowedFragments;

    uint256 public initSupply;

}

contract TIMETRAVELGovernanceStorage {
    /// @notice A record of each accounts delegate
    mapping (address => address) internal _delegates;

    /// @notice A checkpoint for marking number of votes from a given block
    struct Checkpoint {
        uint32 fromBlock;
        uint256 votes;
    }

    /// @notice A record of votes checkpoints for each account, by index
    mapping (address => mapping (uint32 => Checkpoint)) public checkpoints;

    /// @notice The number of checkpoints for each account
    mapping (address => uint32) public numCheckpoints;

    /// @notice The EIP-712 typehash for the contract's domain
    bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)");

    /// @notice The EIP-712 typehash for the delegation struct used by the contract
    bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");

    /// @notice A record of states for signing / validating signatures
    mapping (address => uint) public nonces;
}

contract TIMETRAVELTokenInterface is TIMETRAVELTokenStorage, TIMETRAVELGovernanceStorage {

    /// @notice An event thats emitted when an account changes its delegate
    event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);

    /// @notice An event thats emitted when a delegate account's vote balance changes
    event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance);

    /**
     * @notice Event emitted when tokens are rebased
     */
    event Rebase(uint256 epoch, uint256 prevTimetravelsScalingFactor, uint256 newTimetravelsScalingFactor);

    /*** Gov Events ***/

    /**
     * @notice Event emitted when pendingGov is changed
     */
    event NewPendingGov(address oldPendingGov, address newPendingGov);

    /**
     * @notice Event emitted when gov is changed
     */
    event NewGov(address oldGov, address newGov);

    /**
     * @notice Sets the rebaser contract
     */
    event NewRebaser(address oldRebaser, address newRebaser);

    /**
     * @notice Sets the incentivizer contract
     */
    event NewIncentivizer(address oldIncentivizer, address newIncentivizer);

    /* - ERC20 Events - */

    /**
     * @notice EIP20 Transfer event
     */
    event Transfer(address indexed from, address indexed to, uint amount);

    /**
     * @notice EIP20 Approval event
     */
    event Approval(address indexed owner, address indexed spender, uint amount);

    /* - Extra Events - */
    /**
     * @notice Tokens minted event
     */
    event Mint(address to, uint256 amount);

    // Public functions
    function transfer(address to, uint256 value) external returns(bool);
    function transferFrom(address from, address to, uint256 value) external returns(bool);
    function balanceOf(address who) external view returns(uint256);
    function balanceOfUnderlying(address who) external view returns(uint256);
    function allowance(address owner_, address spender) external view returns(uint256);
    function approve(address spender, uint256 value) external returns (bool);
    function increaseAllowance(address spender, uint256 addedValue) external returns (bool);
    function decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool);
    function maxScalingFactor() external view returns (uint256);

    /* - Governance Functions - */
    function getPriorVotes(address account, uint blockNumber) external view returns (uint256);
    function delegateBySig(address delegatee, uint nonce, uint expiry, uint8 v, bytes32 r, bytes32 s) external;
    function delegate(address delegatee) external;
    function delegates(address delegator) external view returns (address);
    function getCurrentVotes(address account) external view returns (uint256);

    /* - Permissioned/Governance functions - */
    function mint(address to, uint256 amount) external returns (bool);
    function rebase(uint256 epoch, uint256 indexDelta, bool positive) external returns (uint256);
    function _setRebaser(address rebaser_) external;
    function _setIncentivizer(address incentivizer_) external;
    function _setPendingGov(address pendingGov_) external;
    function _acceptGov() external;
}


contract TIMETRAVELGovernanceToken is TIMETRAVELTokenInterface {

      /// @notice An event thats emitted when an account changes its delegate
    event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);

    /// @notice An event thats emitted when a delegate account's vote balance changes
    event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance);

    /**
     * @notice Delegate votes from `msg.sender` to `delegatee`
     * @param delegator The address to get delegatee for
     */
    function delegates(address delegator)
        external
        view
        returns (address)
    {
        return _delegates[delegator];
    }

   /**
    * @notice Delegate votes from `msg.sender` to `delegatee`
    * @param delegatee The address to delegate votes to
    */
    function delegate(address delegatee) external {
        return _delegate(msg.sender, delegatee);
    }

    /**
     * @notice Delegates votes from signatory to `delegatee`
     * @param delegatee The address to delegate votes to
     * @param nonce The contract state required to match the signature
     * @param expiry The time at which to expire the signature
     * @param v The recovery byte of the signature
     * @param r Half of the ECDSA signature pair
     * @param s Half of the ECDSA signature pair
     */
    function delegateBySig(
        address delegatee,
        uint nonce,
        uint expiry,
        uint8 v,
        bytes32 r,
        bytes32 s
    )
        external
    {
        bytes32 domainSeparator = keccak256(
            abi.encode(
                DOMAIN_TYPEHASH,
                keccak256(bytes(name)),
                getChainId(),
                address(this)
            )
        );

        bytes32 structHash = keccak256(
            abi.encode(
                DELEGATION_TYPEHASH,
                delegatee,
                nonce,
                expiry
            )
        );

        bytes32 digest = keccak256(
            abi.encodePacked(
                "\x19\x01",
                domainSeparator,
                structHash
            )
        );

        address signatory = ecrecover(digest, v, r, s);
        require(signatory != address(0), "TIMETRAVEL::delegateBySig: invalid signature");
        require(nonce == nonces[signatory]++, "TIMETRAVEL::delegateBySig: invalid nonce");
        require(now <= expiry, "TIMETRAVEL::delegateBySig: signature expired");
        return _delegate(signatory, delegatee);
    }

    /**
     * @notice Gets the current votes balance for `account`
     * @param account The address to get votes balance
     * @return The number of current votes for `account`
     */
    function getCurrentVotes(address account)
        external
        view
        returns (uint256)
    {
        uint32 nCheckpoints = numCheckpoints[account];
        return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0;
    }

    /**
     * @notice Determine the prior number of votes for an account as of a block number
     * @dev Block number must be a finalized block or else this function will revert to prevent misinformation.
     * @param account The address of the account to check
     * @param blockNumber The block number to get the vote balance at
     * @return The number of votes the account had as of the given block
     */
    function getPriorVotes(address account, uint blockNumber)
        external
        view
        returns (uint256)
    {
        require(blockNumber < block.number, "TIMETRAVEL::getPriorVotes: not yet determined");

        uint32 nCheckpoints = numCheckpoints[account];
        if (nCheckpoints == 0) {
            return 0;
        }

        // First check most recent balance
        if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) {
            return checkpoints[account][nCheckpoints - 1].votes;
        }

        // Next check implicit zero balance
        if (checkpoints[account][0].fromBlock > blockNumber) {
            return 0;
        }

        uint32 lower = 0;
        uint32 upper = nCheckpoints - 1;
        while (upper > lower) {
            uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow
            Checkpoint memory cp = checkpoints[account][center];
            if (cp.fromBlock == blockNumber) {
                return cp.votes;
            } else if (cp.fromBlock < blockNumber) {
                lower = center;
            } else {
                upper = center - 1;
            }
        }
        return checkpoints[account][lower].votes;
    }

    function _delegate(address delegator, address delegatee)
        internal
    {
        address currentDelegate = _delegates[delegator];
        uint256 delegatorBalance = _timetravelBalances[delegator]; // balance of underlying TIMETRAVELs (not scaled);
        _delegates[delegator] = delegatee;

        emit DelegateChanged(delegator, currentDelegate, delegatee);

        _moveDelegates(currentDelegate, delegatee, delegatorBalance);
    }

    function _moveDelegates(address srcRep, address dstRep, uint256 amount) internal {
        if (srcRep != dstRep && amount > 0) {
            if (srcRep != address(0)) {
                // decrease old representative
                uint32 srcRepNum = numCheckpoints[srcRep];
                uint256 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0;
                uint256 srcRepNew = srcRepOld.sub(amount);
                _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew);
            }

            if (dstRep != address(0)) {
                // increase new representative
                uint32 dstRepNum = numCheckpoints[dstRep];
                uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0;
                uint256 dstRepNew = dstRepOld.add(amount);
                _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);
            }
        }
    }

    function _writeCheckpoint(
        address delegatee,
        uint32 nCheckpoints,
        uint256 oldVotes,
        uint256 newVotes
    )
        internal
    {
        uint32 blockNumber = safe32(block.number, "TIMETRAVEL::_writeCheckpoint: block number exceeds 32 bits");

        if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) {
            checkpoints[delegatee][nCheckpoints - 1].votes = newVotes;
        } else {
            checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes);
            numCheckpoints[delegatee] = nCheckpoints + 1;
        }

        emit DelegateVotesChanged(delegatee, oldVotes, newVotes);
    }

    function safe32(uint n, string memory errorMessage) internal pure returns (uint32) {
        require(n < 2**32, errorMessage);
        return uint32(n);
    }

    function getChainId() internal pure returns (uint) {
        uint256 chainId;
        assembly { chainId := chainid() }
        return chainId;
    }
}

contract TIMETRAVELToken is TIMETRAVELGovernanceToken {
    // Modifiers
    modifier onlyGov() {
        require(msg.sender == gov);
        _;
    }

    modifier onlyRebaser() {
        require(msg.sender == rebaser);
        _;
    }

    modifier onlyMinter() {
        require(msg.sender == rebaser || msg.sender == incentivizer || msg.sender == gov, "not minter");
        _;
    }

    modifier validRecipient(address to) {
        require(to != address(0x0));
        require(to != address(this));
        _;
    }

    function initialize(
        string memory name_,
        string memory symbol_,
        uint8 decimals_
    )
        public
    {
        require(timetravelsScalingFactor == 0, "already initialized");
        name = name_;
        symbol = symbol_;
        decimals = decimals_;
    }


    /**
    * @notice Computes the current max scaling factor
    */
    function maxScalingFactor()
        external
        view
        returns (uint256)
    {
        return _maxScalingFactor();
    }

    function _maxScalingFactor()
        internal
        view
        returns (uint256)
    {
        // scaling factor can only go up to 2**256-1 = initSupply * timetravelsScalingFactor
        // this is used to check if timetravelsScalingFactor will be too high to compute balances when rebasing.
        return uint256(-1) / initSupply;
    }

    /**
    * @notice Mints new tokens, increasing totalSupply, initSupply, and a users balance.
    * @dev Limited to onlyMinter modifier
    */
    function mint(address to, uint256 amount)
        external
        onlyMinter
        returns (bool)
    {
        _mint(to, amount);
        return true;
    }

    function _mint(address to, uint256 amount)
        internal
    {
      // increase totalSupply
      totalSupply = totalSupply.add(amount);

      // get underlying value
      uint256 timetravelValue = amount.mul(internalDecimals).div(timetravelsScalingFactor);

      // increase initSupply
      initSupply = initSupply.add(timetravelValue);

      // make sure the mint didnt push maxScalingFactor too low
      require(timetravelsScalingFactor <= _maxScalingFactor(), "max scaling factor too low");

      // add balance
      _timetravelBalances[to] = _timetravelBalances[to].add(timetravelValue);

      // add delegates to the minter
      _moveDelegates(address(0), _delegates[to], timetravelValue);
      emit Mint(to, amount);
    }

    /* - ERC20 functionality - */

    /**
    * @dev Transfer tokens to a specified address.
    * @param to The address to transfer to.
    * @param value The amount to be transferred.
    * @return True on success, false otherwise.
    */
    function transfer(address to, uint256 value)
        external
        validRecipient(to)
        returns (bool)
    {
        // underlying balance is stored in timetravels, so divide by current scaling factor

        // note, this means as scaling factor grows, dust will be untransferrable.
        // minimum transfer value == timetravelsScalingFactor / 1e24;

        // get amount in underlying
        uint256 timetravelValue = value.mul(internalDecimals).div(timetravelsScalingFactor);

        // sub from balance of sender
        _timetravelBalances[msg.sender] = _timetravelBalances[msg.sender].sub(timetravelValue);

        // add to balance of receiver
        _timetravelBalances[to] = _timetravelBalances[to].add(timetravelValue);
        emit Transfer(msg.sender, to, value);

        _moveDelegates(_delegates[msg.sender], _delegates[to], timetravelValue);
        return true;
    }

    /**
    * @dev Transfer tokens from one address to another.
    * @param from The address you want to send tokens from.
    * @param to The address you want to transfer to.
    * @param value The amount of tokens to be transferred.
    */
    function transferFrom(address from, address to, uint256 value)
        external
        validRecipient(to)
        returns (bool)
    {
        // decrease allowance
        _allowedFragments[from][msg.sender] = _allowedFragments[from][msg.sender].sub(value);

        // get value in timetravels
        uint256 timetravelValue = value.mul(internalDecimals).div(timetravelsScalingFactor);

        // sub from from
        _timetravelBalances[from] = _timetravelBalances[from].sub(timetravelValue);
        _timetravelBalances[to] = _timetravelBalances[to].add(timetravelValue);
        emit Transfer(from, to, value);

        _moveDelegates(_delegates[from], _delegates[to], timetravelValue);
        return true;
    }

    /**
    * @param who The address to query.
    * @return The balance of the specified address.
    */
    function balanceOf(address who)
      external
      view
      returns (uint256)
    {
      return _timetravelBalances[who].mul(timetravelsScalingFactor).div(internalDecimals);
    }

    /** @notice Currently returns the internal storage amount
    * @param who The address to query.
    * @return The underlying balance of the specified address.
    */
    function balanceOfUnderlying(address who)
      external
      view
      returns (uint256)
    {
      return _timetravelBalances[who];
    }

    /**
     * @dev Function to check the amount of tokens that an owner has allowed to a spender.
     * @param owner_ The address which owns the funds.
     * @param spender The address which will spend the funds.
     * @return The number of tokens still available for the spender.
     */
    function allowance(address owner_, address spender)
        external
        view
        returns (uint256)
    {
        return _allowedFragments[owner_][spender];
    }

    /**
     * @dev Approve the passed address to spend the specified amount of tokens on behalf of
     * msg.sender. This method is included for ERC20 compatibility.
     * increaseAllowance and decreaseAllowance should be used instead.
     * Changing an allowance with this method brings the risk that someone may transfer both
     * the old and the new allowance - if they are both greater than zero - if a transfer
     * transaction is mined before the later approve() call is mined.
     *
     * @param spender The address which will spend the funds.
     * @param value The amount of tokens to be spent.
     */
    function approve(address spender, uint256 value)
        external
        returns (bool)
    {
        _allowedFragments[msg.sender][spender] = value;
        emit Approval(msg.sender, spender, value);
        return true;
    }

    /**
     * @dev Increase the amount of tokens that an owner has allowed to a spender.
     * This method should be used instead of approve() to avoid the double approval vulnerability
     * described above.
     * @param spender The address which will spend the funds.
     * @param addedValue The amount of tokens to increase the allowance by.
     */
    function increaseAllowance(address spender, uint256 addedValue)
        external
        returns (bool)
    {
        _allowedFragments[msg.sender][spender] =
            _allowedFragments[msg.sender][spender].add(addedValue);
        emit Approval(msg.sender, spender, _allowedFragments[msg.sender][spender]);
        return true;
    }

    /**
     * @dev Decrease the amount of tokens that an owner has allowed to a spender.
     *
     * @param spender The address which will spend the funds.
     * @param subtractedValue The amount of tokens to decrease the allowance by.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue)
        external
        returns (bool)
    {
        uint256 oldValue = _allowedFragments[msg.sender][spender];
        if (subtractedValue >= oldValue) {
            _allowedFragments[msg.sender][spender] = 0;
        } else {
            _allowedFragments[msg.sender][spender] = oldValue.sub(subtractedValue);
        }
        emit Approval(msg.sender, spender, _allowedFragments[msg.sender][spender]);
        return true;
    }

    /* - Governance Functions - */

    /** @notice sets the rebaser
     * @param rebaser_ The address of the rebaser contract to use for authentication.
     */
    function _setRebaser(address rebaser_)
        external
        onlyGov
    {
        address oldRebaser = rebaser;
        rebaser = rebaser_;
        emit NewRebaser(oldRebaser, rebaser_);
    }

    /** @notice sets the incentivizer
     * @param incentivizer_ The address of the rebaser contract to use for authentication.
     */
    function _setIncentivizer(address incentivizer_)
        external
        onlyGov
    {
        address oldIncentivizer = incentivizer;
        incentivizer = incentivizer_;
        emit NewIncentivizer(oldIncentivizer, incentivizer_);
    }

    /** @notice sets the pendingGov
     * @param pendingGov_ The address of the rebaser contract to use for authentication.
     */
    function _setPendingGov(address pendingGov_)
        external
        onlyGov
    {
        address oldPendingGov = pendingGov;
        pendingGov = pendingGov_;
        emit NewPendingGov(oldPendingGov, pendingGov_);
    }

    /** @notice lets msg.sender accept governance
     *
     */
    function _acceptGov()
        external
    {
        require(msg.sender == pendingGov, "!pending");
        address oldGov = gov;
        gov = pendingGov;
        pendingGov = address(0);
        emit NewGov(oldGov, gov);
    }

    /* - Extras - */

    /**
    * @notice Initiates a new rebase operation, provided the minimum time period has elapsed.
    *
    * @dev The supply adjustment equals (totalSupply * DeviationFromTargetRate) / rebaseLag
    *      Where DeviationFromTargetRate is (MarketOracleRate - targetRate) / targetRate
    *      and targetRate is CpiOracleRate / baseCpi
    */
    function rebase(
        uint256 epoch,
        uint256 indexDelta,
        bool positive
    )
        external
        onlyRebaser
        returns (uint256)
    {
        if (indexDelta == 0) {
          emit Rebase(epoch, timetravelsScalingFactor, timetravelsScalingFactor);
          return totalSupply;
        }

        uint256 prevTimetravelsScalingFactor = timetravelsScalingFactor;

        if (!positive) {
           timetravelsScalingFactor = timetravelsScalingFactor.mul(BASE.sub(indexDelta)).div(BASE);
        } else {
            uint256 newScalingFactor = timetravelsScalingFactor.mul(BASE.add(indexDelta)).div(BASE);
            if (newScalingFactor < _maxScalingFactor()) {
                timetravelsScalingFactor = newScalingFactor;
            } else {
              timetravelsScalingFactor = _maxScalingFactor();
            }
        }

        totalSupply = initSupply.mul(timetravelsScalingFactor);
        emit Rebase(epoch, prevTimetravelsScalingFactor, timetravelsScalingFactor);
        return totalSupply;
    }
}

contract TIMETRAVEL is TIMETRAVELToken {
    /**
     * @notice Initialize the new money market
     * @param name_ ERC-20 name of this token
     * @param symbol_ ERC-20 symbol of this token
     * @param decimals_ ERC-20 decimal precision of this token
     */
    function initialize(
        string memory name_,
        string memory symbol_,
        uint8 decimals_,
        address initial_owner,
        uint256 initSupply_
    )
        public
    {
        require(initSupply_ > 0, "0 init supply");

        super.initialize(name_, symbol_, decimals_);

        initSupply = initSupply_.mul(10**24/ (BASE));
        totalSupply = initSupply_;
        timetravelsScalingFactor = BASE;
        _timetravelBalances[initial_owner] = initSupply_.mul(10**24 / (BASE));

        // owner renounces ownership after deployment as they need to set
        // rebaser and incentivizer
        // gov = gov_;
    }
}


contract TIMETRAVELDelegationStorage {
    /**
     * @notice Implementation address for this contract
     */
    address public implementation;
}

contract TIMETRAVELDelegatorInterface is TIMETRAVELDelegationStorage {
    /**
     * @notice Emitted when implementation is changed
     */
    event NewImplementation(address oldImplementation, address newImplementation);

    /**
     * @notice Called by the gov to update the implementation of the delegator
     * @param implementation_ The address of the new implementation for delegation
     * @param allowResign Flag to indicate whether to call _resignImplementation on the old implementation
     * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation
     */
    function _setImplementation(address implementation_, bool allowResign, bytes memory becomeImplementationData) public;
}

contract TIMETRAVELDelegateInterface is TIMETRAVELDelegationStorage {
    /**
     * @notice Called by the delegator on a delegate to initialize it for duty
     * @dev Should revert if any issues arise which make it unfit for delegation
     * @param data The encoded bytes data for any initialization
     */
    function _becomeImplementation(bytes memory data) public;

    /**
     * @notice Called by the delegator on a delegate to forfeit its responsibility
     */
    function _resignImplementation() public;
}


contract TIMETRAVELDelegate is TIMETRAVEL, TIMETRAVELDelegateInterface {
    /**
     * @notice Construct an empty delegate
     */
    constructor() public {}

    /**
     * @notice Called by the delegator on a delegate to initialize it for duty
     * @param data The encoded bytes data for any initialization
     */
    function _becomeImplementation(bytes memory data) public {
        // Shh -- currently unused
        data;

        // Shh -- we don't ever want this hook to be marked pure
        if (false) {
            implementation = address(0);
        }

        require(msg.sender == gov, "only the gov may call _becomeImplementation");
    }

    /**
     * @notice Called by the delegator on a delegate to forfeit its responsibility
     */
    function _resignImplementation() public {
        // Shh -- we don't ever want this hook to be marked pure
        if (false) {
            implementation = address(0);
        }

        require(msg.sender == gov, "only the gov may call _resignImplementation");
    }
}

contract TIMETRAVELDelegator is TIMETRAVELTokenInterface, TIMETRAVELDelegatorInterface {
    /**
     * @notice Construct a new TIMETRAVEL
     * @param name_ ERC-20 name of this token
     * @param symbol_ ERC-20 symbol of this token
     * @param decimals_ ERC-20 decimal precision of this token
     * @param initSupply_ Initial token amount
     * @param implementation_ The address of the implementation the contract delegates to
     * @param becomeImplementationData The encoded args for becomeImplementation
     */
    constructor(
        string memory name_,
        string memory symbol_,
        uint8 decimals_,
        uint256 initSupply_,
        address implementation_,
        bytes memory becomeImplementationData
    )
        public
    {


        // Creator of the contract is gov during initialization
        gov = msg.sender;

        // First delegate gets to initialize the delegator (i.e. storage contract)
        delegateTo(
            implementation_,
            abi.encodeWithSignature(
                "initialize(string,string,uint8,address,uint256)",
                name_,
                symbol_,
                decimals_,
                msg.sender,
                initSupply_
            )
        );

        // New implementations always get set via the settor (post-initialize)
        _setImplementation(implementation_, false, becomeImplementationData);

    }

    /**
     * @notice Called by the gov to update the implementation of the delegator
     * @param implementation_ The address of the new implementation for delegation
     * @param allowResign Flag to indicate whether to call _resignImplementation on the old implementation
     * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation
     */
    function _setImplementation(address implementation_, bool allowResign, bytes memory becomeImplementationData) public {
        require(msg.sender == gov, "TIMETRAVELDelegator::_setImplementation: Caller must be gov");

        if (allowResign) {
            delegateToImplementation(abi.encodeWithSignature("_resignImplementation()"));
        }

        address oldImplementation = implementation;
        implementation = implementation_;

        delegateToImplementation(abi.encodeWithSignature("_becomeImplementation(bytes)", becomeImplementationData));

        emit NewImplementation(oldImplementation, implementation);
    }

    /**
     * @notice Sender supplies assets into the market and receives cTokens in exchange
     * @dev Accrues interest whether or not the operation succeeds, unless reverted
     * @param mintAmount The amount of the underlying asset to supply
     * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
     */
    function mint(address to, uint256 mintAmount)
        external
        returns (bool)
    {
        to; mintAmount; // Shh
        delegateAndReturn();
    }

    /**
     * @notice Transfer `amount` tokens from `msg.sender` to `dst`
     * @param dst The address of the destination account
     * @param amount The number of tokens to transfer
     * @return Whether or not the transfer succeeded
     */
    function transfer(address dst, uint256 amount)
        external
        returns (bool)
    {
        dst; amount; // Shh
        delegateAndReturn();
    }

    /**
     * @notice Transfer `amount` tokens from `src` to `dst`
     * @param src The address of the source account
     * @param dst The address of the destination account
     * @param amount The number of tokens to transfer
     * @return Whether or not the transfer succeeded
     */
    function transferFrom(
        address src,
        address dst,
        uint256 amount
    )
        external
        returns (bool)
    {
        src; dst; amount; // Shh
        delegateAndReturn();
    }

    /**
     * @notice Approve `spender` to transfer up to `amount` from `src`
     * @dev This will overwrite the approval amount for `spender`
     *  and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve)
     * @param spender The address of the account which may transfer tokens
     * @param amount The number of tokens that are approved (-1 means infinite)
     * @return Whether or not the approval succeeded
     */
    function approve(
        address spender,
        uint256 amount
    )
        external
        returns (bool)
    {
        spender; amount; // Shh
        delegateAndReturn();
    }

    /**
     * @dev Increase the amount of tokens that an owner has allowed to a spender.
     * This method should be used instead of approve() to avoid the double approval vulnerability
     * described above.
     * @param spender The address which will spend the funds.
     * @param addedValue The amount of tokens to increase the allowance by.
     */
    function increaseAllowance(
        address spender,
        uint256 addedValue
    )
        external
        returns (bool)
    {
        spender; addedValue; // Shh
        delegateAndReturn();
    }

    function maxScalingFactor()
        external
        view
        returns (uint256)
    {
        delegateToViewAndReturn();
    }

    function rebase(
        uint256 epoch,
        uint256 indexDelta,
        bool positive
    )
        external
        returns (uint256)
    {
        epoch; indexDelta; positive;
        delegateAndReturn();
    }

    /**
     * @dev Decrease the amount of tokens that an owner has allowed to a spender.
     *
     * @param spender The address which will spend the funds.
     * @param subtractedValue The amount of tokens to decrease the allowance by.
     */
    function decreaseAllowance(
        address spender,
        uint256 subtractedValue
    )
        external
        returns (bool)
    {
        spender; subtractedValue; // Shh
        delegateAndReturn();
    }

    /**
     * @notice Get the current allowance from `owner` for `spender`
     * @param owner The address of the account which owns the tokens to be spent
     * @param spender The address of the account which may transfer tokens
     * @return The number of tokens allowed to be spent (-1 means infinite)
     */
    function allowance(
        address owner,
        address spender
    )
        external
        view
        returns (uint256)
    {
        owner; spender; // Shh
        delegateToViewAndReturn();
    }

    /**
     * @notice Get the current allowance from `owner` for `spender`
     * @param delegator The address of the account which has designated a delegate
     * @return Address of delegatee
     */
    function delegates(
        address delegator
    )
        external
        view
        returns (address)
    {
        delegator; // Shh
        delegateToViewAndReturn();
    }

    /**
     * @notice Get the token balance of the `owner`
     * @param owner The address of the account to query
     * @return The number of tokens owned by `owner`
     */
    function balanceOf(address owner)
        external
        view
        returns (uint256)
    {
        owner; // Shh
        delegateToViewAndReturn();
    }

    /**
     * @notice Currently unused. For future compatability
     * @param owner The address of the account to query
     * @return The number of underlying tokens owned by `owner`
     */
    function balanceOfUnderlying(address owner)
        external
        view
        returns (uint256)
    {
        owner; // Shh
        delegateToViewAndReturn();
    }

    /*** Gov Functions ***/

    /**
      * @notice Begins transfer of gov rights. The newPendingGov must call `_acceptGov` to finalize the transfer.
      * @dev Gov function to begin change of gov. The newPendingGov must call `_acceptGov` to finalize the transfer.
      * @param newPendingGov New pending gov.
      */
    function _setPendingGov(address newPendingGov)
        external
    {
        newPendingGov; // Shh
        delegateAndReturn();
    }

    function _setRebaser(address rebaser_)
        external
    {
        rebaser_; // Shh
        delegateAndReturn();
    }

    function _setIncentivizer(address incentivizer_)
        external
    {
        incentivizer_; // Shh
        delegateAndReturn();
    }

    /**
      * @notice Accepts transfer of gov rights. msg.sender must be pendingGov
      * @dev Gov function for pending gov to accept role and update gov
      * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
      */
    function _acceptGov()
        external
    {
        delegateAndReturn();
    }


    function getPriorVotes(address account, uint blockNumber)
        external
        view
        returns (uint256)
    {
        account; blockNumber;
        delegateToViewAndReturn();
    }

    function delegateBySig(
        address delegatee,
        uint nonce,
        uint expiry,
        uint8 v,
        bytes32 r,
        bytes32 s
    )
        external
    {
        delegatee; nonce; expiry; v; r; s;
        delegateAndReturn();
    }

    function delegate(address delegatee)
        external
    {
        delegatee;
        delegateAndReturn();
    }

    function getCurrentVotes(address account)
        external
        view
        returns (uint256)
    {
        account;
        delegateToViewAndReturn();
    }

    /**
     * @notice Internal method to delegate execution to another contract
     * @dev It returns to the external caller whatever the implementation returns or forwards reverts
     * @param callee The contract to delegatecall
     * @param data The raw data to delegatecall
     * @return The returned bytes from the delegatecall
     */
    function delegateTo(address callee, bytes memory data) internal returns (bytes memory) {
        (bool success, bytes memory returnData) = callee.delegatecall(data);
        assembly {
            if eq(success, 0) {
                revert(add(returnData, 0x20), returndatasize)
            }
        }
        return returnData;
    }

    /**
     * @notice Delegates execution to the implementation contract
     * @dev It returns to the external caller whatever the implementation returns or forwards reverts
     * @param data The raw data to delegatecall
     * @return The returned bytes from the delegatecall
     */
    function delegateToImplementation(bytes memory data) public returns (bytes memory) {
        return delegateTo(implementation, data);
    }

    /**
     * @notice Delegates execution to an implementation contract
     * @dev It returns to the external caller whatever the implementation returns or forwards reverts
     *  There are an additional 2 prefix uints from the wrapper returndata, which we ignore since we make an extra hop.
     * @param data The raw data to delegatecall
     * @return The returned bytes from the delegatecall
     */
    function delegateToViewImplementation(bytes memory data) public view returns (bytes memory) {
        (bool success, bytes memory returnData) = address(this).staticcall(abi.encodeWithSignature("delegateToImplementation(bytes)", data));
        assembly {
            if eq(success, 0) {
                revert(add(returnData, 0x20), returndatasize)
            }
        }
        return abi.decode(returnData, (bytes));
    }

    function delegateToViewAndReturn() private view returns (bytes memory) {
        (bool success, ) = address(this).staticcall(abi.encodeWithSignature("delegateToImplementation(bytes)", msg.data));

        assembly {
            let free_mem_ptr := mload(0x40)
            returndatacopy(free_mem_ptr, 0, returndatasize)

            switch success
            case 0 { revert(free_mem_ptr, returndatasize) }
            default { return(add(free_mem_ptr, 0x40), returndatasize) }
        }
    }

    function delegateAndReturn() private returns (bytes memory) {
        (bool success, ) = implementation.delegatecall(msg.data);

        assembly {
            let free_mem_ptr := mload(0x40)
            returndatacopy(free_mem_ptr, 0, returndatasize)

            switch success
            case 0 { revert(free_mem_ptr, returndatasize) }
            default { return(free_mem_ptr, returndatasize) }
        }
    }

    /**
     * @notice Delegates execution to an implementation contract
     * @dev It returns to the external caller whatever the implementation returns or forwards reverts
     */
    function () external payable {
        require(msg.value == 0,"TIMETRAVELDelegator:fallback: cannot send value to fallback");

        // delegate all other functions to current implementation
        delegateAndReturn();
    }
}

Read Contract

BASE 0xec342ad0 → uint256
DELEGATION_TYPEHASH 0xe7a324dc → bytes32
DOMAIN_TYPEHASH 0x20606b70 → bytes32
allowance 0xdd62ed3e → uint256
balanceOf 0x70a08231 → uint256
balanceOfUnderlying 0x3af9e669 → uint256
checkpoints 0xf1127ed8 → uint32, uint256
decimals 0x313ce567 → uint8
delegateToViewImplementation 0x4487152f → bytes
delegates 0x587cde1e → address
getCurrentVotes 0xb4b5ea57 → uint256
getPriorVotes 0x782d6fe1 → uint256
gov 0x12d43a51 → address
implementation 0x5c60da1b → address
incentivizer 0x6fc6407c → address
initSupply 0x97d63f93 → uint256
internalDecimals 0x64dd48f5 → uint256
maxScalingFactor 0x11d3e6c4 → uint256
name 0x06fdde03 → string
nonces 0x7ecebe00 → uint256
numCheckpoints 0x6fcfff45 → uint32
pendingGov 0x25240810 → address
rebaser 0x11fd8a83 → address
symbol 0x95d89b41 → string
timetravelsScalingFactor 0xaaa84f65 → uint256
totalSupply 0x18160ddd → uint256

Write Contract 15 functions

These functions modify contract state and require a wallet transaction to execute.

_acceptGov 0x4bda2e20
No parameters
_setImplementation 0x555bcc40
address implementation_
bool allowResign
bytes becomeImplementationData
_setIncentivizer 0x98dca210
address incentivizer_
_setPendingGov 0x73f03dff
address newPendingGov
_setRebaser 0xfa8f3455
address rebaser_
approve 0x095ea7b3
address spender
uint256 amount
returns: bool
decreaseAllowance 0xa457c2d7
address spender
uint256 subtractedValue
returns: bool
delegate 0x5c19a95c
address delegatee
delegateBySig 0xc3cda520
address delegatee
uint256 nonce
uint256 expiry
uint8 v
bytes32 r
bytes32 s
delegateToImplementation 0x0933c1ed
bytes data
returns: bytes
increaseAllowance 0x39509351
address spender
uint256 addedValue
returns: bool
mint 0x40c10f19
address to
uint256 mintAmount
returns: bool
rebase 0x7af548c1
uint256 epoch
uint256 indexDelta
bool positive
returns: uint256
transfer 0xa9059cbb
address dst
uint256 amount
returns: bool
transferFrom 0x23b872dd
address src
address dst
uint256 amount
returns: bool

Recent Transactions

No transactions found for this address