Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0x38913051E01D4F6910cB66bB9aC3cb77D746Ad81
Balance 0 ETH
Nonce 1
Code Size 5793 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

5793 bytes
0x608060405234801561001057600080fd5b50600436106101da5760003560e01c80638da5cb5b11610104578063b187bd26116100a2578063e7b2509011610071578063e7b2509014610435578063e7eb75f414610448578063f2fde38b1461045b578063f6a03ebf1461046e57600080fd5b8063b187bd26146103ea578063b2b386aa146103fc578063b77a2c1c14610423578063be9a65551461042c57600080fd5b806398807d84116100de57806398807d84146103975780639aba85e2146103aa578063a413af50146103bd578063a4e2d634146103dd57600080fd5b80638da5cb5b146103565780638f13ba4014610369578063900cf0cf1461037c57600080fd5b8063454b06081161017c5780636122682b1161014b5780636122682b146102ea5780637a26ec28146102fd578063857066a7146103105780638778aa1f1461032357600080fd5b8063454b06081461027c5780635053e4611461028f57806357f7bf2d146102985780635de52bed146102ab57600080fd5b80631705a3bd116101b85780631705a3bd146102225780631f09941a1461022b578063211e28b61461023e57806343213d171461025157600080fd5b806303a0a9f6146101df5780630b76619b146101f457806316c38b3c1461020f575b600080fd5b6101f26101ed366004611394565b610481565b005b6101fc61055a565b6040519081526020015b60405180910390f35b6101f261021d3660046113cb565b6105e4565b6101fc60035481565b6101f26102393660046113cb565b610662565b6101f261024c3660046113cb565b6106d7565b6101fc61025f3660046113fa565b600760209081526000928352604080842090915290825290205481565b6101f261028a36600461142d565b610742565b6101fc60015481565b6101f26102a6366004611446565b610888565b6102d27f0000000000000000000000006123b0049f904d730db3c36a31167d9d4121fa6b81565b6040516001600160a01b039091168152602001610206565b6101f26102f836600461142d565b610897565b6101f261030b36600461142d565b610940565b6101f261031e36600461142d565b610a03565b610346610331366004611472565b60066020526000908152604090205460ff1681565b6040519015158152602001610206565b6000546102d2906001600160a01b031681565b6101fc61037736600461148d565b610ac5565b610384610adc565b60405161ffff9091168152602001610206565b6101fc6103a5366004611472565b610b18565b6101f26103b83660046114d0565b610bb9565b6101fc6103cb366004611505565b60086020526000908152604090205481565b6005546103469060ff1681565b60055461034690610100900460ff1681565b6102d27f000000000000000000000000b528edbef013aff855ac3c50b381f253af13b99781565b6101fc60045481565b6101fc60025481565b6101fc610443366004611520565b610bc9565b6005546103469062010000900460ff1681565b6101f2610469366004611472565b610bdf565b6101f261047c36600461142d565b610c54565b6000546001600160a01b031633146104b45760405162461bcd60e51b81526004016104ab9061153c565b60405180910390fd5b6001600160a01b0382166104fb5760405162461bcd60e51b815260206004820152600e60248201526d10afb137b7ba39ba3930b83832b960911b60448201526064016104ab565b6001600160a01b038216600081815260066020908152604091829020805460ff191685151590811790915591519182527f292424b78ec3e8fb1c980fff1077fd8c3be4499856c4f0b633e291ce130ee859910160405180910390a25050565b600080610565610adc565b905060005b60006105768284611578565b61ffff16118015610599575060015460045461059291906115b0565b8161ffff16105b156105df57600860006105ac8385611578565b61ffff1681526020810191909152604001600020546105cb90846115c4565b9250806105d7816115d7565b91505061056a565b505090565b6000546001600160a01b0316331461060e5760405162461bcd60e51b81526004016104ab9061153c565b600580548215156101000261ff00199091161790556040517f3c70af01296aef045b2f5c9d3c30b05d4428fd257145b9c7fcd76418e65b59809061065790831515815260200190565b60405180910390a150565b6000546001600160a01b0316331461068c5760405162461bcd60e51b81526004016104ab9061153c565b60058054821515620100000262ff0000199091161790556040517f9a7151b8813ea6f580bdb107c79de3009e1feac534aa76d7307272676de1c0df9061065790831515815260200190565b6000546001600160a01b031633146107015760405162461bcd60e51b81526004016104ab9061153c565b6005805460ff19168215159081179091556040519081527f9514871d395e6e24ef28f340cbcdcaa89f790cdf4a4fa6c25cf83a81fb27a86d90602001610657565b6003544210158061076257503360009081526006602052604090205460ff165b80610775575060055462010000900460ff165b6107ac5760405162461bcd60e51b8152602060048201526008602482015267216d69677261746560c01b60448201526064016104ab565b600081116107e75760405162461bcd60e51b81526020600482015260086024820152670857d85b5bdd5b9d60c21b60448201526064016104ab565b61081c6001600160a01b037f0000000000000000000000006123b0049f904d730db3c36a31167d9d4121fa6b16333084610cf9565b6108506001600160a01b037f000000000000000000000000b528edbef013aff855ac3c50b381f253af13b997163383610d66565b60405181815233907fa59785389b00cbd19745afbe8d59b28e3161395c6b1e3525861a2b0dede0b90d9060200160405180910390a250565b610893828233610d97565b5050565b6000546001600160a01b031633146108c15760405162461bcd60e51b81526004016104ab9061153c565b600254421080156108d157504281115b61090b5760405162461bcd60e51b815260206004820152600b60248201526a10afb6b4b3b930ba34b7b760a91b60448201526064016104ab565b60038190556040518181527fadd8a4e717b61c206be8f500d93e0a41c411169b2bbaa969ba60cad03d12802a90602001610657565b6000546001600160a01b0316331461096a5760405162461bcd60e51b81526004016104ab9061153c565b6002544210801561097d57508060045410155b801561099457508060045461099291906115f8565b155b6109ce5760405162461bcd60e51b815260206004820152600b60248201526a215f65706f636854696d6560a81b60448201526064016104ab565b60018190556040518181527f123adde53887b72ff53abf58c98fd3741c722f0c18e756205ddc2e4068f90ece90602001610657565b6000546001600160a01b03163314610a2d5760405162461bcd60e51b81526004016104ab9061153c565b6001548110158015610a495750600154610a4790826115f8565b155b8015610a56575060045481105b610a905760405162461bcd60e51b815260206004820152600b60248201526a215f7374616b6554696d6560a81b60448201526064016104ab565b60048190556040518181527f8694f12b01f8a6bc299eb1c05423d0b3414174eb8561af4f4a08f61eed18f63690602001610657565b6000610ad2848484610fbd565b90505b9392505050565b6000600254421015610aee5750600090565b600154600254610afe904261160c565b610b0891906115b0565b610b139060016115c4565b905090565b600080610b23610adc565b905060005b6000610b348284611578565b61ffff16118015610b575750600154600454610b5091906115b0565b8161ffff16105b15610bb2576001600160a01b038416600090815260076020526040812090610b7f8385611578565b61ffff168152602081019190915260400160002054610b9e90846115c4565b925080610baa816115d7565b915050610b28565b5050919050565b610bc4838383610d97565b505050565b6000610bd6338484610fbd565b90505b92915050565b6000546001600160a01b03163314610c095760405162461bcd60e51b81526004016104ab9061153c565b600080546001600160a01b0319166001600160a01b0383169081178255604051909133917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a350565b6000546001600160a01b03163314610c7e5760405162461bcd60e51b81526004016104ab9061153c565b60025442108015610c8e57504281115b610cc45760405162461bcd60e51b81526020600482015260076024820152660857dcdd185c9d60ca1b60448201526064016104ab565b60028190556040518181527fa90eb1b95730847a8accda482028369bf1adf121f830e5fcd90aa769d25dbb2290602001610657565b6040516001600160a01b038481166024830152838116604483015260648201839052610d609186918216906323b872dd906084015b604051602081830303815290604052915060e01b6020820180516001600160e01b0383818316178352505050506111fd565b50505050565b6040516001600160a01b03838116602483015260448201839052610bc491859182169063a9059cbb90606401610d2e565b600554610100900460ff1615610dd85760405162461bcd60e51b81526020600482015260066024820152651c185d5cd95960d21b60448201526064016104ab565b600254421015610e155760405162461bcd60e51b8152602060048201526008602482015267085cdd185c9d195960c21b60448201526064016104ab565b60008211610e505760405162461bcd60e51b81526020600482015260086024820152670857d85b5bdd5b9d60c21b60448201526064016104ab565b6001600160a01b038116610e945760405162461bcd60e51b815260206004820152600b60248201526a0857dc9958da5c1a595b9d60aa1b60448201526064016104ab565b6000610e9e610adc565b6001600160a01b038316600090815260076020908152604080832061ffff85168452909152812080549293508592909190610eda9084906115c4565b909155505061ffff811660009081526008602052604081208054859290610f029084906115c4565b90915550610f6c905033308587610f39577f000000000000000000000000b528edbef013aff855ac3c50b381f253af13b997610f5b565b7f0000000000000000000000006123b0049f904d730db3c36a31167d9d4121fa6b5b6001600160a01b0316929190610cf9565b60408051848152851515602082015261ffff8316916001600160a01b038516917fcce627e2c2d449f785b95ad057ce521f52992c4a79973e2a6f580c9d4855fa45910160405180910390a350505050565b60006001600160a01b0384166110035760405162461bcd60e51b815260206004820152600b60248201526a0857dc9958da5c1a595b9d60aa1b60448201526064016104ab565b8161ffff168361ffff1611156110455760405162461bcd60e51b81526020600482015260076024820152660857dcdd185c9d60ca1b60448201526064016104ab565b60055460ff161580611080575060015460045461106291906115b0565b61106a610adc565b6110749190611578565b61ffff168261ffff1611155b6110b45760405162461bcd60e51b81526020600482015260056024820152640857d95b9960da1b60448201526064016104ab565b825b8261ffff168161ffff1611611133576001600160a01b038516600090815260076020908152604080832061ffff851684529091529020546110f790836115c4565b6001600160a01b038616600090815260076020908152604080832061ffff8616845290915281205591508061112b816115d7565b9150506110b6565b600082116111745760405162461bcd60e51b815260206004820152600e60248201526d085d5b9cdd185ad9505b5bdd5b9d60921b60448201526064016104ab565b6111a86001600160a01b037f000000000000000000000000b528edbef013aff855ac3c50b381f253af13b997168684610d66565b8261ffff168461ffff16866001600160a01b03167f5464cfcfbfe4df8b5921df805eda7849bc1fc09d9dc0f621c43074680de3aa09856040516111ed91815260200190565b60405180910390a4509392505050565b60006112126001600160a01b03841683611260565b90508051600014158015611237575080806020019051810190611235919061161f565b155b15610bc457604051635274afe760e01b81526001600160a01b03841660048201526024016104ab565b6060610bd68383600084600080856001600160a01b03168486604051611286919061163c565b60006040518083038185875af1925050503d80600081146112c3576040519150601f19603f3d011682016040523d82523d6000602084013e6112c8565b606091505b50915091506112d88683836112e2565b9695505050505050565b6060826112f7576112f28261133e565b610ad5565b815115801561130e57506001600160a01b0384163b155b1561133757604051639996b31560e01b81526001600160a01b03851660048201526024016104ab565b5080610ad5565b80511561134e5780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b50565b80356001600160a01b038116811461138157600080fd5b919050565b801515811461136757600080fd5b600080604083850312156113a757600080fd5b6113b08361136a565b915060208301356113c081611386565b809150509250929050565b6000602082840312156113dd57600080fd5b8135610ad581611386565b803561ffff8116811461138157600080fd5b6000806040838503121561140d57600080fd5b6114168361136a565b9150611424602084016113e8565b90509250929050565b60006020828403121561143f57600080fd5b5035919050565b6000806040838503121561145957600080fd5b823561146481611386565b946020939093013593505050565b60006020828403121561148457600080fd5b610bd68261136a565b6000806000606084860312156114a257600080fd5b6114ab8461136a565b92506114b9602085016113e8565b91506114c7604085016113e8565b90509250925092565b6000806000606084860312156114e557600080fd5b83356114f081611386565b9250602084013591506114c76040850161136a565b60006020828403121561151757600080fd5b610bd6826113e8565b6000806040838503121561153357600080fd5b611416836113e8565b6020808252600c908201526b15539055551213d49256915160a21b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b61ffff82811682821603908082111561159357611593611562565b5092915050565b634e487b7160e01b600052601260045260246000fd5b6000826115bf576115bf61159a565b500490565b80820180821115610bd957610bd9611562565b600061ffff8083168181036115ee576115ee611562565b6001019392505050565b6000826116075761160761159a565b500690565b81810381811115610bd957610bd9611562565b60006020828403121561163157600080fd5b8151610ad581611386565b6000825160005b8181101561165d5760208186018101518583015201611643565b50600092019182525091905056fea26469706673582212208da702f1694f8e04eba5f591e518d00cbbd4317e6f2661049e9d5013f3e6ea5664736f6c63430008140033

