Contract 0x7c0E0162de86b01705f5e62A90604A3817e3Fb6C

 
 
Txn Hash
Method
Block
From
To
Value [Txn Fee]
0x2ef8fbf0703073cf66373f0f6c074f6cd2100a57a65dd71ddfc7c8a41974dbef0x60806040353462732022-11-08 7:40:06142 days 4 hrs agoDavos Protocol: Deployer IN  Create: CerosRouter0 MATIC1.284878713469 678.977871935
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
CerosRouter

Compiler Version
v0.8.15+commit.e14f2714

Optimization Enabled:
Yes with 100 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 16 : CerosRouter.sol
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.6;
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "./interfaces/IVault.sol";
import "./interfaces/ISwapRouter.sol";
import "./interfaces/ISwapPool.sol";
import "./interfaces/IPriceGetter.sol";
import "./interfaces/ICerosRouter.sol";
import "./interfaces/ICertToken.sol";
import "../MasterVault/interfaces/IMasterVault.sol";
import "../MasterVault/interfaces/IWETH.sol";

contract CerosRouter is
ICerosRouter,
OwnableUpgradeable,
PausableUpgradeable,
ReentrancyGuardUpgradeable
{
    /**
     * Variables
     */
    IVault private _vault;
    ISwapRouter private _dex;
    // Tokens
    ICertToken private _certToken; // (default aMATICc)
    address private _wMaticAddress;
    IERC20 private _ceToken; // (default ceAMATICc)
    mapping(address => uint256) private _profits;
    IMasterVault private _masterVault;
    uint24 private _pairFee;
    ISwapPool private _pool;
    IPriceGetter private _priceGetter;
    /**
     * Modifiers
     */

    function initialize(
        address certToken,
        address wMaticToken,
        address ceToken,
        address vault,
        address dexAddress,
        uint24 pairFee,
        address swapPool,
        address priceGetter
    ) public initializer {
        __Ownable_init();
        __Pausable_init();
        __ReentrancyGuard_init();
        _certToken = ICertToken(certToken);
        _wMaticAddress = wMaticToken;
        _ceToken = IERC20(ceToken);
        _vault = IVault(vault);
        _dex = ISwapRouter(dexAddress);
        _pairFee = pairFee;
        _pool = ISwapPool(swapPool);
        _priceGetter = IPriceGetter(priceGetter);
        IERC20(wMaticToken).approve(swapPool, type(uint256).max);
        IERC20(certToken).approve(swapPool, type(uint256).max);
        IERC20(wMaticToken).approve(dexAddress, type(uint256).max);
        IERC20(certToken).approve(dexAddress, type(uint256).max);
        IERC20(certToken).approve(vault, type(uint256).max);
    }
    /**
     * DEPOSIT
     */
    function deposit()
    external
    payable
    override
    nonReentrant
    returns (uint256 value)
    {
        uint256 amount = msg.value;
        IWETH(_wMaticAddress).deposit{value: amount}();
        return _deposit(amount);
    }

    function depositWMatic(uint256 amount) 
    external
    nonReentrant
    returns (uint256 value)
    {
        IERC20(_wMaticAddress).transferFrom(msg.sender, address(this), amount);
        return _deposit(amount);
    }

    function _deposit(uint256 amount) internal returns (uint256 value) {
        require(amount > 0, "invalid deposit amount");
        uint256 dexAmount = getAmountOut(_wMaticAddress, address(_certToken), amount);
        // uint256 minAmount = (amount * _certToken.ratio()) / 1e18;
        (uint256 minAmount,) = _pool.getAmountOut(true, amount, false);
        uint256 realAmount;
        if(dexAmount > minAmount) {
            realAmount = swapV3(_wMaticAddress, address(_certToken), amount, minAmount, address(this));
        } else {
            realAmount = _pool.swap(true, amount, address(this));
        }

        require(realAmount >= minAmount, "price too low");

        require(
            _certToken.balanceOf(address(this)) >= realAmount,
            "insufficient amount of CerosRouter in cert token"
        );
        uint256 profit = realAmount - minAmount;
        // add profit
        _profits[msg.sender] += profit;

        value = _vault.depositFor(msg.sender, realAmount - profit);
        emit Deposit(msg.sender, _wMaticAddress, realAmount - profit, profit);
        return value;
    }

    /**
     * CLAIM
     */
    // claim yields in aMATICc
    function claim(address recipient)
    external
    override
    nonReentrant
    returns (uint256 yields)
    {
        yields = _vault.claimYieldsFor(msg.sender, recipient);
        emit Claim(recipient, address(_certToken), yields);
        return yields;
    }
    // claim profit in aMATICc
    function claimProfit(address recipient) external nonReentrant {
        uint256 profit = _profits[msg.sender];
        require(profit > 0, "has not got a profit");
        // let's check balance of CeRouter in aMATICc
        require(
            _certToken.balanceOf(address(this)) >= profit,
            "insufficient amount"
        );
        _certToken.transfer(recipient, profit);
        _profits[msg.sender] -= profit;
        emit Claim(recipient, address(_certToken), profit);
    }
    function getAmountOut(address tokenIn, address tokenOut, uint256 amountIn) public view returns (uint256 amountOut) {
        if(address(_priceGetter) == address(0)) {
            return 0;
        } else {
            amountOut = IPriceGetter(_priceGetter).getPrice(
                tokenIn,
                tokenOut,
                amountIn,
                0,
                _pairFee
            );
        }
    }

    // withdrawal in MATIC via DEX or Swap Pool
    function withdrawWithSlippage(
        address recipient,
        uint256 amount,
        uint256 outAmount
    ) external override nonReentrant returns (uint256 realAmount) {
        realAmount = _vault.withdrawFor(msg.sender, address(this), amount);
        uint256 dexAmount = getAmountOut(address(_certToken), _wMaticAddress, realAmount);
        uint256 amountOut;
        if(dexAmount > outAmount) {
            amountOut = swapV3(address(_certToken), _wMaticAddress, realAmount, outAmount, recipient);
        } else {
            amountOut = _pool.swap(false, realAmount, recipient);
        }
        require(amountOut >= outAmount, "price too low");
        emit Withdrawal(msg.sender, recipient, _wMaticAddress, amountOut);
        return amountOut;
    }
    function swapV3(
        address tokenIn, 
        address tokenOut, 
        uint256 amountIn, 
        uint256 amountOutMin, 
        address recipient) private returns (uint256 amountOut) {
            ISwapRouter.ExactInputSingleParams memory params = ISwapRouter.ExactInputSingleParams(
            tokenIn,                // tokenIn
            tokenOut,               // tokenOut
            _pairFee,               // fee
            recipient,              // recipient
            block.timestamp + 300,  // deadline
            amountIn,               // amountIn
            amountOutMin,           // amountOutMinimum
            0                       // sqrtPriceLimitX96
        );
        amountOut = _dex.exactInputSingle(params);
    }
    function getProfitFor(address account) external view returns (uint256) {
        return _profits[account];
    }
    function getYieldFor(address account) external view returns(uint256) {
        return _vault.getYieldFor(account);
    } 
    function changeVault(address vault) external onlyOwner {
        // update allowances
        _certToken.approve(address(_vault), 0);
        _vault = IVault(vault);
        _certToken.approve(address(_vault), type(uint256).max);
        emit ChangeVault(vault);
    }
    function changeDex(address dex) external onlyOwner {
        IERC20(_wMaticAddress).approve(address(_dex), 0);
        _certToken.approve(address(_dex), 0);
        _dex = ISwapRouter(dex);
        // update allowances
        IERC20(_wMaticAddress).approve(address(_dex), type(uint256).max);
        _certToken.approve(address(_dex), type(uint256).max);
        emit ChangeDex(dex);
    }
    function changeSwapPool(address swapPool) external onlyOwner {
        IERC20(_wMaticAddress).approve(address(_pool), 0);
        _certToken.approve(address(_pool), 0);
        _pool = ISwapPool(swapPool);
        IERC20(_wMaticAddress).approve(swapPool, type(uint256).max);
        _certToken.approve(swapPool, type(uint256).max);
        emit ChangeSwapPool(swapPool);
    }
    function changeProvider(address masterVault) external onlyOwner {
        _masterVault = IMasterVault(masterVault);
        emit ChangeProvider(masterVault);
    }
    function changePairFee(uint24 fee) external onlyOwner {
        _pairFee = fee;
        emit ChangePairFee(fee);
    }
    function changePriceGetter(address priceGetter) external onlyOwner {
        _priceGetter = IPriceGetter(priceGetter);
    }
    function getCeToken() external view returns(address) {
        return address(_ceToken);
    }
    function getWMaticAddress() external view returns(address) {
        return _wMaticAddress;
    }
    function getCertToken() external view returns(address) {
        return address(_certToken);
    }
    function getPoolAddress() external view returns(address) {
        return address(_pool);
    }
    function getDexAddress() external view returns(address) {
        return address(_dex);
    }
    function getVaultAddress() external view returns(address) {
        return address(_vault);
    }
}

