ETH Price: $2,149.28 (+0.79%)

Contract

0x87Be53F4E45f3EAFa4b8f2dD8B852115Bb1f16Ba
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Token Holdings

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Revoke Role234818832025-10-01 8:51:47170 days ago1759308707IN
0x87Be53F4...5Bb1f16Ba
0 ETH0.000049371.7980308
Grant Role234818382025-10-01 8:42:47170 days ago1759308167IN
0x87Be53F4...5Bb1f16Ba
0 ETH0.000037080.72125839
Revoke Role234816582025-10-01 8:06:35170 days ago1759305995IN
0x87Be53F4...5Bb1f16Ba
0 ETH0.000003560.12086136
Grant Role234816562025-10-01 8:06:11170 days ago1759305971IN
0x87Be53F4...5Bb1f16Ba
0 ETH0.000006430.12508054

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Method Block
From
To
Deposit246899032026-03-19 7:01:3529 hrs ago1773903695
0x87Be53F4...5Bb1f16Ba
0.00253907 ETH
Transfer*246899032026-03-19 7:01:3529 hrs ago1773903695
0x87Be53F4...5Bb1f16Ba
0.00253907 ETH
Deposit246764882026-03-17 10:01:353 days ago1773741695
0x87Be53F4...5Bb1f16Ba
0.00574991 ETH
Transfer*246764882026-03-17 10:01:353 days ago1773741695
0x87Be53F4...5Bb1f16Ba
0.00574991 ETH
Deposit246698522026-03-16 11:46:354 days ago1773661595
0x87Be53F4...5Bb1f16Ba
0.0045254 ETH
Transfer*246698522026-03-16 11:46:354 days ago1773661595
0x87Be53F4...5Bb1f16Ba
0.0045254 ETH
Deposit246682902026-03-16 6:31:354 days ago1773642695
0x87Be53F4...5Bb1f16Ba
0.00319355 ETH
Transfer*246682902026-03-16 6:31:354 days ago1773642695
0x87Be53F4...5Bb1f16Ba
0.00319355 ETH
Deposit246528232026-03-14 2:46:236 days ago1773456383
0x87Be53F4...5Bb1f16Ba
0.00180025 ETH
Transfer*246528232026-03-14 2:46:236 days ago1773456383
0x87Be53F4...5Bb1f16Ba
0.00180025 ETH
Deposit246381152026-03-12 1:31:238 days ago1773279083
0x87Be53F4...5Bb1f16Ba
0.00273609 ETH
Transfer*246381152026-03-12 1:31:238 days ago1773279083
0x87Be53F4...5Bb1f16Ba
0.00273609 ETH
Deposit246015682026-03-06 23:01:3513 days ago1772838095
0x87Be53F4...5Bb1f16Ba
0.00850186 ETH
Transfer*246015682026-03-06 23:01:3513 days ago1772838095
0x87Be53F4...5Bb1f16Ba
0.00850186 ETH
Deposit245988052026-03-06 13:46:3513 days ago1772804795
0x87Be53F4...5Bb1f16Ba
0.00420752 ETH
Transfer*245988052026-03-06 13:46:3513 days ago1772804795
0x87Be53F4...5Bb1f16Ba
0.00420752 ETH
Deposit245400302026-02-26 8:55:2322 days ago1772096123
0x87Be53F4...5Bb1f16Ba
0.0059106 ETH
Transfer*245400302026-02-26 8:55:2322 days ago1772096123
0x87Be53F4...5Bb1f16Ba
0.0059106 ETH
Deposit245278552026-02-24 16:07:4723 days ago1771949267
0x87Be53F4...5Bb1f16Ba
0.00634282 ETH
Transfer*245278552026-02-24 16:07:4723 days ago1771949267
0x87Be53F4...5Bb1f16Ba
0.00634282 ETH
Deposit244892722026-02-19 7:03:2329 days ago1771484603
0x87Be53F4...5Bb1f16Ba
0.49156941 ETH
Transfer*244892722026-02-19 7:03:2329 days ago1771484603
0x87Be53F4...5Bb1f16Ba
0.49156941 ETH
Deposit244881522026-02-19 3:18:2329 days ago1771471103
0x87Be53F4...5Bb1f16Ba
0.00232854 ETH
Transfer*244881522026-02-19 3:18:2329 days ago1771471103
0x87Be53F4...5Bb1f16Ba
0.00232854 ETH
Deposit244358642026-02-11 20:17:2336 days ago1770841043
0x87Be53F4...5Bb1f16Ba
0.00149339 ETH
View All Internal Transactions
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
EUSDUSDCBeefyYieldVault

Compiler Version
v0.8.28+commit.7893614a

Optimization Enabled:
Yes with 10000 runs

Other Settings:
cancun EvmVersion
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

/*────────────────────────────── OpenZeppelin ──────────────────────────*/
import { Math } from "@openzeppelin/contracts/utils/math/Math.sol";
import { AccessControl } from "@openzeppelin/contracts/access/AccessControl.sol";
import { Address } from "@openzeppelin/contracts/utils/Address.sol";
import { IBeefyVault } from "src/vendor/beefy/IBeefyVault.sol";
import { ICurvePool } from "src/vendor/curve/ICurvePool.sol";

/*─────────────────────────────── Interfaces ───────────────────────────*/
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { IEUSDUSDCBeefyYieldVault } from "src/interfaces/IEUSDUSDCBeefyYieldVault.sol";
import { IQuoter } from "src/vendor/uniswap_v3/IQuoter.sol";
import { ISwapRouter } from "src/vendor/uniswap_v3/ISwapRouter.sol";
import { IWETH } from "src/vendor/various/IWETH.sol";
import { IYieldManager } from "src/interfaces/IYieldManager.sol";
import { IYieldVault } from "src/interfaces/IYieldVault.sol";
import { ReentrancyGuard } from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import { AggregatorV3Interface } from "src/vendor/chainlink/AggregatorV3Interface.sol";

/**
 * @title EUSDUSDCBeefyYieldVault
 * @notice Implements an underlying vault asset-denominated yield strategy:
 *         ① Wraps ETH → WETH → USDC (Uniswap V3),
 *         ② Adds liquidity to USDe/USDC Curve pool,
 *         ③ Stakes LP tokens in a Beefy vault,
 *         ④ Realises yield in ETH on demand.
 */
contract EUSDUSDCBeefyYieldVault is AccessControl, ReentrancyGuard, IEUSDUSDCBeefyYieldVault {
    using SafeERC20 for IERC20;

    /*//////////////////////////////////////////////////////////////
                               ROLES
    //////////////////////////////////////////////////////////////*/

    /// @inheritdoc IEUSDUSDCBeefyYieldVault
    bytes32 public constant ADMIN_ROLE = keccak256("ADMIN_ROLE");
    /// @inheritdoc IEUSDUSDCBeefyYieldVault
    bytes32 public constant YIELDMANAGER_ROLE = keccak256("YIELDMANAGER_ROLE");

    /*//////////////////////////////////////////////////////////////
                       IMMUTABLE REFERENCES
    //////////////////////////////////////////////////////////////*/

    /// @inheritdoc IEUSDUSDCBeefyYieldVault
    address public immutable WETH;
    /// @inheritdoc IEUSDUSDCBeefyYieldVault
    address public immutable USDC;

    /// @inheritdoc IEUSDUSDCBeefyYieldVault
    ISwapRouter public immutable swapRouter;
    /// @inheritdoc IEUSDUSDCBeefyYieldVault
    IQuoter public immutable quoter;
    /// @inheritdoc IEUSDUSDCBeefyYieldVault
    ICurvePool public immutable curvePool;
    /// @inheritdoc IEUSDUSDCBeefyYieldVault
    IBeefyVault public immutable beefy;
    /// @inheritdoc IEUSDUSDCBeefyYieldVault
    AggregatorV3Interface public immutable ethUsdFeed;
    /// @inheritdoc IEUSDUSDCBeefyYieldVault
    AggregatorV3Interface public immutable usdcUsdFeed;

    /*//////////////////////////////////////////////////////////////
                               CONSTANTS
    //////////////////////////////////////////////////////////////*/

    /// @inheritdoc IEUSDUSDCBeefyYieldVault
    uint24 public constant UNIV3_FEE_TIER = 500; // 0.05 %
    uint24 public constant ETH_USD_ORACLE_MAX_AGE = 3600; // 1 hour
    uint24 public constant USDC_USD_ORACLE_MAX_AGE = 82800; // 23 hours

    /*//////////////////////////////////////////////////////////////
                             CONFIGURABLES
    //////////////////////////////////////////////////////////////*/

    /// @inheritdoc IEUSDUSDCBeefyYieldVault
    uint16 public slippageBps = 50; // 0.50 %

    /*//////////////////////////////////////////////////////////////
                             ACCOUNTING
    //////////////////////////////////////////////////////////////*/

    /// @inheritdoc IEUSDUSDCBeefyYieldVault
    uint256 public principalShares;
    /// @inheritdoc IEUSDUSDCBeefyYieldVault
    uint256 public principalValue;

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

    /**
     * @notice Initializes the vault.
     * @param admin Admin address granted {ADMIN_ROLE}.
     * @param yieldManager YieldManager address granted {YIELDMANAGER_ROLE}.
     * @param _weth WETH token address.
     * @param _usdc USDC token address.
     * @param _swapRouter Uniswap V3 router.
     * @param _quoter Uniswap V3 quoter.
     * @param _curvePool Curve pool for USDe/USDC LP.
     * @param _beefy Beefy vault that stakes the LP tokens.
     */
    constructor(
        address admin,
        address yieldManager,
        address _weth,
        address _usdc,
        address _swapRouter,
        address _quoter,
        address _curvePool,
        address _beefy,
        address _ethUsdFeed,
        address _usdcUsdFeed
    ) {
        if (admin == address(0)) revert InvalidAddress();
        if (yieldManager == address(0)) revert InvalidAddress();
        if (_weth == address(0)) revert InvalidAddress();
        if (_usdc == address(0)) revert InvalidAddress();
        if (_swapRouter == address(0)) revert InvalidAddress();
        if (_quoter == address(0)) revert InvalidAddress();
        if (_curvePool == address(0)) revert InvalidAddress();
        if (_beefy == address(0)) revert InvalidAddress();
        if (_ethUsdFeed == address(0)) revert InvalidAddress();
        if (_usdcUsdFeed == address(0)) revert InvalidAddress();

        _grantRole(ADMIN_ROLE, admin);
        _grantRole(YIELDMANAGER_ROLE, yieldManager);
        _setRoleAdmin(ADMIN_ROLE, ADMIN_ROLE);
        _setRoleAdmin(YIELDMANAGER_ROLE, ADMIN_ROLE);

        WETH = _weth;
        USDC = _usdc;
        swapRouter = ISwapRouter(_swapRouter);
        quoter = IQuoter(_quoter);
        curvePool = ICurvePool(_curvePool);
        beefy = IBeefyVault(_beefy);
        ethUsdFeed = AggregatorV3Interface(_ethUsdFeed);
        usdcUsdFeed = AggregatorV3Interface(_usdcUsdFeed);
    }

    /*//////////////////////////////////////////////////////////////
                                DEPOSIT
    //////////////////////////////////////////////////////////////*/

    /// @inheritdoc IYieldVault
    function deposit()
        external
        payable
        override
        nonReentrant
        onlyRole(YIELDMANAGER_ROLE)
        returns (uint256 depositValue)
    {
        if (msg.value == 0) revert NoEthProvided();

        /* Wrap ETH → WETH */
        IWETH(WETH).deposit{ value: msg.value }();

        /* WETH → USDC via UniV3, using Chainlink Oracle for min-out */
        uint256 chainLinkQuoteUsdc = _chainlinkQuoteEthToUsdc(msg.value);
        uint256 usdcMin = (chainLinkQuoteUsdc * (10_000 - slippageBps)) / 10_000;
        uint256 uniV3Quote = _quoteEthToUsdc(msg.value);
        if (uniV3Quote < usdcMin) revert SlippageExceeded();
        uint256 usdcOut = _swapExactInput(WETH, USDC, msg.value, uniV3Quote);

        /* Add liquidity (USDe/USDC) → LP tokens */
        uint256[] memory amounts = new uint256[](2); // [USDe, USDC]; we only fill USDC index 1
        amounts[0] = 0;
        amounts[1] = usdcOut;
        uint256 lpExpected = (usdcOut * 1e30) / curvePool.get_virtual_price();
        uint256 minMint = (lpExpected * (10_000 - slippageBps)) / 10_000;

        IERC20(USDC).approve(address(curvePool), usdcOut);
        uint256 lpMinted = curvePool.add_liquidity(amounts, minMint);
        if (lpMinted == 0) revert SlippageExceeded();

        /* Stake LP into Beefy */
        uint256 preShares = beefy.balanceOf(address(this));
        IERC20(beefy.want()).approve(address(beefy), lpMinted);
        beefy.depositAll();
        uint256 sharesMinted = beefy.balanceOf(address(this)) - preShares;
        if (sharesMinted == 0) revert NoSharesMinted();

        /* Bookkeeping */
        uint256 ppsNow = beefy.getPricePerFullShare();
        principalShares += sharesMinted;
        depositValue = (sharesMinted * ppsNow) / 1e18;
        if (depositValue == 0) revert ZeroDepositValue();
        principalValue += depositValue;

        emit Deposited(msg.sender, msg.value, sharesMinted);
    }

    /*//////////////////////////////////////////////////////////////
                                 CLAIM
    //////////////////////////////////////////////////////////////*/

    /// @inheritdoc IYieldVault
    function claimYield() external override nonReentrant onlyRole(YIELDMANAGER_ROLE) {
        bool flowActive = IYieldManager(msg.sender).yieldFlowActive();
        uint256 ppsNow = beefy.getPricePerFullShare();
        uint256 currentVaultValue = (principalShares * ppsNow) / 1e18;

        if (!flowActive || currentVaultValue <= principalValue) {
            emit YieldClaimed(0, 0);
            return;
        }

        uint256 yieldShares = ((currentVaultValue - principalValue) * 1e18) / ppsNow;
        if (yieldShares == 0) revert NothingToClaim();

        /* Beefy withdraw yield → LP */
        uint256 lpBefore = IERC20(beefy.want()).balanceOf(address(this));
        beefy.withdraw(yieldShares);
        uint256 lpOut = IERC20(beefy.want()).balanceOf(address(this)) - lpBefore;

        /* LP → USDC */
        uint256 expectedUsdc = (lpOut * curvePool.get_virtual_price()) / 1e30;
        uint256 minUsdc = (expectedUsdc * (10_000 - slippageBps)) / 10_000;
        IERC20(beefy.want()).approve(address(curvePool), lpOut);
        uint256 usdcOut = curvePool.remove_liquidity_one_coin(lpOut, 1, minUsdc);

        /* USDC → ETH */
        uint256 chainLinkQuoteEth = _chainlinkQuoteUsdcToEth(usdcOut);
        uint256 ethMin = (chainLinkQuoteEth * (10_000 - slippageBps)) / 10_000;
        uint256 uniV3Quote = _quoteUsdcToEth(usdcOut);
        if (uniV3Quote < ethMin) revert SlippageExceeded();
        uint256 wethOut = _swapExactInput(USDC, WETH, usdcOut, uniV3Quote);
        IWETH(WETH).withdraw(wethOut);

        /* Update principal BEFORE transfer */
        principalShares -= yieldShares;
        principalValue = (principalShares * ppsNow) / 1e18;

        Address.sendValue(payable(msg.sender), wethOut);
        emit YieldClaimed(yieldShares, wethOut);
    }

    /*//////////////////////////////////////////////////////////////
                        PRINCIPAL RETRIEVAL
    //////////////////////////////////////////////////////////////*/

    /// @inheritdoc IYieldVault
    function retrievePrincipal(uint256 depositValue) external override nonReentrant onlyRole(YIELDMANAGER_ROLE) {
        if (depositValue == 0) revert CannotRetrieveZero();

        uint256 ppsNow = beefy.getPricePerFullShare();

        uint256 sharesToWithdraw = (depositValue * 1e18) / ppsNow;
        if (sharesToWithdraw == 0) revert NoSharesToWithdraw();
        if (sharesToWithdraw > principalShares) {
            sharesToWithdraw = principalShares;
            depositValue = (sharesToWithdraw * ppsNow) / 1e18;
        }

        /* Pre-bookkeeping */
        uint256 pvSlice = (principalValue * sharesToWithdraw) / principalShares;
        principalShares -= sharesToWithdraw;
        principalValue -= pvSlice;

        /* Beefy withdraw → LP */
        uint256 lpBefore = IERC20(beefy.want()).balanceOf(address(this));
        beefy.withdraw(sharesToWithdraw);
        uint256 lpOut = IERC20(beefy.want()).balanceOf(address(this)) - lpBefore;

        /* LP → USDC */
        uint256 expectedUsdc = (lpOut * curvePool.get_virtual_price()) / 1e30;
        uint256 minUsdc = (expectedUsdc * (10_000 - slippageBps)) / 10_000;
        IERC20(beefy.want()).approve(address(curvePool), lpOut);
        uint256 usdcOut = curvePool.remove_liquidity_one_coin(lpOut, 1, minUsdc);

        /* USDC → ETH */
        uint256 chainLinkQuoteEth = _chainlinkQuoteUsdcToEth(usdcOut);
        uint256 ethMin = (chainLinkQuoteEth * (10_000 - slippageBps)) / 10_000;
        uint256 uniV3Quote = _quoteUsdcToEth(usdcOut);
        if (uniV3Quote < ethMin) revert SlippageExceeded();
        uint256 wethOut = _swapExactInput(USDC, WETH, usdcOut, uniV3Quote);
        IWETH(WETH).withdraw(wethOut);

        /* Transfer */
        Address.sendValue(payable(msg.sender), wethOut);
        emit PrincipalRetrieved(sharesToWithdraw, wethOut);
    }

    /*//////////////////////////////////////////////////////////////
                        ADMIN CONFIG SETTER
    //////////////////////////////////////////////////////////////*/

    /// @inheritdoc IEUSDUSDCBeefyYieldVault
    function setSlippageBps(uint16 bps) external override onlyRole(ADMIN_ROLE) {
        if (bps > 1_000) revert SlippageTooHigh(); // hard cap 10 %
        slippageBps = bps;
        emit SlippageSet(bps);
    }

    /*//////////////////////////////////////////////////////////////
                    INTERNAL SWAP & QUOTE HELPERS
    //////////////////////////////////////////////////////////////*/

    /**
     * @notice Executes an exact-input swap on UniV3.
     * @param tokenIn Token to sell.
     * @param tokenOut Token to buy.
     * @param amountIn Exact input amount.
     * @param amountOutMin Minimum acceptable output.
     * @return amountOut Tokens received.
     */
    function _swapExactInput(
        address tokenIn,
        address tokenOut,
        uint256 amountIn,
        uint256 amountOutMin
    ) internal returns (uint256 amountOut) {
        IERC20(tokenIn).approve(address(swapRouter), amountIn);

        ISwapRouter.ExactInputSingleParams memory p = ISwapRouter.ExactInputSingleParams({
            tokenIn: tokenIn,
            tokenOut: tokenOut,
            fee: UNIV3_FEE_TIER,
            recipient: address(this),
            deadline: block.timestamp,
            amountIn: amountIn,
            amountOutMinimum: amountOutMin,
            sqrtPriceLimitX96: 0
        });

        amountOut = swapRouter.exactInputSingle(p);
    }

    /* ---------- Chainlink quoter wrappers ---------- */

    function _chainlinkQuoteEthToUsdc(uint256 ethIn) internal view returns (uint256) {
        uint256 q = _getUSDCperETH_6d(); // USDC per ETH (6d)
        return Math.mulDiv(ethIn, q, 1e18);
    }

    function _chainlinkQuoteUsdcToEth(uint256 usdcIn) internal view returns (uint256) {
        uint256 q = _getUSDCperETH_6d(); // USDC per ETH (6d)
        return Math.mulDiv(usdcIn, 1e18, q);
    }

    /// @dev Returns USDC per 1 ETH, 6 decimals
    function _getUSDCperETH_6d() internal view returns (uint256 qUsdcPerEth6) {
        (, int256 ethUsd, , uint256 ethUpdated, ) = ethUsdFeed.latestRoundData();
        (, int256 usdcUsd, , uint256 usdcUpdated, ) = usdcUsdFeed.latestRoundData();
        if (ethUsd <= 0 || usdcUsd <= 0) revert OracleInvalid();
        if (block.timestamp - ethUpdated > ETH_USD_ORACLE_MAX_AGE) revert OracleStale();
        if (block.timestamp - usdcUpdated > USDC_USD_ORACLE_MAX_AGE) revert OracleStale();

        // Both feeds 8 decimals. USDC/ETH = (ETH/USD) / (USDC/USD).
        qUsdcPerEth6 = Math.mulDiv(uint256(ethUsd), 1e6, uint256(usdcUsd)); // scale to 6d
    }

    /* ---------- Uni V3 quoter wrappers ---------- */

    function _quoteEthToUsdc(uint256 ethIn) internal returns (uint256) {
        return quoter.quoteExactInputSingle(WETH, USDC, UNIV3_FEE_TIER, ethIn, 0);
    }

    function _quoteUsdcToEth(uint256 usdcIn) internal returns (uint256) {
        return quoter.quoteExactInputSingle(USDC, WETH, UNIV3_FEE_TIER, usdcIn, 0);
    }

    /*//////////////////////////////////////////////////////////////
                               RECEIVE
    //////////////////////////////////////////////////////////////*/

    /**
     * @notice Allow this contract to receive ETH (WETH unwraps).
     */
    receive() external payable {}
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/Math.sol)