Verified Source Code Full Match

Compiler: v0.8.20+commit.a1b79de6 EVM: paris Optimization: Yes (200 runs)
AevoStaking.sol 267 lines
/* SPDX-License-Identifier: GPL-3.0*/

pragma solidity ^0.8.20;

import {Owned} from "solmate/auth/Owned.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

/**
 * @title Aevo Staking
 * @notice Stake Aevo and RBN for non-transferrable sAEVO
 */
contract AevoStaking is Owned {
    using SafeERC20 for IERC20;

    /// @notice The rbn address
    address public immutable rbn;
    /// @notice The aevo address
    address public immutable aevo;
    /// @notice The epoch duration
    uint256 public epochTime;
    /// @notice The staking start date
    uint256 public start;
    /// @notice The rbn -> aevo direct migration date
    uint256 public migration;
    /// @notice The hard stake duration
    uint256 public stakeTime;
    /// @notice If hard stake enforced
    bool public isLocked = true;
    /// @notice If staking paused
    bool public isPaused = false;
    /// @notice If can early migrate
    bool public canEarlyMigrate = false;

    /// @notice Boostrapping AEVO LP
    mapping(address => bool) public isBootstrapper;
    /// @notice Account to epoch sAEVO balance
    mapping(address => mapping(uint16 => uint256)) public balance;
    /// @notice Epoch to sAEVO balance
    mapping(uint16 => uint256) public epochBalance;

    /// @notice Constructor
    /// @param _rbn $RBN
    /// @param _aevo $AEVO
    /// @param _start The staking start date
    /// @param _migration The rbn -> aevo direct migration date
    /// @param _epochTime The epoch duration
    /// @param _stakeTime The hard stake duration
    /// @param _bootstrapper The initial bootstrapper
    /// @param _owner The owner
    constructor(
        address _rbn,
        address _aevo,
        uint256 _start,
        uint256 _migration,
        uint256 _epochTime,
        uint256 _stakeTime,
        address _bootstrapper,
        address _owner
    ) Owned(_owner) {
        require(address(_rbn) != address(0), "!_rbn");
        require(address(_aevo) != address(0), "!_aevo");
        require(_start >= block.timestamp, "!_start");
        require(_epochTime > 0, "!_epochTime");
        require(_stakeTime >= _epochTime && _stakeTime % _epochTime == 0, "!_stakeTime");
        require(address(_bootstrapper) != address(0), "!_bootstrapper");

        rbn = _rbn;
        aevo = _aevo;
        start = _start;
        migration = _migration;
        epochTime = _epochTime;
        stakeTime = _stakeTime;
        isBootstrapper[_bootstrapper] = true;
    }

    /// @notice Epoch number
    /// @dev uint16 may overflow for small epochTime
    /// @return Current epoch
    function epoch() public view returns (uint16) {
        return block.timestamp >= start ? uint16((block.timestamp - start) / epochTime + 1) : 0;
    }

    /// @notice Total staked within the stake time sliding window
    /// @dev stakeTime / epochTime should be small enough to not be gas-prohibitive
    /// @return totalStaked total staked
    function staked() external view returns (uint256 totalStaked) {
        uint16 cEpoch = epoch();
        uint16 window = 0;

        while (cEpoch - window > 0 && window < stakeTime / epochTime) {
            totalStaked += epochBalance[cEpoch - window];
            window++;
        }
    }

    /// @notice Total currently staked by an account within the stake time sliding window
    /// @param _account account that is staked
    /// @return totalStaked total staked by account
    function staked(address _account) external view returns (uint256 totalStaked) {
        uint16 cEpoch = epoch();
        uint16 window = 0;

        while (cEpoch - window > 0 && window < stakeTime / epochTime) {
            totalStaked += balance[_account][cEpoch - window];
            window++;
        }
    }

    /// @notice Sets epoch time
    /// @param _epochTime Epoch time
    function setEpochTime(uint256 _epochTime) external onlyOwner {
        require(block.timestamp < start && stakeTime >= _epochTime && stakeTime % _epochTime == 0, "!_epochTime");

        epochTime = _epochTime;
        emit SetEpochTime(_epochTime);
    }

    /// @notice Sets start time
    /// @param _start Start time
    function setStart(uint256 _start) external onlyOwner {
        require(block.timestamp < start && _start > block.timestamp, "!_start");
        start = _start;
        emit SetStart(_start);
    }

    /// @notice Sets migration time
    /// @param _migration Migration time
    function setMigration(uint256 _migration) external onlyOwner {
        require(block.timestamp < start && _migration > block.timestamp, "!_migration");
        migration = _migration;
        emit SetMigration(_migration);
    }

    /// @notice Sets stake time
    /// @param _stakeTime Stake time
    function setStakeTime(uint256 _stakeTime) external onlyOwner {
        require(_stakeTime >= epochTime && _stakeTime % epochTime == 0 && _stakeTime < stakeTime, "!_stakeTime");
        stakeTime = _stakeTime;
        emit SetStakeTime(_stakeTime);
    }

    /// @notice Sets lock status
    /// @param _isLocked Is locked
    function setLocked(bool _isLocked) external onlyOwner {
        isLocked = _isLocked;
        emit SetLocked(_isLocked);
    }

    /// @notice Sets pause status
    /// @param _isPaused Is paused
    function setPaused(bool _isPaused) external onlyOwner {
        isPaused = _isPaused;
        emit SetPaused(_isPaused);
    }

    /// @notice Sets early migrate status
    /// @param _canEarlyMigrate Can early migrate
    function setCanEarlyMigrate(bool _canEarlyMigrate) external onlyOwner {
        canEarlyMigrate = _canEarlyMigrate;
        emit SetCanEarlyMigrate(_canEarlyMigrate);
    }

    /// @notice Sets bootstrapper
    /// @param _bootstrapper Bootstrapper
    /// @param _isBootstrapper Is bootstrapper
    function setBootstrapper(address _bootstrapper, bool _isBootstrapper) external onlyOwner {
        require(_bootstrapper != address(0), "!_bootstrapper");

        isBootstrapper[_bootstrapper] = _isBootstrapper;
        emit SetBootstrapper(_bootstrapper, _isBootstrapper);
    }

    /// @notice Stake RBN or AEVO
    /// @param _isRBN rbn or aevo
    /// @param _amount Amount to stake
    function stake(bool _isRBN, uint256 _amount) external {
        _stake(_isRBN, _amount, msg.sender);
    }

    /// @notice Stake RBN or AEVO for recipient
    /// @param _isRBN rbn or aevo
    /// @param _amount Amount to stake
    /// @param _recipient Recipient of stake
    function stakeFor(bool _isRBN, uint256 _amount, address _recipient) external {
        _stake(_isRBN, _amount, _recipient);
    }

    /// @notice Unstake Aevo
    /// @notice Must unstake to re-stake with new epoch
    /// @param _start Start epoch to unlock
    /// @param _end End epoch to unlock
    function unstake(uint16 _start, uint16 _end) external returns (uint256) {
        return _unstake(msg.sender, _start, _end);
    }

    /// @notice Unstake Aevo for recipient
    /// @param _recipient Recipient of unstake
    /// @param _start Start epoch to unlock
    /// @param _end End epoch to unlock
    function unstakeFor(address _recipient, uint16 _start, uint16 _end) external returns (uint256) {
        return _unstake(_recipient, _start, _end);
    }

    /// @notice Migrate RBN to AEVO (with a 1:1 ratio)
    /// @param _amount Amount to migrate
    function migrate(uint256 _amount) external {
        require(block.timestamp >= migration || isBootstrapper[msg.sender] || canEarlyMigrate, "!migrate");
        require(_amount > 0, "!_amount");

        IERC20(rbn).safeTransferFrom(msg.sender, address(this), _amount);
        IERC20(aevo).safeTransfer(msg.sender, _amount);
        emit Migrate(msg.sender, _amount);
    }

    /// @notice Stake RBN or AEVO
    /// @param _isRBN rbn or aevo
    /// @param _amount Amount to stake
    /// @param _recipient Recipient of stake
    function _stake(bool _isRBN, uint256 _amount, address _recipient) internal {
        require(!isPaused, "paused");
        require(block.timestamp >= start, "!started");
        require(_amount > 0, "!_amount");
        require(_recipient != address(0), "!_recipient");

        uint16 cEpoch = epoch();
        balance[_recipient][cEpoch] += _amount;
        epochBalance[cEpoch] += _amount;
        IERC20(_isRBN ? rbn : aevo).safeTransferFrom(msg.sender, address(this), _amount);
        emit Stake(_recipient, cEpoch, _amount, _isRBN);
    }

    /// @notice Unstake Aevo
    /// @param _recipient Recipient of unstake
    /// @param _start Start epoch to unlock
    /// @param _end End epoch to unlock
    function _unstake(address _recipient, uint16 _start, uint16 _end) internal returns (uint256 unstakeAmount) {
        require(_recipient != address(0), "!_recipient");
        require(_start <= _end, "!_start");
        require(!isLocked || _end <= epoch() - uint16(stakeTime / epochTime), "!_end");

        uint16 cEpoch = _start;

        while (cEpoch <= _end) {
            unstakeAmount += balance[_recipient][cEpoch];
            balance[_recipient][cEpoch] = 0;
            cEpoch++;
        }

        require(unstakeAmount > 0, "!unstakeAmount");

        IERC20(aevo).safeTransfer(_recipient, unstakeAmount);
        emit Unstake(_recipient, _start, _end, unstakeAmount);
    }

    event SetEpochTime(uint256 epochTime);
    event SetStart(uint256 start);
    event SetMigration(uint256 migration);
    event SetStakeTime(uint256 stakeTime);
    event SetLocked(bool isLocked);
    event SetPaused(bool isPaused);
    event SetCanEarlyMigrate(bool canEarlyMigrate);
    event SetBootstrapper(address indexed bootstrapper, bool isBootstrapper);
    event Stake(address indexed recipient, uint16 indexed epoch, uint256 amount, bool isRBN);
    event Unstake(address indexed recipient, uint16 indexed startEpoch, uint16 indexed endEpoch, uint256 amount);
    event Migrate(address indexed recipient, uint256 amount);
}
Owned.sol 44 lines
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;

