Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0xcdee293Cc814FE665aed2a3e20Bff8b23f85529f
Balance 0 ETH
Nonce 46
Code Size 1158 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

1158 bytes
0x608060405234801561001057600080fd5b50600436106100415760003560e01c80631c3e7dd814610046578063613d517d14610075578063f0f0ec011461009c575b600080fd5b6100596100543660046103b7565b6100c3565b6040516001600160a01b03909116815260200160405180910390f35b6100597f0000000000000000000000000b38210ea11411557c13457d4da7dc6ea731b88a81565b6100597f00000000000000000000000079661fe75c0c0394787422fe56eb05a4a4a8e88481565b60408051606086811b6bffffffffffffffffffffffff19908116602084015260e087811b6001600160e01b031990811660348601529087901b1660388401529284901b67ffffffffffffffff1916603c83015233901b9091166054820152600090610168907f00000000000000000000000079661fe75c0c0394787422fe56eb05a4a4a8e88490606801604051602081830303815290604052805190602001206102f7565b6040516323b872dd60e01b81523360048201526001600160a01b0380831660248301526001600160c01b03851660448301529192507f0000000000000000000000000b38210ea11411557c13457d4da7dc6ea731b88a909116906323b872dd906064016020604051808303816000875af11580156101ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061020e9190610427565b50604051631b08932960e01b81523360048201526001600160a01b03868116602483015263ffffffff8087166044840152851660648301526001600160c01b0384166084830152821690631b0893299060a401600060405180830381600087803b15801561027b57600080fd5b505af115801561028f573d6000803e3d6000fd5b50506040805163ffffffff8881168252871660208201526001600160c01b0386168183015290516001600160a01b03891693503392507f356d6eba5b7800134f3f2ba91614e7cd962676648d3f42d5c57682427ec70a489181900360600190a3949350505050565b6000763d602d80600a3d3981f3363d3d373d3d3d363d730000008360601b60e81c176000526e5af43d82803e903d91602b57fd5bf38360781b1760205281603760096000f590506001600160a01b0381166103985760405162461bcd60e51b815260206004820152601760248201527f455243313136373a2063726561746532206661696c6564000000000000000000604482015260640160405180910390fd5b92915050565b803563ffffffff811681146103b257600080fd5b919050565b600080600080608085870312156103cd57600080fd5b84356001600160a01b03811681146103e457600080fd5b93506103f26020860161039e565b92506104006040860161039e565b915060608501356001600160c01b038116811461041c57600080fd5b939692955090935050565b60006020828403121561043957600080fd5b8151801515811461044957600080fd5b939250505056fea2646970667358221220f65391d47bf49eb499d14f3f05bf21d38ea91af2f9646bb979e8b6c88096e1d264736f6c63430008110033

Verified Source Code Full Match

Compiler: v0.8.17+commit.8df45f5f EVM: london Optimization: Yes (200 runs)
StakeableVesting.sol 287 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import "@openzeppelin/contracts/access/Ownable.sol";
import "./interfaces/IStakeableVesting.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "api3-dao/packages/pool/contracts/interfaces/v0.8/IApi3Pool.sol";

