Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0xa476FAa9FD4deEB13e9F76eA0eF95da3adB2d34a
Balance 0 ETH
Nonce 1
Code Size 9164 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

9164 bytes
0x608060405234801561001057600080fd5b506004361061025b5760003560e01c80637c3a00fd11610145578063b85e868e116100bd578063e1d0377e1161008c578063e2c60c2811610071578063e2c60c281461056d578063f2fde38b1461057a578063f470fd5e1461058d57600080fd5b8063e1d0377e1461053a578063e249cfe61461054d57600080fd5b8063b85e868e146104d0578063c87a6d2f146104d9578063db1f7234146104e2578063dd62ed3e146104f457600080fd5b80638da5cb5b11610114578063a457c2d7116100f9578063a457c2d7146104a2578063a9059cbb146104b5578063af14052c146104c857600080fd5b80638da5cb5b1461044857806395d89b411461046657600080fd5b80637c3a00fd146104105780638381e18214610419578063840b00da1461042c57806384ed2f881461043557600080fd5b80634d70dc27116101d857806364dbfd81116101a757806370fa70b61161018c57806370fa70b6146103ed578063715018a6146103f55780637acb7757146103fd57600080fd5b806364dbfd81146103d257806370a08231146103da57600080fd5b80634d70dc27146103575780635f264ebf146103605780635f84f3021461037357806361d027b31461038657600080fd5b806318160ddd1161022f578063313ce56711610214578063313ce56714610320578063395093511461032f578063495715721461034257600080fd5b806318160ddd1461030557806323b872dd1461030d57600080fd5b8062dd6eef1461026057806306fdde0314610286578063095ea7b3146102cf5780630af809cf146102f2575b600080fd5b61027361026e3660046121c9565b6105b4565b6040519081526020015b60405180910390f35b6102c26040518060400160405280600a81526020017f5374616b656420424c550000000000000000000000000000000000000000000081525081565b60405161027d9190612237565b6102e26102dd366004612168565b6105e4565b604051901515815260200161027d565b6102736103003660046121c9565b6105fa565b61027361061b565b6102e261031b36600461212d565b61062d565b6040516012815260200161027d565b6102e261033d366004612168565b610722565b610355610350366004612191565b61076b565b005b61027360035481565b61035561036e3660046121c9565b61084e565b6103556103813660046121c9565b61097d565b6103ad7f000000000000000000000000d67379e5dc0586c15a68d6977b9d4305e400121581565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161027d565b610273610ab2565b6102736103e83660046120e1565b610aca565b610273610af9565b610355610b9c565b6102e261040b3660046121f9565b610c29565b61027360015481565b6102e26104273660046121f9565b610dc3565b61027360065481565b610355610443366004612191565b610f59565b60005473ffffffffffffffffffffffffffffffffffffffff166103ad565b6102c26040518060400160405280600481526020017f73424c550000000000000000000000000000000000000000000000000000000081525081565b6102e26104b0366004612168565b611035565b6102e26104c3366004612168565b61110d565b61027361111d565b61027360055481565b61027360025481565b6004546102e290610100900460ff1681565b6102736105023660046120fb565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260086020908152604080832093909416825291909152205490565b6102736105483660046121c9565b6112bb565b61027361055b3660046120e1565b60076020526000908152604090205481565b6004546102e29060ff1681565b6103556105883660046120e1565b6112d6565b6103ad7f000000000000000000000000e5d2e173b120341face9e9970889c9fe64081ffd81565b60006105be610af9565b6105d46b033b2e3c9fd0803ce8000000846122d9565b6105de91906122a0565b92915050565b60006105f1338484611406565b50600192915050565b60006b033b2e3c9fd0803ce8000000610611610af9565b6105d490846122d9565b60006106286005546105fa565b905090565b6000610642848461063d856105b4565b61156e565b73ffffffffffffffffffffffffffffffffffffffff8416600090815260086020908152604080832033845290915290205482811015610708576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206160448201527f6c6c6f77616e636500000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b6107158533858403611406565b60019150505b9392505050565b33600081815260086020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716845290915281205490916105f1918590610766908690612288565b611406565b60005473ffffffffffffffffffffffffffffffffffffffff1633146107ec576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016106ff565b600480547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff16610100831515908102919091179091556040517fe92868f0894274f2123d55cbdb9202b5db930bef7525495e4394cf6ab76cc59390600090a250565b60005473ffffffffffffffffffffffffffffffffffffffff1633146108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016106ff565b670de0b6b3a7640000811115610941576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f4d696e696d756d2062616c616e63652067726561746572207468616e2031000060448201526064016106ff565b60068190556040518181527f30f22eb16414e4f072a1efe29129ecc5663ec5c357eb28c28d60557118800032906020015b60405180910390a150565b60005473ffffffffffffffffffffffffffffffffffffffff1633146109fe576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016106ff565b6b033b2e3c9fd0803ce8000000811015610a74576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f496e7465726573742072617465206c657373207468616e20310000000000000060448201526064016106ff565b610a7c610ab2565b5060018190556040518181527f323264e3ca065ee856fe1b11204d8896a783bccf148380ac5d7362eb5c4c36a890602001610972565b6000610abc610af9565b600281905542600355919050565b73ffffffffffffffffffffffffffffffffffffffff81166000908152600760205260408120546105de906105fa565b6000600354421015610b67576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f496e76616c69642074696d657374616d7000000000000000000000000000000060448201526064016106ff565b6b033b2e3c9fd0803ce8000000600254610b88600354426105489190612316565b610b9291906122d9565b61062891906122a0565b60005473ffffffffffffffffffffffffffffffffffffffff163314610c1d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016106ff565b610c2760006117a8565b565b60045460009060ff1615610c99576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f5374616b696e672070617573656400000000000000000000000000000000000060448201526064016106ff565b73ffffffffffffffffffffffffffffffffffffffff8216610d16576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f5374616b696e6720746f20746865207a65726f2061646472657373000000000060448201526064016106ff565b610d5873ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000e5d2e173b120341face9e9970889c9fe64081ffd1633308661181d565b610d6a82610d65856105b4565b6118ff565b8173ffffffffffffffffffffffffffffffffffffffff167febedb8b3c678666e7f36970bc8f57abf6d8fa2e828c0da91ea5b75bf68ed101a84604051610db291815260200190565b60405180910390a250600192915050565b600454600090610100900460ff1615610e38576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f556e7374616b696e67207061757365640000000000000000000000000000000060448201526064016106ff565b610e4061111d565b5073ffffffffffffffffffffffffffffffffffffffff8216610ebe576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f556e7374616b696e6720746f20746865207a65726f206164647265737300000060448201526064016106ff565b610ed082610ecb856105b4565b611a31565b610f1173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000e5d2e173b120341face9e9970889c9fe64081ffd168385611be1565b8173ffffffffffffffffffffffffffffffffffffffff167f85082129d87b2fe11527cb1b3b7a520aeb5aa6913f88a3d8757fe40d1db02fdd84604051610db291815260200190565b60005473ffffffffffffffffffffffffffffffffffffffff163314610fda576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016106ff565b600480547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00168215159081179091556040517f8928f869173dafe9aac2539260557f1a1af850f941eaeb8c39276d1e7af9e1b690600090a250565b33600090815260086020908152604080832073ffffffffffffffffffffffffffffffffffffffff86168452909152812054828110156110f6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f00000000000000000000000000000000000000000000000000000060648201526084016106ff565b6111033385858403611406565b5060019392505050565b60006105f1338461063d856105b4565b6000611127610ab2565b5060006111356005546105fa565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015290915060009073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000e5d2e173b120341face9e9970889c9fe64081ffd16906370a082319060240160206040518083038186803b1580156111c057600080fd5b505afa1580156111d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111f891906121e1565b9050818110156112b65761120c8183612316565b6040517f40c10f19000000000000000000000000000000000000000000000000000000008152306004820152602481018290529093507f000000000000000000000000d67379e5dc0586c15a68d6977b9d4305e400121573ffffffffffffffffffffffffffffffffffffffff16906340c10f1990604401600060405180830381600087803b15801561129d57600080fd5b505af11580156112b1573d6000803e3d6000fd5b505050505b505090565b60006105de600154836b033b2e3c9fd0803ce8000000611c37565b60005473ffffffffffffffffffffffffffffffffffffffff163314611357576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016106ff565b73ffffffffffffffffffffffffffffffffffffffff81166113fa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016106ff565b611403816117a8565b50565b73ffffffffffffffffffffffffffffffffffffffff8316611483576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f417070726f76652066726f6d20746865207a65726f206164647265737300000060448201526064016106ff565b73ffffffffffffffffffffffffffffffffffffffff8216611500576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f417070726f766520746f20746865207a65726f2061646472657373000000000060448201526064016106ff565b73ffffffffffffffffffffffffffffffffffffffff83811660008181526008602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b73ffffffffffffffffffffffffffffffffffffffff83166115eb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f5472616e736665722066726f6d20746865207a65726f2061646472657373000060448201526064016106ff565b73ffffffffffffffffffffffffffffffffffffffff8216611668576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f5472616e7366657220746f20746865207a65726f20616464726573730000000060448201526064016106ff565b73ffffffffffffffffffffffffffffffffffffffff83166000908152600760205260409020548111156116f7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5472616e7366657220616d6f756e7420657863656564732062616c616e63650060448201526064016106ff565b73ffffffffffffffffffffffffffffffffffffffff808416600090815260076020526040808220805485900390559184168152908120805483929061173d908490612288565b909155505073ffffffffffffffffffffffffffffffffffffffff8083169084167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef611787846105fa565b60405190815260200160405180910390a36117a3838383611cf5565b505050565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60405173ffffffffffffffffffffffffffffffffffffffff808516602483015283166044820152606481018290526118f99085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152611cfe565b50505050565b73ffffffffffffffffffffffffffffffffffffffff821661197c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f4d696e74696e6720746f20746865207a65726f2061646472657373000000000060448201526064016106ff565b806005600082825461198e9190612288565b909155505073ffffffffffffffffffffffffffffffffffffffff8216600090815260076020526040812080548392906119c8908490612288565b909155505073ffffffffffffffffffffffffffffffffffffffff821660007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef611a10846105fa565b60405190815260200160405180910390a3611a2d60008383611cf5565b5050565b73ffffffffffffffffffffffffffffffffffffffff8216611aae576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f4275726e2066726f6d20746865207a65726f206164647265737300000000000060448201526064016106ff565b73ffffffffffffffffffffffffffffffffffffffff8216600090815260076020526040902054811115611b3d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f4275726e20616d6f756e7420657863656564732062616c616e6365000000000060448201526064016106ff565b73ffffffffffffffffffffffffffffffffffffffff821660009081526007602052604081208054839003905560058054839290611b7b908490612316565b909155506000905073ffffffffffffffffffffffffffffffffffffffff83167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef611bc4846105fa565b60405190815260200160405180910390a3611a2d82600083611cf5565b60405173ffffffffffffffffffffffffffffffffffffffff83166024820152604481018290526117a39084907fa9059cbb0000000000000000000000000000000000000000000000000000000090606401611877565b6000828015611ce957848015611cde57600185168015611c5957869350611c5d565b8493505b50600284046002860495505b8515611cd8578687028760801c15611c8057600080fd5b81810181811015611c9057600080fd5b8690049750506001861615611ccd578684028488820414158815151615611cb657600080fd5b81810181811015611cc657600080fd5b8690049450505b600286049550611c69565b50611ce3565b600092505b50611ced565b8291505b509392505050565b6117a383611e0a565b6000611d60826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16611ece9092919063ffffffff16565b8051909150156117a35780806020019051810190611d7e91906121ad565b6117a3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016106ff565b60065473ffffffffffffffffffffffffffffffffffffffff8216600090815260076020526040902054108015611e64575073ffffffffffffffffffffffffffffffffffffffff811660009081526007602052604090205415155b156114035773ffffffffffffffffffffffffffffffffffffffff81166000908152600760205260408120546005805491929091611ea2908490612316565b909155505073ffffffffffffffffffffffffffffffffffffffff16600090815260076020526040812055565b6060611edd8484600085611ee5565b949350505050565b606082471015611f77576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c000000000000000000000000000000000000000000000000000060648201526084016106ff565b843b611fdf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016106ff565b6000808673ffffffffffffffffffffffffffffffffffffffff168587604051612008919061221b565b60006040518083038185875af1925050503d8060008114612045576040519150601f19603f3d011682016040523d82523d6000602084013e61204a565b606091505b509150915061205a828286612065565b979650505050505050565b6060831561207457508161071b565b8251156120845782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106ff9190612237565b803573ffffffffffffffffffffffffffffffffffffffff811681146120dc57600080fd5b919050565b6000602082840312156120f2578081fd5b61071b826120b8565b6000806040838503121561210d578081fd5b612116836120b8565b9150612124602084016120b8565b90509250929050565b600080600060608486031215612141578081fd5b61214a846120b8565b9250612158602085016120b8565b9150604084013590509250925092565b6000806040838503121561217a578182fd5b612183836120b8565b946020939093013593505050565b6000602082840312156121a2578081fd5b813561071b81612388565b6000602082840312156121be578081fd5b815161071b81612388565b6000602082840312156121da578081fd5b5035919050565b6000602082840312156121f2578081fd5b5051919050565b6000806040838503121561220b578182fd5b82359150612124602084016120b8565b6000825161222d81846020870161232d565b9190910192915050565b602081526000825180602084015261225681604085016020870161232d565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b6000821982111561229b5761229b612359565b500190565b6000826122d4577f4e487b710000000000000000000000000000000000000000000000000000000081526012600452602481fd5b500490565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561231157612311612359565b500290565b60008282101561232857612328612359565b500390565b60005b83811015612348578181015183820152602001612330565b838111156118f95750506000910152565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b801515811461140357600080fdfea2646970667358221220015ab24ae44ef05c9a23fd9ea92c70a3bfd9ec4c4a7847289f55507e8c30244664736f6c63430008040033