/// @notice Simple single owner authorization mixin.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Owned.sol)
abstract contract Owned {
    /*//////////////////////////////////////////////////////////////
                                 EVENTS
    //////////////////////////////////////////////////////////////*/

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

    /*//////////////////////////////////////////////////////////////
                            OWNERSHIP STORAGE
    //////////////////////////////////////////////////////////////*/

    address public owner;

    modifier onlyOwner() virtual {
        require(msg.sender == owner, "UNAUTHORIZED");

        _;
    }

    /*//////////////////////////////////////////////////////////////
                               CONSTRUCTOR
    //////////////////////////////////////////////////////////////*/

    constructor(address _owner) {
        owner = _owner;

        emit OwnershipTransferred(address(0), _owner);
    }

    /*//////////////////////////////////////////////////////////////
                             OWNERSHIP LOGIC
    //////////////////////////////////////////////////////////////*/

    function transferOwnership(address newOwner) public virtual onlyOwner {
        owner = newOwner;

        emit OwnershipTransferred(msg.sender, newOwner);
    }
}
Address.sol 159 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)

pragma solidity ^0.8.20;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev The ETH balance of the account is not enough to perform the operation.
     */
    error AddressInsufficientBalance(address account);

    /**
     * @dev There's no code at `target` (it is not a contract).
     */
    error AddressEmptyCode(address target);

    /**
     * @dev A call to an address target failed. The target may have reverted.
     */
    error FailedInnerCall();

    /**
     * @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://consensys.net/diligence/blog/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.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        if (address(this).balance < amount) {
            revert AddressInsufficientBalance(address(this));
        }

        (bool success, ) = recipient.call{value: amount}("");
        if (!success) {
            revert FailedInnerCall();
        }
    }

    /**
     * @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 or custom error, it is bubbled
     * up by this function (like regular Solidity function calls). However, if
     * the call reverted with no returned reason, this function reverts with a
     * {FailedInnerCall} error.
     *
     * 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.
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0);
    }

    /**
     * @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`.
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        if (address(this).balance < value) {
            revert AddressInsufficientBalance(address(this));
        }
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
     * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
     * unsuccessful call.
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata
    ) internal view returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            // only check if target is a contract if the call was successful and the return data is empty
            // otherwise we already know that it was a contract
            if (returndata.length == 0 && target.code.length == 0) {
                revert AddressEmptyCode(target);
            }
            return returndata;
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
     * revert reason or with a default {FailedInnerCall} error.
     */
    function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            return returndata;
        }
    }

    /**
     * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
     */
    function _revert(bytes memory returndata) private pure {
        // 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
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert FailedInnerCall();
        }
    }
}
IERC20.sol 79 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

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

    /**
     * @dev Returns the value of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

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

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the
     * allowance mechanism. `value` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 value) external returns (bool);
}
SafeERC20.sol 118 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "../IERC20.sol";
import {IERC20Permit} from "../extensions/IERC20Permit.sol";
import {Address} from "../../../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;

    /**
     * @dev An operation with an ERC20 token failed.
     */
    error SafeERC20FailedOperation(address token);

    /**
     * @dev Indicates a failed `decreaseAllowance` request.
     */
    error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        forceApprove(token, spender, oldAllowance + value);
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
     * value, non-reverting calls are assumed to be successful.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
        unchecked {
            uint256 currentAllowance = token.allowance(address(this), spender);
            if (currentAllowance < requestedDecrease) {
                revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
            }
            forceApprove(token, spender, currentAllowance - requestedDecrease);
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @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);
        if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @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).
     *
     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // 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 cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

        (bool success, bytes memory returndata) = address(token).call(data);
        return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;
    }
}
IERC20Permit.sol 90 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 *
 * ==== Security Considerations
 *
 * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
 * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
 * considered as an intention to spend the allowance in any specific way. The second is that because permits have
 * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
 * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
 * generally recommended is:
 *
 * ```solidity
 * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
 *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
 *     doThing(..., value);
 * }
 *
 * function doThing(..., uint256 value) public {
 *     token.safeTransferFrom(msg.sender, address(this), value);
 *     ...
 * }
 * ```
 *
 * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
 * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
 * {SafeERC20-safeTransferFrom}).
 *
 * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
 * contracts should have entry points that don't rely on permit.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     *
     * CAUTION: See Security Considerations above.
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}