/// @title Contract that implements a stakeable vesting of API3 tokens
/// allocated to a beneficiary, which is revocable by the owner of this
/// contract
/// @notice This contract is an implementation that is required to be cloned by
/// a StakeableVestingFactory contract. The beneficiary of the vesting is
/// expected to interact with this contract through a generic, ABI-based UI
/// such as Etherscan's. See the repo's README for instructions.
/// @dev The contract implements the Api3Pool interface explicitly instead of
/// acting as a general call forwarder (with only Api3Token interactions being
/// restricted) because the user will not be provided with a trusted frontend
/// that will encode the calls. This implementation allows general purpose
/// contract interaction frontends to be used.
contract StakeableVesting is Ownable, IStakeableVesting {
    struct Vesting {
        uint32 startTimestamp;
        uint32 endTimestamp;
        uint192 amount;
    }

    /// @notice Api3Token address
    address public immutable override api3Token;

    /// @notice Api3Pool address
    address public immutable api3Pool;

    /// @notice Beneficiary of the vesting
    address public override beneficiary;

    /// @notice Vesting parameters, including the schedule and the amount
    Vesting public override vesting;

    /// @dev Prevents tokens from being locked by setting an unreasonably late
    /// vesting end timestamp. The vesting periods are expected to be 4 years,
    /// and we have 1 year of buffer here in case the vesting is required to
    /// start in the future.
    uint256
        private constant MAXIMUM_TIME_BETWEEN_INITIALIZATION_AND_VESTING_END =
        5 * 365 days;

    /// @dev Reverts if the sender is not the beneficiary
    modifier onlyBeneficiary() {
        require(msg.sender == beneficiary, "Sender not beneficiary");
        _;
    }

    /// @dev This contract is means to be an implementation for
    /// StakeableVestingFactory to clone. To prevent the implementaion from
    /// being used, the contract is rendered uninitializable and the ownership
    /// is renounced.
    /// @param _api3Token Api3Token address
    /// @param _api3Pool Api3Pool address
    constructor(address _api3Token, address _api3Pool) {
        require(_api3Token != address(0), "Api3Token address zero");
        api3Token = _api3Token;
        require(_api3Pool != address(0), "Api3Pool address zero");
        api3Pool = _api3Pool;
        beneficiary = 0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF;
        renounceOwnership();
    }

    /// @notice Initializes a newly cloned StakeableVesting
    /// @dev Since beneficiary is required to be zero address, only clones of
    /// this contract can be initialized.
    /// Anyone can initialize a StakeableVesting clone. The user is required to
    /// prevent others from initializing their clones, for example, by
    /// initializing the clone in the same transaction as it is deployed in.
    /// The StakeableVesting needs to have exactly `_amount` API3 tokens.
    /// @param _owner Owner of this StakeableVesting clone, i.e., the account
    /// that can revoke the vesting
    /// @param _beneficiary Beneficiary of the vesting
    /// @param _startTimestamp Starting timestamp of the vesting
    /// @param _endTimestamp Ending timestamp of the vesting
    /// @param _amount Amount of tokens to be vested over the period
    function initialize(
        address _owner,
        address _beneficiary,
        uint32 _startTimestamp,
        uint32 _endTimestamp,
        uint192 _amount
    ) external override {
        require(beneficiary == address(0), "Already initialized");
        require(_owner != address(0), "Owner address zero");
        require(_beneficiary != address(0), "Beneficiary address zero");
        require(_startTimestamp != 0, "Start timestamp zero");
        require(_endTimestamp > _startTimestamp, "End not later than start");
        require(
            _endTimestamp <=
                block.timestamp +
                    MAXIMUM_TIME_BETWEEN_INITIALIZATION_AND_VESTING_END,
            "End is too far in the future"
        );
        require(_amount != 0, "Amount zero");
        require(
            IERC20(api3Token).balanceOf(address(this)) == _amount,
            "Balance is not vesting amount"
        );
        _transferOwnership(_owner);
        beneficiary = _beneficiary;
        vesting = Vesting({
            startTimestamp: _startTimestamp,
            endTimestamp: _endTimestamp,
            amount: _amount
        });
    }

    /// @notice Called by the owner to set the beneficiary
    /// @dev This can be used to revoke the vesting by setting the beneficiary
    /// to be the owner, or to update the beneficiary address, e.g., because
    /// the previous beneficiary account was compromised
    /// @param _beneficiary Beneficiary of the vesting
    function setBeneficiary(address _beneficiary) external override onlyOwner {
        require(_beneficiary != address(0), "Beneficiary address zero");
        beneficiary = _beneficiary;
        emit SetBeneficiary(_beneficiary);
    }

    /// @notice Called by the owner to withdraw all API3 tokens
    /// @dev This function does not modify the state on purpose, so that the
    /// vesting can easily be reinstituted by returning the withdrawn amount
    function withdrawAsOwner() external override onlyOwner {
        uint256 withdrawalAmount = IERC20(api3Token).balanceOf(address(this));
        require(withdrawalAmount != 0, "No balance to withdraw");
        IERC20(api3Token).transfer(msg.sender, withdrawalAmount);
        emit WithdrawnAsOwner(withdrawalAmount);
    }

    /// @notice Called by the beneficiary as many tokens the vesting schedule
    /// allows
    function withdrawAsBeneficiary() external override onlyBeneficiary {
        uint256 balance = IERC20(api3Token).balanceOf(address(this));
        require(balance != 0, "Balance zero");
        uint256 totalBalance = balance + poolBalance();
        uint256 unvestedAmountInTotalBalance = unvestedAmount();
        require(
            totalBalance > unvestedAmountInTotalBalance,
            "Tokens in balance not vested yet"
        );
        uint256 vestedAmountInTotalBalance = totalBalance -
            unvestedAmountInTotalBalance;
        uint256 withdrawalAmount = vestedAmountInTotalBalance > balance
            ? balance
            : vestedAmountInTotalBalance;
        IERC20(api3Token).transfer(msg.sender, withdrawalAmount);
        emit WithdrawnAsBeneficiary(withdrawalAmount);
    }

    /// @notice Called by the beneficiary to have the StakeableVesting deposit
    /// tokens at the pool
    /// @param amount Amount of tokens
    function depositAtPool(uint256 amount) external override onlyBeneficiary {
        IERC20(api3Token).approve(api3Pool, amount);
        IApi3Pool(api3Pool).depositRegular(amount);
    }

    /// @notice Called by the beneficiary to have the StakeableVesting withdraw
    /// tokens from the pool
    /// @param amount Amount of tokens
    function withdrawAtPool(uint256 amount) external override onlyBeneficiary {
        IApi3Pool(api3Pool).withdrawRegular(amount);
    }

    /// @notice Called by the beneficiary to have the StakeableVesting withdraw
    /// tokens from the pool based on the precalculated amount of locked
    /// staking rewards
    /// @dev This is only needed if the gas cost of calculating the amount of
    /// locked staking rewards exceeds the block gas limit. See the Api3Pool
    /// code for more details.
    /// `precalculateUserLocked()` at Api3Pool needs to be called before using
    /// this function. Since anyone can call it for any user address, it is not
    /// included in this contract.
    /// @param amount Amount of tokens
    function withdrawPrecalculatedAtPool(
        uint256 amount
    ) external override onlyBeneficiary {
        IApi3Pool(api3Pool).withdrawPrecalculated(amount);
    }

    /// @notice Called by the beneficiary to have the StakeableVesting stake
    /// tokens at the pool
    /// @param amount Amount of tokens
    function stakeAtPool(uint256 amount) external override onlyBeneficiary {
        IApi3Pool(api3Pool).stake(amount);
    }

    /// @notice Called by the beneficiary to have the StakeableVesting schedule
    /// an unstaking of tokens at the pool
    /// @param amount Amount of tokens
    function scheduleUnstakeAtPool(
        uint256 amount
    ) external override onlyBeneficiary {
        IApi3Pool(api3Pool).scheduleUnstake(amount);
    }

    /// @notice Called by the beneficiary to have the unstaking that the
    /// StakeableVesting has scheduled to be executed
    /// @dev Anyone can call this function at Api3Pool with the
    /// StakeableVesting address. This function is implemented for the
    /// convenience of the user.
    function unstakeAtPool() external override {
        IApi3Pool(api3Pool).unstake(address(this));
    }

    /// @notice Called by the beneficiary to have the StakeableVesting delegate
    /// its voting power at the pool
    /// @param delegate Address of the account that the voting power will be
    /// delegated to
    function delegateAtPool(
        address delegate
    ) external override onlyBeneficiary {
        IApi3Pool(api3Pool).delegateVotingPower(delegate);
    }

    /// @notice Called by the beneficiary to have the StakeableVesting
    /// undelegate its voting power at the pool
    function undelegateAtPool() external override onlyBeneficiary {
        IApi3Pool(api3Pool).undelegateVotingPower();
    }

    function stateAtPool()
        external
        view
        override
        returns (
            uint256 unstaked,
            uint256 staked,
            uint256 unstaking,
            uint256 unstakeScheduledFor,
            uint256 lockedStakingRewards,
            address delegate,
            uint256 lastDelegationUpdateTimestamp
        )
    {
        delegate = IApi3Pool(api3Pool).userDelegate(address(this));
        lockedStakingRewards = IApi3Pool(api3Pool).userLocked(address(this));
        staked = IApi3Pool(api3Pool).userStake(address(this));
        (
            unstaked,
            ,
            unstaking,
            ,
            unstakeScheduledFor,
            lastDelegationUpdateTimestamp,

        ) = IApi3Pool(api3Pool).getUser(address(this));
    }

    /// @notice Returns the amount of tokens that are yet to be vested based on
    /// the schedule
    /// @return Amount of unvested tokens
    function unvestedAmount() public view override returns (uint256) {
        (uint32 startTimestamp, uint32 endTimestamp, uint192 amount) = (
            vesting.startTimestamp,
            vesting.endTimestamp,
            vesting.amount
        );
        if (block.timestamp <= startTimestamp) {
            return amount;
        } else if (block.timestamp >= endTimestamp) {
            return 0;
        } else {
            uint256 passedTime = block.timestamp - startTimestamp;
            uint256 totalTime = endTimestamp - startTimestamp;
            return amount - (amount * passedTime) / totalTime;
        }
    }

    /// @notice Returns the total balance of StakeableVesting at the pool
    /// @dev Even though it is not certain that the beneficiary will be able to
    /// unstake the funds that are currently staked or being unstaked without
    /// getting slashed, the contract still counts them towards their total
    /// balance in favor of the beneficiary
    /// @return Pool balance
    function poolBalance() private view returns (uint256) {
        uint256 staked = IApi3Pool(api3Pool).userStake(address(this));
        (uint256 unstaked, , uint256 unstaking, , , , ) = IApi3Pool(api3Pool)
            .getUser(address(this));
        return staked + unstaked + unstaking;
    }
}
StakeableVestingFactory.sol 73 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import "./interfaces/IStakeableVestingFactory.sol";
import "./StakeableVesting.sol";
import "@openzeppelin/contracts/proxy/Clones.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