File 2 of 16 : OwnableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.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 OwnableUpgradeable is Initializable, ContextUpgradeable {
    address private _owner;

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    function __Ownable_init() internal onlyInitializing {
        __Ownable_init_unchained();
    }

    function __Ownable_init_unchained() internal onlyInitializing {
        _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);
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[49] private __gap;
}

File 3 of 16 : ReentrancyGuardUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuardUpgradeable is Initializable {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    function __ReentrancyGuard_init() internal onlyInitializing {
        __ReentrancyGuard_init_unchained();
    }

    function __ReentrancyGuard_init_unchained() internal onlyInitializing {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;

        _;

        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[49] private __gap;
}

File 4 of 16 : PausableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)

pragma solidity ^0.8.0;

import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract PausableUpgradeable is Initializable, ContextUpgradeable {
    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    function __Pausable_init() internal onlyInitializing {
        __Pausable_init_unchained();
    }

    function __Pausable_init_unchained() internal onlyInitializing {
        _paused = false;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        _requireNotPaused();
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        _requirePaused();
        _;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        require(!paused(), "Pausable: paused");
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        require(paused(), "Pausable: not paused");
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[49] private __gap;
}

File 5 of 16 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (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 `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);

    /**
     * @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);
}

File 6 of 16 : IVault.sol
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.6;
interface IVault {
    /**
     * Events
     */
    event Deposited(
        address indexed owner,
        address indexed recipient,
        uint256 value
    );
    event Claimed(
        address indexed owner,
        address indexed recipient,
        uint256 value
    );
    event Withdrawn(
        address indexed owner,
        address indexed recipient,
        uint256 value
    );
    event RouterChanged(address router);
    /**
     * Methods
     */
    event RatioUpdated(uint256 currentRatio);
    function deposit(uint256 amount) external returns (uint256);
    function depositFor(address recipient, uint256 amount)
    external
    returns (uint256);
    function claimYields(address recipient) external returns (uint256);
    function claimYieldsFor(address owner, address recipient)
    external
    returns (uint256);
    function withdraw(address recipient, uint256 amount)
    external
    returns (uint256);
    function withdrawFor(
        address owner,
        address recipient,
        uint256 amount
    ) external returns (uint256);
    function getPrincipalOf(address account) external view returns (uint256);
    function getYieldFor(address account) external view returns (uint256);
    function getTotalAmountInVault() external view returns (uint256);
}

File 7 of 16 : ISwapRouter.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
pragma abicoder v2;

/// @title Callback for IUniswapV3PoolActions#swap
/// @notice Any contract that calls IUniswapV3PoolActions#swap must implement this interface
interface IUniswapV3SwapCallback {
    /// @notice Called to `msg.sender` after executing a swap via IUniswapV3Pool#swap.
    /// @dev In the implementation you must pay the pool tokens owed for the swap.
    /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory.
    /// amount0Delta and amount1Delta can both be 0 if no tokens were swapped.
    /// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by
    /// the end of the swap. If positive, the callback must send that amount of token0 to the pool.
    /// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by
    /// the end of the swap. If positive, the callback must send that amount of token1 to the pool.
    /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#swap call
    function uniswapV3SwapCallback(
        int256 amount0Delta,
        int256 amount1Delta,
        bytes calldata data
    ) external;
}

/// @title Periphery Payments
/// @notice Functions to ease deposits and withdrawals of ETH
interface IPeripheryPayments {
    /// @notice Unwraps the contract's WETH9 balance and sends it to recipient as ETH.
    /// @dev The amountMinimum parameter prevents malicious contracts from stealing WETH9 from users.
    /// @param amountMinimum The minimum amount of WETH9 to unwrap
    /// @param recipient The address receiving ETH
    function unwrapWETH9(uint256 amountMinimum, address recipient) external payable;

    /// @notice Refunds any ETH balance held by this contract to the `msg.sender`
    /// @dev Useful for bundling with mint or increase liquidity that uses ether, or exact output swaps
    /// that use ether for the input amount
    function refundETH() external payable;

    /// @notice Transfers the full amount of a token held by this contract to recipient
    /// @dev The amountMinimum parameter prevents malicious contracts from stealing the token from users
    /// @param token The contract address of the token which will be transferred to `recipient`
    /// @param amountMinimum The minimum amount of token required for a transfer
    /// @param recipient The destination address of the token
    function sweepToken(
        address token,
        uint256 amountMinimum,
        address recipient
    ) external payable;
}


/// @title Router token swapping functionality
/// @notice Functions for swapping tokens via Uniswap V3
interface ISwapRouter is IUniswapV3SwapCallback, IPeripheryPayments{
    struct ExactInputSingleParams {
        address tokenIn;
        address tokenOut;
        uint24 fee;
        address recipient;
        uint256 deadline;
        uint256 amountIn;
        uint256 amountOutMinimum;
        uint160 sqrtPriceLimitX96;
    }

    /// @notice Swaps `amountIn` of one token for as much as possible of another token
    /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata
    /// @return amountOut The amount of the received token
    function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);

    struct ExactInputParams {
        bytes path;
        address recipient;
        uint256 deadline;
        uint256 amountIn;
        uint256 amountOutMinimum;
    }

    /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path
    /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata
    /// @return amountOut The amount of the received token
    function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut);

    struct ExactOutputSingleParams {
        address tokenIn;
        address tokenOut;
        uint24 fee;
        address recipient;
        uint256 deadline;
        uint256 amountOut;
        uint256 amountInMaximum;
        uint160 sqrtPriceLimitX96;
    }

    /// @notice Swaps as little as possible of one token for `amountOut` of another token
    /// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata
    /// @return amountIn The amount of the input token
    function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn);

    struct ExactOutputParams {
        bytes path;
        address recipient;
        uint256 deadline;
        uint256 amountOut;
        uint256 amountInMaximum;
    }

    /// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed)
    /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata
    /// @return amountIn The amount of the input token
    function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn);
}

File 8 of 16 : ISwapPool.sol
// SPDX-License-Identifier: Unliscensed
pragma solidity ^0.8.0;

interface ISwapPool {
    function swap(
        bool nativeToCeros,
        uint256 amountIn,
        address receiver
    ) external returns (uint256 amountOut);
    
    function getAmountOut(
        bool nativeToCeros,
        uint amountIn,
        bool isExcludedFromFee) 
        external view returns(uint amountOut, bool enoughLiquidity);
    
    function unstakeFee() external view returns (uint24 unstakeFee);
    function stakeFee() external view returns (uint24 stakeFee);

    function FEE_MAX() external view returns (uint24 feeMax);
}

File 9 of 16 : IPriceGetter.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface IPriceGetter {
    function getPrice(
        address tokenIn,
        address tokenOut,
        uint256 amountIn,
        uint160 sqrtPriceLimitX96,
        uint24 fee
    ) external view returns (uint256 amountOut);
}

File 10 of 16 : ICerosRouter.sol
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.0;

interface ICerosRouter {
    /**
     * Events
     */

    event Deposit(
        address indexed account,
        address indexed token,
        uint256 amount,
        uint256 profit
    );

    event Claim(
        address indexed recipient,
        address indexed token,
        uint256 amount
    );

    event Withdrawal(
        address indexed owner,
        address indexed recipient,
        address indexed token,
        uint256 amount
    );

    event ChangeVault(address vault);

    event ChangeDex(address dex);

    event ChangeDexFactory(address factory);

    event ChangeSwapPool(address pool);

    event ChangeDao(address dao);

    event ChangeCeToken(address ceToken);

    event ChangeCeTokenJoin(address ceTokenJoin);

    event ChangeCertToken(address certToken);

    event ChangeCollateralToken(address collateralToken);

    event ChangeProvider(address provider);

    event ChangePairFee(uint24 fee);

    /**
     * Methods
     */

    /**
     * Deposit
     */

    // in MATIC
    function deposit() external payable returns (uint256);

    function depositWMatic(uint256 amount) external returns (uint256);

    // // in aMATICc
    // function depositAMATICcFrom(address owner, uint256 amount)
    // external
    // returns (uint256);

    // function depositAMATICc(uint256 amount) external returns (uint256);

    /**
     * Claim
     */

    // claim in aMATICc
    function claim(address recipient) external returns (uint256);

    function claimProfit(address recipient) external;

    function getProfitFor(address account) external view returns (uint256);

    function getYieldFor(address account) external view returns(uint256);

    /**
     * Withdrawal
     */

    // MATIC
    // function withdraw(address recipient, uint256 amount)
    // external
    // returns (uint256);

    // MATIC
    // function withdrawFor(address recipient, uint256 amount)
    // external
    // returns (uint256);

    // MATIC
    function withdrawWithSlippage(
        address recipient,
        uint256 amount,
        uint256 slippage
    ) external returns (uint256);

    // // aMATICc
    // function withdrawAMATICc(address recipient, uint256 amount)
    // external
    // returns (uint256);
}

File 11 of 16 : ICertToken.sol
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface ICertToken is IERC20 {

    function burn(address account, uint256 amount) external;

    function mint(address account, uint256 amount) external;

    function balanceWithRewardsOf(address account) external returns (uint256);

    function isRebasing() external returns (bool);

    function ratio() external view returns (uint256);
}

File 12 of 16 : IMasterVault.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

// import "./IERC4626Upgradeable.sol";

interface IMasterVault {
    event DepositFeeChanged(uint256 newDepositFee);
    event MaxDepositFeeChanged(uint256 newMaxDepositFee);
    event WithdrawalFeeChanged(uint256 newWithdrawalFee);
    event MaxWithdrawalFeeChanged(uint256 newMaxWithdrawalFee);
    event ProviderChanged(address provider);
    event RouterChanged(address ceRouter);
    event ManagerAdded(address newManager);
    event ManagerRemoved(address manager);
    event FeeReceiverChanged(address feeReceiver);
    event WaitingPoolChanged(address waitingPool);
    event WaitingPoolCapChanged(uint256 cap);
    event StrategyAllocationChanged(address strategy, uint256 allocation);
    event SwapPoolChanged(address swapPool);
    event StrategyAdded(address strategy, uint256 allocation);
    event StrategyMigrated(address oldStrategy, address newStrategy, uint256 newAllocation);
    event DepositedToStrategy(address strategy, uint256 amount);
    event WithdrawnFromStrategy(address strategy, uint256 value);

    function withdrawETH(address account, uint256 amount) external  returns (uint256);
    function depositETH() external payable returns (uint256);
    function feeReceiver() external returns (address payable);
    function withdrawalFee() external view returns (uint256);
    function strategyParams(address strategy) external view returns(bool active, uint256 allocation, uint256 debt);
}

File 13 of 16 : IWETH.sol
// SPDX-License-Identifier: MIT

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

pragma solidity ^0.8.0;

interface IWETH is IERC20 {
    function deposit() external payable;

    function withdraw(uint256 wad) external;
}

File 14 of 16 : ContextUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";

/**
 * @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 ContextUpgradeable is Initializable {
    function __Context_init() internal onlyInitializing {
    }

    function __Context_init_unchained() internal onlyInitializing {
    }
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

File 15 of 16 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.2;

import "../../utils/AddressUpgradeable.sol";

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
 * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
 * case an upgrade adds a module that needs to be initialized.
 *
 * For example:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * contract MyToken is ERC20Upgradeable {
 *     function initialize() initializer public {
 *         __ERC20_init("MyToken", "MTK");
 *     }
 * }
 * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
 *     function initializeV2() reinitializer(2) public {
 *         __ERC20Permit_init("MyToken");
 *     }
 * }
 * ```
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
 * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() {
 *     _disableInitializers();
 * }
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     * @custom:oz-retyped-from bool
     */
    uint8 private _initialized;

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

    /**
     * @dev Triggered when the contract has been initialized or reinitialized.
     */
    event Initialized(uint8 version);

    /**
     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
     * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.
     */
    modifier initializer() {
        bool isTopLevelCall = !_initializing;
        require(
            (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
            "Initializable: contract is already initialized"
        );
        _initialized = 1;
        if (isTopLevelCall) {
            _initializing = true;
        }
        _;
        if (isTopLevelCall) {
            _initializing = false;
            emit Initialized(1);
        }
    }

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original
     * initialization step. This is essential to configure modules that are added through upgrades and that require
     * initialization.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     */
    modifier reinitializer(uint8 version) {
        require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
        _initialized = version;
        _initializing = true;
        _;
        _initializing = false;
        emit Initialized(version);
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} and {reinitializer} modifiers, directly or indirectly.
     */
    modifier onlyInitializing() {
        require(_initializing, "Initializable: contract is not initializing");
        _;
    }

    /**
     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
     * through proxies.
     */
    function _disableInitializers() internal virtual {
        require(!_initializing, "Initializable: contract is initializing");
        if (_initialized < type(uint8).max) {
            _initialized = type(uint8).max;
            emit Initialized(type(uint8).max);
        }
    }
}

File 16 of 16 : AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library AddressUpgradeable {
    /**
     * @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
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 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 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
                /// @solidity memory-safe-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 100
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"ceToken","type":"address"}],"name":"ChangeCeToken","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"ceTokenJoin","type":"address"}],"name":"ChangeCeTokenJoin","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"certToken","type":"address"}],"name":"ChangeCertToken","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"collateralToken","type":"address"}],"name":"ChangeCollateralToken","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"dao","type":"address"}],"name":"ChangeDao","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"dex","type":"address"}],"name":"ChangeDex","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"factory","type":"address"}],"name":"ChangeDexFactory","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint24","name":"fee","type":"uint24"}],"name":"ChangePairFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"provider","type":"address"}],"name":"ChangeProvider","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"pool","type":"address"}],"name":"ChangeSwapPool","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"vault","type":"address"}],"name":"ChangeVault","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Claim","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"profit","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdrawal","type":"event"},{"inputs":[{"internalType":"address","name":"dex","type":"address"}],"name":"changeDex","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint24","name":"fee","type":"uint24"}],"name":"changePairFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"priceGetter","type":"address"}],"name":"changePriceGetter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"masterVault","type":"address"}],"name":"changeProvider","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"swapPool","type":"address"}],"name":"changeSwapPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"vault","type":"address"}],"name":"changeVault","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"}],"name":"claim","outputs":[{"internalType":"uint256","name":"yields","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"}],"name":"claimProfit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"deposit","outputs":[{"internalType":"uint256","name":"value","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"depositWMatic","outputs":[{"internalType":"uint256","name":"value","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenIn","type":"address"},{"internalType":"address","name":"tokenOut","type":"address"},{"internalType":"uint256","name":"amountIn","type":"uint256"}],"name":"getAmountOut","outputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCeToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCertToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDexAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPoolAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getProfitFor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getVaultAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getWMaticAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getYieldFor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"certToken","type":"address"},{"internalType":"address","name":"wMaticToken","type":"address"},{"internalType":"address","name":"ceToken","type":"address"},{"internalType":"address","name":"vault","type":"address"},{"internalType":"address","name":"dexAddress","type":"address"},{"internalType":"uint24","name":"pairFee","type":"uint24"},{"internalType":"address","name":"swapPool","type":"address"},{"internalType":"address","name":"priceGetter","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"outAmount","type":"uint256"}],"name":"withdrawWithSlippage","outputs":[{"internalType":"uint256","name":"realAmount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"}]

608060405234801561001057600080fd5b50612145806100206000396000f3fe6080604052600436106101565760003560e01c8063854cf3cf116100c1578063ac78467c1161007a578063ac78467c146103a9578063bd70d246146103df578063c0ab44f6146103ff578063caa565421461041f578063d0e30db01461043f578063f2fde38b14610447578063f586c6d91461046757600080fd5b8063854cf3cf146102ef57806389edc86c1461030d5780638da5cb5b1461032d5780639c2439011461034b578063a91756bb1461036b578063ab43c3df1461038957600080fd5b806360e232a91161011357806360e232a91461023e57806365cacaa41461025e57806369d2da9c1461027c5780636eecfdaa1461029c578063715018a6146102ba578063796f69aa146102cf57600080fd5b80630c632bbe1461015b5780631e83409a1461018b578063223888c1146101b95780634aa06652146101d9578063588fbd9c146101f95780635c975abb1461021b575b600080fd5b34801561016757600080fd5b5060cd546001600160a01b03165b6040516101829190611dbb565b60405180910390f35b34801561019757600080fd5b506101ab6101a6366004611deb565b610485565b604051908152602001610182565b3480156101c557600080fd5b506101ab6101d4366004611deb565b610580565b3480156101e557600080fd5b506101ab6101f4366004611e06565b6105f8565b34801561020557600080fd5b50610219610214366004611deb565b6106b5565b005b34801561022757600080fd5b5060655460ff166040519015158152602001610182565b34801561024a57600080fd5b50610219610259366004611deb565b6108f4565b34801561026a57600080fd5b5060c9546001600160a01b0316610175565b34801561028857600080fd5b50610219610297366004611deb565b610a32565b3480156102a857600080fd5b5060cb546001600160a01b0316610175565b3480156102c657600080fd5b50610219610c67565b3480156102db57600080fd5b506102196102ea366004611deb565b610c7b565b3480156102fb57600080fd5b5060ca546001600160a01b0316610175565b34801561031957600080fd5b50610219610328366004611e55565b610cce565b34801561033957600080fd5b506033546001600160a01b0316610175565b34801561035757600080fd5b50610219610366366004611deb565b610d28565b34801561037757600080fd5b5060cc546001600160a01b0316610175565b34801561039557600080fd5b506101ab6103a4366004611e70565b610d52565b3480156103b557600080fd5b506101ab6103c4366004611deb565b6001600160a01b0316600090815260ce602052604090205490565b3480156103eb57600080fd5b506102196103fa366004611ea3565b610f37565b34801561040b57600080fd5b5061021961041a366004611deb565b611326565b34801561042b57600080fd5b506101ab61043a366004611f3a565b61153e565b6101ab6115f3565b34801561045357600080fd5b50610219610462366004611deb565b611691565b34801561047357600080fd5b5060d0546001600160a01b0316610175565b60006002609754036104b25760405162461bcd60e51b81526004016104a990611f53565b60405180910390fd5b600260975560c954604051630440565b60e21b81523360048201526001600160a01b03848116602483015290911690631101596c906044016020604051808303816000875af1158015610509573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061052d9190611f8a565b60cb546040518281529192506001600160a01b0390811691908416907f70eb43c4a8ae8c40502dcf22436c509c28d6ff421cf07c491be56984bd9870689060200160405180910390a36001609755919050565b60c95460405163223888c160e01b81526000916001600160a01b03169063223888c1906105b1908590600401611dbb565b602060405180830381865afa1580156105ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105f29190611f8a565b92915050565b60d1546000906001600160a01b0316610613575060006106ae565b60d15460cf54604051636f20eb4560e11b81526001600160a01b03878116600483015286811660248301526044820186905260006064830152600160a01b90920462ffffff16608482015291169063de41d68a9060a401602060405180830381865afa158015610687573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106ab9190611f8a565b90505b9392505050565b6106bd61170a565b60cc5460d05460405163095ea7b360e01b81526001600160a01b039283169263095ea7b3926106f492911690600090600401611fa3565b6020604051808303816000875af1158015610713573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107379190611fcc565b5060cb5460d05460405163095ea7b360e01b81526001600160a01b039283169263095ea7b39261076f92911690600090600401611fa3565b6020604051808303816000875af115801561078e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107b29190611fcc565b5060d080546001600160a01b0319166001600160a01b038381169190911790915560cc5460405163095ea7b360e01b815291169063095ea7b3906107fe90849060001990600401611fa3565b6020604051808303816000875af115801561081d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108419190611fcc565b5060cb5460405163095ea7b360e01b81526001600160a01b039091169063095ea7b39061087690849060001990600401611fa3565b6020604051808303816000875af1158015610895573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108b99190611fcc565b507fe8d3bd2cf85e2a869209a1161a4c1cc07078af8059b29d9d37482c8f406415a8816040516108e99190611dbb565b60405180910390a150565b6108fc61170a565b60cb5460c95460405163095ea7b360e01b81526001600160a01b039283169263095ea7b39261093392911690600090600401611fa3565b6020604051808303816000875af1158015610952573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109769190611fcc565b5060c980546001600160a01b0319166001600160a01b0383811691821790925560cb5460405163095ea7b360e01b815292169163095ea7b3916109bf9160001990600401611fa3565b6020604051808303816000875af11580156109de573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a029190611fcc565b507f646d70535c6b451b92021874a72abd441f122ba1c0b8f24d074352bd169fad3f816040516108e99190611dbb565b610a3a61170a565b60cc5460ca5460405163095ea7b360e01b81526001600160a01b039283169263095ea7b392610a7192911690600090600401611fa3565b6020604051808303816000875af1158015610a90573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ab49190611fcc565b5060cb5460ca5460405163095ea7b360e01b81526001600160a01b039283169263095ea7b392610aec92911690600090600401611fa3565b6020604051808303816000875af1158015610b0b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b2f9190611fcc565b5060ca80546001600160a01b0319166001600160a01b0383811691821790925560cc5460405163095ea7b360e01b815292169163095ea7b391610b789160001990600401611fa3565b6020604051808303816000875af1158015610b97573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bbb9190611fcc565b5060cb5460ca5460405163095ea7b360e01b81526001600160a01b039283169263095ea7b392610bf49291169060001990600401611fa3565b6020604051808303816000875af1158015610c13573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c379190611fcc565b507f90252124b346c6d6c466196d470d708d0c0c7026fe5ba62a2e01b5adbf39e279816040516108e99190611dbb565b610c6f61170a565b610c796000611764565b565b610c8361170a565b60cf80546001600160a01b0319166001600160a01b0383161790556040517f9a33114b94f1c4c094352deff0082e220c977361e70d556dfb5565ad4678ce4d906108e9908390611dbb565b610cd661170a565b60cf805462ffffff60a01b1916600160a01b62ffffff8416908102919091179091556040519081527f29df655a1cd3447fd57dbc94979c503525dcad29ecf69f21eeac2f347216ad2a906020016108e9565b610d3061170a565b60d180546001600160a01b0319166001600160a01b0392909216919091179055565b6000600260975403610d765760405162461bcd60e51b81526004016104a990611f53565b600260975560c954604051639f1d926760e01b81526001600160a01b0390911690639f1d926790610daf90339030908890600401611fe7565b6020604051808303816000875af1158015610dce573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610df29190611f8a565b60cb5460cc54919250600091610e15916001600160a01b039081169116846105f8565b9050600083821115610e475760cb5460cc54610e40916001600160a01b03908116911685878a6117b6565b9050610ec2565b60d054604051630b6adc0760e31b81526001600160a01b0390911690635b56e03890610e7c9060009087908b9060040161200b565b6020604051808303816000875af1158015610e9b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ebf9190611f8a565b90505b83811015610ee25760405162461bcd60e51b81526004016104a99061202c565b60cc546040518281526001600160a01b039182169188169033907f342e7ff505a8a0364cd0dc2ff195c315e43bce86b204846ecd36913e117b109e9060200160405180910390a4600160975595945050505050565b600054610100900460ff1615808015610f575750600054600160ff909116105b80610f715750303b158015610f71575060005460ff166001145b610fd45760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016104a9565b6000805460ff191660011790558015610ff7576000805461ff0019166101001790555b610fff611902565b611007611931565b61100f611960565b60cb80546001600160a01b03199081166001600160a01b038c81169190911790925560cc805482168b841690811790915560cd805483168b851617905560c9805483168a851617905560ca8054831689851617905560cf805462ffffff60a01b1916600160a01b62ffffff8a160217905560d08054831687851617905560d1805490921692851692909217905560405163095ea7b360e01b815263095ea7b3906110c190869060001990600401611fa3565b6020604051808303816000875af11580156110e0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111049190611fcc565b5060405163095ea7b360e01b81526001600160a01b038a169063095ea7b39061113590869060001990600401611fa3565b6020604051808303816000875af1158015611154573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111789190611fcc565b5060405163095ea7b360e01b81526001600160a01b0389169063095ea7b3906111a990889060001990600401611fa3565b6020604051808303816000875af11580156111c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111ec9190611fcc565b5060405163095ea7b360e01b81526001600160a01b038a169063095ea7b39061121d90889060001990600401611fa3565b6020604051808303816000875af115801561123c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112609190611fcc565b5060405163095ea7b360e01b81526001600160a01b038a169063095ea7b39061129190899060001990600401611fa3565b6020604051808303816000875af11580156112b0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112d49190611fcc565b50801561131b576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050505050505050565b6002609754036113485760405162461bcd60e51b81526004016104a990611f53565b600260975533600090815260ce6020526040902054806113a15760405162461bcd60e51b81526020600482015260146024820152731a185cc81b9bdd0819dbdd0818481c1c9bd99a5d60621b60448201526064016104a9565b60cb546040516370a0823160e01b815282916001600160a01b0316906370a08231906113d1903090600401611dbb565b602060405180830381865afa1580156113ee573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114129190611f8a565b10156114565760405162461bcd60e51b81526020600482015260136024820152721a5b9cdd59999a58da595b9d08185b5bdd5b9d606a1b60448201526064016104a9565b60cb5460405163a9059cbb60e01b81526001600160a01b039091169063a9059cbb906114889085908590600401611fa3565b6020604051808303816000875af11580156114a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114cb9190611fcc565b5033600090815260ce6020526040812080548392906114eb908490612069565b909155505060cb546040518281526001600160a01b03918216918416907f70eb43c4a8ae8c40502dcf22436c509c28d6ff421cf07c491be56984bd9870689060200160405180910390a350506001609755565b60006002609754036115625760405162461bcd60e51b81526004016104a990611f53565b600260975560cc546040516323b872dd60e01b81526001600160a01b03909116906323b872dd9061159b90339030908790600401611fe7565b6020604051808303816000875af11580156115ba573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115de9190611fcc565b506115e88261198f565b600160975592915050565b60006002609754036116175760405162461bcd60e51b81526004016104a990611f53565b600260975560cc5460408051630d0e30db60e41b8152905134926001600160a01b03169163d0e30db091849160048082019260009290919082900301818588803b15801561166457600080fd5b505af1158015611678573d6000803e3d6000fd5b50505050506116868161198f565b915050600160975590565b61169961170a565b6001600160a01b0381166116fe5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016104a9565b61170781611764565b50565b6033546001600160a01b03163314610c795760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104a9565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600080604051806101000160405280886001600160a01b03168152602001876001600160a01b0316815260200160cf60149054906101000a900462ffffff1662ffffff168152602001846001600160a01b031681526020014261012c61181c9190612080565b815260208082018890526040808301889052600060609384015260ca54815163414bf38960e01b815285516001600160a01b03908116600483015293860151841660248201529185015162ffffff16604483015292840151821660648201526080840151608482015260a084015160a482015260c084015160c482015260e0840151821660e4820152929350169063414bf38990610104016020604051808303816000875af11580156118d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118f79190611f8a565b979650505050505050565b600054610100900460ff166119295760405162461bcd60e51b81526004016104a990612098565b610c79611d2a565b600054610100900460ff166119585760405162461bcd60e51b81526004016104a990612098565b610c79611d5a565b600054610100900460ff166119875760405162461bcd60e51b81526004016104a990612098565b610c79611d8d565b60008082116119d95760405162461bcd60e51b81526020600482015260166024820152751a5b9d985b1a590819195c1bdcda5d08185b5bdd5b9d60521b60448201526064016104a9565b60cc5460cb546000916119f9916001600160a01b039182169116856105f8565b60d054604051631b427eb960e01b815260016004820152602481018690526000604482018190529293506001600160a01b0390911690631b427eb9906064016040805180830381865afa158015611a54573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a7891906120e3565b509050600081831115611aab5760cc5460cb54611aa4916001600160a01b0390811691168785306117b6565b9050611b26565b60d054604051630b6adc0760e31b81526001600160a01b0390911690635b56e03890611ae0906001908990309060040161200b565b6020604051808303816000875af1158015611aff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b239190611f8a565b90505b81811015611b465760405162461bcd60e51b81526004016104a99061202c565b60cb546040516370a0823160e01b815282916001600160a01b0316906370a0823190611b76903090600401611dbb565b602060405180830381865afa158015611b93573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bb79190611f8a565b1015611c1e5760405162461bcd60e51b815260206004820152603060248201527f696e73756666696369656e7420616d6f756e74206f66204365726f73526f757460448201526f32b91034b71031b2b93a103a37b5b2b760811b60648201526084016104a9565b6000611c2a8383612069565b33600090815260ce6020526040812080549293508392909190611c4e908490612080565b909155505060c9546001600160a01b0316632f4f21e233611c6f8486612069565b6040518363ffffffff1660e01b8152600401611c8c929190611fa3565b6020604051808303816000875af1158015611cab573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ccf9190611f8a565b60cc549095506001600160a01b0316337fdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d7611d0a8486612069565b60408051918252602082018690520160405180910390a350505050919050565b600054610100900460ff16611d515760405162461bcd60e51b81526004016104a990612098565b610c7933611764565b600054610100900460ff16611d815760405162461bcd60e51b81526004016104a990612098565b6065805460ff19169055565b600054610100900460ff16611db45760405162461bcd60e51b81526004016104a990612098565b6001609755565b6001600160a01b0391909116815260200190565b80356001600160a01b0381168114611de657600080fd5b919050565b600060208284031215611dfd57600080fd5b6106ae82611dcf565b600080600060608486031215611e1b57600080fd5b611e2484611dcf565b9250611e3260208501611dcf565b9150604084013590509250925092565b803562ffffff81168114611de657600080fd5b600060208284031215611e6757600080fd5b6106ae82611e42565b600080600060608486031215611e8557600080fd5b611e8e84611dcf565b95602085013595506040909401359392505050565b600080600080600080600080610100898b031215611ec057600080fd5b611ec989611dcf565b9750611ed760208a01611dcf565b9650611ee560408a01611dcf565b9550611ef360608a01611dcf565b9450611f0160808a01611dcf565b9350611f0f60a08a01611e42565b9250611f1d60c08a01611dcf565b9150611f2b60e08a01611dcf565b90509295985092959890939650565b600060208284031215611f4c57600080fd5b5035919050565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b600060208284031215611f9c57600080fd5b5051919050565b6001600160a01b03929092168252602082015260400190565b80518015158114611de657600080fd5b600060208284031215611fde57600080fd5b6106ae82611fbc565b6001600160a01b039384168152919092166020820152604081019190915260600190565b921515835260208301919091526001600160a01b0316604082015260600190565b6020808252600d908201526c707269636520746f6f206c6f7760981b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b60008282101561207b5761207b612053565b500390565b6000821982111561209357612093612053565b500190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b600080604083850312156120f657600080fd5b8251915061210660208401611fbc565b9050925092905056fea26469706673582212203bf80a85a010ed8246d0f9012b5b8a9497973ad8121bea09e7a5ed2fc38cc25b64736f6c634300080f0033

Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.