pragma solidity ^0.8.20;

import {Panic} from "../Panic.sol";
import {SafeCast} from "./SafeCast.sol";

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    enum Rounding {
        Floor, // Toward negative infinity
        Ceil, // Toward positive infinity
        Trunc, // Toward zero
        Expand // Away from zero
    }

    /**
     * @dev Returns the addition of two unsigned integers, with an success flag (no overflow).
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, with an success flag (no overflow).
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
        unchecked {
            if (b > a) return (false, 0);
            return (true, a - b);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an success flag (no overflow).
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
        unchecked {
            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
            // benefit is lost if 'b' is also tested.
            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
            if (a == 0) return (true, 0);
            uint256 c = a * b;
            if (c / a != b) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a success flag (no division by zero).
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a / b);
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a success flag (no division by zero).
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a % b);
        }
    }

    /**
     * @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant.
     *
     * IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.
     * However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute
     * one branch when needed, making this function more expensive.
     */
    function ternary(bool condition, uint256 a, uint256 b) internal pure returns (uint256) {
        unchecked {
            // branchless ternary works because:
            // b ^ (a ^ b) == a
            // b ^ 0 == b
            return b ^ ((a ^ b) * SafeCast.toUint(condition));
        }
    }

    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return ternary(a > b, a, b);
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return ternary(a < b, a, b);
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds towards infinity instead
     * of rounding towards zero.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        if (b == 0) {
            // Guarantee the same behavior as in a regular Solidity division.
            Panic.panic(Panic.DIVISION_BY_ZERO);
        }

        // The following calculation ensures accurate ceiling division without overflow.
        // Since a is non-zero, (a - 1) / b will not overflow.
        // The largest possible result occurs when (a - 1) / b is type(uint256).max,
        // but the largest value we can obtain is type(uint256).max - 1, which happens
        // when a = type(uint256).max and b = 1.
        unchecked {
            return SafeCast.toUint(a > 0) * ((a - 1) / b + 1);
        }
    }

    /**
     * @dev Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
     * denominator == 0.
     *
     * Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by
     * Uniswap Labs also under MIT license.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2²⁵⁶ and mod 2²⁵⁶ - 1, then use
            // the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2²⁵⁶ + prod0.
            uint256 prod0 = x * y; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                // Solidity will revert if denominator == 0, unlike the div opcode on its own.
                // The surrounding unchecked block does not change this fact.
                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
                return prod0 / denominator;
            }

            // Make sure the result is less than 2²⁵⁶. Also prevents denominator == 0.
            if (denominator <= prod1) {
                Panic.panic(ternary(denominator == 0, Panic.DIVISION_BY_ZERO, Panic.UNDER_OVERFLOW));
            }

            ///////////////////////////////////////////////
            // 512 by 256 division.
            ///////////////////////////////////////////////

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator and compute largest power of two divisor of denominator.
            // Always >= 1. See https://cs.stackexchange.com/q/138556/92363.

            uint256 twos = denominator & (0 - denominator);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

                // Flip twos such that it is 2²⁵⁶ / twos. If twos is zero, then it becomes one.
                twos := add(div(sub(0, twos), twos), 1)
            }

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * twos;

            // Invert denominator mod 2²⁵⁶. Now that denominator is an odd number, it has an inverse modulo 2²⁵⁶ such
            // that denominator * inv ≡ 1 mod 2²⁵⁶. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv ≡ 1 mod 2⁴.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also
            // works in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2⁸
            inverse *= 2 - denominator * inverse; // inverse mod 2¹⁶
            inverse *= 2 - denominator * inverse; // inverse mod 2³²
            inverse *= 2 - denominator * inverse; // inverse mod 2⁶⁴
            inverse *= 2 - denominator * inverse; // inverse mod 2¹²⁸
            inverse *= 2 - denominator * inverse; // inverse mod 2²⁵⁶

            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
            // This will give us the correct result modulo 2²⁵⁶. Since the preconditions guarantee that the outcome is
            // less than 2²⁵⁶, this is the final result. We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inverse;
            return result;
        }
    }

    /**
     * @dev Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
        return mulDiv(x, y, denominator) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0);
    }

    /**
     * @dev Calculate the modular multiplicative inverse of a number in Z/nZ.
     *
     * If n is a prime, then Z/nZ is a field. In that case all elements are inversible, except 0.
     * If n is not a prime, then Z/nZ is not a field, and some elements might not be inversible.
     *
     * If the input value is not inversible, 0 is returned.
     *
     * NOTE: If you know for sure that n is (big) a prime, it may be cheaper to use Fermat's little theorem and get the
     * inverse using `Math.modExp(a, n - 2, n)`. See {invModPrime}.
     */
    function invMod(uint256 a, uint256 n) internal pure returns (uint256) {
        unchecked {
            if (n == 0) return 0;

            // The inverse modulo is calculated using the Extended Euclidean Algorithm (iterative version)
            // Used to compute integers x and y such that: ax + ny = gcd(a, n).
            // When the gcd is 1, then the inverse of a modulo n exists and it's x.
            // ax + ny = 1
            // ax = 1 + (-y)n
            // ax ≡ 1 (mod n) # x is the inverse of a modulo n

            // If the remainder is 0 the gcd is n right away.
            uint256 remainder = a % n;
            uint256 gcd = n;

            // Therefore the initial coefficients are:
            // ax + ny = gcd(a, n) = n
            // 0a + 1n = n
            int256 x = 0;
            int256 y = 1;

            while (remainder != 0) {
                uint256 quotient = gcd / remainder;

                (gcd, remainder) = (
                    // The old remainder is the next gcd to try.
                    remainder,
                    // Compute the next remainder.
                    // Can't overflow given that (a % gcd) * (gcd // (a % gcd)) <= gcd
                    // where gcd is at most n (capped to type(uint256).max)
                    gcd - remainder * quotient
                );

                (x, y) = (
                    // Increment the coefficient of a.
                    y,
                    // Decrement the coefficient of n.
                    // Can overflow, but the result is casted to uint256 so that the
                    // next value of y is "wrapped around" to a value between 0 and n - 1.
                    x - y * int256(quotient)
                );
            }

            if (gcd != 1) return 0; // No inverse exists.
            return ternary(x < 0, n - uint256(-x), uint256(x)); // Wrap the result if it's negative.
        }
    }

    /**
     * @dev Variant of {invMod}. More efficient, but only works if `p` is known to be a prime greater than `2`.
     *
     * From https://en.wikipedia.org/wiki/Fermat%27s_little_theorem[Fermat's little theorem], we know that if p is
     * prime, then `a**(p-1) ≡ 1 mod p`. As a consequence, we have `a * a**(p-2) ≡ 1 mod p`, which means that
     * `a**(p-2)` is the modular multiplicative inverse of a in Fp.
     *
     * NOTE: this function does NOT check that `p` is a prime greater than `2`.
     */
    function invModPrime(uint256 a, uint256 p) internal view returns (uint256) {
        unchecked {
            return Math.modExp(a, p - 2, p);
        }
    }

    /**
     * @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m)
     *
     * Requirements:
     * - modulus can't be zero
     * - underlying staticcall to precompile must succeed
     *
     * IMPORTANT: The result is only valid if the underlying call succeeds. When using this function, make
     * sure the chain you're using it on supports the precompiled contract for modular exponentiation
     * at address 0x05 as specified in https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise,
     * the underlying function will succeed given the lack of a revert, but the result may be incorrectly
     * interpreted as 0.
     */
    function modExp(uint256 b, uint256 e, uint256 m) internal view returns (uint256) {
        (bool success, uint256 result) = tryModExp(b, e, m);
        if (!success) {
            Panic.panic(Panic.DIVISION_BY_ZERO);
        }
        return result;
    }

    /**
     * @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m).
     * It includes a success flag indicating if the operation succeeded. Operation will be marked as failed if trying
     * to operate modulo 0 or if the underlying precompile reverted.
     *
     * IMPORTANT: The result is only valid if the success flag is true. When using this function, make sure the chain
     * you're using it on supports the precompiled contract for modular exponentiation at address 0x05 as specified in
     * https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, the underlying function will succeed given the lack
     * of a revert, but the result may be incorrectly interpreted as 0.
     */
    function tryModExp(uint256 b, uint256 e, uint256 m) internal view returns (bool success, uint256 result) {
        if (m == 0) return (false, 0);
        assembly ("memory-safe") {
            let ptr := mload(0x40)
            // | Offset    | Content    | Content (Hex)                                                      |
            // |-----------|------------|--------------------------------------------------------------------|
            // | 0x00:0x1f | size of b  | 0x0000000000000000000000000000000000000000000000000000000000000020 |
            // | 0x20:0x3f | size of e  | 0x0000000000000000000000000000000000000000000000000000000000000020 |
            // | 0x40:0x5f | size of m  | 0x0000000000000000000000000000000000000000000000000000000000000020 |
            // | 0x60:0x7f | value of b | 0x<.............................................................b> |
            // | 0x80:0x9f | value of e | 0x<.............................................................e> |
            // | 0xa0:0xbf | value of m | 0x<.............................................................m> |
            mstore(ptr, 0x20)
            mstore(add(ptr, 0x20), 0x20)
            mstore(add(ptr, 0x40), 0x20)
            mstore(add(ptr, 0x60), b)
            mstore(add(ptr, 0x80), e)
            mstore(add(ptr, 0xa0), m)

            // Given the result < m, it's guaranteed to fit in 32 bytes,
            // so we can use the memory scratch space located at offset 0.
            success := staticcall(gas(), 0x05, ptr, 0xc0, 0x00, 0x20)
            result := mload(0x00)
        }
    }

    /**
     * @dev Variant of {modExp} that supports inputs of arbitrary length.
     */
    function modExp(bytes memory b, bytes memory e, bytes memory m) internal view returns (bytes memory) {
        (bool success, bytes memory result) = tryModExp(b, e, m);
        if (!success) {
            Panic.panic(Panic.DIVISION_BY_ZERO);
        }
        return result;
    }

    /**
     * @dev Variant of {tryModExp} that supports inputs of arbitrary length.
     */
    function tryModExp(
        bytes memory b,
        bytes memory e,
        bytes memory m
    ) internal view returns (bool success, bytes memory result) {
        if (_zeroBytes(m)) return (false, new bytes(0));

        uint256 mLen = m.length;

        // Encode call args in result and move the free memory pointer
        result = abi.encodePacked(b.length, e.length, mLen, b, e, m);

        assembly ("memory-safe") {
            let dataPtr := add(result, 0x20)
            // Write result on top of args to avoid allocating extra memory.
            success := staticcall(gas(), 0x05, dataPtr, mload(result), dataPtr, mLen)
            // Overwrite the length.
            // result.length > returndatasize() is guaranteed because returndatasize() == m.length
            mstore(result, mLen)
            // Set the memory pointer after the returned data.
            mstore(0x40, add(dataPtr, mLen))
        }
    }

    /**
     * @dev Returns whether the provided byte array is zero.
     */
    function _zeroBytes(bytes memory byteArray) private pure returns (bool) {
        for (uint256 i = 0; i < byteArray.length; ++i) {
            if (byteArray[i] != 0) {
                return false;
            }
        }
        return true;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
     * towards zero.
     *
     * This method is based on Newton's method for computing square roots; the algorithm is restricted to only
     * using integer operations.
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        unchecked {
            // Take care of easy edge cases when a == 0 or a == 1
            if (a <= 1) {
                return a;
            }

            // In this function, we use Newton's method to get a root of `f(x) := x² - a`. It involves building a
            // sequence x_n that converges toward sqrt(a). For each iteration x_n, we also define the error between
            // the current value as `ε_n = | x_n - sqrt(a) |`.
            //
            // For our first estimation, we consider `e` the smallest power of 2 which is bigger than the square root
            // of the target. (i.e. `2**(e-1) ≤ sqrt(a) < 2**e`). We know that `e ≤ 128` because `(2¹²⁸)² = 2²⁵⁶` is
            // bigger than any uint256.
            //
            // By noticing that
            // `2**(e-1) ≤ sqrt(a) < 2**e → (2**(e-1))² ≤ a < (2**e)² → 2**(2*e-2) ≤ a < 2**(2*e)`
            // we can deduce that `e - 1` is `log2(a) / 2`. We can thus compute `x_n = 2**(e-1)` using a method similar
            // to the msb function.
            uint256 aa = a;
            uint256 xn = 1;

            if (aa >= (1 << 128)) {
                aa >>= 128;
                xn <<= 64;
            }
            if (aa >= (1 << 64)) {
                aa >>= 64;
                xn <<= 32;
            }
            if (aa >= (1 << 32)) {
                aa >>= 32;
                xn <<= 16;
            }
            if (aa >= (1 << 16)) {
                aa >>= 16;
                xn <<= 8;
            }
            if (aa >= (1 << 8)) {
                aa >>= 8;
                xn <<= 4;
            }
            if (aa >= (1 << 4)) {
                aa >>= 4;
                xn <<= 2;
            }
            if (aa >= (1 << 2)) {
                xn <<= 1;
            }

            // We now have x_n such that `x_n = 2**(e-1) ≤ sqrt(a) < 2**e = 2 * x_n`. This implies ε_n ≤ 2**(e-1).
            //
            // We can refine our estimation by noticing that the middle of that interval minimizes the error.
            // If we move x_n to equal 2**(e-1) + 2**(e-2), then we reduce the error to ε_n ≤ 2**(e-2).
            // This is going to be our x_0 (and ε_0)
            xn = (3 * xn) >> 1; // ε_0 := | x_0 - sqrt(a) | ≤ 2**(e-2)

            // From here, Newton's method give us:
            // x_{n+1} = (x_n + a / x_n) / 2
            //
            // One should note that:
            // x_{n+1}² - a = ((x_n + a / x_n) / 2)² - a
            //              = ((x_n² + a) / (2 * x_n))² - a
            //              = (x_n⁴ + 2 * a * x_n² + a²) / (4 * x_n²) - a
            //              = (x_n⁴ + 2 * a * x_n² + a² - 4 * a * x_n²) / (4 * x_n²)
            //              = (x_n⁴ - 2 * a * x_n² + a²) / (4 * x_n²)
            //              = (x_n² - a)² / (2 * x_n)²
            //              = ((x_n² - a) / (2 * x_n))²
            //              ≥ 0
            // Which proves that for all n ≥ 1, sqrt(a) ≤ x_n
            //
            // This gives us the proof of quadratic convergence of the sequence:
            // ε_{n+1} = | x_{n+1} - sqrt(a) |
            //         = | (x_n + a / x_n) / 2 - sqrt(a) |
            //         = | (x_n² + a - 2*x_n*sqrt(a)) / (2 * x_n) |
            //         = | (x_n - sqrt(a))² / (2 * x_n) |
            //         = | ε_n² / (2 * x_n) |
            //         = ε_n² / | (2 * x_n) |
            //
            // For the first iteration, we have a special case where x_0 is known:
            // ε_1 = ε_0² / | (2 * x_0) |
            //     ≤ (2**(e-2))² / (2 * (2**(e-1) + 2**(e-2)))
            //     ≤ 2**(2*e-4) / (3 * 2**(e-1))
            //     ≤ 2**(e-3) / 3
            //     ≤ 2**(e-3-log2(3))
            //     ≤ 2**(e-4.5)
            //
            // For the following iterations, we use the fact that, 2**(e-1) ≤ sqrt(a) ≤ x_n:
            // ε_{n+1} = ε_n² / | (2 * x_n) |
            //         ≤ (2**(e-k))² / (2 * 2**(e-1))
            //         ≤ 2**(2*e-2*k) / 2**e
            //         ≤ 2**(e-2*k)
            xn = (xn + a / xn) >> 1; // ε_1 := | x_1 - sqrt(a) | ≤ 2**(e-4.5)  -- special case, see above
            xn = (xn + a / xn) >> 1; // ε_2 := | x_2 - sqrt(a) | ≤ 2**(e-9)    -- general case with k = 4.5
            xn = (xn + a / xn) >> 1; // ε_3 := | x_3 - sqrt(a) | ≤ 2**(e-18)   -- general case with k = 9
            xn = (xn + a / xn) >> 1; // ε_4 := | x_4 - sqrt(a) | ≤ 2**(e-36)   -- general case with k = 18
            xn = (xn + a / xn) >> 1; // ε_5 := | x_5 - sqrt(a) | ≤ 2**(e-72)   -- general case with k = 36
            xn = (xn + a / xn) >> 1; // ε_6 := | x_6 - sqrt(a) | ≤ 2**(e-144)  -- general case with k = 72

            // Because e ≤ 128 (as discussed during the first estimation phase), we know have reached a precision
            // ε_6 ≤ 2**(e-144) < 1. Given we're operating on integers, then we can ensure that xn is now either
            // sqrt(a) or sqrt(a) + 1.
            return xn - SafeCast.toUint(xn > a / xn);
        }
    }

    /**
     * @dev Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = sqrt(a);
            return result + SafeCast.toUint(unsignedRoundsUp(rounding) && result * result < a);
        }
    }

    /**
     * @dev Return the log in base 2 of a positive value rounded towards zero.
     * Returns 0 if given 0.
     */
    function log2(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        uint256 exp;
        unchecked {
            exp = 128 * SafeCast.toUint(value > (1 << 128) - 1);
            value >>= exp;
            result += exp;

            exp = 64 * SafeCast.toUint(value > (1 << 64) - 1);
            value >>= exp;
            result += exp;

            exp = 32 * SafeCast.toUint(value > (1 << 32) - 1);
            value >>= exp;
            result += exp;

            exp = 16 * SafeCast.toUint(value > (1 << 16) - 1);
            value >>= exp;
            result += exp;

            exp = 8 * SafeCast.toUint(value > (1 << 8) - 1);
            value >>= exp;
            result += exp;

            exp = 4 * SafeCast.toUint(value > (1 << 4) - 1);
            value >>= exp;
            result += exp;

            exp = 2 * SafeCast.toUint(value > (1 << 2) - 1);
            value >>= exp;
            result += exp;

            result += SafeCast.toUint(value > 1);
        }
        return result;
    }

    /**
     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log2(value);
            return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << result < value);
        }
    }

    /**
     * @dev Return the log in base 10 of a positive value rounded towards zero.
     * Returns 0 if given 0.
     */
    function log10(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >= 10 ** 64) {
                value /= 10 ** 64;
                result += 64;
            }
            if (value >= 10 ** 32) {
                value /= 10 ** 32;
                result += 32;
            }
            if (value >= 10 ** 16) {
                value /= 10 ** 16;
                result += 16;
            }
            if (value >= 10 ** 8) {
                value /= 10 ** 8;
                result += 8;
            }
            if (value >= 10 ** 4) {
                value /= 10 ** 4;
                result += 4;
            }
            if (value >= 10 ** 2) {
                value /= 10 ** 2;
                result += 2;
            }
            if (value >= 10 ** 1) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log10(value);
            return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 10 ** result < value);
        }
    }

    /**
     * @dev Return the log in base 256 of a positive value rounded towards zero.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        uint256 isGt;
        unchecked {
            isGt = SafeCast.toUint(value > (1 << 128) - 1);
            value >>= isGt * 128;
            result += isGt * 16;

            isGt = SafeCast.toUint(value > (1 << 64) - 1);
            value >>= isGt * 64;
            result += isGt * 8;

            isGt = SafeCast.toUint(value > (1 << 32) - 1);
            value >>= isGt * 32;
            result += isGt * 4;

            isGt = SafeCast.toUint(value > (1 << 16) - 1);
            value >>= isGt * 16;
            result += isGt * 2;

            result += SafeCast.toUint(value > (1 << 8) - 1);
        }
        return result;
    }

    /**
     * @dev Return the log in base 256, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log256(value);
            return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << (result << 3) < value);
        }
    }

    /**
     * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
     */
    function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
        return uint8(rounding) % 2 == 1;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)