/// @title Contract that deploys a StakeableVesting implementation and allows
/// it to be cloned to create vestings
contract StakeableVestingFactory is IStakeableVestingFactory {
    /// @notice Api3Token address
    address public immutable override api3Token;

    /// @notice StakeableVesting implementation address
    address public immutable override stakeableVestingImplementation;

    /// @param _api3Token Api3Token address
    /// @param _api3Pool Api3Pool address
    constructor(address _api3Token, address _api3Pool) {
        require(_api3Token != address(0), "Api3Token address zero");
        api3Token = _api3Token;
        stakeableVestingImplementation = address(
            new StakeableVesting(_api3Token, _api3Pool)
        );
    }

    /// @notice Deploys a StakeableVesting clone and transfers the vesting
    /// amount to it from the sender
    /// @dev The sender needs to approve `amount` API3 tokens to this contract
    /// before calling this.
    /// The sender will be the owner of the StakeableVesting clone, allowing it
    /// to revoke the vesting.
    /// @param beneficiary Beneficiary of the vesting
    /// @param startTimestamp Starting timestamp of the vesting
    /// @param endTimestamp Ending timestamp of the vesting
    /// @param amount Amount of tokens to be vested over the period
    /// @return stakeableVesting StakeableVesting clone address
    function deployStakeableVesting(
        address beneficiary,
        uint32 startTimestamp,
        uint32 endTimestamp,
        uint192 amount
    ) external override returns (address stakeableVesting) {
        stakeableVesting = Clones.cloneDeterministic(
            stakeableVestingImplementation,
            keccak256(
                abi.encodePacked(
                    beneficiary,
                    startTimestamp,
                    endTimestamp,
                    amount,
                    msg.sender
                )
            )
        );
        IERC20(api3Token).transferFrom(msg.sender, stakeableVesting, amount);
        IStakeableVesting(stakeableVesting).initialize(
            msg.sender,
            beneficiary,
            startTimestamp,
            endTimestamp,
            amount
        );
        emit DeployedStakeableVesting(
            msg.sender,
            beneficiary,
            startTimestamp,
            endTimestamp,
            amount
        );
    }
}
Clones.sol 89 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (proxy/Clones.sol)