Read Contract

aevo 0xb2b386aa → address
balance 0x43213d17 → uint256
canEarlyMigrate 0xe7eb75f4 → bool
epoch 0x900cf0cf → uint16
epochBalance 0xa413af50 → uint256
epochTime 0x5053e461 → uint256
isBootstrapper 0x8778aa1f → bool
isLocked 0xa4e2d634 → bool
isPaused 0xb187bd26 → bool
migration 0x1705a3bd → uint256
owner 0x8da5cb5b → address
rbn 0x5de52bed → address
stakeTime 0xb77a2c1c → uint256
staked 0x0b76619b → uint256
staked 0x98807d84 → uint256
start 0xbe9a6555 → uint256

Write Contract 14 functions

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

migrate 0x454b0608
uint256 _amount
setBootstrapper 0x03a0a9f6
address _bootstrapper
bool _isBootstrapper
setCanEarlyMigrate 0x1f09941a
bool _canEarlyMigrate
setEpochTime 0x7a26ec28
uint256 _epochTime
setLocked 0x211e28b6
bool _isLocked
setMigration 0x6122682b
uint256 _migration
setPaused 0x16c38b3c
bool _isPaused
setStakeTime 0x857066a7
uint256 _stakeTime
setStart 0xf6a03ebf
uint256 _start
stake 0x57f7bf2d
bool _isRBN
uint256 _amount
stakeFor 0x9aba85e2
bool _isRBN
uint256 _amount
address _recipient
transferOwnership 0xf2fde38b
address newOwner
unstake 0xe7b25090
uint16 _start
uint16 _end
returns: uint256
unstakeFor 0x8f13ba40
address _recipient
uint16 _start
uint16 _end
returns: uint256

Recent Transactions

No transactions found for this address