pragma solidity ^0.8.20;

import {IAccessControl} from "./IAccessControl.sol";
import {Context} from "../utils/Context.sol";
import {ERC165} from "../utils/introspection/ERC165.sol";

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms. This is a lightweight version that doesn't allow enumerating role
 * members except through off-chain means by accessing the contract event logs. Some
 * applications may benefit from on-chain enumerability, for those cases see
 * {AccessControlEnumerable}.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```solidity
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```solidity
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
 * to enforce additional security measures for this role.
 */
abstract contract AccessControl is Context, IAccessControl, ERC165 {
    struct RoleData {
        mapping(address account => bool) hasRole;
        bytes32 adminRole;
    }

    mapping(bytes32 role => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with an {AccessControlUnauthorizedAccount} error including the required role.
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role);
        _;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) public view virtual returns (bool) {
        return _roles[role].hasRole[account];
    }

    /**
     * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`
     * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.
     */
    function _checkRole(bytes32 role) internal view virtual {
        _checkRole(role, _msgSender());
    }

    /**
     * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`
     * is missing `role`.
     */
    function _checkRole(bytes32 role, address account) internal view virtual {
        if (!hasRole(role, account)) {
            revert AccessControlUnauthorizedAccount(account, role);
        }
    }

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {
        return _roles[role].adminRole;
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleGranted} event.
     */
    function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
        _grantRole(role, account);
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleRevoked} event.
     */
    function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
        _revokeRole(role, account);
    }

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been revoked `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `callerConfirmation`.
     *
     * May emit a {RoleRevoked} event.
     */
    function renounceRole(bytes32 role, address callerConfirmation) public virtual {
        if (callerConfirmation != _msgSender()) {
            revert AccessControlBadConfirmation();
        }

        _revokeRole(role, callerConfirmation);
    }

    /**
     * @dev Sets `adminRole` as ``role``'s admin role.
     *
     * Emits a {RoleAdminChanged} event.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
        bytes32 previousAdminRole = getRoleAdmin(role);
        _roles[role].adminRole = adminRole;
        emit RoleAdminChanged(role, previousAdminRole, adminRole);
    }

    /**
     * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleGranted} event.
     */
    function _grantRole(bytes32 role, address account) internal virtual returns (bool) {
        if (!hasRole(role, account)) {
            _roles[role].hasRole[account] = true;
            emit RoleGranted(role, account, _msgSender());
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleRevoked} event.
     */
    function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {
        if (hasRole(role, account)) {
            _roles[role].hasRole[account] = false;
            emit RoleRevoked(role, account, _msgSender());
            return true;
        } else {
            return false;
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.2.0) (utils/Address.sol)

pragma solidity ^0.8.20;

import {Errors} from "./Errors.sol";

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev There's no code at `target` (it is not a contract).
     */
    error AddressEmptyCode(address target);

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

        (bool success, bytes memory returndata) = recipient.call{value: amount}("");
        if (!success) {
            _revert(returndata);
        }
    }

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        if (address(this).balance < value) {
            revert Errors.InsufficientBalance(address(this).balance, value);
        }
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

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

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

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

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

    /**
     * @dev Reverts with returndata if present. Otherwise reverts with {Errors.FailedCall}.
     */
    function _revert(bytes memory returndata) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            assembly ("memory-safe") {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert Errors.FailedCall();
        }
    }
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

/* ── Beefy vault ───────────────────────────────────────── */
interface IBeefyVault {
    function depositAll() external;
    function withdraw(uint256 shares) external;
    function balanceOf(address) external view returns (uint256);
    function getPricePerFullShare() external view returns (uint256);
    function want() external view returns (address);
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

/* ── Curve USDeUSDC pool ──────────────────────────────────────── */
interface ICurvePool {
    /// @notice Add liquidity (indices: 0=USDe 1=USDC)
    function add_liquidity(uint256[] calldata amounts, uint256 minMint) external returns (uint256);

    /// @notice Remove liquidity in a single coin
    function remove_liquidity_one_coin(uint256 lpAmount, int128 i, uint256 minOut) external returns (uint256);

    /* -------- view helpers -------- */
    function calc_token_amount(uint256[] calldata amounts, bool isDeposit) external view returns (uint256);
    function calc_withdraw_one_coin(uint256 lpAmount, int128 i) external view returns (uint256 outAmount);
    function get_virtual_price() external view returns (uint256);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.20;

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

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

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

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

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

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

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

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

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

import { IYieldVault } from "src/interfaces/IYieldVault.sol";
import { ISwapRouter } from "src/vendor/uniswap_v3/ISwapRouter.sol";
import { IQuoter } from "src/vendor/uniswap_v3/IQuoter.sol";
import { ICurvePool } from "src/vendor/curve/ICurvePool.sol";
import { IBeefyVault } from "src/vendor/beefy/IBeefyVault.sol";
import { AggregatorV3Interface } from "src/vendor/chainlink/AggregatorV3Interface.sol";

/**
 * @title IEUSDUSDCBeefyYieldVault
 * @notice Yield-strategy vault that:
 *         1. Wraps ETH → WETH → USDC (Uniswap V3),
 *         2. Adds liquidity to the USDe/USDC Curve pool,
 *         3. Stakes LP tokens in a Beefy vault,
 *         4. Realises yield in ETH on demand.
 *
 * @dev Implements the generic {IYieldVault} hooks (`deposit`, `claimYield`,
 *      `retrievePrincipal`) so it can plug into the Seba Yield-Manager.
 */
interface IEUSDUSDCBeefyYieldVault is IYieldVault {
    /*//////////////////////////////////////////////////////////////
                                ERRORS
    //////////////////////////////////////////////////////////////*/

    /// Zero address passed to constructor.
    error InvalidAddress();

    /// `deposit()` called with zero ETH.
    error NoEthProvided();

    /// Vault finds no yield to claim.
    error NothingToClaim();

    /// Curve or Uniswap swap / mint returned less than the min-out.
    error SlippageExceeded();

    // No shares minted on Beefy
    error NoSharesMinted();

    // Value of deposit is zero
    error ZeroDepositValue();

    /// Asked to retrieve 0 principal.
    error CannotRetrieveZero();

    /// No shares to withdraw
    error NoSharesToWithdraw();

    /// Configured slippage is too high
    error SlippageTooHigh();

    // Oracle is invalid
    error OracleInvalid();

    // Oracle is stale
    error OracleStale();

    /*//////////////////////////////////////////////////////////////
                                EVENTS
    //////////////////////////////////////////////////////////////*/

    /// Emitted after ETH is invested and Beefy shares are minted.
    event Deposited(address indexed depositor, uint256 ethIn, uint256 sharesMinted);

    /// Emitted when yield is harvested and paid out in ETH.
    event YieldClaimed(uint256 sharesRedeemed, uint256 ethOut);

    /// Emitted when principal is unwound and returned to caller.
    event PrincipalRetrieved(uint256 sharesRedeemed, uint256 ethOut);

    /// Emitted when admin updates slippage tolerance.
    event SlippageSet(uint16 bps);

    /*//////////////////////////////////////////////////////////////
                      PUBLIC CONSTANTS & VARIABLES
    //////////////////////////////////////////////////////////////*/

    /// Current slippage tolerance (basis-points) used for every swap.
    function slippageBps() external view returns (uint16);

    /// Fixed Uniswap V3 fee tier (0.05 % = 500).
    function UNIV3_FEE_TIER() external view returns (uint24);

    /// Access-control role identifiers.
    function ADMIN_ROLE() external view returns (bytes32);
    function YIELDMANAGER_ROLE() external view returns (bytes32);

    /// Token & protocol references.
    function WETH() external view returns (address);
    function USDC() external view returns (address);
    function swapRouter() external view returns (ISwapRouter);
    function quoter() external view returns (IQuoter);
    function curvePool() external view returns (ICurvePool);
    function beefy() external view returns (IBeefyVault);
    function ethUsdFeed() external view returns (AggregatorV3Interface);
    function usdcUsdFeed() external view returns (AggregatorV3Interface);

    /// Accounting snapshots.
    function principalShares() external view returns (uint256);
    function principalValue() external view returns (uint256);

    /*//////////////////////////////////////////////////////////////
                                SETTERS
    //////////////////////////////////////////////////////////////*/

    /**
     * @notice Admin setter to update the vault-wide slippage tolerance.
     * @param bps  New tolerance in basis-points (max 1 000 = 10 %).
     *
     * @dev Emits {SlippageSet}.
     *      Reverts {InvalidAddress} if `msg.sender` lacks `ADMIN_ROLE`.
     */
    function setSlippageBps(uint16 bps) external;
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

interface IQuoter {
    function quoteExactInputSingle(
        address tokenIn,
        address tokenOut,
        uint24 fee,
        uint256 amountIn,
        uint160 sqrtPriceLimitX96
    ) external returns (uint256);
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

interface ISwapRouter {
    struct ExactInputSingleParams {
        address tokenIn;
        address tokenOut;
        uint24 fee;
        address recipient;
        uint256 deadline;
        uint256 amountIn;
        uint256 amountOutMinimum;
        uint160 sqrtPriceLimitX96;
    }
    function exactInputSingle(ExactInputSingleParams calldata p) external payable returns (uint256);
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

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

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

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { IEthToBoldRouter } from "src/interfaces/IEthToBoldRouter.sol";
import { ISBOLD } from "src/vendor/liquity/ISBOLD.sol";
import { IPYBSeba } from "src/interfaces/IPYBSeba.sol";
import { IYieldVault } from "src/interfaces/IYieldVault.sol";

/**
 * @title IYieldManager
 * @notice Interface for the Seba Yield-Manager that
 *         - handles BoostPool funding (50 / 50 split),
 *         - accepts time-locked user deposits,
 *         - manages ETH→BOLD→sBOLD conversion and SebaVault top-ups,
 *         - claims and routes strategy yield,
 *         - lets admins migrate or pull principal from the active vault.
 */
interface IYieldManager {
    /*//////////////////////////////////////////////////////////////
                               STRUCTS
    //////////////////////////////////////////////////////////////*/

    /// @notice Configuration for one user deposit that is locked for
    ///         `USER_LOCK_SECS` seconds after the block timestamp.
    /// @param depositor        The user who supplied the ETH.
    /// @param vaultAtDeposit   Strategy vault that currently holds the funds.
    /// @param amount           Principal amount in underlying (ETH value, wei).
    /// @param unlockTime       Timestamp (UTC-seconds) after which withdrawal
    ///                         via {retrieveFunds} is allowed.
    struct Deposit {
        address depositor;
        IYieldVault vaultAtDeposit;
        uint256 amount;
        uint32 unlockTime;
    }

    /*//////////////////////////////////////////////////////////////
                                ERRORS
    //////////////////////////////////////////////////////////////*/

    /// Thrown when an address argument is zero.
    error InvalidAddress();

    /// Thrown when `msg.value == 0` in {depositFunds}.
    error EmptyDeposit();

    /// Thrown when trying to cancel a CowSwap order but no UID is stored.
    error NoActiveRouterIntent();

    /// Thrown if {activateYieldFlow} is called more than once.
    error YieldFlowAlreadyActivated();

    // Value of deposit is zero
    error ZeroDepositValue();

    /// Thrown when a referenced deposit‐ID does not exist.
    error NonExistingDeposit(uint256 id);

    /// Thrown when someone other than the original depositor calls {retrieveFunds}.
    error InvalidDepositor(address depositor);

    /// Thrown when a user tries to withdraw before `unlockTime`.
    error DepositStillLocked(uint256 now_, uint32 unlockTime);

    /// Thrown when an ETH transfer to a user fails.
    error TransferFailed();

    /// Thrown when admin tries to pull protocol principal but none is deployed.
    error NoPrincipalDeployed();

    /// Thrown when the slippage is configured too high
    error SlippageTooHigh();

    /// Thrown when the max fee is configured too high
    error MaxFeeTooHigh();

    /// Thrown when the invalidity is set to 0
    error InvalidValidity();

    /*//////////////////////////////////////////////////////////////
                                EVENTS
    //////////////////////////////////////////////////////////////*/

    /// Emitted after any ETH deposit is processed
    /// (BoostPool or external user).
    /// @param from              Sender of the ETH.
    /// @param amountUnderlying  Amount accounted as *underlying* (ETH value)
    ///                          and forwarded to a strategy vault (if any).
    event DepositReceived(address indexed from, uint256 amountUnderlying);

    /// Emitted when a new ETH→BOLD CowSwap order (intent) is started.
    /// @param uid    56-byte unique identifier returned by Eth-flow.
    /// @param ethIn  Exact ETH amount committed to the order.
    event BoldConversionStarted(bytes32 uid, uint256 ethIn);

    /// Emitted when BOLD is converted to sBOLD and staked into SebaVault.
    /// @param boldIn   BOLD tokens consumed.
    /// @param sBoldOut sBOLD tokens minted & deposited.
    event BoldConversionFinalised(uint256 boldIn, uint256 sBoldOut);

    /// Emitted once when admin switches yield routing to SebaVault.
    event YieldFlowActivated();

    /// Emitted every time yield is handled.
    /// @param ethAmount    Yield size in ETH.
    /// @param toSebaVault  True  = routed to SebaVault via conversion.<br>
    ///                     False = auto-compounded in the current vault.
    event YieldDistributed(uint256 ethAmount, bool toSebaVault);

    /// Emitted when slippage tolerance for CowSwap intents is adjusted.
    event RouterSlippageBpsSet(uint16 previous, uint16 current);

    /// Emitted when max fee tolerance for CowSwap intents is adjusted.
    event MaxFeeBpsSet(uint16 previous, uint16 current);

    /// Emitted when validity window for CowSwap intents is adjusted.
    event RouterValiditySecsSet(uint32 previous, uint32 current);

    /// Emitted after a successful strategy-vault migration.
    event NewYieldVaultSet(address yieldVault);

    /// Emitted when protocol principal is pulled back to this contract.
    event PrincipalRetrieved();

    /// Emitted when protocol principal is (re)deployed into the active vault.
    event PrincipalDeposited(uint256 principal);

    /// Emitted on new user deposit creation.
    event FundsDeposited(uint256 depositId, address depositor, uint256 amountEth);

    /// Emitted when a user successfully withdraws principal.
    event FundsRetrieved(uint256 depositId, address depositor, uint256 amountEth);

    /*//////////////////////////////////////////////////////////////
                       PUBLIC CONSTANTS & VARIABLES
    //////////////////////////////////////////////////////////////*/

    /// @notice Seconds a user deposit remains locked.
    function USER_LOCK_SECS() external view returns (uint32);

    /// @notice CowSwap fee (basis-points, 1 bp = 0.01 %).
    function MAX_FEE_BPS() external view returns (uint16);

    /// @notice CowSwap slippage tolerance (basis-points, 1 bp = 0.01 %).
    function ROUTER_SLIPPAGE_BPS() external view returns (uint16);

    /// @notice CowSwap order validity in seconds.
    function ROUTER_VALIDITY_SECS() external view returns (uint32);

    /// Role IDs used by AccessControl.
    function ADMIN_ROLE() external view returns (bytes32);
    function AUTOMATOR_ROLE() external view returns (bytes32);

    /// External contract references
    function router() external view returns (IEthToBoldRouter);
    function BOLD() external view returns (IERC20);
    function sBOLD() external view returns (ISBOLD);
    function sebaVault() external view returns (IPYBSeba);
    function yieldVault() external view returns (IYieldVault);
    function sebaPool() external view returns (address);

    /// Conversion & yield state
    function activeRouterUid() external view returns (bytes32);
    function pendingBoldConversion() external view returns (uint256);
    function yieldFlowActive() external view returns (bool);
    function lastConversionStartTimestamp() external view returns (uint256);

    /// Principal deployed on behalf of Seba (ETH value)
    function principalValue() external view returns (uint256);

    /// Incrementing deposit counter
    function depositId() external view returns (uint256);

    /// Mapping accessor for deposits
    function deposits(
        uint256 id
    ) external view returns (address depositor, IYieldVault vaultAtDeposit, uint256 amount, uint32 unlockTime);

    /*//////////////////////////////////////////////////////////////
                                ACTIONS
    //////////////////////////////////////////////////////////////*/

    /**
     * @notice Deposit ETH into the manager.
     *         • If `msg.sender == boostPool`: 50 / 50 split — half routed
     *           to CowSwap, half deposited into the strategy vault.
     *         • Else: entire amount deposited & locked under the caller.
     *
     * @dev Emits {DepositReceived}.
     *      Emits {FundsDeposited} for the *user* branch.
     *
     * Reverts {EmptyDeposit}.
     */
    function depositFunds() external payable;

    /**
     * @notice Withdraw the caller’s locked principal once the lock expires.
     * @param id  The deposit ID obtained from {FundsDeposited}.
     *
     * @dev Reverts {NonExistingDeposit}, {InvalidDepositor},
     *      {DepositStillLocked}.
     *      Emits {FundsRetrieved}.
     */
    function retrieveFunds(uint256 id) external;

    /**
     * @notice House-keeping for the ETH→BOLD→sBOLD pipeline:
     *         - Cancel & refund expired CowSwap order (if any),
     *         - Convert any held BOLD into sBOLD & top-up SebaVault,
     *         - Start a new CowSwap order if ETH is pending.
     *
     * @dev Emits {BoldConversionFinalised} and/or {BoldConversionStarted}.
     */
    function runBoldConversion(uint256 feeAmount) external;

    /**
     * @notice Claim yield from the active vault.
     *         • If `yieldFlowActive == false`: auto-compound back into vault.
     *         • Else: add ETH to pending conversion for SebaVault top-up.
     *
     * @dev Restricted to role `AUTOMATOR_ROLE`.
     *      Emits {YieldDistributed}.
     */
    function distributeYield() external;

    /**
     * @notice One-time switch that routes *future* yield to SebaVault
     *         via the sBOLD conversion path.
     *
     * @dev Reverts {YieldFlowAlreadyActivated}.
     *      Emits {YieldFlowActivated}.
     *      Only an `ADMIN_ROLE` holder may call.
     */
    function activateYieldFlow() external;

    /* ----------------------------- Admin ops --------------------------- */

    /**
     * @notice Point the manager at a new strategy vault.
     *         Existing principal is pulled first.
     */
    function setYieldVault(address _yieldVault) external;

    /// Retrieve protocol-owned principal from the current vault.
    function retrievePrincipalFromYieldVault() external;

    /// Deposit any idle principal held by this contract into the vault.
    function depositPrincipalIntoYieldVault() external;

    /// Adjust CowSwap slippage tolerance (basis-points).
    function setRouterSlippageBps(uint16 _bps) external;

    /// Adjust CowSwap order validity window (seconds).
    function setRouterValiditySecs(uint32 _secs) external;

    /// Adjust CowSwap Max fee tolerance (basis-points).
    function setMaxFeeBPS(uint16 _bps) external;
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

/**
 * @title IYieldVault
 * @notice Minimal interface that any yield-strategy vault must implement for Seba’s
 *         ecosystem. A vault manages principal (in underlying vault asset terms) and can:
 *         ① accept deposits, ② realise and forward yield, and ③ allow principal retrieval.
 * @dev Every strategy-specific vault (e.g., Beefy, Aave, Compound) must implement
 *      this interface so it can be plugged into the Seba YieldManager.
 */
interface IYieldVault {
    /*//////////////////////////////////////////////////////////////
                                FUNCTIONS
    //////////////////////////////////////////////////////////////*/

    /**
     * @notice Deposit ETH into the strategy.
     * @dev The caller (usually a YieldManager) transfers ETH with the call.
     *      Implementations should convert / invest as needed and return
     *      the ETH-denominated value credited as principal.
     * @return depositValue Value (in unerlying vault asset terms) accounted as principal.
     */
    function deposit() external payable returns (uint256 depositValue);

    /**
     * @notice Claim strategy yield and transfer it back to the caller
     *         (either auto-compounded or forwarded on, depending on the caller’s logic).
     * @dev Implementations decide what constitutes “yield” versus principal.
     */
    function claimYield() external;

    /**
     * @notice Retrieve an arbitrary slice of principal, denominated in the underlying vault asset.
     * @param depositValue Amount of principal (underlying vault asset terms) requested for return.
     */
    function retrievePrincipal(uint256 depositValue) external;
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuard.sol)

pragma solidity ^0.8.20;

/**
 * @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 EIP-1153 (transient storage) is available on the chain you're deploying at,
 * consider using {ReentrancyGuardTransient} instead.
 *
 * 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 ReentrancyGuard {
    // 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;

    /**
     * @dev Unauthorized reentrant call.
     */
    error ReentrancyGuardReentrantCall();

    constructor() {
        _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() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be NOT_ENTERED
        if (_status == ENTERED) {
            revert ReentrancyGuardReentrantCall();
        }

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

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

    /**
     * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
     * `nonReentrant` function in the call stack.
     */
    function _reentrancyGuardEntered() internal view returns (bool) {
        return _status == ENTERED;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.2.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";

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

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

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

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

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     *
     * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
     * smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
     * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
     * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        forceApprove(token, spender, oldAllowance + value);
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
     * value, non-reverting calls are assumed to be successful.
     *
     * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
     * smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
     * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
     * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
        unchecked {
            uint256 currentAllowance = token.allowance(address(this), spender);
            if (currentAllowance < requestedDecrease) {
                revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
            }
            forceApprove(token, spender, currentAllowance - requestedDecrease);
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     *
     * NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
     * only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
     * set here.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));

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

    /**
     * @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
     * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
     * targeting contracts.
     *
     * Reverts if the returned value is other than `true`.
     */
    function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
        if (to.code.length == 0) {
            safeTransfer(token, to, value);
        } else if (!token.transferAndCall(to, value, data)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
     * has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
     * targeting contracts.
     *
     * Reverts if the returned value is other than `true`.
     */
    function transferFromAndCallRelaxed(
        IERC1363 token,
        address from,
        address to,
        uint256 value,
        bytes memory data
    ) internal {
        if (to.code.length == 0) {
            safeTransferFrom(token, from, to, value);
        } else if (!token.transferFromAndCall(from, to, value, data)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
     * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
     * targeting contracts.
     *
     * NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
     * Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
     * once without retrying, and relies on the returned value to be true.
     *
     * Reverts if the returned value is other than `true`.
     */
    function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
        if (to.code.length == 0) {
            forceApprove(token, to, value);
        } else if (!token.approveAndCall(to, value, data)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturnBool} that reverts if call fails to meet the requirements.
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        uint256 returnSize;
        uint256 returnValue;
        assembly ("memory-safe") {
            let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
            // bubble errors
            if iszero(success) {
                let ptr := mload(0x40)
                returndatacopy(ptr, 0, returndatasize())
                revert(ptr, returndatasize())
            }
            returnSize := returndatasize()
            returnValue := mload(0)
        }

        if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturn} that silently catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        bool success;
        uint256 returnSize;
        uint256 returnValue;
        assembly ("memory-safe") {
            success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
            returnSize := returndatasize()
            returnValue := mload(0)
        }
        return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
    }
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

interface AggregatorV3Interface {
    function latestRoundData() external view returns (uint80, int256 answer, uint256, uint256 updatedAt, uint80);
    function decimals() external view returns (uint8);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Panic.sol)

pragma solidity ^0.8.20;

/**
 * @dev Helper library for emitting standardized panic codes.
 *
 * ```solidity
 * contract Example {
 *      using Panic for uint256;
 *
 *      // Use any of the declared internal constants
 *      function foo() { Panic.GENERIC.panic(); }
 *
 *      // Alternatively
 *      function foo() { Panic.panic(Panic.GENERIC); }
 * }
 * ```
 *
 * Follows the list from https://github.com/ethereum/solidity/blob/v0.8.24/libsolutil/ErrorCodes.h[libsolutil].
 *
 * _Available since v5.1._
 */
// slither-disable-next-line unused-state
library Panic {
    /// @dev generic / unspecified error
    uint256 internal constant GENERIC = 0x00;
    /// @dev used by the assert() builtin
    uint256 internal constant ASSERT = 0x01;
    /// @dev arithmetic underflow or overflow
    uint256 internal constant UNDER_OVERFLOW = 0x11;
    /// @dev division or modulo by zero
    uint256 internal constant DIVISION_BY_ZERO = 0x12;
    /// @dev enum conversion error
    uint256 internal constant ENUM_CONVERSION_ERROR = 0x21;
    /// @dev invalid encoding in storage
    uint256 internal constant STORAGE_ENCODING_ERROR = 0x22;
    /// @dev empty array pop
    uint256 internal constant EMPTY_ARRAY_POP = 0x31;
    /// @dev array out of bounds access
    uint256 internal constant ARRAY_OUT_OF_BOUNDS = 0x32;
    /// @dev resource error (too large allocation or too large array)
    uint256 internal constant RESOURCE_ERROR = 0x41;
    /// @dev calling invalid internal function
    uint256 internal constant INVALID_INTERNAL_FUNCTION = 0x51;

    /// @dev Reverts with a panic code. Recommended to use with
    /// the internal constants with predefined codes.
    function panic(uint256 code) internal pure {
        assembly ("memory-safe") {
            mstore(0x00, 0x4e487b71)
            mstore(0x20, code)
            revert(0x1c, 0x24)
        }
    }
}

File 18 of 30 : SafeCast.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.

pragma solidity ^0.8.20;

/**
 * @dev Wrappers over Solidity's uintXX/intXX/bool casting operators with added overflow
 * checks.
 *
 * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
 * easily result in undesired exploitation or bugs, since developers usually
 * assume that overflows raise errors. `SafeCast` restores this intuition by
 * reverting the transaction when such an operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeCast {
    /**
     * @dev Value doesn't fit in an uint of `bits` size.
     */
    error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);

    /**
     * @dev An int value doesn't fit in an uint of `bits` size.
     */
    error SafeCastOverflowedIntToUint(int256 value);

    /**
     * @dev Value doesn't fit in an int of `bits` size.
     */
    error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);

    /**
     * @dev An uint value doesn't fit in an int of `bits` size.
     */
    error SafeCastOverflowedUintToInt(uint256 value);

    /**
     * @dev Returns the downcasted uint248 from uint256, reverting on
     * overflow (when the input is greater than largest uint248).
     *
     * Counterpart to Solidity's `uint248` operator.
     *
     * Requirements:
     *
     * - input must fit into 248 bits
     */
    function toUint248(uint256 value) internal pure returns (uint248) {
        if (value > type(uint248).max) {
            revert SafeCastOverflowedUintDowncast(248, value);
        }
        return uint248(value);
    }

    /**
     * @dev Returns the downcasted uint240 from uint256, reverting on
     * overflow (when the input is greater than largest uint240).
     *
     * Counterpart to Solidity's `uint240` operator.
     *
     * Requirements:
     *
     * - input must fit into 240 bits
     */
    function toUint240(uint256 value) internal pure returns (uint240) {
        if (value > type(uint240).max) {
            revert SafeCastOverflowedUintDowncast(240, value);
        }
        return uint240(value);
    }

    /**
     * @dev Returns the downcasted uint232 from uint256, reverting on
     * overflow (when the input is greater than largest uint232).
     *
     * Counterpart to Solidity's `uint232` operator.
     *
     * Requirements:
     *
     * - input must fit into 232 bits
     */
    function toUint232(uint256 value) internal pure returns (uint232) {
        if (value > type(uint232).max) {
            revert SafeCastOverflowedUintDowncast(232, value);
        }
        return uint232(value);
    }

    /**
     * @dev Returns the downcasted uint224 from uint256, reverting on
     * overflow (when the input is greater than largest uint224).
     *
     * Counterpart to Solidity's `uint224` operator.
     *
     * Requirements:
     *
     * - input must fit into 224 bits
     */
    function toUint224(uint256 value) internal pure returns (uint224) {
        if (value > type(uint224).max) {
            revert SafeCastOverflowedUintDowncast(224, value);
        }
        return uint224(value);
    }

    /**
     * @dev Returns the downcasted uint216 from uint256, reverting on
     * overflow (when the input is greater than largest uint216).
     *
     * Counterpart to Solidity's `uint216` operator.
     *
     * Requirements:
     *
     * - input must fit into 216 bits
     */
    function toUint216(uint256 value) internal pure returns (uint216) {
        if (value > type(uint216).max) {
            revert SafeCastOverflowedUintDowncast(216, value);
        }
        return uint216(value);
    }

    /**
     * @dev Returns the downcasted uint208 from uint256, reverting on
     * overflow (when the input is greater than largest uint208).
     *
     * Counterpart to Solidity's `uint208` operator.
     *
     * Requirements:
     *
     * - input must fit into 208 bits
     */
    function toUint208(uint256 value) internal pure returns (uint208) {
        if (value > type(uint208).max) {
            revert SafeCastOverflowedUintDowncast(208, value);
        }
        return uint208(value);
    }

    /**
     * @dev Returns the downcasted uint200 from uint256, reverting on
     * overflow (when the input is greater than largest uint200).
     *
     * Counterpart to Solidity's `uint200` operator.
     *
     * Requirements:
     *
     * - input must fit into 200 bits
     */
    function toUint200(uint256 value) internal pure returns (uint200) {
        if (value > type(uint200).max) {
            revert SafeCastOverflowedUintDowncast(200, value);
        }
        return uint200(value);
    }

    /**
     * @dev Returns the downcasted uint192 from uint256, reverting on
     * overflow (when the input is greater than largest uint192).
     *
     * Counterpart to Solidity's `uint192` operator.
     *
     * Requirements:
     *
     * - input must fit into 192 bits
     */
    function toUint192(uint256 value) internal pure returns (uint192) {
        if (value > type(uint192).max) {
            revert SafeCastOverflowedUintDowncast(192, value);
        }
        return uint192(value);
    }

    /**
     * @dev Returns the downcasted uint184 from uint256, reverting on
     * overflow (when the input is greater than largest uint184).
     *
     * Counterpart to Solidity's `uint184` operator.
     *
     * Requirements:
     *
     * - input must fit into 184 bits
     */
    function toUint184(uint256 value) internal pure returns (uint184) {
        if (value > type(uint184).max) {
            revert SafeCastOverflowedUintDowncast(184, value);
        }
        return uint184(value);
    }

    /**
     * @dev Returns the downcasted uint176 from uint256, reverting on
     * overflow (when the input is greater than largest uint176).
     *
     * Counterpart to Solidity's `uint176` operator.
     *
     * Requirements:
     *
     * - input must fit into 176 bits
     */
    function toUint176(uint256 value) internal pure returns (uint176) {
        if (value > type(uint176).max) {
            revert SafeCastOverflowedUintDowncast(176, value);
        }
        return uint176(value);
    }

    /**
     * @dev Returns the downcasted uint168 from uint256, reverting on
     * overflow (when the input is greater than largest uint168).
     *
     * Counterpart to Solidity's `uint168` operator.
     *
     * Requirements:
     *
     * - input must fit into 168 bits
     */
    function toUint168(uint256 value) internal pure returns (uint168) {
        if (value > type(uint168).max) {
            revert SafeCastOverflowedUintDowncast(168, value);
        }
        return uint168(value);
    }

    /**
     * @dev Returns the downcasted uint160 from uint256, reverting on
     * overflow (when the input is greater than largest uint160).
     *
     * Counterpart to Solidity's `uint160` operator.
     *
     * Requirements:
     *
     * - input must fit into 160 bits
     */
    function toUint160(uint256 value) internal pure returns (uint160) {
        if (value > type(uint160).max) {
            revert SafeCastOverflowedUintDowncast(160, value);
        }
        return uint160(value);
    }

    /**
     * @dev Returns the downcasted uint152 from uint256, reverting on
     * overflow (when the input is greater than largest uint152).
     *
     * Counterpart to Solidity's `uint152` operator.
     *
     * Requirements:
     *
     * - input must fit into 152 bits
     */
    function toUint152(uint256 value) internal pure returns (uint152) {
        if (value > type(uint152).max) {
            revert SafeCastOverflowedUintDowncast(152, value);
        }
        return uint152(value);
    }

    /**
     * @dev Returns the downcasted uint144 from uint256, reverting on
     * overflow (when the input is greater than largest uint144).
     *
     * Counterpart to Solidity's `uint144` operator.
     *
     * Requirements:
     *
     * - input must fit into 144 bits
     */
    function toUint144(uint256 value) internal pure returns (uint144) {
        if (value > type(uint144).max) {
            revert SafeCastOverflowedUintDowncast(144, value);
        }
        return uint144(value);
    }

    /**
     * @dev Returns the downcasted uint136 from uint256, reverting on
     * overflow (when the input is greater than largest uint136).
     *
     * Counterpart to Solidity's `uint136` operator.
     *
     * Requirements:
     *
     * - input must fit into 136 bits
     */
    function toUint136(uint256 value) internal pure returns (uint136) {
        if (value > type(uint136).max) {
            revert SafeCastOverflowedUintDowncast(136, value);
        }
        return uint136(value);
    }

    /**
     * @dev Returns the downcasted uint128 from uint256, reverting on
     * overflow (when the input is greater than largest uint128).
     *
     * Counterpart to Solidity's `uint128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     */
    function toUint128(uint256 value) internal pure returns (uint128) {
        if (value > type(uint128).max) {
            revert SafeCastOverflowedUintDowncast(128, value);
        }
        return uint128(value);
    }

    /**
     * @dev Returns the downcasted uint120 from uint256, reverting on
     * overflow (when the input is greater than largest uint120).
     *
     * Counterpart to Solidity's `uint120` operator.
     *
     * Requirements:
     *
     * - input must fit into 120 bits
     */
    function toUint120(uint256 value) internal pure returns (uint120) {
        if (value > type(uint120).max) {
            revert SafeCastOverflowedUintDowncast(120, value);
        }
        return uint120(value);
    }

    /**
     * @dev Returns the downcasted uint112 from uint256, reverting on
     * overflow (when the input is greater than largest uint112).
     *
     * Counterpart to Solidity's `uint112` operator.
     *
     * Requirements:
     *
     * - input must fit into 112 bits
     */
    function toUint112(uint256 value) internal pure returns (uint112) {
        if (value > type(uint112).max) {
            revert SafeCastOverflowedUintDowncast(112, value);
        }
        return uint112(value);
    }

    /**
     * @dev Returns the downcasted uint104 from uint256, reverting on
     * overflow (when the input is greater than largest uint104).
     *
     * Counterpart to Solidity's `uint104` operator.
     *
     * Requirements:
     *
     * - input must fit into 104 bits
     */
    function toUint104(uint256 value) internal pure returns (uint104) {
        if (value > type(uint104).max) {
            revert SafeCastOverflowedUintDowncast(104, value);
        }
        return uint104(value);
    }

    /**
     * @dev Returns the downcasted uint96 from uint256, reverting on
     * overflow (when the input is greater than largest uint96).
     *
     * Counterpart to Solidity's `uint96` operator.
     *
     * Requirements:
     *
     * - input must fit into 96 bits
     */
    function toUint96(uint256 value) internal pure returns (uint96) {
        if (value > type(uint96).max) {
            revert SafeCastOverflowedUintDowncast(96, value);
        }
        return uint96(value);
    }

    /**
     * @dev Returns the downcasted uint88 from uint256, reverting on
     * overflow (when the input is greater than largest uint88).
     *
     * Counterpart to Solidity's `uint88` operator.
     *
     * Requirements:
     *
     * - input must fit into 88 bits
     */
    function toUint88(uint256 value) internal pure returns (uint88) {
        if (value > type(uint88).max) {
            revert SafeCastOverflowedUintDowncast(88, value);
        }
        return uint88(value);
    }

    /**
     * @dev Returns the downcasted uint80 from uint256, reverting on
     * overflow (when the input is greater than largest uint80).
     *
     * Counterpart to Solidity's `uint80` operator.
     *
     * Requirements:
     *
     * - input must fit into 80 bits
     */
    function toUint80(uint256 value) internal pure returns (uint80) {
        if (value > type(uint80).max) {
            revert SafeCastOverflowedUintDowncast(80, value);
        }
        return uint80(value);
    }

    /**
     * @dev Returns the downcasted uint72 from uint256, reverting on
     * overflow (when the input is greater than largest uint72).
     *
     * Counterpart to Solidity's `uint72` operator.
     *
     * Requirements:
     *
     * - input must fit into 72 bits
     */
    function toUint72(uint256 value) internal pure returns (uint72) {
        if (value > type(uint72).max) {
            revert SafeCastOverflowedUintDowncast(72, value);
        }
        return uint72(value);
    }

    /**
     * @dev Returns the downcasted uint64 from uint256, reverting on
     * overflow (when the input is greater than largest uint64).
     *
     * Counterpart to Solidity's `uint64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     */
    function toUint64(uint256 value) internal pure returns (uint64) {
        if (value > type(uint64).max) {
            revert SafeCastOverflowedUintDowncast(64, value);
        }
        return uint64(value);
    }

    /**
     * @dev Returns the downcasted uint56 from uint256, reverting on
     * overflow (when the input is greater than largest uint56).
     *
     * Counterpart to Solidity's `uint56` operator.
     *
     * Requirements:
     *
     * - input must fit into 56 bits
     */
    function toUint56(uint256 value) internal pure returns (uint56) {
        if (value > type(uint56).max) {
            revert SafeCastOverflowedUintDowncast(56, value);
        }
        return uint56(value);
    }

    /**
     * @dev Returns the downcasted uint48 from uint256, reverting on
     * overflow (when the input is greater than largest uint48).
     *
     * Counterpart to Solidity's `uint48` operator.
     *
     * Requirements:
     *
     * - input must fit into 48 bits
     */
    function toUint48(uint256 value) internal pure returns (uint48) {
        if (value > type(uint48).max) {
            revert SafeCastOverflowedUintDowncast(48, value);
        }
        return uint48(value);
    }

    /**
     * @dev Returns the downcasted uint40 from uint256, reverting on
     * overflow (when the input is greater than largest uint40).
     *
     * Counterpart to Solidity's `uint40` operator.
     *
     * Requirements:
     *
     * - input must fit into 40 bits
     */
    function toUint40(uint256 value) internal pure returns (uint40) {
        if (value > type(uint40).max) {
            revert SafeCastOverflowedUintDowncast(40, value);
        }
        return uint40(value);
    }

    /**
     * @dev Returns the downcasted uint32 from uint256, reverting on
     * overflow (when the input is greater than largest uint32).
     *
     * Counterpart to Solidity's `uint32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     */
    function toUint32(uint256 value) internal pure returns (uint32) {
        if (value > type(uint32).max) {
            revert SafeCastOverflowedUintDowncast(32, value);
        }
        return uint32(value);
    }

    /**
     * @dev Returns the downcasted uint24 from uint256, reverting on
     * overflow (when the input is greater than largest uint24).
     *
     * Counterpart to Solidity's `uint24` operator.
     *
     * Requirements:
     *
     * - input must fit into 24 bits
     */
    function toUint24(uint256 value) internal pure returns (uint24) {
        if (value > type(uint24).max) {
            revert SafeCastOverflowedUintDowncast(24, value);
        }
        return uint24(value);
    }

    /**
     * @dev Returns the downcasted uint16 from uint256, reverting on
     * overflow (when the input is greater than largest uint16).
     *
     * Counterpart to Solidity's `uint16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     */
    function toUint16(uint256 value) internal pure returns (uint16) {
        if (value > type(uint16).max) {
            revert SafeCastOverflowedUintDowncast(16, value);
        }
        return uint16(value);
    }

    /**
     * @dev Returns the downcasted uint8 from uint256, reverting on
     * overflow (when the input is greater than largest uint8).
     *
     * Counterpart to Solidity's `uint8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits
     */
    function toUint8(uint256 value) internal pure returns (uint8) {
        if (value > type(uint8).max) {
            revert SafeCastOverflowedUintDowncast(8, value);
        }
        return uint8(value);
    }

    /**
     * @dev Converts a signed int256 into an unsigned uint256.
     *
     * Requirements:
     *
     * - input must be greater than or equal to 0.
     */
    function toUint256(int256 value) internal pure returns (uint256) {
        if (value < 0) {
            revert SafeCastOverflowedIntToUint(value);
        }
        return uint256(value);
    }

    /**
     * @dev Returns the downcasted int248 from int256, reverting on
     * overflow (when the input is less than smallest int248 or
     * greater than largest int248).
     *
     * Counterpart to Solidity's `int248` operator.
     *
     * Requirements:
     *
     * - input must fit into 248 bits
     */
    function toInt248(int256 value) internal pure returns (int248 downcasted) {
        downcasted = int248(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(248, value);
        }
    }

    /**
     * @dev Returns the downcasted int240 from int256, reverting on
     * overflow (when the input is less than smallest int240 or
     * greater than largest int240).
     *
     * Counterpart to Solidity's `int240` operator.
     *
     * Requirements:
     *
     * - input must fit into 240 bits
     */
    function toInt240(int256 value) internal pure returns (int240 downcasted) {
        downcasted = int240(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(240, value);
        }
    }

    /**
     * @dev Returns the downcasted int232 from int256, reverting on
     * overflow (when the input is less than smallest int232 or
     * greater than largest int232).
     *
     * Counterpart to Solidity's `int232` operator.
     *
     * Requirements:
     *
     * - input must fit into 232 bits
     */
    function toInt232(int256 value) internal pure returns (int232 downcasted) {
        downcasted = int232(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(232, value);
        }
    }

    /**
     * @dev Returns the downcasted int224 from int256, reverting on
     * overflow (when the input is less than smallest int224 or
     * greater than largest int224).
     *
     * Counterpart to Solidity's `int224` operator.
     *
     * Requirements:
     *
     * - input must fit into 224 bits
     */
    function toInt224(int256 value) internal pure returns (int224 downcasted) {
        downcasted = int224(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(224, value);
        }
    }

    /**
     * @dev Returns the downcasted int216 from int256, reverting on
     * overflow (when the input is less than smallest int216 or
     * greater than largest int216).
     *
     * Counterpart to Solidity's `int216` operator.
     *
     * Requirements:
     *
     * - input must fit into 216 bits
     */
    function toInt216(int256 value) internal pure returns (int216 downcasted) {
        downcasted = int216(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(216, value);
        }
    }

    /**
     * @dev Returns the downcasted int208 from int256, reverting on
     * overflow (when the input is less than smallest int208 or
     * greater than largest int208).
     *
     * Counterpart to Solidity's `int208` operator.
     *
     * Requirements:
     *
     * - input must fit into 208 bits
     */
    function toInt208(int256 value) internal pure returns (int208 downcasted) {
        downcasted = int208(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(208, value);
        }
    }

    /**
     * @dev Returns the downcasted int200 from int256, reverting on
     * overflow (when the input is less than smallest int200 or
     * greater than largest int200).
     *
     * Counterpart to Solidity's `int200` operator.
     *
     * Requirements:
     *
     * - input must fit into 200 bits
     */
    function toInt200(int256 value) internal pure returns (int200 downcasted) {
        downcasted = int200(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(200, value);
        }
    }

    /**
     * @dev Returns the downcasted int192 from int256, reverting on
     * overflow (when the input is less than smallest int192 or
     * greater than largest int192).
     *
     * Counterpart to Solidity's `int192` operator.
     *
     * Requirements:
     *
     * - input must fit into 192 bits
     */
    function toInt192(int256 value) internal pure returns (int192 downcasted) {
        downcasted = int192(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(192, value);
        }
    }

    /**
     * @dev Returns the downcasted int184 from int256, reverting on
     * overflow (when the input is less than smallest int184 or
     * greater than largest int184).
     *
     * Counterpart to Solidity's `int184` operator.
     *
     * Requirements:
     *
     * - input must fit into 184 bits
     */
    function toInt184(int256 value) internal pure returns (int184 downcasted) {
        downcasted = int184(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(184, value);
        }
    }

    /**
     * @dev Returns the downcasted int176 from int256, reverting on
     * overflow (when the input is less than smallest int176 or
     * greater than largest int176).
     *
     * Counterpart to Solidity's `int176` operator.
     *
     * Requirements:
     *
     * - input must fit into 176 bits
     */
    function toInt176(int256 value) internal pure returns (int176 downcasted) {
        downcasted = int176(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(176, value);
        }
    }

    /**
     * @dev Returns the downcasted int168 from int256, reverting on
     * overflow (when the input is less than smallest int168 or
     * greater than largest int168).
     *
     * Counterpart to Solidity's `int168` operator.
     *
     * Requirements:
     *
     * - input must fit into 168 bits
     */
    function toInt168(int256 value) internal pure returns (int168 downcasted) {
        downcasted = int168(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(168, value);
        }
    }

    /**
     * @dev Returns the downcasted int160 from int256, reverting on
     * overflow (when the input is less than smallest int160 or
     * greater than largest int160).
     *
     * Counterpart to Solidity's `int160` operator.
     *
     * Requirements:
     *
     * - input must fit into 160 bits
     */
    function toInt160(int256 value) internal pure returns (int160 downcasted) {
        downcasted = int160(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(160, value);
        }
    }

    /**
     * @dev Returns the downcasted int152 from int256, reverting on
     * overflow (when the input is less than smallest int152 or
     * greater than largest int152).
     *
     * Counterpart to Solidity's `int152` operator.
     *
     * Requirements:
     *
     * - input must fit into 152 bits
     */
    function toInt152(int256 value) internal pure returns (int152 downcasted) {
        downcasted = int152(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(152, value);
        }
    }

    /**
     * @dev Returns the downcasted int144 from int256, reverting on
     * overflow (when the input is less than smallest int144 or
     * greater than largest int144).
     *
     * Counterpart to Solidity's `int144` operator.
     *
     * Requirements:
     *
     * - input must fit into 144 bits
     */
    function toInt144(int256 value) internal pure returns (int144 downcasted) {
        downcasted = int144(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(144, value);
        }
    }

    /**
     * @dev Returns the downcasted int136 from int256, reverting on
     * overflow (when the input is less than smallest int136 or
     * greater than largest int136).
     *
     * Counterpart to Solidity's `int136` operator.
     *
     * Requirements:
     *
     * - input must fit into 136 bits
     */
    function toInt136(int256 value) internal pure returns (int136 downcasted) {
        downcasted = int136(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(136, value);
        }
    }

    /**
     * @dev Returns the downcasted int128 from int256, reverting on
     * overflow (when the input is less than smallest int128 or
     * greater than largest int128).
     *
     * Counterpart to Solidity's `int128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     */
    function toInt128(int256 value) internal pure returns (int128 downcasted) {
        downcasted = int128(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(128, value);
        }
    }

    /**
     * @dev Returns the downcasted int120 from int256, reverting on
     * overflow (when the input is less than smallest int120 or
     * greater than largest int120).
     *
     * Counterpart to Solidity's `int120` operator.
     *
     * Requirements:
     *
     * - input must fit into 120 bits
     */
    function toInt120(int256 value) internal pure returns (int120 downcasted) {
        downcasted = int120(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(120, value);
        }
    }

    /**
     * @dev Returns the downcasted int112 from int256, reverting on
     * overflow (when the input is less than smallest int112 or
     * greater than largest int112).
     *
     * Counterpart to Solidity's `int112` operator.
     *
     * Requirements:
     *
     * - input must fit into 112 bits
     */
    function toInt112(int256 value) internal pure returns (int112 downcasted) {
        downcasted = int112(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(112, value);
        }
    }

    /**
     * @dev Returns the downcasted int104 from int256, reverting on
     * overflow (when the input is less than smallest int104 or
     * greater than largest int104).
     *
     * Counterpart to Solidity's `int104` operator.
     *
     * Requirements:
     *
     * - input must fit into 104 bits
     */
    function toInt104(int256 value) internal pure returns (int104 downcasted) {
        downcasted = int104(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(104, value);
        }
    }

    /**
     * @dev Returns the downcasted int96 from int256, reverting on
     * overflow (when the input is less than smallest int96 or
     * greater than largest int96).
     *
     * Counterpart to Solidity's `int96` operator.
     *
     * Requirements:
     *
     * - input must fit into 96 bits
     */
    function toInt96(int256 value) internal pure returns (int96 downcasted) {
        downcasted = int96(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(96, value);
        }
    }

    /**
     * @dev Returns the downcasted int88 from int256, reverting on
     * overflow (when the input is less than smallest int88 or
     * greater than largest int88).
     *
     * Counterpart to Solidity's `int88` operator.
     *
     * Requirements:
     *
     * - input must fit into 88 bits
     */
    function toInt88(int256 value) internal pure returns (int88 downcasted) {
        downcasted = int88(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(88, value);
        }
    }

    /**
     * @dev Returns the downcasted int80 from int256, reverting on
     * overflow (when the input is less than smallest int80 or
     * greater than largest int80).
     *
     * Counterpart to Solidity's `int80` operator.
     *
     * Requirements:
     *
     * - input must fit into 80 bits
     */
    function toInt80(int256 value) internal pure returns (int80 downcasted) {
        downcasted = int80(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(80, value);
        }
    }

    /**
     * @dev Returns the downcasted int72 from int256, reverting on
     * overflow (when the input is less than smallest int72 or
     * greater than largest int72).
     *
     * Counterpart to Solidity's `int72` operator.
     *
     * Requirements:
     *
     * - input must fit into 72 bits
     */
    function toInt72(int256 value) internal pure returns (int72 downcasted) {
        downcasted = int72(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(72, value);
        }
    }

    /**
     * @dev Returns the downcasted int64 from int256, reverting on
     * overflow (when the input is less than smallest int64 or
     * greater than largest int64).
     *
     * Counterpart to Solidity's `int64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     */
    function toInt64(int256 value) internal pure returns (int64 downcasted) {
        downcasted = int64(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(64, value);
        }
    }

    /**
     * @dev Returns the downcasted int56 from int256, reverting on
     * overflow (when the input is less than smallest int56 or
     * greater than largest int56).
     *
     * Counterpart to Solidity's `int56` operator.
     *
     * Requirements:
     *
     * - input must fit into 56 bits
     */
    function toInt56(int256 value) internal pure returns (int56 downcasted) {
        downcasted = int56(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(56, value);
        }
    }

    /**
     * @dev Returns the downcasted int48 from int256, reverting on
     * overflow (when the input is less than smallest int48 or
     * greater than largest int48).
     *
     * Counterpart to Solidity's `int48` operator.
     *
     * Requirements:
     *
     * - input must fit into 48 bits
     */
    function toInt48(int256 value) internal pure returns (int48 downcasted) {
        downcasted = int48(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(48, value);
        }
    }

    /**
     * @dev Returns the downcasted int40 from int256, reverting on
     * overflow (when the input is less than smallest int40 or
     * greater than largest int40).
     *
     * Counterpart to Solidity's `int40` operator.
     *
     * Requirements:
     *
     * - input must fit into 40 bits
     */
    function toInt40(int256 value) internal pure returns (int40 downcasted) {
        downcasted = int40(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(40, value);
        }
    }

    /**
     * @dev Returns the downcasted int32 from int256, reverting on
     * overflow (when the input is less than smallest int32 or
     * greater than largest int32).
     *
     * Counterpart to Solidity's `int32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     */
    function toInt32(int256 value) internal pure returns (int32 downcasted) {
        downcasted = int32(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(32, value);
        }
    }

    /**
     * @dev Returns the downcasted int24 from int256, reverting on
     * overflow (when the input is less than smallest int24 or
     * greater than largest int24).
     *
     * Counterpart to Solidity's `int24` operator.
     *
     * Requirements:
     *
     * - input must fit into 24 bits
     */
    function toInt24(int256 value) internal pure returns (int24 downcasted) {
        downcasted = int24(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(24, value);
        }
    }

    /**
     * @dev Returns the downcasted int16 from int256, reverting on
     * overflow (when the input is less than smallest int16 or
     * greater than largest int16).
     *
     * Counterpart to Solidity's `int16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     */
    function toInt16(int256 value) internal pure returns (int16 downcasted) {
        downcasted = int16(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(16, value);
        }
    }

    /**
     * @dev Returns the downcasted int8 from int256, reverting on
     * overflow (when the input is less than smallest int8 or
     * greater than largest int8).
     *
     * Counterpart to Solidity's `int8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits
     */
    function toInt8(int256 value) internal pure returns (int8 downcasted) {
        downcasted = int8(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(8, value);
        }
    }

    /**
     * @dev Converts an unsigned uint256 into a signed int256.
     *
     * Requirements:
     *
     * - input must be less than or equal to maxInt256.
     */
    function toInt256(uint256 value) internal pure returns (int256) {
        // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
        if (value > uint256(type(int256).max)) {
            revert SafeCastOverflowedUintToInt(value);
        }
        return int256(value);
    }

    /**
     * @dev Cast a boolean (false or true) to a uint256 (0 or 1) with no jump.
     */
    function toUint(bool b) internal pure returns (uint256 u) {
        assembly ("memory-safe") {
            u := iszero(iszero(b))
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (access/IAccessControl.sol)

pragma solidity ^0.8.20;

/**
 * @dev External interface of AccessControl declared to support ERC-165 detection.
 */
interface IAccessControl {
    /**
     * @dev The `account` is missing a role.
     */
    error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);

    /**
     * @dev The caller of a function is not the expected one.
     *
     * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.
     */
    error AccessControlBadConfirmation();

    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted signaling this.
     */
    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call. This account bears the admin role (for the granted role).
     * Expected in cases where the role was granted using the internal {AccessControl-_grantRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) external view returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `callerConfirmation`.
     */
    function renounceRole(bytes32 role, address callerConfirmation) external;
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;

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

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/ERC165.sol)

pragma solidity ^0.8.20;

import {IERC165} from "./IERC165.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC-165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}

File 22 of 30 : Errors.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Errors.sol)