pragma solidity ^0.8.0;

/**
 * @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for
 * deploying minimal proxy contracts, also known as "clones".
 *
 * > To simply and cheaply clone contract functionality in an immutable way, this standard specifies
 * > a minimal bytecode implementation that delegates all calls to a known, fixed address.
 *
 * The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2`
 * (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the
 * deterministic method.
 *
 * _Available since v3.4._
 */
library Clones {
    /**
     * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.
     *
     * This function uses the create opcode, which should never revert.
     */
    function clone(address implementation) internal returns (address instance) {
        /// @solidity memory-safe-assembly
        assembly {
            // Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes
            // of the `implementation` address with the bytecode before the address.
            mstore(0x00, or(shr(0xe8, shl(0x60, implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000))
            // Packs the remaining 17 bytes of `implementation` with the bytecode after the address.
            mstore(0x20, or(shl(0x78, implementation), 0x5af43d82803e903d91602b57fd5bf3))
            instance := create(0, 0x09, 0x37)
        }
        require(instance != address(0), "ERC1167: create failed");
    }

    /**
     * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.
     *
     * This function uses the create2 opcode and a `salt` to deterministically deploy
     * the clone. Using the same `implementation` and `salt` multiple time will revert, since
     * the clones cannot be deployed twice at the same address.
     */
    function cloneDeterministic(address implementation, bytes32 salt) internal returns (address instance) {
        /// @solidity memory-safe-assembly
        assembly {
            // Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes
            // of the `implementation` address with the bytecode before the address.
            mstore(0x00, or(shr(0xe8, shl(0x60, implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000))
            // Packs the remaining 17 bytes of `implementation` with the bytecode after the address.
            mstore(0x20, or(shl(0x78, implementation), 0x5af43d82803e903d91602b57fd5bf3))
            instance := create2(0, 0x09, 0x37, salt)
        }
        require(instance != address(0), "ERC1167: create2 failed");
    }

    /**
     * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
     */
    function predictDeterministicAddress(
        address implementation,
        bytes32 salt,
        address deployer
    ) internal pure returns (address predicted) {
        /// @solidity memory-safe-assembly
        assembly {
            let ptr := mload(0x40)
            mstore(add(ptr, 0x38), deployer)
            mstore(add(ptr, 0x24), 0x5af43d82803e903d91602b57fd5bf3ff)
            mstore(add(ptr, 0x14), implementation)
            mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73)
            mstore(add(ptr, 0x58), salt)
            mstore(add(ptr, 0x78), keccak256(add(ptr, 0x0c), 0x37))
            predicted := keccak256(add(ptr, 0x43), 0x55)
        }
    }

    /**
     * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
     */
    function predictDeterministicAddress(address implementation, bytes32 salt)
        internal
        view
        returns (address predicted)
    {
        return predictDeterministicAddress(implementation, salt, address(this));
    }
}
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;
    }
}
Ownable.sol 83 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (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 Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

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

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        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);
    }
}
IStakeableVesting.sol 63 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