Verified Source Code Full Match

Compiler: v0.8.4+commit.c7e474f2 EVM: istanbul Optimization: Yes (1000000 runs)
Address.sol 217 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}
IERC20.sol 6 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (interfaces/IERC20.sol)

pragma solidity ^0.8.0;

import "../token/ERC20/IERC20.sol";
Ownable.sol 76 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/Context.sol";

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

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

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

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

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

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}
SafeERC20.sol 99 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using Address for address;

    function safeTransfer(
        IERC20 token,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(
        IERC20 token,
        address from,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    function safeIncreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        uint256 newAllowance = token.allowance(address(this), spender) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        if (returndata.length > 0) {
            // Return data is optional
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}
ExponentMath.sol 60 lines
// SPDX-License-Identifier: AGPL-3.0-or-later
// https://github.com/makerdao/dss/blob/master/src/abaci.sol
pragma solidity ^0.8.4;

library ExponentMath {
  function rpow(
    uint256 x,
    uint256 n,
    uint256 b
  ) internal pure returns (uint256 z) {
    assembly {
      switch n
      case 0 {
        z := b
      }
      default {
        switch x
        case 0 {
          z := 0
        }
        default {
          switch mod(n, 2)
          case 0 {
            z := b
          }
          default {
            z := x
          }
          let half := div(b, 2) // for rounding.
          for {
            n := div(n, 2)
          } n {
            n := div(n, 2)
          } {
            let xx := mul(x, x)
            if shr(128, x) {
              revert(0, 0)
            }
            let xxRound := add(xx, half)
            if lt(xxRound, xx) {
              revert(0, 0)
            }
            x := div(xxRound, b)
            if mod(n, 2) {
              let zx := mul(z, x)
              if and(iszero(iszero(x)), iszero(eq(div(zx, x), z))) {
                revert(0, 0)
              }
              let zxRound := add(zx, half)
              if lt(zxRound, zx) {
                revert(0, 0)
              }
              z := div(zxRound, b)
            }
          }
        }
      }
    }
  }
}
IStakedToken.sol 43 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

import "@openzeppelin/contracts/interfaces/IERC20.sol";

interface IStakedToken is IERC20 {
  function stake(uint256 amount, address recipient) external returns (bool);

  function unstake(uint256 amount, address recipient) external returns (bool);

  function updateAccumulatedRate() external returns (uint256);

  function rebase() external returns (uint256 mintedTokens);

  function currentAccumulatedRate() external view returns (uint256);

  function denormalize(uint256 amount) external view returns (uint256);

  function normalize(uint256 amount) external view returns (uint256);

  function compoundedInterest(uint256 timePeriod)
    external
    view
    returns (uint256);

  function setInterestRate(uint256 _interestRate) external;

  function setMinimumNormalizedBalance(uint256 _minimumNormalizedBalance)
    external;

  function setIsStakePaused(bool pause) external;

  function setIsUnstakePaused(bool pause) external;

  function decimals() external view returns (uint8);

  event Stake(address indexed recipient, uint256 amount);
  event Unstake(address indexed recipient, uint256 amount);
  event UpdatedInterestRate(uint256 interestRate);
  event UpdatedMinimumNormalizedBalance(uint256 minimumNormalizedBalance);
  event StakePaused(bool indexed isPaused);
  event UnstakePaused(bool indexed isPaused);
}
ITreasury.sol 37 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

interface ITreasury {
  function mint(address to, uint256 amount) external;

  function withdraw(
    address token,
    address to,
    uint256 amount
  ) external;

  function increaseMintLimit(address minter, uint256 amount) external;

  function decreaseMintLimit(address minter, uint256 amount) external;

  function increaseWithdrawalLimit(
    address asset,
    address spender,
    uint256 amount
  ) external;

  function decreaseWithdrawalLimit(
    address asset,
    address spender,
    uint256 amount
  ) external;

  event Mint(address indexed to, uint256 amount);
  event Withdraw(address indexed token, address indexed to, uint256 amount);
  event MintLimitUpdate(address indexed minter, uint256 amount);
  event WithdrawLimitUpdate(
    address indexed token,
    address indexed minter,
    uint256 amount
  );
}
StakedToken.sol 464 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "./library/ExponentMath.sol";

import "./interfaces/IStakedToken.sol";
import "./interfaces/ITreasury.sol";

/// @title StakedToken
/// @author Bluejay Core Team
/// @notice StakedToken is the contract for sBLU token.
/// The token accumulates interest every second and maintains a
/// one-to-one ratio with the underlying BLU token.
contract StakedToken is Ownable, IStakedToken {
  using SafeERC20 for IERC20;

  uint256 private constant WAD = 10**18;
  uint256 private constant RAY = 10**27;

  /// @notice The name of the token
  string public constant name = "Staked BLU";

  /// @notice The symbol of the token
  string public constant symbol = "sBLU";

  /// @notice Contract address of the underlying BLU token
  IERC20 public immutable BLU;

  /// @notice Contract address of the treasury contract for minting BLU
  ITreasury public immutable treasury;

  /// @notice Interest rate per second, in RAY
  /// @dev To obtain the per second interest rate from APY:
  /// nthRoot(<APY-IN-RAY> + RAY, 365 * 24 * 60 * 60)
  uint256 public interestRate;

  /// @notice Accumulated interest rates, in RAY
  uint256 public accumulatedRates;

  /// @notice Last time the interest rate was updated, in unix epoch time
  uint256 public lastInterestRateUpdate;

  /// @notice Flag to pause staking
  bool public isStakePaused;

  /// @notice Flag to pause unstaking
  bool public isUnstakePaused;

  /// @notice Normalized total supply of token, in WAD
  uint256 public normalizedTotalSupply;

  /// @notice Minimum amount of normalized balance allowed for an address, in WAD
  /// Any account with balance lower than this number will be zeroed
  uint256 public minimumNormalizedBalance;

  /// @notice Mapping of addresses to their normalized token balances, in WAD
  mapping(address => uint256) public normalizedBalances;

  /// @notice Mapping of owners to spenders to spendable allowances, in WAD
  /// @dev Stored as allowances[owner][spender].
  /// Nore that the allowance is already denormalized
  mapping(address => mapping(address => uint256)) private allowances;

  /// @notice Constructor to initialize the contract
  /// @param _BLU Contract address of the underlying BLU token
  /// @param _treasury Contract address of the treasury contract for minting BLU
  /// @param _interestRate Interest rate per second, in RAY
  constructor(
    address _BLU,
    address _treasury,
    uint256 _interestRate
  ) {
    BLU = IERC20(_BLU);
    treasury = ITreasury(_treasury);

    lastInterestRateUpdate = block.timestamp;
    interestRate = _interestRate;
    accumulatedRates = RAY;
    minimumNormalizedBalance = WAD / 10**3; // 1/1000th of a BLU
    isStakePaused = true;

    emit UpdatedInterestRate(interestRate);
    emit UpdatedMinimumNormalizedBalance(minimumNormalizedBalance);
  }

  // =============================== INTERNAL FUNCTIONS =================================

  /// @notice Internal function to transfer token from one address to another
  /// @param sender Address of token sender
  /// @param recipient Address of token recipient
  /// @param normalizedAmount Amount of tokens to transfer, in normalized form
  function _transfer(
    address sender,
    address recipient,
    uint256 normalizedAmount
  ) internal {
    require(sender != address(0), "Transfer from the zero address");
    require(recipient != address(0), "Transfer to the zero address");

    require(
      normalizedBalances[sender] >= normalizedAmount,
      "Transfer amount exceeds balance"
    );

    _beforeTokenTransfer(sender, recipient, normalizedAmount);

    unchecked {
      normalizedBalances[sender] -= normalizedAmount;
    }
    normalizedBalances[recipient] += normalizedAmount;

    emit Transfer(sender, recipient, denormalize(normalizedAmount));

    _afterTokenTransfer(sender, recipient, normalizedAmount);
  }

  /// @notice Internal function to mint sBLU token to an address
  /// @param account Address of account to credit tokens to
  /// @param normalizedAmount Amount of tokens to mint, in normalized form
  function _mint(address account, uint256 normalizedAmount) internal {
    require(account != address(0), "Minting to the zero address");

    _beforeTokenTransfer(address(0), account, normalizedAmount);

    normalizedTotalSupply += normalizedAmount;
    normalizedBalances[account] += normalizedAmount;
    emit Transfer(address(0), account, denormalize(normalizedAmount));

    _afterTokenTransfer(address(0), account, normalizedAmount);
  }

  /// @notice Internal function to burn sBLU token from an address
  /// @param account Address of account to burn tokens from
  /// @param normalizedAmount Amount of tokens to burn, in normalized form
  function _burn(address account, uint256 normalizedAmount) internal {
    require(account != address(0), "Burn from the zero address");

    _beforeTokenTransfer(account, address(0), normalizedAmount);

    require(
      normalizedBalances[account] >= normalizedAmount,
      "Burn amount exceeds balance"
    );
    unchecked {
      normalizedBalances[account] -= normalizedAmount;
    }
    normalizedTotalSupply -= normalizedAmount;

    emit Transfer(account, address(0), denormalize(normalizedAmount));

    _afterTokenTransfer(account, address(0), normalizedAmount);
  }

  /// @notice Internal function to approve a spender to spend a certain amount of tokens
  /// @param owner Address of owner who is approving the spending
  /// @param spender Address of spender who is allowed to spend
  /// @param denormalizedAmount Amount of tokens as allowance, in denormalized form
  function _approve(
    address owner,
    address spender,
    uint256 denormalizedAmount
  ) internal {
    require(owner != address(0), "Approve from the zero address");
    require(spender != address(0), "Approve to the zero address");

    allowances[owner][spender] = denormalizedAmount;
    emit Approval(owner, spender, denormalizedAmount);
  }

  /// @notice Internal function to zero out balance on an address if the balance is too low
  /// @param account Address to check for small balances
  function _zeroMinimumBalances(address account) internal {
    if (
      normalizedBalances[account] < minimumNormalizedBalance &&
      normalizedBalances[account] != 0
    ) {
      // Cannot use _burn here because it would be recursive
      normalizedTotalSupply -= normalizedBalances[account];
      normalizedBalances[account] = 0;
    }
  }

  /// @notice Internal function to run before a token transfer occurs
  function _beforeTokenTransfer(
    address,
    address,
    uint256
  ) internal {}

  /// @notice Internal function to run after a token transfer occurs
  /// @dev A cleanup is run after every token transfer to remove accounts with negligible amount of tokens
  /// @param sender Address of token sender
  function _afterTokenTransfer(
    address sender,
    address,
    uint256
  ) internal {
    _zeroMinimumBalances(sender);
  }

  // =============================== PUBLIC FUNCTIONS =================================

  /// @notice Staking function allowing users to convert BLU to sBLU at one-to-one ratio
  /// @dev The transfer may result in small rounding error due to normalization
  /// and denormalization. Dusty accounts will also be zeroed our after the process.
  /// @param amount Amount of BLU to stake, in WAD
  /// @param recipient Address of sBLU recipient
  /// @return success Whether the staking was successful
  function stake(uint256 amount, address recipient)
    public
    override
    returns (bool)
  {
    require(!isStakePaused, "Staking paused");
    require(recipient != address(0), "Staking to the zero address");
    BLU.safeTransferFrom(msg.sender, address(this), amount);
    _mint(recipient, normalize(amount));
    emit Stake(recipient, amount);
    return true;
  }

  /// @notice Unstaking function allowing users to convert sBLU to BLU at one-to-one ratio
  /// @dev The transfer may result in small rounding error due to normalization
  /// and denormalization. Dusty accounts will also be zeroed our after the process.
  /// Rebase is called each time to ensure this contact is sufficient funded with BLU
  /// tokens from the treasury.
  /// @param amount Amount of sBLU to unstake, in WAD
  /// @param recipient Address of BLU recipient
  /// @return success Whether the unstaking was successful
  function unstake(uint256 amount, address recipient)
    public
    override
    returns (bool)
  {
    require(!isUnstakePaused, "Unstaking paused");
    rebase();
    require(recipient != address(0), "Unstaking to the zero address");
    _burn(recipient, normalize(amount));
    BLU.safeTransfer(recipient, amount);
    emit Unstake(recipient, amount);
    return true;
  }

  /// @notice Transfer sBLU from one address to another
  /// @dev The transfer may result in small rounding error due to normalization
  /// and denormalization. Dusty accounts will also be zeroed our after the process.
  /// @param recipient Address of sBLU recipient
  /// @param amount Amount of sBLU to transfer, in WAD
  /// @return success Whether the transfer was successful
  function transfer(address recipient, uint256 amount)
    public
    override
    returns (bool)
  {
    _transfer(msg.sender, recipient, normalize(amount));
    return true;
  }

  /// @notice Returns the remaining number of tokens that `spender` will be
  /// allowed to spend on behalf of `owner` through {transferFrom}. This is
  /// zero by default.
  /// @param owner Address of owner
  /// @param spender Address of spender
  /// @return allowance Amount of tokens that `spender` is allowed to spend from owner, in WAD
  function allowance(address owner, address spender)
    public
    view
    override
    returns (uint256)
  {
    return allowances[owner][spender];
  }

  /// @notice Sets `amount` as the allowance of `spender` over the caller's tokens
  /// @param spender Address of spender
  /// @param amount Amount of tokens that `spender` is allowed to spend, in WAD
  /// @return success Whether the allowance was set successfully
  function approve(address spender, uint256 amount)
    public
    override
    returns (bool)
  {
    _approve(msg.sender, spender, amount);
    return true;
  }

  /// @notice Moves `amount` tokens from `from` to `to` using the
  /// allowance mechanism. `amount` is then deducted from the caller's
  /// allowance.
  /// @param sender Address of the sender of sBLU tokens
  /// @param recipient Address of the recipient of sBLU tokens
  /// @param amount Amount of sBLU tokens to transfer, in WAD
  /// @return success Whether the transfer was successful
  function transferFrom(
    address sender,
    address recipient,
    uint256 amount
  ) public override returns (bool) {
    _transfer(sender, recipient, normalize(amount));

    uint256 currentAllowance = allowances[sender][msg.sender];
    require(
      currentAllowance >= amount,
      "ERC20: transfer amount exceeds allowance"
    );
    unchecked {
      _approve(sender, msg.sender, currentAllowance - amount);
    }

    return true;
  }

  /// @notice Atomically increases the allowance granted to `spender` by the caller
  /// @param spender Address of the spender to increase allowance for
  /// @param addedValue Amount of allowance to increment, in WAD
  /// @return success Whether the allowance increment was successful
  function increaseAllowance(address spender, uint256 addedValue)
    public
    returns (bool)
  {
    _approve(msg.sender, spender, allowances[msg.sender][spender] + addedValue);
    return true;
  }

  /// @notice Atomically decreases the allowance granted to `spender` by the caller
  /// @param spender Address of the spender to decrease allowance for
  /// @param subtractedValue Amount of allowance to decrement, in WAD
  /// @return success Whether the allowance decrement was successful
  function decreaseAllowance(address spender, uint256 subtractedValue)
    public
    returns (bool)
  {
    uint256 currentAllowance = allowances[msg.sender][spender];
    require(
      currentAllowance >= subtractedValue,
      "ERC20: decreased allowance below zero"
    );
    unchecked {
      _approve(msg.sender, spender, currentAllowance - subtractedValue);
    }
    return true;
  }

  /// @notice Update the accumulated rate and the last updated timestamp
  /// @return accumulatedRates Updated accumulated interest rate
  function updateAccumulatedRate() public override returns (uint256) {
    accumulatedRates = currentAccumulatedRate();
    lastInterestRateUpdate = block.timestamp;
    return accumulatedRates;
  }

  /// @notice Rebase function that ensures the contract is funded with sufficient
  /// BLU tokens from the treasury to ensure that all unstake can be fulfilled.
  /// @return mintedTokens Amount of BLU tokens minted to this contract
  function rebase() public override returns (uint256 mintedTokens) {
    updateAccumulatedRate();
    uint256 mappedTokens = denormalize(normalizedTotalSupply);
    uint256 tokenBalance = BLU.balanceOf(address(this));
    if (tokenBalance < mappedTokens) {
      mintedTokens = mappedTokens - tokenBalance;
      treasury.mint(address(this), mintedTokens);
    }
  }

  // =============================== ADMIN FUNCTIONS =================================

  /// @notice Sets the interest rate for the staking contract
  /// @dev The interest rate compounds per second and cannot be less than RAY to ensure
  /// balance is monotonic increasing.
  /// @param _interestRate Interest rate per second, in RAY
  function setInterestRate(uint256 _interestRate) public override onlyOwner {
    require(_interestRate >= RAY, "Interest rate less than 1");
    updateAccumulatedRate();
    interestRate = _interestRate;
    emit UpdatedInterestRate(interestRate);
  }

  /// @notice Sets the minimum amount of normalized balance on an account to prevent
  /// accounts from having extremely small amount of sBLU.
  /// @param _minimumNormalizedBalance Minimum normalized balance, in WAD
  function setMinimumNormalizedBalance(uint256 _minimumNormalizedBalance)
    public
    override
    onlyOwner
  {
    require(_minimumNormalizedBalance <= WAD, "Minimum balance greater than 1");
    minimumNormalizedBalance = _minimumNormalizedBalance;
    emit UpdatedMinimumNormalizedBalance(_minimumNormalizedBalance);
  }

  /// @notice Pause or unpause staking
  /// @param pause True to pause staking, false to unpause staking
  function setIsStakePaused(bool pause) public override onlyOwner {
    isStakePaused = pause;
    emit StakePaused(pause);
  }

  /// @notice Pause or unpause unstaking
  /// @param pause True to pause unstaking, false to unpause unstaking
  function setIsUnstakePaused(bool pause) public override onlyOwner {
    isUnstakePaused = pause;
    emit UnstakePaused(pause);
  }

  // =============================== PUBLIC FUNCTIONS =================================

  /// @notice Number of decimals for sBLU token
  /// @return decimals Number of decimals for sBLU token
  function decimals() public view virtual override returns (uint8) {
    return 18;
  }

  /// @notice Total supply of sBLU token
  /// @return totalSupply Total supply of sBLU token
  function totalSupply() public view override returns (uint256) {
    return denormalize(normalizedTotalSupply);
  }

  /// @notice Token balance of `owner`
  /// @param account Address of account
  /// @return balance Token balance of `owner`
  function balanceOf(address account) public view override returns (uint256) {
    return denormalize(normalizedBalances[account]);
  }

  /// @notice Current compounded interest rate since the deployment of the contract
  /// @return accumulatedRates Current compounded interest rate, in RAY
  function currentAccumulatedRate() public view override returns (uint256) {
    require(block.timestamp >= lastInterestRateUpdate, "Invalid timestamp");
    return
      (compoundedInterest(block.timestamp - lastInterestRateUpdate) *
        accumulatedRates) / RAY;
  }

  /// @notice Denormalize a number by the accumulated interest rate
  /// @dev Use this to obtain the denormalized form used for presentation purposes
  /// @param amount Amount to denormalize
  /// @return denormalizedAmount Denormalized amount
  function denormalize(uint256 amount) public view override returns (uint256) {
    return (amount * currentAccumulatedRate()) / RAY;
  }

  /// @notice Normalize a number by the accumulated interest rate
  /// @dev Use this to obtain the normalized form used for storage purposes
  /// @param amount Amount to normalize
  /// @return normalizedAmount Normalized amount
  function normalize(uint256 amount) public view override returns (uint256) {
    return (amount * RAY) / currentAccumulatedRate();
  }

  /// @notice Current interest rate compounded by the timePeriod
  /// @dev Use this to obtain the interest rate over other periods of time like a year
  /// @param timePeriod Number of seconds to compound the interest rate by
  function compoundedInterest(uint256 timePeriod)
    public
    view
    override
    returns (uint256)
  {
    return ExponentMath.rpow(interestRate, timePeriod, RAY);
  }
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

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

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}
IERC20.sol 82 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

Read Contract

BLU 0xf470fd5e → address
accumulatedRates 0xc87a6d2f → uint256
allowance 0xdd62ed3e → uint256
balanceOf 0x70a08231 → uint256
compoundedInterest 0xe1d0377e → uint256
currentAccumulatedRate 0x70fa70b6 → uint256
decimals 0x313ce567 → uint8
denormalize 0x0af809cf → uint256
interestRate 0x7c3a00fd → uint256
isStakePaused 0xe2c60c28 → bool
isUnstakePaused 0xdb1f7234 → bool
lastInterestRateUpdate 0x4d70dc27 → uint256
minimumNormalizedBalance 0x840b00da → uint256
name 0x06fdde03 → string
normalize 0x00dd6eef → uint256
normalizedBalances 0xe249cfe6 → uint256
normalizedTotalSupply 0xb85e868e → uint256
owner 0x8da5cb5b → address
symbol 0x95d89b41 → string
totalSupply 0x18160ddd → uint256
treasury 0x61d027b3 → address

Write Contract 15 functions

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

approve 0x095ea7b3
address spender
uint256 amount
returns: bool
decreaseAllowance 0xa457c2d7
address spender
uint256 subtractedValue
returns: bool
increaseAllowance 0x39509351
address spender
uint256 addedValue
returns: bool
rebase 0xaf14052c
No parameters
returns: uint256
renounceOwnership 0x715018a6
No parameters
setInterestRate 0x5f84f302
uint256 _interestRate
setIsStakePaused 0x84ed2f88
bool pause
setIsUnstakePaused 0x49571572
bool pause
setMinimumNormalizedBalance 0x5f264ebf
uint256 _minimumNormalizedBalance
stake 0x7acb7757
uint256 amount
address recipient
returns: bool
transfer 0xa9059cbb
address recipient
uint256 amount
returns: bool
transferFrom 0x23b872dd
address sender
address recipient
uint256 amount
returns: bool
transferOwnership 0xf2fde38b
address newOwner
unstake 0x8381e182
uint256 amount
address recipient
returns: bool
updateAccumulatedRate 0x64dbfd81
No parameters
returns: uint256

Recent Transactions

No transactions found for this address