pragma solidity ^0.8.20;

/**
 * @dev Collection of common custom errors used in multiple contracts
 *
 * IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library.
 * It is recommended to avoid relying on the error API for critical functionality.
 *
 * _Available since v5.1._
 */
library Errors {
    /**
     * @dev The ETH balance of the account is not enough to perform the operation.
     */
    error InsufficientBalance(uint256 balance, uint256 needed);

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

    /**
     * @dev The deployment failed.
     */
    error FailedDeployment();

    /**
     * @dev A necessary precompile is missing.
     */
    error MissingPrecompile(address);
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

import { IEthFlow } from "src/vendor/cowswap/IEthFlow.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { AggregatorV3Interface } from "src/vendor/chainlink/AggregatorV3Interface.sol";

/**
 * @title IEthToBoldRouter
 * @notice Interface for the router that swaps ETH→BOLD using CowSwap Eth-flow,
 *         sizes `minOut` via Chainlink ETH/USD, tracks a single open intent per initiator,
 *         and exposes helpers to query or cancel the intent.
 */
interface IEthToBoldRouter {
    /*//////////////////////////////////////////////////////////////
                               ERRORS
    //////////////////////////////////////////////////////////////*/

    /// @notice Thrown when an address parameter is the zero address.
    error InvalidAddress();
    /// @notice Thrown when no ETH is sent for a swap.
    error NoEthSent();
    /// @notice Thrown when slippage bps is invalid or exceeds the max.
    error InvalidSlippage(uint256 slippage, uint256 maxSlippage);
    /// @notice Thrown when fee bps is invalid or exceeds the max.
    error InvalidFee(uint256 fee, uint256 maxFee);
    /// @notice Thrown when an initiator already has an open order.
    error OrderAlreadyOpen();
    /// @notice Thrown when the Chainlink price is non-positive.
    error OraclePriceInvalid(int256 px);
    /// @notice Thrown when the Chainlink price is stale.
    error StaleOracle();
    /// @notice Thrown when cancel is invoked with no active order.
    error NoActiveOrder();
    /// @notice Thrown when refunding ETH to the initiator fails.
    error FailedETHRefund();

    /*//////////////////////////////////////////////////////////////
                                EVENTS
    //////////////////////////////////////////////////////////////*/

    /// @notice Emitted when an intent is created on Eth-flow.
    /// @param initiator The initiating address (also the receiver of BOLD).
    /// @param ethIn The ETH amount committed.
    /// @param minBoldOut The minimum BOLD the order will accept.
    /// @param uid The 56-byte order UID.
    /// @param validTo Expiry timestamp used by the order.
    event IntentCreated(address indexed initiator, uint256 ethIn, uint256 minBoldOut, bytes32 uid, uint32 validTo);

    /// @notice Emitted when an open intent is actively cancelled.
    /// @param initiator The initiator cancelling their order.
    /// @param uid The order UID.
    /// @param ethRefunded Any ETH refunded back to the initiator.
    /// @param boldReceived Any BOLD received as results of succesful intent solving
    event IntentFinalized(address indexed initiator, bytes32 uid, uint256 ethRefunded, uint256 boldReceived);

    /*//////////////////////////////////////////////////////////////
                               STRUCTS
    //////////////////////////////////////////////////////////////*/

    /// @notice Local tracking for a single open order per initiator.
    struct Order {
        address initiator; // the calling address
        uint256 ethAmount; // telemetry/reference only
        bytes32 uid; // 56-byte order UID
        bool active; // order is open in our local view
        IEthFlow.Data data; // Intent data
    }

    /*//////////////////////////////////////////////////////////////
                       PUBLIC CONSTANTS & VARIABLES
    //////////////////////////////////////////////////////////////*/

    /// Role IDs used by AccessControl.
    function ADMIN_ROLE() external view returns (bytes32);
    function YIELD_MANAGER_ROLE() external view returns (bytes32);

    /// @notice Returns the CowSwap Eth-flow contract.
    function ETH_FLOW() external view returns (IEthFlow);

    /// @notice Returns the BOLD ERC-20 token.
    function BOLD() external view returns (IERC20);

    /// @notice Public getter for the pending order.
    function order()
        external
        view
        returns (address initiator, uint256 ethAmount, bytes32 uid, bool active, IEthFlow.Data memory data);

    /*//////////////////////////////////////////////////////////////
                                FUNCTIONS
    //////////////////////////////////////////////////////////////*/

    /**
     * @notice Swap caller’s ETH→BOLD via Eth-flow.
     * @dev Uses Chainlink ETH/USD to size `minOut` with the provided slippage bps and validity.
     *      Reverts with {NoEthSent}, {InvalidSlippage}, {OrderAlreadyOpen},
     *      {OraclePriceInvalid}, {StaleOracle} on failure.
     * @param minBoldBeforeSlippage Minimum amount of BOLD to expect before slippage taken into account.
     * @param slippageBps Maximum slippage in basis points (0 … 9,999).
     * @param validity Validity window (seconds) added to current timestamp.
     * @return uid The 56-byte UID of the created order.
     */
    function swapExactEthForBold(
        uint256 minBoldBeforeSlippage,
        uint16 slippageBps,
        uint32 validity
    ) external payable returns (bytes32 uid);

    /**
     * @notice Finalize the caller’s open intent and returns ETH and/or BOLD. If already filled/expired, closes local state without reverting.
     */
    function finalizeIntent() external;
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

/// @notice vault-specific interface for sBOLD.
interface ISBOLD {
    // --- Vault-specific methods ---
    /// Deposits BOLD and mints sBOLD shares to msg.sender.
    function deposit(uint256 boldAmount, address receiver) external returns (uint256 sharesMinted);

    /// Withdraws BOLD by burning sBOLD and sending it to the receiver.
    function withdraw(uint256 assets, address receiver, address owner) external returns (uint256);
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

/**
 * @title IPYBSeba
 * @notice Interface for the Perpetual Seba vault.
 * @dev Extends an ERC4626-style vault. It adds functions for topping up and distributing shares, as well as setting the BoostPool.
 */
interface IPYBSeba {
    /*//////////////////////////////////////////////////////////////
                              ERRORS
    //////////////////////////////////////////////////////////////*/

    /// @notice Thrown when an address parameter is the zero address.
    error InvalidAddress();
    /// @notice Thrown when a function is called by an address other than the SebaPool.
    /// @param sender The address that attempted the call.
    error NotSebaPool(address sender);
    /// @notice Thrown when a deposit or mint operation would result in zero shares.
    error ZeroShares();
    /// @notice Thrown when a deposit or mint operation would result in zero assets.
    error ZeroAssets();
    /// @notice Thrown when a deposit or mint would cause the total share supply to exceed the cap.
    error SupplyCapExceeded();
    /// @notice Thrown when a deposit is tried as it is not allowed.
    error DepositNotAllowed();
    /// @notice Thrown when a mint is tried as it is not allowed.
    error MintNotAllowed();

    /*//////////////////////////////////////////////////////////////
                              EVENTS
    //////////////////////////////////////////////////////////////*/

    /// @notice Emitted when the SebaPool address is updated.
    /// @param sebaPool The new SebaPool address.
    event SebaPoolChanged(address indexed sebaPool);
    /// @notice Emitted when the vault is topped up.
    /// @param sender The address initiating the topup.
    /// @param amount The amount of assets transferred.
    event Topup(address indexed sender, uint256 amount);
    /// @notice Emitted when shares are distributed.
    /// @param receiver The address receiving the shares.
    /// @param shares The number of shares distributed.
    event SharesDistributed(address indexed receiver, uint256 shares);

    /*//////////////////////////////////////////////////////////////
                         PUBLIC VARIABLES (Getters)
    //////////////////////////////////////////////////////////////*/

    /// @notice Returns the total assets held in the vault.
    function assetTotal() external view returns (uint256);
    /// @notice Returns the SebaPool contract address.
    function sebaPool() external view returns (address);

    /// @notice The role identifier for administrative functions.
    function ADMIN_ROLE() external view returns (bytes32);

    /*//////////////////////////////////////////////////////////////
                              FUNCTIONS
    //////////////////////////////////////////////////////////////*/

    /**
     * @notice Tops up the vault by transferring assets from the caller.
     * @dev See {topup} in the contract.
     * @param amount The amount of assets to top up.
     */
    function topup(uint256 amount) external;

    /**
     * @notice Distributes yield-bearing shares to a receiver.
     * @dev Can only be called by the BoostPool. Emits a {SharesDistributed} event.
     * @param receiver The address to receive shares.
     * @param shares The number of shares to distribute.
     */
    function distributeShares(address receiver, uint256 shares) external;

    /**
     * @notice Sets the SebaPool address.
     * @dev Reverts if the new address is zero. Emits a {SebaPoolChanged} event.
     * @param _sebaPool The new SebaPool address.
     */
    function setSebaPool(address _sebaPool) external;
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/IERC1363.sol)

pragma solidity ^0.8.20;

import {IERC20} from "./IERC20.sol";
import {IERC165} from "./IERC165.sol";

/**
 * @title IERC1363
 * @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
 *
 * Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
 * after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
 */
interface IERC1363 is IERC20, IERC165 {
    /*
     * Note: the ERC-165 identifier for this interface is 0xb0202a11.
     * 0xb0202a11 ===
     *   bytes4(keccak256('transferAndCall(address,uint256)')) ^
     *   bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
     *   bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
     *   bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
     *   bytes4(keccak256('approveAndCall(address,uint256)')) ^
     *   bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
     */

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferAndCall(address to, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @param data Additional data with no specified format, sent in call to `to`.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param from The address which you want to send tokens from.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferFromAndCall(address from, address to, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param from The address which you want to send tokens from.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @param data Additional data with no specified format, sent in call to `to`.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
     * @param spender The address which will spend the funds.
     * @param value The amount of tokens to be spent.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function approveAndCall(address spender, uint256 value) external returns (bool);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
     * @param spender The address which will spend the funds.
     * @param value The amount of tokens to be spent.
     * @param data Additional data with no specified format, sent in call to `spender`.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC-165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[ERC].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

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

interface IEthFlow {
    struct Data {
        /// @dev The address of the token that should be bought for ETH. It follows the same format as in the CoW Swap
        /// contracts, meaning that the token GPv2Transfer.BUY_ETH_ADDRESS (0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
        /// represents native ETH (and should most likely not be used in this context).
        IERC20 buyToken;
        /// @dev The address that should receive the proceeds from the order. Note that using the address
        /// GPv2Order.RECEIVER_SAME_AS_OWNER (i.e., the zero address) as the receiver is not allowed.
        address receiver;
        /// @dev The exact amount of ETH that should be sold in this order.
        uint256 sellAmount;
        /// @dev The minimum amount of buyToken that should be received to settle this order.
        uint256 buyAmount;
        /// @dev Extra data to include in the order. It is used by the CoW Swap infrastructure as extra information on
        /// the order and has no direct effect on on-chain execution.
        bytes32 appData;
        /// @dev The exact amount of ETH that should be paid by the user to the CoW Swap contract after the order is
        /// settled.
        uint256 feeAmount;
        /// @dev The last timestamp in seconds from which the order can be settled (order cannot resolve after this timestamp).
        uint32 validTo;
        /// @dev Flag indicating whether the order is fill-or-kill or can be filled partially.
        bool partiallyFillable;
        /// @dev quoteId The quote id obtained from the CoW Swap API to lock in the current price. It is not directly
        /// used by any onchain component but is part of the information emitted onchain on order creation and may be
        /// required for an order to be automatically picked up by the CoW Swap orderbook.
        int64 quoteId;
    }
    function createOrder(Data calldata order) external payable returns (bytes32 orderHash);

    function invalidateOrder(Data calldata order) external;
}

File 29 of 30 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "../token/ERC20/IERC20.sol";

File 30 of 30 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC165.sol)

pragma solidity ^0.8.20;

import {IERC165} from "../utils/introspection/IERC165.sol";

Settings
{
  "remappings": [
    "@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/",
    "forge-std/=node_modules/forge-std/",
    "@prb/test/=node_modules/@prb/test/src/",
    "@uniswap/v3-core/=node_modules/@uniswap/v3-core/\",/",
    "@uniswap/v3-periphery/=node_modules/@uniswap/v3-periphery/\"/",
    "base64-sol/=node_modules/base64-sol/",
    "solmate/=node_modules/solmate/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 10000
  },
  "metadata": {
    "useLiteralContent": false,
    "bytecodeHash": "none",
    "appendCBOR": false
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "cancun",
  "viaIR": false
}

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"address","name":"admin","type":"address"},{"internalType":"address","name":"yieldManager","type":"address"},{"internalType":"address","name":"_weth","type":"address"},{"internalType":"address","name":"_usdc","type":"address"},{"internalType":"address","name":"_swapRouter","type":"address"},{"internalType":"address","name":"_quoter","type":"address"},{"internalType":"address","name":"_curvePool","type":"address"},{"internalType":"address","name":"_beefy","type":"address"},{"internalType":"address","name":"_ethUsdFeed","type":"address"},{"internalType":"address","name":"_usdcUsdFeed","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[],"name":"CannotRetrieveZero","type":"error"},{"inputs":[],"name":"FailedCall","type":"error"},{"inputs":[{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"InsufficientBalance","type":"error"},{"inputs":[],"name":"InvalidAddress","type":"error"},{"inputs":[],"name":"NoEthProvided","type":"error"},{"inputs":[],"name":"NoSharesMinted","type":"error"},{"inputs":[],"name":"NoSharesToWithdraw","type":"error"},{"inputs":[],"name":"NothingToClaim","type":"error"},{"inputs":[],"name":"OracleInvalid","type":"error"},{"inputs":[],"name":"OracleStale","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[],"name":"SlippageExceeded","type":"error"},{"inputs":[],"name":"SlippageTooHigh","type":"error"},{"inputs":[],"name":"ZeroDepositValue","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"depositor","type":"address"},{"indexed":false,"internalType":"uint256","name":"ethIn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"sharesMinted","type":"uint256"}],"name":"Deposited","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"sharesRedeemed","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"ethOut","type":"uint256"}],"name":"PrincipalRetrieved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"bps","type":"uint16"}],"name":"SlippageSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"sharesRedeemed","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"ethOut","type":"uint256"}],"name":"YieldClaimed","type":"event"},{"inputs":[],"name":"ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ETH_USD_ORACLE_MAX_AGE","outputs":[{"internalType":"uint24","name":"","type":"uint24"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UNIV3_FEE_TIER","outputs":[{"internalType":"uint24","name":"","type":"uint24"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"USDC","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"USDC_USD_ORACLE_MAX_AGE","outputs":[{"internalType":"uint24","name":"","type":"uint24"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WETH","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"YIELDMANAGER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"beefy","outputs":[{"internalType":"contract IBeefyVault","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimYield","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"curvePool","outputs":[{"internalType":"contract ICurvePool","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"deposit","outputs":[{"internalType":"uint256","name":"depositValue","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"ethUsdFeed","outputs":[{"internalType":"contract AggregatorV3Interface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"principalShares","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"principalValue","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"quoter","outputs":[{"internalType":"contract IQuoter","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"depositValue","type":"uint256"}],"name":"retrievePrincipal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"bps","type":"uint16"}],"name":"setSlippageBps","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"slippageBps","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"swapRouter","outputs":[{"internalType":"contract ISwapRouter","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"usdcUsdFeed","outputs":[{"internalType":"contract AggregatorV3Interface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]

6101806040526002805461ffff1916603217905534801561001e575f5ffd5b5060405161364238038061364283398101604081905261003d9161037f565b600180556001600160a01b038a166100685760405163e6c4247b60e01b815260040160405180910390fd5b6001600160a01b03891661008f5760405163e6c4247b60e01b815260040160405180910390fd5b6001600160a01b0388166100b65760405163e6c4247b60e01b815260040160405180910390fd5b6001600160a01b0387166100dd5760405163e6c4247b60e01b815260040160405180910390fd5b6001600160a01b0386166101045760405163e6c4247b60e01b815260040160405180910390fd5b6001600160a01b03851661012b5760405163e6c4247b60e01b815260040160405180910390fd5b6001600160a01b0384166101525760405163e6c4247b60e01b815260040160405180910390fd5b6001600160a01b0383166101795760405163e6c4247b60e01b815260040160405180910390fd5b6001600160a01b0382166101a05760405163e6c4247b60e01b815260040160405180910390fd5b6001600160a01b0381166101c75760405163e6c4247b60e01b815260040160405180910390fd5b6101de5f5160206136225f395f51905f528b610271565b506101f65f5160206136025f395f51905f528a610271565b5061020e5f5160206136225f395f51905f528061031a565b6102325f5160206136025f395f51905f525f5160206136225f395f51905f5261031a565b6001600160a01b0397881660805295871660a05293861660c05291851660e0528416610100528316610120528216610140521661016052506104339050565b5f828152602081815260408083206001600160a01b038516845290915281205460ff16610311575f838152602081815260408083206001600160a01b03861684529091529020805460ff191660011790556102c93390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a4506001610314565b505f5b92915050565b5f82815260208190526040808220600101805490849055905190918391839186917fbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff9190a4505050565b80516001600160a01b038116811461037a575f5ffd5b919050565b5f5f5f5f5f5f5f5f5f5f6101408b8d031215610399575f5ffd5b6103a28b610364565b99506103b060208c01610364565b98506103be60408c01610364565b97506103cc60608c01610364565b96506103da60808c01610364565b95506103e860a08c01610364565b94506103f660c08c01610364565b935061040460e08c01610364565b92506104136101008c01610364565b91506104226101208c01610364565b90509295989b9194979a5092959850565b60805160a05160c05160e051610100516101205161014051610160516130396105c95f395f818161031b0152612a3b01525f81816103f601526129b201525f81816104f9015281816106f70152818161084f01528181610980015281816109e301528181610bc701528181611075015281816111d7015281816113080152818161136b0152818161154f01528181611ec001528181611f3501528181611fe3015281816120610152818161210701526121b801525f818161021801528181610aff01528181610c7501528181610d3001528181611487015281816115fd015281816116b801528181611c0c01528181611d0d0152611dde01525f818161057e0152818161243f015261290d01525f818161052c015281816124dc01526125c901525f818161042901528181610e2e015281816117b601528181611b7f01528181611d3f015281816123d701526128cd01525f81816104c601528181610e4f01528181610ea7015281816117d70152818161182f01528181611a6601528181611b5e015281816123ff01526128a501526130395ff3fe6080604052600436106101a7575f3560e01c80638009b7bd116100e7578063c31c9c0711610087578063d0e30db011610062578063d0e30db0146105a0578063d547741f146105a8578063f0b0a05a146105c7578063fd3d8139146105dc575f5ffd5b8063c31c9c071461051b578063c5479d4c1461054e578063c6bbd5a71461056d575f5ffd5b806393aa895a116100c257806393aa895a1461048d578063a217fddf146104a2578063ad5c4648146104b5578063bf4ab869146104e8575f5ffd5b80638009b7bd146103e557806389a302711461041857806391d148541461044b575f5ffd5b8063406cf229116101525780634fae11391161012d5780634fae11391461033d578063578c71d91461037057806375b238fc1461039d5780637da68d34146103d0575f5ffd5b8063406cf229146102cc5780634c3046df146102e05780634d9a75e51461030a575f5ffd5b8063248a9ca311610182578063248a9ca3146102525780632f2ff15d1461028e57806336568abe146102ad575f5ffd5b806301ffc9a7146101b25780631a55a6c7146101e6578063218751b214610207575f5ffd5b366101ae57005b5f5ffd5b3480156101bd575f5ffd5b506101d16101cc366004612cd0565b6105f1565b60405190151581526020015b60405180910390f35b3480156101f1575f5ffd5b50610205610200366004612d0f565b610689565b005b348015610212575f5ffd5b5061023a7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016101dd565b34801561025d575f5ffd5b5061028061026c366004612d0f565b5f9081526020819052604090206001015490565b6040519081526020016101dd565b348015610299575f5ffd5b506102056102a8366004612d3a565b610f62565b3480156102b8575f5ffd5b506102056102c7366004612d3a565b610f8c565b3480156102d7575f5ffd5b50610205610fdd565b3480156102eb575f5ffd5b506102f66201437081565b60405162ffffff90911681526020016101dd565b348015610315575f5ffd5b5061023a7f000000000000000000000000000000000000000000000000000000000000000081565b348015610348575f5ffd5b506102807f843ded6098cbc132fd5f02085d81d05d778b30640aa0bf194ad7683dd553f35381565b34801561037b575f5ffd5b5060025461038a9061ffff1681565b60405161ffff90911681526020016101dd565b3480156103a8575f5ffd5b506102807fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c2177581565b3480156103db575f5ffd5b5061028060045481565b3480156103f0575f5ffd5b5061023a7f000000000000000000000000000000000000000000000000000000000000000081565b348015610423575f5ffd5b5061023a7f000000000000000000000000000000000000000000000000000000000000000081565b348015610456575f5ffd5b506101d1610465366004612d3a565b5f918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b348015610498575f5ffd5b506102f66101f481565b3480156104ad575f5ffd5b506102805f81565b3480156104c0575f5ffd5b5061023a7f000000000000000000000000000000000000000000000000000000000000000081565b3480156104f3575f5ffd5b5061023a7f000000000000000000000000000000000000000000000000000000000000000081565b348015610526575f5ffd5b5061023a7f000000000000000000000000000000000000000000000000000000000000000081565b348015610559575f5ffd5b50610205610568366004612d68565b611926565b348015610578575f5ffd5b5061023a7f000000000000000000000000000000000000000000000000000000000000000081565b6102806119f8565b3480156105b3575f5ffd5b506102056105c2366004612d3a565b612310565b3480156105d2575f5ffd5b506102f6610e1081565b3480156105e7575f5ffd5b5061028060035481565b5f7fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b00000000000000000000000000000000000000000000000000000000148061068357507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b610691612334565b7f843ded6098cbc132fd5f02085d81d05d778b30640aa0bf194ad7683dd553f3536106bb81612377565b815f036106f4576040517fe2cd3e9a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166377c7b8fc6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610751573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906107759190612d89565b90505f8161078b85670de0b6b3a7640000612dcd565b6107959190612e11565b9050805f036107d0576040517ff22c500100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6003548111156107fe5750600354670de0b6b3a76400006107f18383612dcd565b6107fb9190612e11565b93505b5f600354826004546108109190612dcd565b61081a9190612e11565b90508160035f82825461082d9190612e49565b925050819055508060045f8282546108459190612e49565b925050819055505f7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316631f1fcd516040518163ffffffff1660e01b8152600401602060405180830381865afa1580156108a9573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906108cd9190612e5c565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b0391909116906370a0823190602401602060405180830381865afa15801561092a573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061094e9190612d89565b6040517f2e1a7d4d000000000000000000000000000000000000000000000000000000008152600481018590529091507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690632e1a7d4d906024015f604051808303815f87803b1580156109c9575f5ffd5b505af11580156109db573d5f5f3e3d5ffd5b505050505f817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316631f1fcd516040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a3d573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a619190612e5c565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b0391909116906370a0823190602401602060405180830381865afa158015610abe573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610ae29190612d89565b610aec9190612e49565b90505f6c0c9f2c9cd04674edea400000007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663bb7b8b806040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b59573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610b7d9190612d89565b610b879084612dcd565b610b919190612e11565b6002549091505f9061271090610bab9061ffff1682612e77565b610bb99061ffff1684612dcd565b610bc39190612e11565b90507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316631f1fcd516040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c21573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610c459190612e5c565b6040517f095ea7b30000000000000000000000000000000000000000000000000000000081526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000008116600483015260248201869052919091169063095ea7b3906044016020604051808303815f875af1158015610ccc573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610cf09190612e91565b506040517f1a4d01d20000000000000000000000000000000000000000000000000000000081526004810184905260016024820152604481018290525f907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690631a4d01d2906064016020604051808303815f875af1158015610d7e573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610da29190612d89565b90505f610dae82612381565b6002549091505f9061271090610dc89061ffff1682612e77565b610dd69061ffff1684612dcd565b610de09190612e11565b90505f610dec846123a7565b905081811015610e28576040517f8199f5f300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f610e757f00000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000000087856124ac565b6040517f2e1a7d4d000000000000000000000000000000000000000000000000000000008152600481018290529091507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690632e1a7d4d906024015f604051808303815f87803b158015610ef0575f5ffd5b505af1158015610f02573d5f5f3e3d5ffd5b50505050610f103382612648565b604080518c8152602081018390527f73bcff5b0439792d025981fa38899fabf40de0b38cc908216e767f4f9948c3e0910160405180910390a150505050505050505050505050610f5f60018055565b50565b5f82815260208190526040902060010154610f7c81612377565b610f8683836126f2565b50505050565b6001600160a01b0381163314610fce576040517f6697b23200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610fd882826127b7565b505050565b610fe5612334565b7f843ded6098cbc132fd5f02085d81d05d778b30640aa0bf194ad7683dd553f35361100f81612377565b5f336001600160a01b031663c2f18a1a6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561104c573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906110709190612e91565b90505f7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166377c7b8fc6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156110cf573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906110f39190612d89565b90505f670de0b6b3a76400008260035461110d9190612dcd565b6111179190612e11565b905082158061112857506004548111155b1561116d57604080515f80825260208201527fcf996e5ed7066f464b47962b0c29e7da8e4cd86d95981acf1d4bbdcc4e38de4e910160405180910390a150505061191a565b5f826004548361117d9190612e49565b61118f90670de0b6b3a7640000612dcd565b6111999190612e11565b9050805f036111d4576040517f969bf72800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316631f1fcd516040518163ffffffff1660e01b8152600401602060405180830381865afa158015611231573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906112559190612e5c565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b0391909116906370a0823190602401602060405180830381865afa1580156112b2573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906112d69190612d89565b6040517f2e1a7d4d000000000000000000000000000000000000000000000000000000008152600481018490529091507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690632e1a7d4d906024015f604051808303815f87803b158015611351575f5ffd5b505af1158015611363573d5f5f3e3d5ffd5b505050505f817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316631f1fcd516040518163ffffffff1660e01b8152600401602060405180830381865afa1580156113c5573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906113e99190612e5c565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b0391909116906370a0823190602401602060405180830381865afa158015611446573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061146a9190612d89565b6114749190612e49565b90505f6c0c9f2c9cd04674edea400000007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663bb7b8b806040518163ffffffff1660e01b8152600401602060405180830381865afa1580156114e1573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906115059190612d89565b61150f9084612dcd565b6115199190612e11565b6002549091505f90612710906115339061ffff1682612e77565b6115419061ffff1684612dcd565b61154b9190612e11565b90507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316631f1fcd516040518163ffffffff1660e01b8152600401602060405180830381865afa1580156115a9573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906115cd9190612e5c565b6040517f095ea7b30000000000000000000000000000000000000000000000000000000081526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000008116600483015260248201869052919091169063095ea7b3906044016020604051808303815f875af1158015611654573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906116789190612e91565b506040517f1a4d01d20000000000000000000000000000000000000000000000000000000081526004810184905260016024820152604481018290525f907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690631a4d01d2906064016020604051808303815f875af1158015611706573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061172a9190612d89565b90505f61173682612381565b6002549091505f90612710906117509061ffff1682612e77565b61175e9061ffff1684612dcd565b6117689190612e11565b90505f611774846123a7565b9050818110156117b0576040517f8199f5f300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f6117fd7f00000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000000087856124ac565b6040517f2e1a7d4d000000000000000000000000000000000000000000000000000000008152600481018290529091507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690632e1a7d4d906024015f604051808303815f87803b158015611878575f5ffd5b505af115801561188a573d5f5f3e3d5ffd5b505050508960035f82825461189f9190612e49565b9091555050600354670de0b6b3a7640000906118bc908e90612dcd565b6118c69190612e11565b6004556118d33382612648565b604080518b8152602081018390527fcf996e5ed7066f464b47962b0c29e7da8e4cd86d95981acf1d4bbdcc4e38de4e910160405180910390a1505050505050505050505050505b5061192460018055565b565b7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c2177561195081612377565b6103e88261ffff161115611990576040517f850c6f7600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00001661ffff84169081179091556040519081527ff81c5fcf3aecd6806cef1d458fedb8ca3fb79150451dc8c8d1aef6215c4a82d89060200160405180910390a15050565b5f611a01612334565b7f843ded6098cbc132fd5f02085d81d05d778b30640aa0bf194ad7683dd553f353611a2b81612377565b345f03611a64576040517f5b03a9be00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004015f604051808303818588803b158015611abd575f5ffd5b505af1158015611acf573d5f5f3e3d5ffd5b50505050505f611ade34612856565b6002549091505f9061271090611af89061ffff1682612e77565b611b069061ffff1684612dcd565b611b109190612e11565b90505f611b1c34612875565b905081811015611b58576040517f8199f5f300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f611ba57f00000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000000034856124ac565b6040805160028082526060820183529293505f9290916020830190803683370190505090505f815f81518110611bdd57611bdd612eb0565b6020026020010181815250508181600181518110611bfd57611bfd612eb0565b6020026020010181815250505f7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663bb7b8b806040518163ffffffff1660e01b8152600401602060405180830381865afa158015611c66573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611c8a9190612d89565b611ca1846c0c9f2c9cd04674edea40000000612dcd565b611cab9190612e11565b6002549091505f9061271090611cc59061ffff1682612e77565b611cd39061ffff1684612dcd565b611cdd9190612e11565b6040517f095ea7b30000000000000000000000000000000000000000000000000000000081526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081166004830152602482018790529192507f00000000000000000000000000000000000000000000000000000000000000009091169063095ea7b3906044016020604051808303815f875af1158015611d87573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611dab9190612e91565b506040517fb72df5de0000000000000000000000000000000000000000000000000000000081525f906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063b72df5de90611e159087908690600401612edd565b6020604051808303815f875af1158015611e31573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611e559190612d89565b9050805f03611e90576040517f8199f5f300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201525f907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa158015611f0d573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611f319190612d89565b90507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316631f1fcd516040518163ffffffff1660e01b8152600401602060405180830381865afa158015611f8f573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611fb39190612e5c565b6040517f095ea7b30000000000000000000000000000000000000000000000000000000081526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000008116600483015260248201859052919091169063095ea7b3906044016020604051808303815f875af115801561203a573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061205e9190612e91565b507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663de5f62686040518163ffffffff1660e01b81526004015f604051808303815f87803b1580156120b7575f5ffd5b505af11580156120c9573d5f5f3e3d5ffd5b50506040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201525f92508391506001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906370a0823190602401602060405180830381865afa15801561214c573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906121709190612d89565b61217a9190612e49565b9050805f036121b5576040517f77f43aca00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166377c7b8fc6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612212573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906122369190612d89565b90508160035f8282546122499190612f29565b90915550670de0b6b3a764000090506122628284612dcd565b61226c9190612e11565b9c508c5f036122a7576040517f6620a2aa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8c60045f8282546122b89190612f29565b9091555050604080513481526020810184905233917f73a19dd210f1a7f902193214c0ee91dd35ee5b4d920cba8d519eca65a7b488ca910160405180910390a250505050505050505050505061230d60018055565b90565b5f8281526020819052604090206001015461232a81612377565b610f8683836127b7565b600260015403612370576040517f3ee5aeb500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6002600155565b610f5f813361293e565b5f5f61238b6129ad565b90506123a083670de0b6b3a764000083612ba8565b9392505050565b6040517ff7729d430000000000000000000000000000000000000000000000000000000081526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811660048301527f0000000000000000000000000000000000000000000000000000000000000000811660248301526101f46044830152606482018390525f60848301819052917f00000000000000000000000000000000000000000000000000000000000000009091169063f7729d439060a4015b6020604051808303815f875af1158015612488573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906106839190612d89565b6040517f095ea7b30000000000000000000000000000000000000000000000000000000081526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081166004830152602482018490525f919086169063095ea7b3906044016020604051808303815f875af1158015612534573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906125589190612e91565b5060408051610100810182526001600160a01b03808816825286811660208301526101f48284015230606083015242608083015260a0820186905260c082018590525f60e083015291517f414bf38900000000000000000000000000000000000000000000000000000000815290917f0000000000000000000000000000000000000000000000000000000000000000169063414bf389906125fe908490600401612f3c565b6020604051808303815f875af115801561261a573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061263e9190612d89565b9695505050505050565b80471015612690576040517fcf479181000000000000000000000000000000000000000000000000000000008152476004820152602481018290526044015b60405180910390fd5b5f5f836001600160a01b0316836040515f6040518083038185875af1925050503d805f81146126da576040519150601f19603f3d011682016040523d82523d5f602084013e6126df565b606091505b509150915081610f8657610f8681612c7d565b5f828152602081815260408083206001600160a01b038516845290915281205460ff166127b0575f838152602081815260408083206001600160a01b0386168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556127683390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a4506001610683565b505f610683565b5f828152602081815260408083206001600160a01b038516845290915281205460ff16156127b0575f838152602081815260408083206001600160a01b038616808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a4506001610683565b5f5f6128606129ad565b90506123a08382670de0b6b3a7640000612ba8565b6040517ff7729d430000000000000000000000000000000000000000000000000000000081526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811660048301527f0000000000000000000000000000000000000000000000000000000000000000811660248301526101f46044830152606482018390525f60848301819052917f00000000000000000000000000000000000000000000000000000000000000009091169063f7729d439060a40161246c565b5f828152602081815260408083206001600160a01b038516845290915290205460ff166129a9576040517fe2517d3f0000000000000000000000000000000000000000000000000000000081526001600160a01b038216600482015260248101839052604401612687565b5050565b5f5f5f7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015612a0c573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612a309190612feb565b509350509250505f5f7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015612a95573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612ab99190612feb565b509350509250505f84131580612acf57505f8213155b15612b06576040517fb421e52200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610e10612b138442612e49565b1115612b4b576040517f0457869800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62014370612b598242612e49565b1115612b91576040517f0457869800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612b9f84620f424084612ba8565b94505050505090565b5f838302817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff85870982811083820303915050805f03612bfb57838281612bf157612bf1612de4565b04925050506123a0565b808411612c1257612c126003851502601118612cbf565b5f848688095f868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b805115612c8d5780518082602001fd5b6040517fd6bda27500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b634e487b715f52806020526024601cfd5b5f60208284031215612ce0575f5ffd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146123a0575f5ffd5b5f60208284031215612d1f575f5ffd5b5035919050565b6001600160a01b0381168114610f5f575f5ffd5b5f5f60408385031215612d4b575f5ffd5b823591506020830135612d5d81612d26565b809150509250929050565b5f60208284031215612d78575f5ffd5b813561ffff811681146123a0575f5ffd5b5f60208284031215612d99575f5ffd5b5051919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b808202811582820484141761068357610683612da0565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f82612e44577f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b500490565b8181038181111561068357610683612da0565b5f60208284031215612e6c575f5ffd5b81516123a081612d26565b61ffff828116828216039081111561068357610683612da0565b5f60208284031215612ea1575f5ffd5b815180151581146123a0575f5ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b604080825283519082018190525f9060208501906060840190835b81811015612f16578351835260209384019390920191600101612ef8565b5050602093909301939093525092915050565b8082018082111561068357610683612da0565b5f610100820190506001600160a01b0383511682526001600160a01b03602084015116602083015262ffffff60408401511660408301526060830151612f8d60608401826001600160a01b03169052565b506080830151608083015260a083015160a083015260c083015160c083015260e0830151612fc660e08401826001600160a01b03169052565b5092915050565b805169ffffffffffffffffffff81168114612fe6575f5ffd5b919050565b5f5f5f5f5f60a08688031215612fff575f5ffd5b61300886612fcd565b6020870151604088015160608901519297509095509350915061302d60808701612fcd565b9050929550929590935056843ded6098cbc132fd5f02085d81d05d778b30640aa0bf194ad7683dd553f353a49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c217750000000000000000000000005ebaaa3e84f9595fbf787a71c3caad97d370bc280000000000000000000000005ebaaa3e84f9595fbf787a71c3caad97d370bc28000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564000000000000000000000000b27308f9f90d607463bb33ea1bebb41c27ce5ab600000000000000000000000008bfa22bb3e024cdfeb3eca53c0cb93bf59c41470000000000000000000000001817cffc44c78d5aed61420bf48cc273e504b7be000000000000000000000000c0053f3fbccd593758258334dfce24c2a9a673ad0000000000000000000000008fffffd4afb6115b954bd326cbe7b4ba576818f6

Deployed Bytecode

0x6080604052600436106101a7575f3560e01c80638009b7bd116100e7578063c31c9c0711610087578063d0e30db011610062578063d0e30db0146105a0578063d547741f146105a8578063f0b0a05a146105c7578063fd3d8139146105dc575f5ffd5b8063c31c9c071461051b578063c5479d4c1461054e578063c6bbd5a71461056d575f5ffd5b806393aa895a116100c257806393aa895a1461048d578063a217fddf146104a2578063ad5c4648146104b5578063bf4ab869146104e8575f5ffd5b80638009b7bd146103e557806389a302711461041857806391d148541461044b575f5ffd5b8063406cf229116101525780634fae11391161012d5780634fae11391461033d578063578c71d91461037057806375b238fc1461039d5780637da68d34146103d0575f5ffd5b8063406cf229146102cc5780634c3046df146102e05780634d9a75e51461030a575f5ffd5b8063248a9ca311610182578063248a9ca3146102525780632f2ff15d1461028e57806336568abe146102ad575f5ffd5b806301ffc9a7146101b25780631a55a6c7146101e6578063218751b214610207575f5ffd5b366101ae57005b5f5ffd5b3480156101bd575f5ffd5b506101d16101cc366004612cd0565b6105f1565b60405190151581526020015b60405180910390f35b3480156101f1575f5ffd5b50610205610200366004612d0f565b610689565b005b348015610212575f5ffd5b5061023a7f00000000000000000000000008bfa22bb3e024cdfeb3eca53c0cb93bf59c414781565b6040516001600160a01b0390911681526020016101dd565b34801561025d575f5ffd5b5061028061026c366004612d0f565b5f9081526020819052604090206001015490565b6040519081526020016101dd565b348015610299575f5ffd5b506102056102a8366004612d3a565b610f62565b3480156102b8575f5ffd5b506102056102c7366004612d3a565b610f8c565b3480156102d7575f5ffd5b50610205610fdd565b3480156102eb575f5ffd5b506102f66201437081565b60405162ffffff90911681526020016101dd565b348015610315575f5ffd5b5061023a7f0000000000000000000000008fffffd4afb6115b954bd326cbe7b4ba576818f681565b348015610348575f5ffd5b506102807f843ded6098cbc132fd5f02085d81d05d778b30640aa0bf194ad7683dd553f35381565b34801561037b575f5ffd5b5060025461038a9061ffff1681565b60405161ffff90911681526020016101dd565b3480156103a8575f5ffd5b506102807fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c2177581565b3480156103db575f5ffd5b5061028060045481565b3480156103f0575f5ffd5b5061023a7f000000000000000000000000c0053f3fbccd593758258334dfce24c2a9a673ad81565b348015610423575f5ffd5b5061023a7f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4881565b348015610456575f5ffd5b506101d1610465366004612d3a565b5f918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b348015610498575f5ffd5b506102f66101f481565b3480156104ad575f5ffd5b506102805f81565b3480156104c0575f5ffd5b5061023a7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b3480156104f3575f5ffd5b5061023a7f0000000000000000000000001817cffc44c78d5aed61420bf48cc273e504b7be81565b348015610526575f5ffd5b5061023a7f000000000000000000000000e592427a0aece92de3edee1f18e0157c0586156481565b348015610559575f5ffd5b50610205610568366004612d68565b611926565b348015610578575f5ffd5b5061023a7f000000000000000000000000b27308f9f90d607463bb33ea1bebb41c27ce5ab681565b6102806119f8565b3480156105b3575f5ffd5b506102056105c2366004612d3a565b612310565b3480156105d2575f5ffd5b506102f6610e1081565b3480156105e7575f5ffd5b5061028060035481565b5f7fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b00000000000000000000000000000000000000000000000000000000148061068357507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b610691612334565b7f843ded6098cbc132fd5f02085d81d05d778b30640aa0bf194ad7683dd553f3536106bb81612377565b815f036106f4576040517fe2cd3e9a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f7f0000000000000000000000001817cffc44c78d5aed61420bf48cc273e504b7be6001600160a01b03166377c7b8fc6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610751573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906107759190612d89565b90505f8161078b85670de0b6b3a7640000612dcd565b6107959190612e11565b9050805f036107d0576040517ff22c500100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6003548111156107fe5750600354670de0b6b3a76400006107f18383612dcd565b6107fb9190612e11565b93505b5f600354826004546108109190612dcd565b61081a9190612e11565b90508160035f82825461082d9190612e49565b925050819055508060045f8282546108459190612e49565b925050819055505f7f0000000000000000000000001817cffc44c78d5aed61420bf48cc273e504b7be6001600160a01b0316631f1fcd516040518163ffffffff1660e01b8152600401602060405180830381865afa1580156108a9573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906108cd9190612e5c565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b0391909116906370a0823190602401602060405180830381865afa15801561092a573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061094e9190612d89565b6040517f2e1a7d4d000000000000000000000000000000000000000000000000000000008152600481018590529091507f0000000000000000000000001817cffc44c78d5aed61420bf48cc273e504b7be6001600160a01b031690632e1a7d4d906024015f604051808303815f87803b1580156109c9575f5ffd5b505af11580156109db573d5f5f3e3d5ffd5b505050505f817f0000000000000000000000001817cffc44c78d5aed61420bf48cc273e504b7be6001600160a01b0316631f1fcd516040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a3d573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a619190612e5c565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b0391909116906370a0823190602401602060405180830381865afa158015610abe573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610ae29190612d89565b610aec9190612e49565b90505f6c0c9f2c9cd04674edea400000007f00000000000000000000000008bfa22bb3e024cdfeb3eca53c0cb93bf59c41476001600160a01b031663bb7b8b806040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b59573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610b7d9190612d89565b610b879084612dcd565b610b919190612e11565b6002549091505f9061271090610bab9061ffff1682612e77565b610bb99061ffff1684612dcd565b610bc39190612e11565b90507f0000000000000000000000001817cffc44c78d5aed61420bf48cc273e504b7be6001600160a01b0316631f1fcd516040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c21573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610c459190612e5c565b6040517f095ea7b30000000000000000000000000000000000000000000000000000000081526001600160a01b037f00000000000000000000000008bfa22bb3e024cdfeb3eca53c0cb93bf59c41478116600483015260248201869052919091169063095ea7b3906044016020604051808303815f875af1158015610ccc573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610cf09190612e91565b506040517f1a4d01d20000000000000000000000000000000000000000000000000000000081526004810184905260016024820152604481018290525f907f00000000000000000000000008bfa22bb3e024cdfeb3eca53c0cb93bf59c41476001600160a01b031690631a4d01d2906064016020604051808303815f875af1158015610d7e573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610da29190612d89565b90505f610dae82612381565b6002549091505f9061271090610dc89061ffff1682612e77565b610dd69061ffff1684612dcd565b610de09190612e11565b90505f610dec846123a7565b905081811015610e28576040517f8199f5f300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f610e757f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb487f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc287856124ac565b6040517f2e1a7d4d000000000000000000000000000000000000000000000000000000008152600481018290529091507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031690632e1a7d4d906024015f604051808303815f87803b158015610ef0575f5ffd5b505af1158015610f02573d5f5f3e3d5ffd5b50505050610f103382612648565b604080518c8152602081018390527f73bcff5b0439792d025981fa38899fabf40de0b38cc908216e767f4f9948c3e0910160405180910390a150505050505050505050505050610f5f60018055565b50565b5f82815260208190526040902060010154610f7c81612377565b610f8683836126f2565b50505050565b6001600160a01b0381163314610fce576040517f6697b23200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610fd882826127b7565b505050565b610fe5612334565b7f843ded6098cbc132fd5f02085d81d05d778b30640aa0bf194ad7683dd553f35361100f81612377565b5f336001600160a01b031663c2f18a1a6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561104c573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906110709190612e91565b90505f7f0000000000000000000000001817cffc44c78d5aed61420bf48cc273e504b7be6001600160a01b03166377c7b8fc6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156110cf573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906110f39190612d89565b90505f670de0b6b3a76400008260035461110d9190612dcd565b6111179190612e11565b905082158061112857506004548111155b1561116d57604080515f80825260208201527fcf996e5ed7066f464b47962b0c29e7da8e4cd86d95981acf1d4bbdcc4e38de4e910160405180910390a150505061191a565b5f826004548361117d9190612e49565b61118f90670de0b6b3a7640000612dcd565b6111999190612e11565b9050805f036111d4576040517f969bf72800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f7f0000000000000000000000001817cffc44c78d5aed61420bf48cc273e504b7be6001600160a01b0316631f1fcd516040518163ffffffff1660e01b8152600401602060405180830381865afa158015611231573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906112559190612e5c565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b0391909116906370a0823190602401602060405180830381865afa1580156112b2573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906112d69190612d89565b6040517f2e1a7d4d000000000000000000000000000000000000000000000000000000008152600481018490529091507f0000000000000000000000001817cffc44c78d5aed61420bf48cc273e504b7be6001600160a01b031690632e1a7d4d906024015f604051808303815f87803b158015611351575f5ffd5b505af1158015611363573d5f5f3e3d5ffd5b505050505f817f0000000000000000000000001817cffc44c78d5aed61420bf48cc273e504b7be6001600160a01b0316631f1fcd516040518163ffffffff1660e01b8152600401602060405180830381865afa1580156113c5573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906113e99190612e5c565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b0391909116906370a0823190602401602060405180830381865afa158015611446573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061146a9190612d89565b6114749190612e49565b90505f6c0c9f2c9cd04674edea400000007f00000000000000000000000008bfa22bb3e024cdfeb3eca53c0cb93bf59c41476001600160a01b031663bb7b8b806040518163ffffffff1660e01b8152600401602060405180830381865afa1580156114e1573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906115059190612d89565b61150f9084612dcd565b6115199190612e11565b6002549091505f90612710906115339061ffff1682612e77565b6115419061ffff1684612dcd565b61154b9190612e11565b90507f0000000000000000000000001817cffc44c78d5aed61420bf48cc273e504b7be6001600160a01b0316631f1fcd516040518163ffffffff1660e01b8152600401602060405180830381865afa1580156115a9573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906115cd9190612e5c565b6040517f095ea7b30000000000000000000000000000000000000000000000000000000081526001600160a01b037f00000000000000000000000008bfa22bb3e024cdfeb3eca53c0cb93bf59c41478116600483015260248201869052919091169063095ea7b3906044016020604051808303815f875af1158015611654573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906116789190612e91565b506040517f1a4d01d20000000000000000000000000000000000000000000000000000000081526004810184905260016024820152604481018290525f907f00000000000000000000000008bfa22bb3e024cdfeb3eca53c0cb93bf59c41476001600160a01b031690631a4d01d2906064016020604051808303815f875af1158015611706573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061172a9190612d89565b90505f61173682612381565b6002549091505f90612710906117509061ffff1682612e77565b61175e9061ffff1684612dcd565b6117689190612e11565b90505f611774846123a7565b9050818110156117b0576040517f8199f5f300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f6117fd7f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb487f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc287856124ac565b6040517f2e1a7d4d000000000000000000000000000000000000000000000000000000008152600481018290529091507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031690632e1a7d4d906024015f604051808303815f87803b158015611878575f5ffd5b505af115801561188a573d5f5f3e3d5ffd5b505050508960035f82825461189f9190612e49565b9091555050600354670de0b6b3a7640000906118bc908e90612dcd565b6118c69190612e11565b6004556118d33382612648565b604080518b8152602081018390527fcf996e5ed7066f464b47962b0c29e7da8e4cd86d95981acf1d4bbdcc4e38de4e910160405180910390a1505050505050505050505050505b5061192460018055565b565b7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c2177561195081612377565b6103e88261ffff161115611990576040517f850c6f7600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00001661ffff84169081179091556040519081527ff81c5fcf3aecd6806cef1d458fedb8ca3fb79150451dc8c8d1aef6215c4a82d89060200160405180910390a15050565b5f611a01612334565b7f843ded6098cbc132fd5f02085d81d05d778b30640aa0bf194ad7683dd553f353611a2b81612377565b345f03611a64576040517f5b03a9be00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004015f604051808303818588803b158015611abd575f5ffd5b505af1158015611acf573d5f5f3e3d5ffd5b50505050505f611ade34612856565b6002549091505f9061271090611af89061ffff1682612e77565b611b069061ffff1684612dcd565b611b109190612e11565b90505f611b1c34612875565b905081811015611b58576040517f8199f5f300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f611ba57f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc27f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4834856124ac565b6040805160028082526060820183529293505f9290916020830190803683370190505090505f815f81518110611bdd57611bdd612eb0565b6020026020010181815250508181600181518110611bfd57611bfd612eb0565b6020026020010181815250505f7f00000000000000000000000008bfa22bb3e024cdfeb3eca53c0cb93bf59c41476001600160a01b031663bb7b8b806040518163ffffffff1660e01b8152600401602060405180830381865afa158015611c66573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611c8a9190612d89565b611ca1846c0c9f2c9cd04674edea40000000612dcd565b611cab9190612e11565b6002549091505f9061271090611cc59061ffff1682612e77565b611cd39061ffff1684612dcd565b611cdd9190612e11565b6040517f095ea7b30000000000000000000000000000000000000000000000000000000081526001600160a01b037f00000000000000000000000008bfa22bb3e024cdfeb3eca53c0cb93bf59c414781166004830152602482018790529192507f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb489091169063095ea7b3906044016020604051808303815f875af1158015611d87573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611dab9190612e91565b506040517fb72df5de0000000000000000000000000000000000000000000000000000000081525f906001600160a01b037f00000000000000000000000008bfa22bb3e024cdfeb3eca53c0cb93bf59c4147169063b72df5de90611e159087908690600401612edd565b6020604051808303815f875af1158015611e31573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611e559190612d89565b9050805f03611e90576040517f8199f5f300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201525f907f0000000000000000000000001817cffc44c78d5aed61420bf48cc273e504b7be6001600160a01b0316906370a0823190602401602060405180830381865afa158015611f0d573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611f319190612d89565b90507f0000000000000000000000001817cffc44c78d5aed61420bf48cc273e504b7be6001600160a01b0316631f1fcd516040518163ffffffff1660e01b8152600401602060405180830381865afa158015611f8f573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611fb39190612e5c565b6040517f095ea7b30000000000000000000000000000000000000000000000000000000081526001600160a01b037f0000000000000000000000001817cffc44c78d5aed61420bf48cc273e504b7be8116600483015260248201859052919091169063095ea7b3906044016020604051808303815f875af115801561203a573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061205e9190612e91565b507f0000000000000000000000001817cffc44c78d5aed61420bf48cc273e504b7be6001600160a01b031663de5f62686040518163ffffffff1660e01b81526004015f604051808303815f87803b1580156120b7575f5ffd5b505af11580156120c9573d5f5f3e3d5ffd5b50506040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201525f92508391506001600160a01b037f0000000000000000000000001817cffc44c78d5aed61420bf48cc273e504b7be16906370a0823190602401602060405180830381865afa15801561214c573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906121709190612d89565b61217a9190612e49565b9050805f036121b5576040517f77f43aca00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f7f0000000000000000000000001817cffc44c78d5aed61420bf48cc273e504b7be6001600160a01b03166377c7b8fc6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612212573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906122369190612d89565b90508160035f8282546122499190612f29565b90915550670de0b6b3a764000090506122628284612dcd565b61226c9190612e11565b9c508c5f036122a7576040517f6620a2aa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8c60045f8282546122b89190612f29565b9091555050604080513481526020810184905233917f73a19dd210f1a7f902193214c0ee91dd35ee5b4d920cba8d519eca65a7b488ca910160405180910390a250505050505050505050505061230d60018055565b90565b5f8281526020819052604090206001015461232a81612377565b610f8683836127b7565b600260015403612370576040517f3ee5aeb500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6002600155565b610f5f813361293e565b5f5f61238b6129ad565b90506123a083670de0b6b3a764000083612ba8565b9392505050565b6040517ff7729d430000000000000000000000000000000000000000000000000000000081526001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48811660048301527f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2811660248301526101f46044830152606482018390525f60848301819052917f000000000000000000000000b27308f9f90d607463bb33ea1bebb41c27ce5ab69091169063f7729d439060a4015b6020604051808303815f875af1158015612488573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906106839190612d89565b6040517f095ea7b30000000000000000000000000000000000000000000000000000000081526001600160a01b037f000000000000000000000000e592427a0aece92de3edee1f18e0157c0586156481166004830152602482018490525f919086169063095ea7b3906044016020604051808303815f875af1158015612534573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906125589190612e91565b5060408051610100810182526001600160a01b03808816825286811660208301526101f48284015230606083015242608083015260a0820186905260c082018590525f60e083015291517f414bf38900000000000000000000000000000000000000000000000000000000815290917f000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564169063414bf389906125fe908490600401612f3c565b6020604051808303815f875af115801561261a573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061263e9190612d89565b9695505050505050565b80471015612690576040517fcf479181000000000000000000000000000000000000000000000000000000008152476004820152602481018290526044015b60405180910390fd5b5f5f836001600160a01b0316836040515f6040518083038185875af1925050503d805f81146126da576040519150601f19603f3d011682016040523d82523d5f602084013e6126df565b606091505b509150915081610f8657610f8681612c7d565b5f828152602081815260408083206001600160a01b038516845290915281205460ff166127b0575f838152602081815260408083206001600160a01b0386168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556127683390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a4506001610683565b505f610683565b5f828152602081815260408083206001600160a01b038516845290915281205460ff16156127b0575f838152602081815260408083206001600160a01b038616808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a4506001610683565b5f5f6128606129ad565b90506123a08382670de0b6b3a7640000612ba8565b6040517ff7729d430000000000000000000000000000000000000000000000000000000081526001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2811660048301527f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48811660248301526101f46044830152606482018390525f60848301819052917f000000000000000000000000b27308f9f90d607463bb33ea1bebb41c27ce5ab69091169063f7729d439060a40161246c565b5f828152602081815260408083206001600160a01b038516845290915290205460ff166129a9576040517fe2517d3f0000000000000000000000000000000000000000000000000000000081526001600160a01b038216600482015260248101839052604401612687565b5050565b5f5f5f7f000000000000000000000000c0053f3fbccd593758258334dfce24c2a9a673ad6001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015612a0c573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612a309190612feb565b509350509250505f5f7f0000000000000000000000008fffffd4afb6115b954bd326cbe7b4ba576818f66001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015612a95573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612ab99190612feb565b509350509250505f84131580612acf57505f8213155b15612b06576040517fb421e52200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610e10612b138442612e49565b1115612b4b576040517f0457869800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62014370612b598242612e49565b1115612b91576040517f0457869800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612b9f84620f424084612ba8565b94505050505090565b5f838302817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff85870982811083820303915050805f03612bfb57838281612bf157612bf1612de4565b04925050506123a0565b808411612c1257612c126003851502601118612cbf565b5f848688095f868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b805115612c8d5780518082602001fd5b6040517fd6bda27500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b634e487b715f52806020526024601cfd5b5f60208284031215612ce0575f5ffd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146123a0575f5ffd5b5f60208284031215612d1f575f5ffd5b5035919050565b6001600160a01b0381168114610f5f575f5ffd5b5f5f60408385031215612d4b575f5ffd5b823591506020830135612d5d81612d26565b809150509250929050565b5f60208284031215612d78575f5ffd5b813561ffff811681146123a0575f5ffd5b5f60208284031215612d99575f5ffd5b5051919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b808202811582820484141761068357610683612da0565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f82612e44577f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b500490565b8181038181111561068357610683612da0565b5f60208284031215612e6c575f5ffd5b81516123a081612d26565b61ffff828116828216039081111561068357610683612da0565b5f60208284031215612ea1575f5ffd5b815180151581146123a0575f5ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b604080825283519082018190525f9060208501906060840190835b81811015612f16578351835260209384019390920191600101612ef8565b5050602093909301939093525092915050565b8082018082111561068357610683612da0565b5f610100820190506001600160a01b0383511682526001600160a01b03602084015116602083015262ffffff60408401511660408301526060830151612f8d60608401826001600160a01b03169052565b506080830151608083015260a083015160a083015260c083015160c083015260e0830151612fc660e08401826001600160a01b03169052565b5092915050565b805169ffffffffffffffffffff81168114612fe6575f5ffd5b919050565b5f5f5f5f5f60a08688031215612fff575f5ffd5b61300886612fcd565b6020870151604088015160608901519297509095509350915061302d60808701612fcd565b9050929550929590935056

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

0000000000000000000000005ebaaa3e84f9595fbf787a71c3caad97d370bc280000000000000000000000005ebaaa3e84f9595fbf787a71c3caad97d370bc28000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564000000000000000000000000b27308f9f90d607463bb33ea1bebb41c27ce5ab600000000000000000000000008bfa22bb3e024cdfeb3eca53c0cb93bf59c41470000000000000000000000001817cffc44c78d5aed61420bf48cc273e504b7be000000000000000000000000c0053f3fbccd593758258334dfce24c2a9a673ad0000000000000000000000008fffffd4afb6115b954bd326cbe7b4ba576818f6

-----Decoded View---------------
Arg [0] : admin (address): 0x5EBAAA3E84F9595fBF787A71C3CAad97d370BC28
Arg [1] : yieldManager (address): 0x5EBAAA3E84F9595fBF787A71C3CAad97d370BC28
Arg [2] : _weth (address): 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
Arg [3] : _usdc (address): 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
Arg [4] : _swapRouter (address): 0xE592427A0AEce92De3Edee1F18E0157C05861564
Arg [5] : _quoter (address): 0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6
Arg [6] : _curvePool (address): 0x08BfA22bB3e024CDfEB3eca53c0cb93bF59c4147
Arg [7] : _beefy (address): 0x1817CFfc44c78d5aED61420bF48Cc273E504B7BE
Arg [8] : _ethUsdFeed (address): 0xc0053f3FBcCD593758258334Dfce24C2A9A673aD
Arg [9] : _usdcUsdFeed (address): 0x8fFfFfd4AfB6115b954Bd326cbe7B4BA576818f6

-----Encoded View---------------
10 Constructor Arguments found :
Arg [0] : 0000000000000000000000005ebaaa3e84f9595fbf787a71c3caad97d370bc28
Arg [1] : 0000000000000000000000005ebaaa3e84f9595fbf787a71c3caad97d370bc28
Arg [2] : 000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
Arg [3] : 000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48
Arg [4] : 000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564
Arg [5] : 000000000000000000000000b27308f9f90d607463bb33ea1bebb41c27ce5ab6
Arg [6] : 00000000000000000000000008bfa22bb3e024cdfeb3eca53c0cb93bf59c4147
Arg [7] : 0000000000000000000000001817cffc44c78d5aed61420bf48cc273e504b7be
Arg [8] : 000000000000000000000000c0053f3fbccd593758258334dfce24c2a9a673ad
Arg [9] : 0000000000000000000000008fffffd4afb6115b954bd326cbe7b4ba576818f6


Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.