interface IStakeableVesting {
    event SetBeneficiary(address beneficiary);

    event WithdrawnAsBeneficiary(uint256 amount);

    event WithdrawnAsOwner(uint256 amount);

    function initialize(
        address _owner,
        address _beneficiary,
        uint32 startTimestamp,
        uint32 endTimestamp,
        uint192 amount
    ) external;

    function setBeneficiary(address _beneficiary) external;

    function withdrawAsOwner() external;

    function withdrawAsBeneficiary() external;

    function depositAtPool(uint256 amount) external;

    function withdrawAtPool(uint256 amount) external;

    function withdrawPrecalculatedAtPool(uint256 amount) external;

    function stakeAtPool(uint256 amount) external;

    function scheduleUnstakeAtPool(uint256 amount) external;

    function unstakeAtPool() external;

    function delegateAtPool(address delegate) external;

    function undelegateAtPool() external;

    function stateAtPool()
        external
        view
        returns (
            uint256 unstaked,
            uint256 staked,
            uint256 unstaking,
            uint256 unstakeScheduledFor,
            uint256 lockedStakingRewards,
            address delegate,
            uint256 lastDelegationUpdateTimestamp
        );

    function unvestedAmount() external view returns (uint256);

    function api3Token() external returns (address);

    function beneficiary() external returns (address);

    function vesting()
        external
        returns (uint32 startTimestamp, uint32 endTimestamp, uint192 amount);
}
IERC20.sol 82 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @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 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 `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, 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 `from` to `to` 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 from,
        address to,
        uint256 amount
    ) external returns (bool);
}
IStakeableVestingFactory.sol 23 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

interface IStakeableVestingFactory {
    event DeployedStakeableVesting(
        address indexed deployer,
        address indexed beneficiary,
        uint32 startTimestamp,
        uint32 endTimestamp,
        uint192 amount
    );

    function deployStakeableVesting(
        address beneficiary,
        uint32 startTimestamp,
        uint32 endTimestamp,
        uint192 amount
    ) external returns (address stakeableVesting);

    function api3Token() external returns (address);

    function stakeableVestingImplementation() external returns (address);
}
IApi3Pool.sol 7 lines
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./ITimelockUtils.sol";

interface IApi3Pool is ITimelockUtils {
}
IClaimUtils.sol 18 lines
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./IStakeUtils.sol";

interface IClaimUtils is IStakeUtils {
    event PaidOutClaim(
        address indexed recipient,
        uint256 amount,
        uint256 totalStake
        );

    function payOutClaim(
        address recipient,
        uint256 amount
        )
        external;
}
IStakeUtils.sol 48 lines
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./ITransferUtils.sol";

interface IStakeUtils is ITransferUtils{
    event Staked(
        address indexed user,
        uint256 amount,
        uint256 mintedShares,
        uint256 userUnstaked,
        uint256 userShares,
        uint256 totalShares,
        uint256 totalStake
        );

    event ScheduledUnstake(
        address indexed user,
        uint256 amount,
        uint256 shares,
        uint256 scheduledFor,
        uint256 userShares
        );

    event Unstaked(
        address indexed user,
        uint256 amount,
        uint256 userUnstaked,
        uint256 totalShares,
        uint256 totalStake
        );

    function stake(uint256 amount)
        external;

    function depositAndStake(uint256 amount)
        external;

    function scheduleUnstake(uint256 amount)
        external;

    function unstake(address userAddress)
        external
        returns (uint256);

    function unstakeAndWithdraw()
        external;
}
IStateUtils.sol 74 lines
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IStateUtils {
    event SetDaoApps(
        address agentAppPrimary,
        address agentAppSecondary,
        address votingAppPrimary,
        address votingAppSecondary
        );

    event SetClaimsManagerStatus(
        address indexed claimsManager,
        bool indexed status
        );

    event SetStakeTarget(uint256 stakeTarget);

    event SetMaxApr(uint256 maxApr);

    event SetMinApr(uint256 minApr);

    event SetUnstakeWaitPeriod(uint256 unstakeWaitPeriod);

    event SetAprUpdateStep(uint256 aprUpdateStep);

    event SetProposalVotingPowerThreshold(uint256 proposalVotingPowerThreshold);

    event UpdatedLastProposalTimestamp(
        address indexed user,
        uint256 lastProposalTimestamp,
        address votingApp
        );

    function setDaoApps(
        address _agentAppPrimary,
        address _agentAppSecondary,
        address _votingAppPrimary,
        address _votingAppSecondary
        )
        external;

    function setClaimsManagerStatus(
        address claimsManager,
        bool status
        )
        external;

    function setStakeTarget(uint256 _stakeTarget)
        external;

    function setMaxApr(uint256 _maxApr)
        external;

    function setMinApr(uint256 _minApr)
        external;

    function setUnstakeWaitPeriod(uint256 _unstakeWaitPeriod)
        external;

    function setAprUpdateStep(uint256 _aprUpdateStep)
        external;

    function setProposalVotingPowerThreshold(uint256 _proposalVotingPowerThreshold)
        external;

    function updateLastProposalTimestamp(address userAddress)
        external;

    function isGenesisEpoch()
        external
        view
        returns (bool);
}
IGetterUtils.sol 91 lines
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./IStateUtils.sol";

interface IGetterUtils is IStateUtils {
    function userVotingPowerAt(
        address userAddress,
        uint256 _block
        )
        external
        view
        returns (uint256);

    function userVotingPower(address userAddress)
        external
        view
        returns (uint256);

    function totalSharesAt(uint256 _block)
        external
        view
        returns (uint256);

    function totalShares()
        external
        view
        returns (uint256);

    function userSharesAt(
        address userAddress,
        uint256 _block
        )
        external
        view
        returns (uint256);

    function userShares(address userAddress)
        external
        view
        returns (uint256);

    function userStake(address userAddress)
        external
        view
        returns (uint256);

    function delegatedToUserAt(
        address userAddress,
        uint256 _block
        )
        external
        view
        returns (uint256);

    function delegatedToUser(address userAddress)
        external
        view
        returns (uint256);

    function userDelegateAt(
        address userAddress,
        uint256 _block
        )
        external
        view
        returns (address);

    function userDelegate(address userAddress)
        external
        view
        returns (address);

    function userLocked(address userAddress)
        external
        view
        returns (uint256);

    function getUser(address userAddress)
        external
        view
        returns (
            uint256 unstaked,
            uint256 vesting,
            uint256 unstakeShares,
            uint256 unstakeAmount,
            uint256 unstakeScheduledFor,
            uint256 lastDelegationUpdateTimestamp,
            uint256 lastProposalTimestamp
            );
}
IRewardUtils.sol 16 lines
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./IGetterUtils.sol";

interface IRewardUtils is IGetterUtils {
    event MintedReward(
        uint256 indexed epochIndex,
        uint256 amount,
        uint256 newApr,
        uint256 totalStake
        );

    function mintReward()
        external;
}
ITimelockUtils.sol 46 lines
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./IClaimUtils.sol";

interface ITimelockUtils is IClaimUtils {
    event DepositedByTimelockManager(
        address indexed user,
        uint256 amount,
        uint256 userUnstaked
        );

    event DepositedVesting(
        address indexed user,
        uint256 amount,
        uint256 start,
        uint256 end,
        uint256 userUnstaked,
        uint256 userVesting
        );

    event VestedTimelock(
        address indexed user,
        uint256 amount,
        uint256 userVesting
        );

    function deposit(
        address source,
        uint256 amount,
        address userAddress
        )
        external;

    function depositWithVesting(
        address source,
        uint256 amount,
        address userAddress,
        uint256 releaseStart,
        uint256 releaseEnd
        )
        external;

    function updateTimelockStatus(address userAddress)
        external;
}
ITransferUtils.sol 45 lines
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./IDelegationUtils.sol";

interface ITransferUtils is IDelegationUtils{
    event Deposited(
        address indexed user,
        uint256 amount,
        uint256 userUnstaked
        );

    event Withdrawn(
        address indexed user,
        uint256 amount,
        uint256 userUnstaked
        );

    event CalculatingUserLocked(
        address indexed user,
        uint256 nextIndEpoch,
        uint256 oldestLockedEpoch
        );

    event CalculatedUserLocked(
        address indexed user,
        uint256 amount
        );

    function depositRegular(uint256 amount)
        external;

    function withdrawRegular(uint256 amount)
        external;

    function precalculateUserLocked(
        address userAddress,
        uint256 noEpochsPerIteration
        )
        external
        returns (bool finished);

    function withdrawPrecalculated(uint256 amount)
        external;
}
IDelegationUtils.sol 36 lines
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./IRewardUtils.sol";

interface IDelegationUtils is IRewardUtils {
    event Delegated(
        address indexed user,
        address indexed delegate,
        uint256 shares,
        uint256 totalDelegatedTo
        );

    event Undelegated(
        address indexed user,
        address indexed delegate,
        uint256 shares,
        uint256 totalDelegatedTo
        );

    event UpdatedDelegation(
        address indexed user,
        address indexed delegate,
        bool delta,
        uint256 shares,
        uint256 totalDelegatedTo
        );

    function delegateVotingPower(address delegate) 
        external;

    function undelegateVotingPower()
        external;

    
}

Read Contract

api3Token 0x613d517d → address
stakeableVestingImplementation 0xf0f0ec01 → address

Write Contract 1 functions

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

deployStakeableVesting 0x1c3e7dd8
address beneficiary
uint32 startTimestamp
uint32 endTimestamp
uint192 amount
returns: address

Recent Transactions

No transactions found for this address