ETH Price: $2,129.81 (-13.62%)

Contract

0x63c2bFC348E4193432E5dC5a3496ae39d4C6FD15
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Create Fixed ERC...202991022024-07-13 17:34:11233 days ago1720892051IN
0x63c2bFC3...9d4C6FD15
0 ETH0.002991871.96571776
Create Fixed ERC...202859732024-07-11 21:31:59235 days ago1720733519IN
0x63c2bFC3...9d4C6FD15
0 ETH0.006478584.25647838
Create Fixed ERC...202782432024-07-10 19:38:59236 days ago1720640339IN
0x63c2bFC3...9d4C6FD15
0 ETH0.008204295.39036982
Create Fixed ERC...202771542024-07-10 16:00:35236 days ago1720627235IN
0x63c2bFC3...9d4C6FD15
0 ETH0.0365529624.01596278
Create Fixed ERC...202764342024-07-10 13:35:23236 days ago1720618523IN
0x63c2bFC3...9d4C6FD15
0 ETH0.011735657.7105362
Create Fixed ERC...202757402024-07-10 11:16:23236 days ago1720610183IN
0x63c2bFC3...9d4C6FD15
0 ETH0.009406055.88003809
Create Fixed ERC...202725262024-07-10 0:30:59237 days ago1720571459IN
0x63c2bFC3...9d4C6FD15
0 ETH0.0036682.42136719
Create Fixed Nat...202724742024-07-10 0:20:35237 days ago1720570835IN
0x63c2bFC3...9d4C6FD15
0 ETH0.003371082.32222801
Create Fixed Nat...202716542024-07-09 21:35:23237 days ago1720560923IN
0x63c2bFC3...9d4C6FD15
0 ETH0.008208225.65437034

Latest 9 internal transactions

Advanced mode:
Parent Transaction Hash Block
From
To
202991022024-07-13 17:34:11233 days ago1720892051
0x63c2bFC3...9d4C6FD15
 Contract Creation0 ETH
202859732024-07-11 21:31:59235 days ago1720733519
0x63c2bFC3...9d4C6FD15
 Contract Creation0 ETH
202782432024-07-10 19:38:59236 days ago1720640339
0x63c2bFC3...9d4C6FD15
 Contract Creation0 ETH
202771542024-07-10 16:00:35236 days ago1720627235
0x63c2bFC3...9d4C6FD15
 Contract Creation0 ETH
202764342024-07-10 13:35:23236 days ago1720618523
0x63c2bFC3...9d4C6FD15
 Contract Creation0 ETH
202757402024-07-10 11:16:23236 days ago1720610183
0x63c2bFC3...9d4C6FD15
 Contract Creation0 ETH
202725262024-07-10 0:30:59237 days ago1720571459
0x63c2bFC3...9d4C6FD15
 Contract Creation0 ETH
202724742024-07-10 0:20:35237 days ago1720570835
0x63c2bFC3...9d4C6FD15
 Contract Creation0 ETH
202716542024-07-09 21:35:23237 days ago1720560923
0x63c2bFC3...9d4C6FD15
 Contract Creation0 ETH
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
FixedPriceFactory

Compiler Version
v0.8.25+commit.b61c2a91

Optimization Enabled:
Yes with 200 runs

Other Settings:
paris EvmVersion
File 1 of 9 : FixedPriceFactory.sol
//SPDX-License-Identifier: MIT

pragma solidity =0.8.25;

import "./FixedERC20MVP.sol";
import "./FixedNativeMVP.sol";
import "solady/utils/CREATE3.sol";

contract FixedPriceFactory {
    using CREATE3 for *;

    event PoolCreated(address indexed poolAddress, PoolType poolType);

    error PoolCreationFailed();

    enum PoolType {
        Native,
        ERC20
    }

    function createFixedNative(
        address _shareToken,
        uint256 _weiPerToken,
        uint256 _sharesForSale,
        uint256 _userMaxShares,
        address _feeRecipient,
        uint256 _platformFeeWAD,
        uint256 _swapFeeWAD,
        uint40 _saleStart,
        uint40 _saleEnd,
        uint40 _redemptionTimestamp
    )
        public
        returns (address pool)
    {
        bytes32 salt = keccak256(
            abi.encodePacked(
                msg.sender,
                _shareToken,
                _weiPerToken,
                _sharesForSale,
                _userMaxShares,
                _feeRecipient,
                _platformFeeWAD,
                _swapFeeWAD,
                _saleStart,
                _saleEnd,
                _redemptionTimestamp
            )
        );

        pool = salt.deploy(
            getCreationBytecodeNative(
                msg.sender,
                _shareToken,
                _weiPerToken,
                _sharesForSale,
                _userMaxShares,
                _feeRecipient,
                _platformFeeWAD,
                _swapFeeWAD,
                _saleStart,
                _saleEnd,
                _redemptionTimestamp
            ),
            0
        );
        if (pool == address(0)) revert PoolCreationFailed();
        emit PoolCreated(pool, PoolType.Native);
    }

    function getFixedNativeAddress(
        address _sender,
        address _shareToken,
        uint256 _weiPerToken,
        uint256 _sharesForSale,
        uint256 _userMaxShares,
        address _feeRecipient,
        uint256 _platformFeeWAD,
        uint256 _swapFeeWAD,
        uint40 _saleStart,
        uint40 _saleEnd,
        uint40 _redemptionTimestamp
    )
        public
        view
        returns (address)
    {
        bytes32 salt = keccak256(
            abi.encodePacked(
                _sender,
                _shareToken,
                _weiPerToken,
                _sharesForSale,
                _userMaxShares,
                _feeRecipient,
                _platformFeeWAD,
                _swapFeeWAD,
                _saleStart,
                _saleEnd,
                _redemptionTimestamp
            )
        );

        return CREATE3.getDeployed(salt);
    }

    function createFixedERC20(
        address _shareToken,
        address _assetToken,
        uint256 _assetsPerToken,
        uint256 _sharesForSale,
        uint256 _userMaxShares,
        address _feeRecipient,
        uint256 _platformFeeWAD,
        uint256 _swapFeeWAD,
        uint40 _saleStart,
        uint40 _saleEnd,
        uint40 _redemptionTimestamp
    )
        public
        returns (address pool)
    {
        bytes32 salt = keccak256(
            abi.encodePacked(
                msg.sender,
                _shareToken,
                _assetToken,
                _assetsPerToken,
                _sharesForSale,
                _userMaxShares,
                _feeRecipient,
                _platformFeeWAD,
                _swapFeeWAD,
                _saleStart,
                _saleEnd,
                _redemptionTimestamp
            )
        );

        pool = salt.deploy(
            getCreationBytecodeERC20(
                msg.sender,
                _shareToken,
                _assetToken,
                _assetsPerToken,
                _sharesForSale,
                _userMaxShares,
                _feeRecipient,
                _platformFeeWAD,
                _swapFeeWAD,
                _saleStart,
                _saleEnd,
                _redemptionTimestamp
            ),
            0
        );
        if (pool == address(0)) {
            revert PoolCreationFailed();
        }
        emit PoolCreated(pool, PoolType.ERC20);
    }

    function getFixedERC20Address(
        address _sender,
        address _shareToken,
        address _assetToken,
        uint256 _assetsPerToken,
        uint256 _sharesForSale,
        uint256 _userMaxShares,
        address _feeRecipient,
        uint256 _platformFeeWAD,
        uint256 _swapFeeWAD,
        uint40 _saleStart,
        uint40 _saleEnd,
        uint40 _redemptionTimestamp
    )
        public
        view
        returns (address)
    {
        bytes32 salt = keccak256(
            abi.encodePacked(
                _sender,
                _shareToken,
                _assetToken,
                _assetsPerToken,
                _sharesForSale,
                _userMaxShares,
                _feeRecipient,
                _platformFeeWAD,
                _swapFeeWAD,
                _saleStart,
                _saleEnd,
                _redemptionTimestamp
            )
        );
        return CREATE3.getDeployed(salt);
    }

    function getCreationBytecodeNative(
        address _owner,
        address _shareToken,
        uint256 _weiPerToken,
        uint256 _sharesForSale,
        uint256 _userMaximumShares,
        address _feeRecipient,
        uint256 _platformFeeWAD,
        uint256 _swapFeeWAD,
        uint40 _saleStart,
        uint40 _saleEnd,
        uint40 _redemptionTimestamp
    )
        public
        pure
        returns (bytes memory)
    {
        bytes memory bytecode = type(FixedNativeMVP).creationCode;

        return abi.encodePacked(
            bytecode,
            abi.encode(
                _owner,
                _shareToken,
                _weiPerToken,
                _sharesForSale,
                _userMaximumShares,
                _feeRecipient,
                _platformFeeWAD,
                _swapFeeWAD,
                _saleStart,
                _saleEnd,
                _redemptionTimestamp
            )
        );
    }

    function getCreationBytecodeERC20(
        address _owner,
        address _shareToken,
        address _assetToken,
        uint256 _assetsPerToken,
        uint256 _sharesForSale,
        uint256 _userMaximumShares,
        address _feeRecipient,
        uint256 _platformFeeWAD,
        uint256 _swapFeeWAD,
        uint40 _saleStart,
        uint40 _saleEnd,
        uint40 _redemptionTimestamp
    )
        public
        pure
        returns (bytes memory)
    {
        bytes memory bytecode = type(FixedERC20MVP).creationCode;

        return abi.encodePacked(
            bytecode,
            abi.encode(
                _owner,
                _shareToken,
                _assetToken,
                _assetsPerToken,
                _sharesForSale,
                _userMaximumShares,
                _feeRecipient,
                _platformFeeWAD,
                _swapFeeWAD,
                _saleStart,
                _saleEnd,
                _redemptionTimestamp
            )
        );
    }
}

File 2 of 9 : FixedERC20MVP.sol
//SPDX-License-Identifier: MIT

pragma solidity =0.8.25;

import "solady/utils/SafeTransferLib.sol";
import "solady/utils/FixedPointMathLib.sol";
import "solady/utils/ReentrancyGuard.sol";
// import { ReentrancyGuard, FixedPointMathLib, SafeTransferLib } from "solady/Milady.sol";

import "./interfaces/IERC20.sol";
import "./types.sol";

/// Allows the creation of a fixed price pool where users can purchase shares of an ERC20 token
/// exclusively utilizing another ERC20 token. The pool creator can set the number of shares available
/// for purchase and the price of each share in the asset token. The pool creator can also set a fee
/// percentage that will be taken from the raised funds and sent to a fee recipient. The pool creator
/// can also set the start and end dates of the sale, as well as the date when the shares can be redeemed.
/// The pool creator can pause/unpause the sale, deposit initial shares for trading, cancel the sale before
/// it begins, and close the pool to distribute the fees and remaining funds. Users can purchase shares
/// during the sale period, and redeem their shares after the redemption date has passed.

contract FixedERC20MVP is ReentrancyGuard {
    /// -----------------------------------------------------------------------
    /// Dependencies
    /// -----------------------------------------------------------------------
    using SafeTransferLib for address;
    using FixedPointMathLib for uint256;

    /// -----------------------------------------------------------------------
    /// Errors
    /// -----------------------------------------------------------------------
    error InsufficientFunds();
    error SaleInactive();
    error AlreadyClosed();
    error InvalidDates();
    error InvalidFee();
    error InvalidPrice();
    error SaleActive();
    error ZeroAddress();
    error SharesOutExceeded();
    error NotOwner();
    error RedeemedTooEarly();
    error AlreadyDeposited();
    error SaleCancelled();
    error TransferZero();
    error UserMaxSharesExceeded();
    error PurchaseTooLow();
    error InvalidAmount();

    /// -----------------------------------------------------------------------
    /// Events
    /// -----------------------------------------------------------------------

    event BuyFixedShares(address indexed recipient, uint256 sharesOut, uint256 assetsIn);
    event SharesDeposited(uint256 amount);
    event PauseToggled(bool paused);
    event Closed(uint256 totalFundsRaised, uint256 totalSharesSold, uint256 fee);
    event Redeemed(address indexed recipient, uint256 shares);
    event PoolCreated(address indexed poolAddress);
    event PoolCanceled();
    event PoolCompleted();

    /// -----------------------------------------------------------------------
    /// Immutable State
    /// -----------------------------------------------------------------------
    /// @notice The number of assets (with decimals) required to purchase 1 share.
    uint256 public immutable assetsPerToken;
    /// @notice The number of shares available for purchase (with decimals.)
    uint256 public immutable sharesForSale;
    /// @notice The fee percentage in WAD (1e18) that will be taken from the raised funds.
    uint256 public immutable platformFeeWAD;
    uint256 public immutable swapFeeWAD;
    /// @notice The maximum number of shares (with decimals) a user can purchase per sale.
    uint256 public immutable userMaximumShares;
    /// @notice The address of the pool creator that retains administrative control.
    address public immutable owner;
    /// @notice The address that will receive the fees generated from the raised funds.
    address public immutable feeRecipient;
    /// @notice The address of the ERC20 token that represents the shares.
    address public immutable shareToken;
    /// @notice The address of the ERC20 token that will be used to purchase shares.
    address public immutable assetToken;
    /// @notice The timestamp when the sale will begin.
    uint40 public immutable saleStart;
    /// @notice The timestamp when the sale will end.
    uint40 public immutable saleEnd;
    /// @notice The timestamp when the shares can be redeemed.
    uint40 public immutable redemptionTimestamp;

    uint8 private immutable assetDecimals;
    uint8 private immutable shareDecimals;

    /// -----------------------------------------------------------------------
    /// Mutable State
    /// -----------------------------------------------------------------------
    uint256 public totalSharesSold;
    uint256 public swapFees;
    bool public closed;
    bool public paused;
    bool public canceled;
    mapping(address => uint256) public purchasedShares;

    /// -----------------------------------------------------------------------
    /// Modifiers
    /// -----------------------------------------------------------------------
    modifier whenSaleActive() {
        if (
            uint40(block.timestamp) < saleStart || uint40(block.timestamp) >= saleEnd || closed
                || canceled || paused
        ) {
            revert SaleInactive();
        }
        _;
    }

    modifier onlyOwner() {
        if (msg.sender != owner) {
            revert NotOwner();
        }
        _;
    }

    constructor(
        address _owner,
        address _shareToken,
        address _assetToken,
        uint256 _assetsPerToken,
        uint256 _sharesForSale,
        uint256 _userMaximumShares,
        address _feeRecipient,
        uint256 _platformFeeWAD,
        uint256 _swapFeeWAD,
        uint40 _saleStart,
        uint40 _saleEnd,
        uint40 _redemptionTimestamp
    ) {
        if (_shareToken == address(0) || _assetToken == address(0) || _feeRecipient == address(0)) {
            revert ZeroAddress();
        }
        if (_saleStart >= _saleEnd || _saleEnd > _redemptionTimestamp) revert InvalidDates();
        if (_platformFeeWAD >= 1e18 || _swapFeeWAD >= 1e18) revert InvalidFee();
        if (_assetsPerToken == 0) revert InvalidPrice();

        shareToken = _shareToken;
        assetToken = _assetToken;
        assetsPerToken = _assetsPerToken;
        owner = _owner;
        platformFeeWAD = _platformFeeWAD;
        swapFeeWAD = _swapFeeWAD;
        feeRecipient = _feeRecipient;
        saleStart = _saleStart;
        saleEnd = _saleEnd;
        redemptionTimestamp = _redemptionTimestamp;
        sharesForSale = _sharesForSale;
        userMaximumShares = _userMaximumShares > 0 ? _userMaximumShares : type(uint256).max;

        shareToken.safeTransferFrom(_owner, address(this), sharesForSale);
        shareDecimals = IERC20(shareToken).decimals();
        assetDecimals = IERC20(assetToken).decimals();
        emit SharesDeposited(sharesForSale);
    }

    /// @notice Creates a new Fixed Price (Native Token) Pool
    /// @param _owner The address of the pool creator that retains administrative control.
    /// @param _shareToken The address of the ERC20-share that's up for purchase.
    /// @param _assetsPerToken The number of tokens used to purchase 1 unit of the share token (including token decimals).
    /// @param _sharesForSale The number of shares available for purchase. (including token decimals)
    /// @param _userMaximumShares The maximum number of shares a user can purchase per sale.
    /// @param _feeRecipient The address that will receive the fees generated from the raised funds.
    /// @param _feeWAD The fee percentage in WAD (1e18) that will be taken from the raised funds. 1e18 = 100% fee.
    /// @param _saleStart The timestamp when the sale will begin.
    /// @param _saleEnd The timestamp when the sale will end.
    /// @param _redemptionTimestamp The timestamp when the shares can be redeemed.

    /// -----------------------------------------------------------------------
    /// Public Write Functions
    /// -----------------------------------------------------------------------

    /// @notice Allows a user to buy shares in the pool with ERC20 assets.
    /// @param shares The number of shares to purchase.
    /// @param recipient The address that will receive the shares once redeemed.
    function buyExactShares(
        uint256 shares,
        address recipient
    )
        external
        nonReentrant
        whenSaleActive
        returns (uint256 assetsIn)
    {
        if (shares == 0) {
            revert TransferZero();
        }
        if (shares + totalSharesSold > sharesForSale) {
            revert SharesOutExceeded();
        }
        if (shares + purchasedShares[recipient] > userMaximumShares) {
            revert UserMaxSharesExceeded();
        }
        if (recipient == address(0)) {
            revert ZeroAddress();
        }

        if (!_isAboveMandatoryMinimum(shares)) {
            revert PurchaseTooLow();
        }

        if (sharesRemaining() - shares < getMandatoryMinimum()) {
            revert InvalidAmount();
        }

        uint256 sharesScaled = scaleTokenBefore(shareDecimals, shares);

        uint256 priceScaled = scaleTokenBefore(assetDecimals, assetsPerToken);

        uint256 assetsInScaled = sharesScaled.mulWad(priceScaled);

        assetsIn = scaleTokenAfter(assetDecimals, assetsInScaled);

        if (assetsIn == 0) {
            revert TransferZero();
        }

        uint256 _swapFees = assetsIn.mulWad(swapFeeWAD);

        totalSharesSold += shares;
        purchasedShares[recipient] += shares;
        swapFees += _swapFees;

        assetsIn = assetsIn.rawAdd(_swapFees);

        assetToken.safeTransferFrom(msg.sender, address(this), assetsIn);

        if (totalSharesSold == sharesForSale) {
            emit PoolCompleted();
        }

        emit BuyFixedShares(recipient, shares, assetsIn);
    }

    function scaleTokenBefore(
        uint8 decimals,
        uint256 value
    )
        internal
        pure
        returns (uint256 scaledAmount)
    {
        scaledAmount = value;
        if (decimals < 18) {
            uint8 decimalDiff = 18 - decimals;
            scaledAmount *= 10 ** decimalDiff;
        } else if (decimals > 18) {
            uint8 decimalDiff = decimals - 18;
            scaledAmount /= 10 ** decimalDiff;
        }
    }

    function scaleTokenAfter(
        uint8 decimals,
        uint256 value
    )
        internal
        pure
        returns (uint256 scaledAmount)
    {
        scaledAmount = value;
        if (decimals < 18) {
            uint8 decimalDiff = 18 - decimals;
            scaledAmount /= 10 ** decimalDiff;
        } else if (decimals > 18) {
            uint8 decimalDiff = decimals - 18;
            scaledAmount *= 10 ** decimalDiff;
        }
    }

    /// @notice Allows any user to close the pool and distribute the fees.
    /// @dev The pool can only be closed after the sale end date has passed, OR the max shares sold have been reached.
    function close()
        external
        nonReentrant
        returns (uint256 feesGenerated, uint256 fundsRaised, uint256 sharesNotSold)
    {
        if (!canClose()) {
            revert SaleActive();
        }

        closed = true;
        feesGenerated = IERC20(assetToken).balanceOf(address(this)).rawSub(swapFees).mulWad(
            platformFeeWAD
        ).rawAdd(swapFees);

        if (feesGenerated > 0) {
            assetToken.safeTransfer(feeRecipient, feesGenerated);
        }

        fundsRaised = IERC20(assetToken).balanceOf(address(this));

        if (fundsRaised > 0) {
            assetToken.safeTransfer(owner, fundsRaised);
        }

        sharesNotSold = sharesForSale - totalSharesSold;

        if (sharesNotSold > 0) {
            shareToken.safeTransfer(owner, sharesNotSold);
        }

        emit Closed(fundsRaised, totalSharesSold, feesGenerated);
    }

    /// @notice Allows a user to redeem purchased shares after the redemption date has passed.
    function redeem() external nonReentrant returns (uint256 shares) {
        if (canceled) {
            revert SaleCancelled();
        }
        if (!closed) {
            revert SaleActive();
        }

        if (uint40(block.timestamp) < redemptionTimestamp) {
            revert RedeemedTooEarly();
        }

        shares = purchasedShares[msg.sender];
        delete purchasedShares[msg.sender];

        if (shares > 0) {
            shareToken.safeTransfer(msg.sender, shares);
        }
        emit Redeemed(msg.sender, shares);
    }

    /// -----------------------------------------------------------------------
    /// Owner-Only Write Functions
    /// -----------------------------------------------------------------------

    /// @notice Allows the pool creator to pause/unpause the sale, halting/enabling any trading activity.
    function togglePause() external nonReentrant onlyOwner {
        paused = !paused;
        emit PauseToggled(paused);
    }

    /// @notice Allows the pool creator to cancel the sale and withdraw all funds and shares before a sale begins.
    function cancelSale() external nonReentrant onlyOwner {
        if (closed) {
            revert AlreadyClosed();
        }
        if (canceled) {
            revert SaleCancelled();
        }
        if (uint40(block.timestamp) >= saleStart) {
            revert SaleActive();
        }

        canceled = true;
        shareToken.safeTransfer(owner, sharesForSale);
        emit PoolCanceled();
    }

    /// -----------------------------------------------------------------------
    /// Public Read Functions
    /// -----------------------------------------------------------------------

    /// @notice Checks if the pool can be closed.
    /// @return True if the pool can be closed, false otherwise.
    /// @dev The pool can be closed if all shares have been sold, or the sale end date has passed.
    function canClose() public view returns (bool) {
        if (canceled || closed) {
            return false;
        }
        if (totalSharesSold == sharesForSale || uint40(block.timestamp) >= saleEnd) {
            return true;
        }

        return false;
    }
    /// @notice Returns the number of shares remaining for purchase.

    function sharesRemaining() public view returns (uint256) {
        return sharesForSale - totalSharesSold;
    }
    /// @notice Returns the number of shares remaining for purchase for a specific user.

    function userSharesRemaining(address user) external view returns (uint256) {
        return userMaximumShares - purchasedShares[user];
    }

    function args() public view returns (PoolArgs memory) {
        return (
            PoolArgs(
                shareToken,
                assetToken,
                owner,
                feeRecipient,
                assetsPerToken,
                sharesForSale,
                platformFeeWAD,
                swapFeeWAD,
                saleStart,
                saleEnd,
                redemptionTimestamp,
                totalSharesSold,
                closed,
                paused,
                canceled,
                canClose(),
                userMaximumShares,
                getMandatoryMinimum()
            )
        );
    }

    function _isAboveMandatoryMinimum(uint256 amount) internal view returns (bool) {
        return amount >= getMandatoryMinimum();
    }

    function getMandatoryMinimum() public view returns (uint256) {
        if (shareDecimals > assetDecimals) {
            return 10 ** (shareDecimals - assetDecimals);
        } else {
            return 0;
        }
    }
}

File 3 of 9 : FixedNativeMVP.sol
//SPDX-License-Identifier: MIT

pragma solidity =0.8.25;

import "solady/utils/SafeTransferLib.sol";
import "solady/utils/FixedPointMathLib.sol";
import "solady/utils/ReentrancyGuard.sol";

import "./interfaces/IERC20.sol";

import "./types.sol";

/// Allows the creation of a fixed price pool where users can purchase shares of an ERC20 token
/// exclusively utilizing another the native token. The pool creator can set the number of shares available
/// for purchase and the price of each share in the asset token. The pool creator can also set a fee
/// percentage that will be taken from the raised funds and sent to a fee recipient. The pool creator
/// can also set the start and end dates of the sale, as well as the date when the shares can be redeemed.
/// The pool creator can pause/unpause the sale, deposit initial shares for trading, cancel the sale before
/// it begins, and close the pool to distribute the fees and remaining funds. Users can purchase shares
/// during the sale period, and redeem their shares after the redemption date has passed.

contract FixedNativeMVP is ReentrancyGuard {
    /// -----------------------------------------------------------------------
    /// Dependencies
    /// -----------------------------------------------------------------------
    using SafeTransferLib for address;
    using FixedPointMathLib for uint256;

    /// -----------------------------------------------------------------------
    /// Errors
    /// -----------------------------------------------------------------------

    error InsufficientFunds();
    error SaleInactive();
    error AlreadyClosed();
    error InvalidDates();
    error SaleActive();
    error InvalidFee();
    error ZeroAddress();
    error SharesOutExceeded();
    error NotOwner();
    error RedeemedTooEarly();
    error AlreadyDeposited();
    error TransferZero();
    error UserMaxSharesExceeded();
    error SaleCancelled();
    error PurchaseTooLow();
    error InvalidAmount();

    /// -----------------------------------------------------------------------
    /// Events
    /// -----------------------------------------------------------------------

    event BuyFixedShares(address indexed recipient, uint256 sharesOut, uint256 assetsIn);
    event SharesDeposited(uint256 amount);
    event PauseToggled(bool paused);
    event Closed(uint256 totalFundsRaised, uint256 totalSharesSold, uint256 fee);
    event Redeemed(address indexed recipient, uint256 shares);
    event PoolCanceled();
    event PoolCompleted();

    /// -----------------------------------------------------------------------
    /// Immutable State
    /// -----------------------------------------------------------------------
    /// @notice The number of wei required to purchase 1 share.
    uint256 public immutable weiPerToken;
    /// @notice The number of shares available for purchase (with decimals.)
    uint256 public immutable sharesForSale;
    /// @notice The fee percentage in WAD (1e18) that will be taken from the raised funds.
    uint256 public immutable platformFeeWAD;
    uint256 public immutable swapFeeWAD;
    /// @notice The maximum number of shares (with decimals) a user can purchase per sale.
    uint256 public immutable userMaximumShares;
    /// @notice The address of the pool creator that retains administrative control.
    address public immutable owner;
    /// @notice The address that will receive the fees generated from the raised funds.
    address public immutable feeRecipient;
    /// @notice The address of the ERC20 token that represents the shares.
    address public immutable shareToken;
    /// @notice The timestamp when the sale will begin.
    uint40 public immutable saleStart;
    /// @notice The timestamp when the sale will end.
    uint40 public immutable saleEnd;
    /// @notice The timestamp when the shares can be redeemed.
    uint40 public immutable redemptionTimestamp;

    uint8 private constant assetDecimals = 18;
    uint8 private immutable shareDecimals;
    //
    /// -----------------------------------------------------------------------
    /// Mutable Read Functions
    /// -----------------------------------------------------------------------
    uint256 public totalSharesSold;
    uint256 public swapFees;
    bool public closed;
    bool public paused;
    bool public canceled;
    mapping(address => uint256) public purchasedShares;

    /// -----------------------------------------------------------------------
    /// Modifiers
    /// -----------------------------------------------------------------------

    modifier whenSaleActive() {
        if (
            uint40(block.timestamp) < saleStart || uint40(block.timestamp) >= saleEnd || closed
                || paused || canceled
        ) {
            revert SaleInactive();
        }
        _;
    }

    modifier onlyOwner() {
        if (msg.sender != owner) {
            revert NotOwner();
        }
        _;
    }

    constructor(
        address _owner,
        address _shareToken,
        uint256 _weiPerToken,
        uint256 _sharesForSale,
        uint256 _userMaximumShares,
        address _feeRecipient,
        uint256 _platformFeeWAD,
        uint256 _swapFeeWAD,
        uint40 _saleStart,
        uint40 _saleEnd,
        uint40 _redemptionTimestamp
    ) {
        if (_shareToken == address(0) || _feeRecipient == address(0) || _owner == address(0)) {
            revert ZeroAddress();
        }
        if (_saleStart >= _saleEnd || _saleEnd > _redemptionTimestamp) revert InvalidDates();
        if (_platformFeeWAD >= 1e18 || _weiPerToken == 0 || _swapFeeWAD >= 1e18) {
            revert InvalidFee();
        }

        shareToken = _shareToken;
        weiPerToken = _weiPerToken;
        owner = _owner;
        platformFeeWAD = _platformFeeWAD;
        swapFeeWAD = _swapFeeWAD;
        feeRecipient = _feeRecipient;
        saleStart = _saleStart;
        saleEnd = _saleEnd;
        redemptionTimestamp = _redemptionTimestamp;
        sharesForSale = _sharesForSale;
        userMaximumShares = _userMaximumShares > 0 ? _userMaximumShares : type(uint256).max;

        shareDecimals = IERC20(shareToken).decimals();
        shareToken.safeTransferFrom(_owner, address(this), _sharesForSale);
        emit SharesDeposited(_sharesForSale);
    }

    /// @notice Creates a new Fixed Price (Native Token) Pool
    /// @param _owner The address of the pool creator that retains administrative control.
    /// @param _shareToken The address of the ERC20-share that's up for purchase.
    /// @param _weiPerToken The number of WEI used to purchase 1 unit of the share.
    /// @param _sharesForSale The number of shares available for purchase. (including token decimals)
    /// @param _userMaximumShares The maximum number of shares a user can purchase per sale.
    /// @param _feeRecipient The address that will receive the fees generated from the raised funds.
    /// @param _feeWAD The fee percentage in WAD (1e18) that will be taken from the raised funds. 1e18 = 100% fee.
    /// @param _saleStart The timestamp when the sale will begin.
    /// @param _saleEnd The timestamp when the sale will end.
    /// @param _redemptionTimestamp The timestamp when the shares can be redeemed.

    /// -----------------------------------------------------------------------
    /// Public Write Functions
    /// -----------------------------------------------------------------------

    /// @notice Allows a user to buy shares in the pool with native assets.
    /// @param shares The number of shares to purchase.
    /// @param recipient The address that will receive the shares once redeemed.
    function buyExactShares(
        uint256 shares,
        address recipient
    )
        external
        payable
        nonReentrant
        whenSaleActive
        returns (uint256 assetsIn)
    {
        if (shares == 0 || msg.value == 0) {
            revert TransferZero();
        }

        if (recipient == address(0)) {
            revert ZeroAddress();
        }

        if (shares + totalSharesSold > sharesForSale) {
            revert SharesOutExceeded();
        }
        if (shares + purchasedShares[recipient] > userMaximumShares) {
            revert UserMaxSharesExceeded();
        }

        if (!_isAboveMandatoryMinimum(shares)) {
            revert PurchaseTooLow();
        }

        if (sharesRemaining() - shares < getMandatoryMinimum()) {
            revert InvalidAmount();
        }

        uint256 sharesScaled = scaleTokenBefore(shareDecimals, shares);
        uint256 priceScaled = scaleTokenBefore(18, weiPerToken);

        uint256 assetsInScaled = sharesScaled.mulWad(priceScaled);

        assetsIn = scaleTokenAfter(18, assetsInScaled);

        if (assetsIn == 0) {
            revert TransferZero();
        }

        uint256 _swapFees = assetsIn.mulWad(swapFeeWAD);
        assetsIn = assetsIn.rawAdd(_swapFees);

        if (msg.value < assetsIn) {
            revert InsufficientFunds();
        }

        totalSharesSold += shares;
        purchasedShares[recipient] += shares;
        swapFees += _swapFees;

        if (totalSharesSold == sharesForSale) {
            emit PoolCompleted();
        }

        emit BuyFixedShares(recipient, shares, assetsIn);
    }

    function scaleTokenBefore(
        uint8 decimals,
        uint256 value
    )
        internal
        pure
        returns (uint256 scaledAmount)
    {
        scaledAmount = value;
        if (decimals < 18) {
            uint8 decimalDiff = 18 - decimals;
            scaledAmount *= 10 ** decimalDiff;
        } else if (decimals > 18) {
            uint8 decimalDiff = decimals - 18;
            scaledAmount /= 10 ** decimalDiff;
        }
    }

    function scaleTokenAfter(
        uint8 decimals,
        uint256 value
    )
        internal
        pure
        returns (uint256 scaledAmount)
    {
        scaledAmount = value;
        if (decimals < 18) {
            uint8 decimalDiff = 18 - decimals;
            scaledAmount /= 10 ** decimalDiff;
        } else if (decimals > 18) {
            uint8 decimalDiff = decimals - 18;
            scaledAmount *= 10 ** decimalDiff;
        }
    }

    /// @notice Allows any user to close the pool and distribute the fees.
    /// @dev The pool can only be closed after the sale end date has passed, OR the max shares sold have been reached.
    function close()
        external
        nonReentrant
        returns (uint256 feesGenerated, uint256 fundsRaised, uint256 sharesNotSold)
    {
        if (!canClose()) {
            revert SaleActive();
        }

        closed = true;

        feesGenerated = address(this).balance.rawSub(swapFees).mulWad(platformFeeWAD) + swapFees;

        if (feesGenerated > 0) {
            SafeTransferLib.safeTransferETH(feeRecipient, feesGenerated);
        }

        fundsRaised = address(this).balance;

        if (fundsRaised > 0) {
            SafeTransferLib.forceSafeTransferETH(owner, fundsRaised);
        }

        sharesNotSold = sharesForSale - totalSharesSold;

        if (sharesNotSold > 0) {
            shareToken.safeTransfer(owner, sharesNotSold);
        }

        emit Closed(fundsRaised, totalSharesSold, feesGenerated);
    }

    /// @notice Allows a user to redeem purchased shares after the redemption date has passed.
    function redeem() external nonReentrant returns (uint256 shares) {
        if (canceled) {
            revert SaleCancelled();
        }
        if (!closed) {
            revert SaleActive();
        }

        if (uint40(block.timestamp) < redemptionTimestamp) {
            revert RedeemedTooEarly();
        }

        shares = purchasedShares[msg.sender];
        delete purchasedShares[msg.sender];

        if (shares > 0) {
            shareToken.safeTransfer(msg.sender, shares);
        }
        emit Redeemed(msg.sender, shares);
    }

    /// -----------------------------------------------------------------------
    /// Owner-Only Write Functions
    /// -----------------------------------------------------------------------

    /// @notice Allows the pool creator to pause/unpause the sale, halting/enabling any trading activity.
    function togglePause() external nonReentrant onlyOwner {
        paused = !paused;
        emit PauseToggled(paused);
    }

    /// @notice Allows the pool creator to cancel the sale and withdraw all funds and shares before a sale begins.
    function cancelSale() external nonReentrant onlyOwner {
        if (closed) {
            revert AlreadyClosed();
        }
        if (canceled) {
            revert SaleCancelled();
        }
        if (uint40(block.timestamp) >= saleStart) {
            revert SaleActive();
        }

        canceled = true;
        shareToken.safeTransfer(owner, sharesForSale);
        emit PoolCanceled();
    }

    /// -----------------------------------------------------------------------
    /// Public Read Functions
    /// -----------------------------------------------------------------------

    /// @notice Checks if the pool can be closed.
    /// @return True if the pool can be closed, false otherwise.
    /// @dev The pool can be closed if all shares have been sold, or the sale end date has passed.
    function canClose() public view returns (bool) {
        if (canceled || closed) {
            return false;
        }
        if (totalSharesSold == sharesForSale || uint40(block.timestamp) >= saleEnd) {
            return true;
        }

        return false;
    }

    /// @notice Checks the number of shares remaining for sale.
    function sharesRemaining() public view returns (uint256) {
        return sharesForSale - totalSharesSold;
    }

    function userSharesRemaining(address user) external view returns (uint256) {
        return userMaximumShares - purchasedShares[user];
    }

    function args() public view returns (PoolArgs memory) {
        return PoolArgs(
            shareToken,
            address(0),
            owner,
            feeRecipient,
            weiPerToken,
            sharesForSale,
            platformFeeWAD,
            swapFeeWAD,
            saleStart,
            saleEnd,
            redemptionTimestamp,
            totalSharesSold,
            closed,
            paused,
            canceled,
            canClose(),
            userMaximumShares,
            getMandatoryMinimum()
        );
    }

    function _isAboveMandatoryMinimum(uint256 amount) internal view returns (bool) {
        return amount >= getMandatoryMinimum();
    }

    function getMandatoryMinimum() public view returns (uint256) {
        if (shareDecimals > assetDecimals) {
            return 10 ** (shareDecimals - assetDecimals);
        } else {
            return 0;
        }
    }
}

File 4 of 9 : CREATE3.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

/// @notice Deploy to deterministic addresses without an initcode factor.
/// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/CREATE3.sol)
/// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/CREATE3.sol)
/// @author Modified from 0xSequence (https://github.com/0xSequence/create3/blob/master/contracts/Create3.sol)
library CREATE3 {
    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                        CUSTOM ERRORS                       */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Unable to deploy the contract.
    error DeploymentFailed();

    /// @dev Unable to initialize the contract.
    error InitializationFailed();

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                      BYTECODE CONSTANTS                    */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /**
     * -------------------------------------------------------------------+
     * Opcode      | Mnemonic         | Stack        | Memory             |
     * -------------------------------------------------------------------|
     * 36          | CALLDATASIZE     | cds          |                    |
     * 3d          | RETURNDATASIZE   | 0 cds        |                    |
     * 3d          | RETURNDATASIZE   | 0 0 cds      |                    |
     * 37          | CALLDATACOPY     |              | [0..cds): calldata |
     * 36          | CALLDATASIZE     | cds          | [0..cds): calldata |
     * 3d          | RETURNDATASIZE   | 0 cds        | [0..cds): calldata |
     * 34          | CALLVALUE        | value 0 cds  | [0..cds): calldata |
     * f0          | CREATE           | newContract  | [0..cds): calldata |
     * -------------------------------------------------------------------|
     * Opcode      | Mnemonic         | Stack        | Memory             |
     * -------------------------------------------------------------------|
     * 67 bytecode | PUSH8 bytecode   | bytecode     |                    |
     * 3d          | RETURNDATASIZE   | 0 bytecode   |                    |
     * 52          | MSTORE           |              | [0..8): bytecode   |
     * 60 0x08     | PUSH1 0x08       | 0x08         | [0..8): bytecode   |
     * 60 0x18     | PUSH1 0x18       | 0x18 0x08    | [0..8): bytecode   |
     * f3          | RETURN           |              | [0..8): bytecode   |
     * -------------------------------------------------------------------+
     */

    /// @dev The proxy bytecode.
    uint256 private constant _PROXY_BYTECODE = 0x67363d3d37363d34f03d5260086018f3;

    /// @dev Hash of the `_PROXY_BYTECODE`.
    /// Equivalent to `keccak256(abi.encodePacked(hex"67363d3d37363d34f03d5260086018f3"))`.
    bytes32 private constant _PROXY_BYTECODE_HASH =
        0x21c35dbe1b344a2488cf3321d6ce542f8e9f305544ff09e4993a62319a497c1f;

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                      CREATE3 OPERATIONS                    */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Deploys `creationCode` deterministically with a `salt`.
    /// The deployed contract is funded with `value` (in wei) ETH.
    /// Returns the deterministic address of the deployed contract,
    /// which solely depends on `salt`.
    function deploy(bytes32 salt, bytes memory creationCode, uint256 value)
        internal
        returns (address deployed)
    {
        /// @solidity memory-safe-assembly
        assembly {
            // Store the `_PROXY_BYTECODE` into scratch space.
            mstore(0x00, _PROXY_BYTECODE)
            // Deploy a new contract with our pre-made bytecode via CREATE2.
            let proxy := create2(0, 0x10, 0x10, salt)

            // If the result of `create2` is the zero address, revert.
            if iszero(proxy) {
                // Store the function selector of `DeploymentFailed()`.
                mstore(0x00, 0x30116425)
                // Revert with (offset, size).
                revert(0x1c, 0x04)
            }

            // Store the proxy's address.
            mstore(0x14, proxy)
            // 0xd6 = 0xc0 (short RLP prefix) + 0x16 (length of: 0x94 ++ proxy ++ 0x01).
            // 0x94 = 0x80 + 0x14 (0x14 = the length of an address, 20 bytes, in hex).
            mstore(0x00, 0xd694)
            // Nonce of the proxy contract (1).
            mstore8(0x34, 0x01)

            deployed := keccak256(0x1e, 0x17)

            // If the `call` fails, revert.
            if iszero(
                call(
                    gas(), // Gas remaining.
                    proxy, // Proxy's address.
                    value, // Ether value.
                    add(creationCode, 0x20), // Start of `creationCode`.
                    mload(creationCode), // Length of `creationCode`.
                    0x00, // Offset of output.
                    0x00 // Length of output.
                )
            ) {
                // Store the function selector of `InitializationFailed()`.
                mstore(0x00, 0x19b991a8)
                // Revert with (offset, size).
                revert(0x1c, 0x04)
            }

            // If the code size of `deployed` is zero, revert.
            if iszero(extcodesize(deployed)) {
                // Store the function selector of `InitializationFailed()`.
                mstore(0x00, 0x19b991a8)
                // Revert with (offset, size).
                revert(0x1c, 0x04)
            }
        }
    }

    /// @dev Returns the deterministic address for `salt` with `deployer`.
    function getDeployed(bytes32 salt, address deployer) internal pure returns (address deployed) {
        /// @solidity memory-safe-assembly
        assembly {
            // Cache the free memory pointer.
            let m := mload(0x40)
            // Store `deployer`.
            mstore(0x00, deployer)
            // Store the prefix.
            mstore8(0x0b, 0xff)
            // Store the salt.
            mstore(0x20, salt)
            // Store the bytecode hash.
            mstore(0x40, _PROXY_BYTECODE_HASH)

            // Store the proxy's address.
            mstore(0x14, keccak256(0x0b, 0x55))
            // Restore the free memory pointer.
            mstore(0x40, m)
            // 0xd6 = 0xc0 (short RLP prefix) + 0x16 (length of: 0x94 ++ proxy ++ 0x01).
            // 0x94 = 0x80 + 0x14 (0x14 = the length of an address, 20 bytes, in hex).
            mstore(0x00, 0xd694)
            // Nonce of the proxy contract (1).
            mstore8(0x34, 0x01)

            deployed := keccak256(0x1e, 0x17)
        }
    }

    /// @dev Returns the deterministic address for `salt`.
    function getDeployed(bytes32 salt) internal view returns (address deployed) {
        deployed = getDeployed(salt, address(this));
    }
}

File 5 of 9 : SafeTransferLib.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

/// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values.
/// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/SafeTransferLib.sol)
/// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol)
/// @author Permit2 operations from (https://github.com/Uniswap/permit2/blob/main/src/libraries/Permit2Lib.sol)
///
/// @dev Note:
/// - For ETH transfers, please use `forceSafeTransferETH` for DoS protection.
/// - For ERC20s, this implementation won't check that a token has code,
///   responsibility is delegated to the caller.
library SafeTransferLib {
    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                       CUSTOM ERRORS                        */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev The ETH transfer has failed.
    error ETHTransferFailed();

    /// @dev The ERC20 `transferFrom` has failed.
    error TransferFromFailed();

    /// @dev The ERC20 `transfer` has failed.
    error TransferFailed();

    /// @dev The ERC20 `approve` has failed.
    error ApproveFailed();

    /// @dev The Permit2 operation has failed.
    error Permit2Failed();

    /// @dev The Permit2 amount must be less than `2**160 - 1`.
    error Permit2AmountOverflow();

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                         CONSTANTS                          */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Suggested gas stipend for contract receiving ETH that disallows any storage writes.
    uint256 internal constant GAS_STIPEND_NO_STORAGE_WRITES = 2300;

    /// @dev Suggested gas stipend for contract receiving ETH to perform a few
    /// storage reads and writes, but low enough to prevent griefing.
    uint256 internal constant GAS_STIPEND_NO_GRIEF = 100000;

    /// @dev The unique EIP-712 domain domain separator for the DAI token contract.
    bytes32 internal constant DAI_DOMAIN_SEPARATOR =
        0xdbb8cf42e1ecb028be3f3dbc922e1d878b963f411dc388ced501601c60f7c6f7;

    /// @dev The address for the WETH9 contract on Ethereum mainnet.
    address internal constant WETH9 = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;

    /// @dev The canonical Permit2 address.
    /// [Github](https://github.com/Uniswap/permit2)
    /// [Etherscan](https://etherscan.io/address/0x000000000022D473030F116dDEE9F6B43aC78BA3)
    address internal constant PERMIT2 = 0x000000000022D473030F116dDEE9F6B43aC78BA3;

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                       ETH OPERATIONS                       */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    // If the ETH transfer MUST succeed with a reasonable gas budget, use the force variants.
    //
    // The regular variants:
    // - Forwards all remaining gas to the target.
    // - Reverts if the target reverts.
    // - Reverts if the current contract has insufficient balance.
    //
    // The force variants:
    // - Forwards with an optional gas stipend
    //   (defaults to `GAS_STIPEND_NO_GRIEF`, which is sufficient for most cases).
    // - If the target reverts, or if the gas stipend is exhausted,
    //   creates a temporary contract to force send the ETH via `SELFDESTRUCT`.
    //   Future compatible with `SENDALL`: https://eips.ethereum.org/EIPS/eip-4758.
    // - Reverts if the current contract has insufficient balance.
    //
    // The try variants:
    // - Forwards with a mandatory gas stipend.
    // - Instead of reverting, returns whether the transfer succeeded.

    /// @dev Sends `amount` (in wei) ETH to `to`.
    function safeTransferETH(address to, uint256 amount) internal {
        /// @solidity memory-safe-assembly
        assembly {
            if iszero(call(gas(), to, amount, codesize(), 0x00, codesize(), 0x00)) {
                mstore(0x00, 0xb12d13eb) // `ETHTransferFailed()`.
                revert(0x1c, 0x04)
            }
        }
    }

    /// @dev Sends all the ETH in the current contract to `to`.
    function safeTransferAllETH(address to) internal {
        /// @solidity memory-safe-assembly
        assembly {
            // Transfer all the ETH and check if it succeeded or not.
            if iszero(call(gas(), to, selfbalance(), codesize(), 0x00, codesize(), 0x00)) {
                mstore(0x00, 0xb12d13eb) // `ETHTransferFailed()`.
                revert(0x1c, 0x04)
            }
        }
    }

    /// @dev Force sends `amount` (in wei) ETH to `to`, with a `gasStipend`.
    function forceSafeTransferETH(address to, uint256 amount, uint256 gasStipend) internal {
        /// @solidity memory-safe-assembly
        assembly {
            if lt(selfbalance(), amount) {
                mstore(0x00, 0xb12d13eb) // `ETHTransferFailed()`.
                revert(0x1c, 0x04)
            }
            if iszero(call(gasStipend, to, amount, codesize(), 0x00, codesize(), 0x00)) {
                mstore(0x00, to) // Store the address in scratch space.
                mstore8(0x0b, 0x73) // Opcode `PUSH20`.
                mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`.
                if iszero(create(amount, 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation.
            }
        }
    }

    /// @dev Force sends all the ETH in the current contract to `to`, with a `gasStipend`.
    function forceSafeTransferAllETH(address to, uint256 gasStipend) internal {
        /// @solidity memory-safe-assembly
        assembly {
            if iszero(call(gasStipend, to, selfbalance(), codesize(), 0x00, codesize(), 0x00)) {
                mstore(0x00, to) // Store the address in scratch space.
                mstore8(0x0b, 0x73) // Opcode `PUSH20`.
                mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`.
                if iszero(create(selfbalance(), 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation.
            }
        }
    }

    /// @dev Force sends `amount` (in wei) ETH to `to`, with `GAS_STIPEND_NO_GRIEF`.
    function forceSafeTransferETH(address to, uint256 amount) internal {
        /// @solidity memory-safe-assembly
        assembly {
            if lt(selfbalance(), amount) {
                mstore(0x00, 0xb12d13eb) // `ETHTransferFailed()`.
                revert(0x1c, 0x04)
            }
            if iszero(call(GAS_STIPEND_NO_GRIEF, to, amount, codesize(), 0x00, codesize(), 0x00)) {
                mstore(0x00, to) // Store the address in scratch space.
                mstore8(0x0b, 0x73) // Opcode `PUSH20`.
                mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`.
                if iszero(create(amount, 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation.
            }
        }
    }

    /// @dev Force sends all the ETH in the current contract to `to`, with `GAS_STIPEND_NO_GRIEF`.
    function forceSafeTransferAllETH(address to) internal {
        /// @solidity memory-safe-assembly
        assembly {
            // forgefmt: disable-next-item
            if iszero(call(GAS_STIPEND_NO_GRIEF, to, selfbalance(), codesize(), 0x00, codesize(), 0x00)) {
                mstore(0x00, to) // Store the address in scratch space.
                mstore8(0x0b, 0x73) // Opcode `PUSH20`.
                mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`.
                if iszero(create(selfbalance(), 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation.
            }
        }
    }

    /// @dev Sends `amount` (in wei) ETH to `to`, with a `gasStipend`.
    function trySafeTransferETH(address to, uint256 amount, uint256 gasStipend)
        internal
        returns (bool success)
    {
        /// @solidity memory-safe-assembly
        assembly {
            success := call(gasStipend, to, amount, codesize(), 0x00, codesize(), 0x00)
        }
    }

    /// @dev Sends all the ETH in the current contract to `to`, with a `gasStipend`.
    function trySafeTransferAllETH(address to, uint256 gasStipend)
        internal
        returns (bool success)
    {
        /// @solidity memory-safe-assembly
        assembly {
            success := call(gasStipend, to, selfbalance(), codesize(), 0x00, codesize(), 0x00)
        }
    }

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                      ERC20 OPERATIONS                      */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Sends `amount` of ERC20 `token` from `from` to `to`.
    /// Reverts upon failure.
    ///
    /// The `from` account must have at least `amount` approved for
    /// the current contract to manage.
    function safeTransferFrom(address token, address from, address to, uint256 amount) internal {
        /// @solidity memory-safe-assembly
        assembly {
            let m := mload(0x40) // Cache the free memory pointer.
            mstore(0x60, amount) // Store the `amount` argument.
            mstore(0x40, to) // Store the `to` argument.
            mstore(0x2c, shl(96, from)) // Store the `from` argument.
            mstore(0x0c, 0x23b872dd000000000000000000000000) // `transferFrom(address,address,uint256)`.
            // Perform the transfer, reverting upon failure.
            if iszero(
                and( // The arguments of `and` are evaluated from right to left.
                    or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.
                    call(gas(), token, 0, 0x1c, 0x64, 0x00, 0x20)
                )
            ) {
                mstore(0x00, 0x7939f424) // `TransferFromFailed()`.
                revert(0x1c, 0x04)
            }
            mstore(0x60, 0) // Restore the zero slot to zero.
            mstore(0x40, m) // Restore the free memory pointer.
        }
    }

    /// @dev Sends `amount` of ERC20 `token` from `from` to `to`.
    ///
    /// The `from` account must have at least `amount` approved for the current contract to manage.
    function trySafeTransferFrom(address token, address from, address to, uint256 amount)
        internal
        returns (bool success)
    {
        /// @solidity memory-safe-assembly
        assembly {
            let m := mload(0x40) // Cache the free memory pointer.
            mstore(0x60, amount) // Store the `amount` argument.
            mstore(0x40, to) // Store the `to` argument.
            mstore(0x2c, shl(96, from)) // Store the `from` argument.
            mstore(0x0c, 0x23b872dd000000000000000000000000) // `transferFrom(address,address,uint256)`.
            success :=
                and( // The arguments of `and` are evaluated from right to left.
                    or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.
                    call(gas(), token, 0, 0x1c, 0x64, 0x00, 0x20)
                )
            mstore(0x60, 0) // Restore the zero slot to zero.
            mstore(0x40, m) // Restore the free memory pointer.
        }
    }

    /// @dev Sends all of ERC20 `token` from `from` to `to`.
    /// Reverts upon failure.
    ///
    /// The `from` account must have their entire balance approved for the current contract to manage.
    function safeTransferAllFrom(address token, address from, address to)
        internal
        returns (uint256 amount)
    {
        /// @solidity memory-safe-assembly
        assembly {
            let m := mload(0x40) // Cache the free memory pointer.
            mstore(0x40, to) // Store the `to` argument.
            mstore(0x2c, shl(96, from)) // Store the `from` argument.
            mstore(0x0c, 0x70a08231000000000000000000000000) // `balanceOf(address)`.
            // Read the balance, reverting upon failure.
            if iszero(
                and( // The arguments of `and` are evaluated from right to left.
                    gt(returndatasize(), 0x1f), // At least 32 bytes returned.
                    staticcall(gas(), token, 0x1c, 0x24, 0x60, 0x20)
                )
            ) {
                mstore(0x00, 0x7939f424) // `TransferFromFailed()`.
                revert(0x1c, 0x04)
            }
            mstore(0x00, 0x23b872dd) // `transferFrom(address,address,uint256)`.
            amount := mload(0x60) // The `amount` is already at 0x60. We'll need to return it.
            // Perform the transfer, reverting upon failure.
            if iszero(
                and( // The arguments of `and` are evaluated from right to left.
                    or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.
                    call(gas(), token, 0, 0x1c, 0x64, 0x00, 0x20)
                )
            ) {
                mstore(0x00, 0x7939f424) // `TransferFromFailed()`.
                revert(0x1c, 0x04)
            }
            mstore(0x60, 0) // Restore the zero slot to zero.
            mstore(0x40, m) // Restore the free memory pointer.
        }
    }

    /// @dev Sends `amount` of ERC20 `token` from the current contract to `to`.
    /// Reverts upon failure.
    function safeTransfer(address token, address to, uint256 amount) internal {
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x14, to) // Store the `to` argument.
            mstore(0x34, amount) // Store the `amount` argument.
            mstore(0x00, 0xa9059cbb000000000000000000000000) // `transfer(address,uint256)`.
            // Perform the transfer, reverting upon failure.
            if iszero(
                and( // The arguments of `and` are evaluated from right to left.
                    or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.
                    call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20)
                )
            ) {
                mstore(0x00, 0x90b8ec18) // `TransferFailed()`.
                revert(0x1c, 0x04)
            }
            mstore(0x34, 0) // Restore the part of the free memory pointer that was overwritten.
        }
    }

    /// @dev Sends all of ERC20 `token` from the current contract to `to`.
    /// Reverts upon failure.
    function safeTransferAll(address token, address to) internal returns (uint256 amount) {
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x00, 0x70a08231) // Store the function selector of `balanceOf(address)`.
            mstore(0x20, address()) // Store the address of the current contract.
            // Read the balance, reverting upon failure.
            if iszero(
                and( // The arguments of `and` are evaluated from right to left.
                    gt(returndatasize(), 0x1f), // At least 32 bytes returned.
                    staticcall(gas(), token, 0x1c, 0x24, 0x34, 0x20)
                )
            ) {
                mstore(0x00, 0x90b8ec18) // `TransferFailed()`.
                revert(0x1c, 0x04)
            }
            mstore(0x14, to) // Store the `to` argument.
            amount := mload(0x34) // The `amount` is already at 0x34. We'll need to return it.
            mstore(0x00, 0xa9059cbb000000000000000000000000) // `transfer(address,uint256)`.
            // Perform the transfer, reverting upon failure.
            if iszero(
                and( // The arguments of `and` are evaluated from right to left.
                    or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.
                    call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20)
                )
            ) {
                mstore(0x00, 0x90b8ec18) // `TransferFailed()`.
                revert(0x1c, 0x04)
            }
            mstore(0x34, 0) // Restore the part of the free memory pointer that was overwritten.
        }
    }

    /// @dev Sets `amount` of ERC20 `token` for `to` to manage on behalf of the current contract.
    /// Reverts upon failure.
    function safeApprove(address token, address to, uint256 amount) internal {
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x14, to) // Store the `to` argument.
            mstore(0x34, amount) // Store the `amount` argument.
            mstore(0x00, 0x095ea7b3000000000000000000000000) // `approve(address,uint256)`.
            // Perform the approval, reverting upon failure.
            if iszero(
                and( // The arguments of `and` are evaluated from right to left.
                    or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.
                    call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20)
                )
            ) {
                mstore(0x00, 0x3e3f8f73) // `ApproveFailed()`.
                revert(0x1c, 0x04)
            }
            mstore(0x34, 0) // Restore the part of the free memory pointer that was overwritten.
        }
    }

    /// @dev Sets `amount` of ERC20 `token` for `to` to manage on behalf of the current contract.
    /// If the initial attempt to approve fails, attempts to reset the approved amount to zero,
    /// then retries the approval again (some tokens, e.g. USDT, requires this).
    /// Reverts upon failure.
    function safeApproveWithRetry(address token, address to, uint256 amount) internal {
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x14, to) // Store the `to` argument.
            mstore(0x34, amount) // Store the `amount` argument.
            mstore(0x00, 0x095ea7b3000000000000000000000000) // `approve(address,uint256)`.
            // Perform the approval, retrying upon failure.
            if iszero(
                and( // The arguments of `and` are evaluated from right to left.
                    or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.
                    call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20)
                )
            ) {
                mstore(0x34, 0) // Store 0 for the `amount`.
                mstore(0x00, 0x095ea7b3000000000000000000000000) // `approve(address,uint256)`.
                pop(call(gas(), token, 0, 0x10, 0x44, codesize(), 0x00)) // Reset the approval.
                mstore(0x34, amount) // Store back the original `amount`.
                // Retry the approval, reverting upon failure.
                if iszero(
                    and(
                        or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.
                        call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20)
                    )
                ) {
                    mstore(0x00, 0x3e3f8f73) // `ApproveFailed()`.
                    revert(0x1c, 0x04)
                }
            }
            mstore(0x34, 0) // Restore the part of the free memory pointer that was overwritten.
        }
    }

    /// @dev Returns the amount of ERC20 `token` owned by `account`.
    /// Returns zero if the `token` does not exist.
    function balanceOf(address token, address account) internal view returns (uint256 amount) {
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x14, account) // Store the `account` argument.
            mstore(0x00, 0x70a08231000000000000000000000000) // `balanceOf(address)`.
            amount :=
                mul( // The arguments of `mul` are evaluated from right to left.
                    mload(0x20),
                    and( // The arguments of `and` are evaluated from right to left.
                        gt(returndatasize(), 0x1f), // At least 32 bytes returned.
                        staticcall(gas(), token, 0x10, 0x24, 0x20, 0x20)
                    )
                )
        }
    }

    /// @dev Sends `amount` of ERC20 `token` from `from` to `to`.
    /// If the initial attempt fails, try to use Permit2 to transfer the token.
    /// Reverts upon failure.
    ///
    /// The `from` account must have at least `amount` approved for the current contract to manage.
    function safeTransferFrom2(address token, address from, address to, uint256 amount) internal {
        if (!trySafeTransferFrom(token, from, to, amount)) {
            permit2TransferFrom(token, from, to, amount);
        }
    }

    /// @dev Sends `amount` of ERC20 `token` from `from` to `to` via Permit2.
    /// Reverts upon failure.
    function permit2TransferFrom(address token, address from, address to, uint256 amount)
        internal
    {
        /// @solidity memory-safe-assembly
        assembly {
            let m := mload(0x40)
            mstore(add(m, 0x74), shr(96, shl(96, token)))
            mstore(add(m, 0x54), amount)
            mstore(add(m, 0x34), to)
            mstore(add(m, 0x20), shl(96, from))
            // `transferFrom(address,address,uint160,address)`.
            mstore(m, 0x36c78516000000000000000000000000)
            let p := PERMIT2
            let exists := eq(chainid(), 1)
            if iszero(exists) { exists := iszero(iszero(extcodesize(p))) }
            if iszero(and(call(gas(), p, 0, add(m, 0x10), 0x84, codesize(), 0x00), exists)) {
                mstore(0x00, 0x7939f4248757f0fd) // `TransferFromFailed()` or `Permit2AmountOverflow()`.
                revert(add(0x18, shl(2, iszero(iszero(shr(160, amount))))), 0x04)
            }
        }
    }

    /// @dev Permit a user to spend a given amount of
    /// another user's tokens via native EIP-2612 permit if possible, falling
    /// back to Permit2 if native permit fails or is not implemented on the token.
    function permit2(
        address token,
        address owner,
        address spender,
        uint256 amount,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        bool success;
        /// @solidity memory-safe-assembly
        assembly {
            for {} shl(96, xor(token, WETH9)) {} {
                mstore(0x00, 0x3644e515) // `DOMAIN_SEPARATOR()`.
                if iszero(
                    and( // The arguments of `and` are evaluated from right to left.
                        lt(iszero(mload(0x00)), eq(returndatasize(), 0x20)), // Returns 1 non-zero word.
                        // Gas stipend to limit gas burn for tokens that don't refund gas when
                        // an non-existing function is called. 5K should be enough for a SLOAD.
                        staticcall(5000, token, 0x1c, 0x04, 0x00, 0x20)
                    )
                ) { break }
                // After here, we can be sure that token is a contract.
                let m := mload(0x40)
                mstore(add(m, 0x34), spender)
                mstore(add(m, 0x20), shl(96, owner))
                mstore(add(m, 0x74), deadline)
                if eq(mload(0x00), DAI_DOMAIN_SEPARATOR) {
                    mstore(0x14, owner)
                    mstore(0x00, 0x7ecebe00000000000000000000000000) // `nonces(address)`.
                    mstore(add(m, 0x94), staticcall(gas(), token, 0x10, 0x24, add(m, 0x54), 0x20))
                    mstore(m, 0x8fcbaf0c000000000000000000000000) // `IDAIPermit.permit`.
                    // `nonces` is already at `add(m, 0x54)`.
                    // `1` is already stored at `add(m, 0x94)`.
                    mstore(add(m, 0xb4), and(0xff, v))
                    mstore(add(m, 0xd4), r)
                    mstore(add(m, 0xf4), s)
                    success := call(gas(), token, 0, add(m, 0x10), 0x104, codesize(), 0x00)
                    break
                }
                mstore(m, 0xd505accf000000000000000000000000) // `IERC20Permit.permit`.
                mstore(add(m, 0x54), amount)
                mstore(add(m, 0x94), and(0xff, v))
                mstore(add(m, 0xb4), r)
                mstore(add(m, 0xd4), s)
                success := call(gas(), token, 0, add(m, 0x10), 0xe4, codesize(), 0x00)
                break
            }
        }
        if (!success) simplePermit2(token, owner, spender, amount, deadline, v, r, s);
    }

    /// @dev Simple permit on the Permit2 contract.
    function simplePermit2(
        address token,
        address owner,
        address spender,
        uint256 amount,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        /// @solidity memory-safe-assembly
        assembly {
            let m := mload(0x40)
            mstore(m, 0x927da105) // `allowance(address,address,address)`.
            {
                let addressMask := shr(96, not(0))
                mstore(add(m, 0x20), and(addressMask, owner))
                mstore(add(m, 0x40), and(addressMask, token))
                mstore(add(m, 0x60), and(addressMask, spender))
                mstore(add(m, 0xc0), and(addressMask, spender))
            }
            let p := mul(PERMIT2, iszero(shr(160, amount)))
            if iszero(
                and( // The arguments of `and` are evaluated from right to left.
                    gt(returndatasize(), 0x5f), // Returns 3 words: `amount`, `expiration`, `nonce`.
                    staticcall(gas(), p, add(m, 0x1c), 0x64, add(m, 0x60), 0x60)
                )
            ) {
                mstore(0x00, 0x6b836e6b8757f0fd) // `Permit2Failed()` or `Permit2AmountOverflow()`.
                revert(add(0x18, shl(2, iszero(p))), 0x04)
            }
            mstore(m, 0x2b67b570) // `Permit2.permit` (PermitSingle variant).
            // `owner` is already `add(m, 0x20)`.
            // `token` is already at `add(m, 0x40)`.
            mstore(add(m, 0x60), amount)
            mstore(add(m, 0x80), 0xffffffffffff) // `expiration = type(uint48).max`.
            // `nonce` is already at `add(m, 0xa0)`.
            // `spender` is already at `add(m, 0xc0)`.
            mstore(add(m, 0xe0), deadline)
            mstore(add(m, 0x100), 0x100) // `signature` offset.
            mstore(add(m, 0x120), 0x41) // `signature` length.
            mstore(add(m, 0x140), r)
            mstore(add(m, 0x160), s)
            mstore(add(m, 0x180), shl(248, v))
            if iszero(call(gas(), p, 0, add(m, 0x1c), 0x184, codesize(), 0x00)) {
                mstore(0x00, 0x6b836e6b) // `Permit2Failed()`.
                revert(0x1c, 0x04)
            }
        }
    }
}

File 6 of 9 : FixedPointMathLib.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

/// @notice Arithmetic library with operations for fixed-point numbers.
/// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/FixedPointMathLib.sol)
/// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/FixedPointMathLib.sol)
library FixedPointMathLib {
    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                       CUSTOM ERRORS                        */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev The operation failed, as the output exceeds the maximum value of uint256.
    error ExpOverflow();

    /// @dev The operation failed, as the output exceeds the maximum value of uint256.
    error FactorialOverflow();

    /// @dev The operation failed, due to an overflow.
    error RPowOverflow();

    /// @dev The mantissa is too big to fit.
    error MantissaOverflow();

    /// @dev The operation failed, due to an multiplication overflow.
    error MulWadFailed();

    /// @dev The operation failed, due to an multiplication overflow.
    error SMulWadFailed();

    /// @dev The operation failed, either due to a multiplication overflow, or a division by a zero.
    error DivWadFailed();

    /// @dev The operation failed, either due to a multiplication overflow, or a division by a zero.
    error SDivWadFailed();

    /// @dev The operation failed, either due to a multiplication overflow, or a division by a zero.
    error MulDivFailed();

    /// @dev The division failed, as the denominator is zero.
    error DivFailed();

    /// @dev The full precision multiply-divide operation failed, either due
    /// to the result being larger than 256 bits, or a division by a zero.
    error FullMulDivFailed();

    /// @dev The output is undefined, as the input is less-than-or-equal to zero.
    error LnWadUndefined();

    /// @dev The input outside the acceptable domain.
    error OutOfDomain();

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                         CONSTANTS                          */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev The scalar of ETH and most ERC20s.
    uint256 internal constant WAD = 1e18;

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*              SIMPLIFIED FIXED POINT OPERATIONS             */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Equivalent to `(x * y) / WAD` rounded down.
    function mulWad(uint256 x, uint256 y) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            // Equivalent to `require(y == 0 || x <= type(uint256).max / y)`.
            if mul(y, gt(x, div(not(0), y))) {
                mstore(0x00, 0xbac65e5b) // `MulWadFailed()`.
                revert(0x1c, 0x04)
            }
            z := div(mul(x, y), WAD)
        }
    }

    /// @dev Equivalent to `(x * y) / WAD` rounded down.
    function sMulWad(int256 x, int256 y) internal pure returns (int256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            z := mul(x, y)
            // Equivalent to `require((x == 0 || z / x == y) && !(x == -1 && y == type(int256).min))`.
            if iszero(gt(or(iszero(x), eq(sdiv(z, x), y)), lt(not(x), eq(y, shl(255, 1))))) {
                mstore(0x00, 0xedcd4dd4) // `SMulWadFailed()`.
                revert(0x1c, 0x04)
            }
            z := sdiv(z, WAD)
        }
    }

    /// @dev Equivalent to `(x * y) / WAD` rounded down, but without overflow checks.
    function rawMulWad(uint256 x, uint256 y) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            z := div(mul(x, y), WAD)
        }
    }

    /// @dev Equivalent to `(x * y) / WAD` rounded down, but without overflow checks.
    function rawSMulWad(int256 x, int256 y) internal pure returns (int256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            z := sdiv(mul(x, y), WAD)
        }
    }

    /// @dev Equivalent to `(x * y) / WAD` rounded up.
    function mulWadUp(uint256 x, uint256 y) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            // Equivalent to `require(y == 0 || x <= type(uint256).max / y)`.
            if mul(y, gt(x, div(not(0), y))) {
                mstore(0x00, 0xbac65e5b) // `MulWadFailed()`.
                revert(0x1c, 0x04)
            }
            z := add(iszero(iszero(mod(mul(x, y), WAD))), div(mul(x, y), WAD))
        }
    }

    /// @dev Equivalent to `(x * y) / WAD` rounded up, but without overflow checks.
    function rawMulWadUp(uint256 x, uint256 y) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            z := add(iszero(iszero(mod(mul(x, y), WAD))), div(mul(x, y), WAD))
        }
    }

    /// @dev Equivalent to `(x * WAD) / y` rounded down.
    function divWad(uint256 x, uint256 y) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            // Equivalent to `require(y != 0 && (WAD == 0 || x <= type(uint256).max / WAD))`.
            if iszero(mul(y, iszero(mul(WAD, gt(x, div(not(0), WAD)))))) {
                mstore(0x00, 0x7c5f487d) // `DivWadFailed()`.
                revert(0x1c, 0x04)
            }
            z := div(mul(x, WAD), y)
        }
    }

    /// @dev Equivalent to `(x * WAD) / y` rounded down.
    function sDivWad(int256 x, int256 y) internal pure returns (int256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            z := mul(x, WAD)
            // Equivalent to `require(y != 0 && ((x * WAD) / WAD == x))`.
            if iszero(and(iszero(iszero(y)), eq(sdiv(z, WAD), x))) {
                mstore(0x00, 0x5c43740d) // `SDivWadFailed()`.
                revert(0x1c, 0x04)
            }
            z := sdiv(mul(x, WAD), y)
        }
    }

    /// @dev Equivalent to `(x * WAD) / y` rounded down, but without overflow and divide by zero checks.
    function rawDivWad(uint256 x, uint256 y) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            z := div(mul(x, WAD), y)
        }
    }

    /// @dev Equivalent to `(x * WAD) / y` rounded down, but without overflow and divide by zero checks.
    function rawSDivWad(int256 x, int256 y) internal pure returns (int256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            z := sdiv(mul(x, WAD), y)
        }
    }

    /// @dev Equivalent to `(x * WAD) / y` rounded up.
    function divWadUp(uint256 x, uint256 y) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            // Equivalent to `require(y != 0 && (WAD == 0 || x <= type(uint256).max / WAD))`.
            if iszero(mul(y, iszero(mul(WAD, gt(x, div(not(0), WAD)))))) {
                mstore(0x00, 0x7c5f487d) // `DivWadFailed()`.
                revert(0x1c, 0x04)
            }
            z := add(iszero(iszero(mod(mul(x, WAD), y))), div(mul(x, WAD), y))
        }
    }

    /// @dev Equivalent to `(x * WAD) / y` rounded up, but without overflow and divide by zero checks.
    function rawDivWadUp(uint256 x, uint256 y) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            z := add(iszero(iszero(mod(mul(x, WAD), y))), div(mul(x, WAD), y))
        }
    }

    /// @dev Equivalent to `x` to the power of `y`.
    /// because `x ** y = (e ** ln(x)) ** y = e ** (ln(x) * y)`.
    /// Note: This function is an approximation.
    function powWad(int256 x, int256 y) internal pure returns (int256) {
        // Using `ln(x)` means `x` must be greater than 0.
        return expWad((lnWad(x) * y) / int256(WAD));
    }

    /// @dev Returns `exp(x)`, denominated in `WAD`.
    /// Credit to Remco Bloemen under MIT license: https://2π.com/22/exp-ln
    /// Note: This function is an approximation. Monotonically increasing.
    function expWad(int256 x) internal pure returns (int256 r) {
        unchecked {
            // When the result is less than 0.5 we return zero.
            // This happens when `x <= (log(1e-18) * 1e18) ~ -4.15e19`.
            if (x <= -41446531673892822313) return r;

            /// @solidity memory-safe-assembly
            assembly {
                // When the result is greater than `(2**255 - 1) / 1e18` we can not represent it as
                // an int. This happens when `x >= floor(log((2**255 - 1) / 1e18) * 1e18) ≈ 135`.
                if iszero(slt(x, 135305999368893231589)) {
                    mstore(0x00, 0xa37bfec9) // `ExpOverflow()`.
                    revert(0x1c, 0x04)
                }
            }

            // `x` is now in the range `(-42, 136) * 1e18`. Convert to `(-42, 136) * 2**96`
            // for more intermediate precision and a binary basis. This base conversion
            // is a multiplication by 1e18 / 2**96 = 5**18 / 2**78.
            x = (x << 78) / 5 ** 18;

            // Reduce range of x to (-½ ln 2, ½ ln 2) * 2**96 by factoring out powers
            // of two such that exp(x) = exp(x') * 2**k, where k is an integer.
            // Solving this gives k = round(x / log(2)) and x' = x - k * log(2).
            int256 k = ((x << 96) / 54916777467707473351141471128 + 2 ** 95) >> 96;
            x = x - k * 54916777467707473351141471128;

            // `k` is in the range `[-61, 195]`.

            // Evaluate using a (6, 7)-term rational approximation.
            // `p` is made monic, we'll multiply by a scale factor later.
            int256 y = x + 1346386616545796478920950773328;
            y = ((y * x) >> 96) + 57155421227552351082224309758442;
            int256 p = y + x - 94201549194550492254356042504812;
            p = ((p * y) >> 96) + 28719021644029726153956944680412240;
            p = p * x + (4385272521454847904659076985693276 << 96);

            // We leave `p` in `2**192` basis so we don't need to scale it back up for the division.
            int256 q = x - 2855989394907223263936484059900;
            q = ((q * x) >> 96) + 50020603652535783019961831881945;
            q = ((q * x) >> 96) - 533845033583426703283633433725380;
            q = ((q * x) >> 96) + 3604857256930695427073651918091429;
            q = ((q * x) >> 96) - 14423608567350463180887372962807573;
            q = ((q * x) >> 96) + 26449188498355588339934803723976023;

            /// @solidity memory-safe-assembly
            assembly {
                // Div in assembly because solidity adds a zero check despite the unchecked.
                // The q polynomial won't have zeros in the domain as all its roots are complex.
                // No scaling is necessary because p is already `2**96` too large.
                r := sdiv(p, q)
            }

            // r should be in the range `(0.09, 0.25) * 2**96`.

            // We now need to multiply r by:
            // - The scale factor `s ≈ 6.031367120`.
            // - The `2**k` factor from the range reduction.
            // - The `1e18 / 2**96` factor for base conversion.
            // We do this all at once, with an intermediate result in `2**213`
            // basis, so the final right shift is always by a positive amount.
            r = int256(
                (uint256(r) * 3822833074963236453042738258902158003155416615667) >> uint256(195 - k)
            );
        }
    }

    /// @dev Returns `ln(x)`, denominated in `WAD`.
    /// Credit to Remco Bloemen under MIT license: https://2π.com/22/exp-ln
    /// Note: This function is an approximation. Monotonically increasing.
    function lnWad(int256 x) internal pure returns (int256 r) {
        /// @solidity memory-safe-assembly
        assembly {
            // We want to convert `x` from `10**18` fixed point to `2**96` fixed point.
            // We do this by multiplying by `2**96 / 10**18`. But since
            // `ln(x * C) = ln(x) + ln(C)`, we can simply do nothing here
            // and add `ln(2**96 / 10**18)` at the end.

            // Compute `k = log2(x) - 96`, `r = 159 - k = 255 - log2(x) = 255 ^ log2(x)`.
            r := shl(7, lt(0xffffffffffffffffffffffffffffffff, x))
            r := or(r, shl(6, lt(0xffffffffffffffff, shr(r, x))))
            r := or(r, shl(5, lt(0xffffffff, shr(r, x))))
            r := or(r, shl(4, lt(0xffff, shr(r, x))))
            r := or(r, shl(3, lt(0xff, shr(r, x))))
            // We place the check here for more optimal stack operations.
            if iszero(sgt(x, 0)) {
                mstore(0x00, 0x1615e638) // `LnWadUndefined()`.
                revert(0x1c, 0x04)
            }
            // forgefmt: disable-next-item
            r := xor(r, byte(and(0x1f, shr(shr(r, x), 0x8421084210842108cc6318c6db6d54be)),
                0xf8f9f9faf9fdfafbf9fdfcfdfafbfcfef9fafdfafcfcfbfefafafcfbffffffff))

            // Reduce range of x to (1, 2) * 2**96
            // ln(2^k * x) = k * ln(2) + ln(x)
            x := shr(159, shl(r, x))

            // Evaluate using a (8, 8)-term rational approximation.
            // `p` is made monic, we will multiply by a scale factor later.
            // forgefmt: disable-next-item
            let p := sub( // This heavily nested expression is to avoid stack-too-deep for via-ir.
                sar(96, mul(add(43456485725739037958740375743393,
                sar(96, mul(add(24828157081833163892658089445524,
                sar(96, mul(add(3273285459638523848632254066296,
                    x), x))), x))), x)), 11111509109440967052023855526967)
            p := sub(sar(96, mul(p, x)), 45023709667254063763336534515857)
            p := sub(sar(96, mul(p, x)), 14706773417378608786704636184526)
            p := sub(mul(p, x), shl(96, 795164235651350426258249787498))
            // We leave `p` in `2**192` basis so we don't need to scale it back up for the division.

            // `q` is monic by convention.
            let q := add(5573035233440673466300451813936, x)
            q := add(71694874799317883764090561454958, sar(96, mul(x, q)))
            q := add(283447036172924575727196451306956, sar(96, mul(x, q)))
            q := add(401686690394027663651624208769553, sar(96, mul(x, q)))
            q := add(204048457590392012362485061816622, sar(96, mul(x, q)))
            q := add(31853899698501571402653359427138, sar(96, mul(x, q)))
            q := add(909429971244387300277376558375, sar(96, mul(x, q)))

            // `p / q` is in the range `(0, 0.125) * 2**96`.

            // Finalization, we need to:
            // - Multiply by the scale factor `s = 5.549…`.
            // - Add `ln(2**96 / 10**18)`.
            // - Add `k * ln(2)`.
            // - Multiply by `10**18 / 2**96 = 5**18 >> 78`.

            // The q polynomial is known not to have zeros in the domain.
            // No scaling required because p is already `2**96` too large.
            p := sdiv(p, q)
            // Multiply by the scaling factor: `s * 5**18 * 2**96`, base is now `5**18 * 2**192`.
            p := mul(1677202110996718588342820967067443963516166, p)
            // Add `ln(2) * k * 5**18 * 2**192`.
            // forgefmt: disable-next-item
            p := add(mul(16597577552685614221487285958193947469193820559219878177908093499208371, sub(159, r)), p)
            // Add `ln(2**96 / 10**18) * 5**18 * 2**192`.
            p := add(600920179829731861736702779321621459595472258049074101567377883020018308, p)
            // Base conversion: mul `2**18 / 2**192`.
            r := sar(174, p)
        }
    }

    /// @dev Returns `W_0(x)`, denominated in `WAD`.
    /// See: https://en.wikipedia.org/wiki/Lambert_W_function
    /// a.k.a. Product log function. This is an approximation of the principal branch.
    /// Note: This function is an approximation. Monotonically increasing.
    function lambertW0Wad(int256 x) internal pure returns (int256 w) {
        // forgefmt: disable-next-item
        unchecked {
            if ((w = x) <= -367879441171442322) revert OutOfDomain(); // `x` less than `-1/e`.
            int256 wad = int256(WAD);
            int256 p = x;
            uint256 c; // Whether we need to avoid catastrophic cancellation.
            uint256 i = 4; // Number of iterations.
            if (w <= 0x1ffffffffffff) {
                if (-0x4000000000000 <= w) {
                    i = 1; // Inputs near zero only take one step to converge.
                } else if (w <= -0x3ffffffffffffff) {
                    i = 32; // Inputs near `-1/e` take very long to converge.
                }
            } else if (uint256(w >> 63) == uint256(0)) {
                /// @solidity memory-safe-assembly
                assembly {
                    // Inline log2 for more performance, since the range is small.
                    let v := shr(49, w)
                    let l := shl(3, lt(0xff, v))
                    l := add(or(l, byte(and(0x1f, shr(shr(l, v), 0x8421084210842108cc6318c6db6d54be)),
                        0x0706060506020504060203020504030106050205030304010505030400000000)), 49)
                    w := sdiv(shl(l, 7), byte(sub(l, 31), 0x0303030303030303040506080c13))
                    c := gt(l, 60)
                    i := add(2, add(gt(l, 53), c))
                }
            } else {
                int256 ll = lnWad(w = lnWad(w));
                /// @solidity memory-safe-assembly
                assembly {
                    // `w = ln(x) - ln(ln(x)) + b * ln(ln(x)) / ln(x)`.
                    w := add(sdiv(mul(ll, 1023715080943847266), w), sub(w, ll))
                    i := add(3, iszero(shr(68, x)))
                    c := iszero(shr(143, x))
                }
                if (c == uint256(0)) {
                    do { // If `x` is big, use Newton's so that intermediate values won't overflow.
                        int256 e = expWad(w);
                        /// @solidity memory-safe-assembly
                        assembly {
                            let t := mul(w, div(e, wad))
                            w := sub(w, sdiv(sub(t, x), div(add(e, t), wad)))
                        }
                        if (p <= w) break;
                        p = w;
                    } while (--i != uint256(0));
                    /// @solidity memory-safe-assembly
                    assembly {
                        w := sub(w, sgt(w, 2))
                    }
                    return w;
                }
            }
            do { // Otherwise, use Halley's for faster convergence.
                int256 e = expWad(w);
                /// @solidity memory-safe-assembly
                assembly {
                    let t := add(w, wad)
                    let s := sub(mul(w, e), mul(x, wad))
                    w := sub(w, sdiv(mul(s, wad), sub(mul(e, t), sdiv(mul(add(t, wad), s), add(t, t)))))
                }
                if (p <= w) break;
                p = w;
            } while (--i != c);
            /// @solidity memory-safe-assembly
            assembly {
                w := sub(w, sgt(w, 2))
            }
            // For certain ranges of `x`, we'll use the quadratic-rate recursive formula of
            // R. Iacono and J.P. Boyd for the last iteration, to avoid catastrophic cancellation.
            if (c == uint256(0)) return w;
            int256 t = w | 1;
            /// @solidity memory-safe-assembly
            assembly {
                x := sdiv(mul(x, wad), t)
            }
            x = (t * (wad + lnWad(x)));
            /// @solidity memory-safe-assembly
            assembly {
                w := sdiv(x, add(wad, t))
            }
        }
    }

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                  GENERAL NUMBER UTILITIES                  */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Calculates `floor(x * y / d)` with full precision.
    /// Throws if result overflows a uint256 or when `d` is zero.
    /// Credit to Remco Bloemen under MIT license: https://2π.com/21/muldiv
    function fullMulDiv(uint256 x, uint256 y, uint256 d) internal pure returns (uint256 result) {
        /// @solidity memory-safe-assembly
        assembly {
            // 512-bit multiply `[p1 p0] = x * y`.
            // Compute the product mod `2**256` and mod `2**256 - 1`
            // then use the Chinese Remainder Theorem to reconstruct
            // the 512 bit result. The result is stored in two 256
            // variables such that `product = p1 * 2**256 + p0`.

            // Temporarily use `result` as `p0` to save gas.
            result := mul(x, y) // Lower 256 bits of `x * y`.
            for {} 1 {} {
                // If overflows.
                if iszero(mul(or(iszero(x), eq(div(result, x), y)), d)) {
                    let mm := mulmod(x, y, not(0))
                    let p1 := sub(mm, add(result, lt(mm, result))) // Upper 256 bits of `x * y`.

                    /*------------------- 512 by 256 division --------------------*/

                    // Make division exact by subtracting the remainder from `[p1 p0]`.
                    let r := mulmod(x, y, d) // Compute remainder using mulmod.
                    let t := and(d, sub(0, d)) // The least significant bit of `d`. `t >= 1`.
                    // Make sure the result is less than `2**256`. Also prevents `d == 0`.
                    // Placing the check here seems to give more optimal stack operations.
                    if iszero(gt(d, p1)) {
                        mstore(0x00, 0xae47f702) // `FullMulDivFailed()`.
                        revert(0x1c, 0x04)
                    }
                    d := div(d, t) // Divide `d` by `t`, which is a power of two.
                    // Invert `d mod 2**256`
                    // Now that `d` is an odd number, it has an inverse
                    // modulo `2**256` such that `d * inv = 1 mod 2**256`.
                    // Compute the inverse by starting with a seed that is correct
                    // correct for four bits. That is, `d * inv = 1 mod 2**4`.
                    let inv := xor(2, mul(3, d))
                    // Now use 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.
                    inv := mul(inv, sub(2, mul(d, inv))) // inverse mod 2**8
                    inv := mul(inv, sub(2, mul(d, inv))) // inverse mod 2**16
                    inv := mul(inv, sub(2, mul(d, inv))) // inverse mod 2**32
                    inv := mul(inv, sub(2, mul(d, inv))) // inverse mod 2**64
                    inv := mul(inv, sub(2, mul(d, inv))) // inverse mod 2**128
                    result :=
                        mul(
                            // Divide [p1 p0] by the factors of two.
                            // Shift in bits from `p1` into `p0`. For this we need
                            // to flip `t` such that it is `2**256 / t`.
                            or(
                                mul(sub(p1, gt(r, result)), add(div(sub(0, t), t), 1)),
                                div(sub(result, r), t)
                            ),
                            mul(sub(2, mul(d, inv)), inv) // inverse mod 2**256
                        )
                    break
                }
                result := div(result, d)
                break
            }
        }
    }

    /// @dev Calculates `floor(x * y / d)` with full precision.
    /// Behavior is undefined if `d` is zero or the final result cannot fit in 256 bits.
    /// Performs the full 512 bit calculation regardless.
    function fullMulDivUnchecked(uint256 x, uint256 y, uint256 d)
        internal
        pure
        returns (uint256 result)
    {
        /// @solidity memory-safe-assembly
        assembly {
            result := mul(x, y)
            let mm := mulmod(x, y, not(0))
            let p1 := sub(mm, add(result, lt(mm, result)))
            let t := and(d, sub(0, d))
            let r := mulmod(x, y, d)
            d := div(d, t)
            let inv := xor(2, mul(3, d))
            inv := mul(inv, sub(2, mul(d, inv)))
            inv := mul(inv, sub(2, mul(d, inv)))
            inv := mul(inv, sub(2, mul(d, inv)))
            inv := mul(inv, sub(2, mul(d, inv)))
            inv := mul(inv, sub(2, mul(d, inv)))
            result :=
                mul(
                    or(mul(sub(p1, gt(r, result)), add(div(sub(0, t), t), 1)), div(sub(result, r), t)),
                    mul(sub(2, mul(d, inv)), inv)
                )
        }
    }

    /// @dev Calculates `floor(x * y / d)` with full precision, rounded up.
    /// Throws if result overflows a uint256 or when `d` is zero.
    /// Credit to Uniswap-v3-core under MIT license:
    /// https://github.com/Uniswap/v3-core/blob/main/contracts/libraries/FullMath.sol
    function fullMulDivUp(uint256 x, uint256 y, uint256 d) internal pure returns (uint256 result) {
        result = fullMulDiv(x, y, d);
        /// @solidity memory-safe-assembly
        assembly {
            if mulmod(x, y, d) {
                result := add(result, 1)
                if iszero(result) {
                    mstore(0x00, 0xae47f702) // `FullMulDivFailed()`.
                    revert(0x1c, 0x04)
                }
            }
        }
    }

    /// @dev Returns `floor(x * y / d)`.
    /// Reverts if `x * y` overflows, or `d` is zero.
    function mulDiv(uint256 x, uint256 y, uint256 d) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            z := mul(x, y)
            // Equivalent to `require(d != 0 && (y == 0 || x <= type(uint256).max / y))`.
            if iszero(mul(or(iszero(x), eq(div(z, x), y)), d)) {
                mstore(0x00, 0xad251c27) // `MulDivFailed()`.
                revert(0x1c, 0x04)
            }
            z := div(z, d)
        }
    }

    /// @dev Returns `ceil(x * y / d)`.
    /// Reverts if `x * y` overflows, or `d` is zero.
    function mulDivUp(uint256 x, uint256 y, uint256 d) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            z := mul(x, y)
            // Equivalent to `require(d != 0 && (y == 0 || x <= type(uint256).max / y))`.
            if iszero(mul(or(iszero(x), eq(div(z, x), y)), d)) {
                mstore(0x00, 0xad251c27) // `MulDivFailed()`.
                revert(0x1c, 0x04)
            }
            z := add(iszero(iszero(mod(z, d))), div(z, d))
        }
    }

    /// @dev Returns `ceil(x / d)`.
    /// Reverts if `d` is zero.
    function divUp(uint256 x, uint256 d) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            if iszero(d) {
                mstore(0x00, 0x65244e4e) // `DivFailed()`.
                revert(0x1c, 0x04)
            }
            z := add(iszero(iszero(mod(x, d))), div(x, d))
        }
    }

    /// @dev Returns `max(0, x - y)`.
    function zeroFloorSub(uint256 x, uint256 y) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            z := mul(gt(x, y), sub(x, y))
        }
    }

    /// @dev Returns `condition ? x : y`, without branching.
    function ternary(bool condition, uint256 x, uint256 y) internal pure returns (uint256 result) {
        /// @solidity memory-safe-assembly
        assembly {
            result := xor(x, mul(xor(x, y), iszero(condition)))
        }
    }

    /// @dev Exponentiate `x` to `y` by squaring, denominated in base `b`.
    /// Reverts if the computation overflows.
    function rpow(uint256 x, uint256 y, uint256 b) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            z := mul(b, iszero(y)) // `0 ** 0 = 1`. Otherwise, `0 ** n = 0`.
            if x {
                z := xor(b, mul(xor(b, x), and(y, 1))) // `z = isEven(y) ? scale : x`
                let half := shr(1, b) // Divide `b` by 2.
                // Divide `y` by 2 every iteration.
                for { y := shr(1, y) } y { y := shr(1, y) } {
                    let xx := mul(x, x) // Store x squared.
                    let xxRound := add(xx, half) // Round to the nearest number.
                    // Revert if `xx + half` overflowed, or if `x ** 2` overflows.
                    if or(lt(xxRound, xx), shr(128, x)) {
                        mstore(0x00, 0x49f7642b) // `RPowOverflow()`.
                        revert(0x1c, 0x04)
                    }
                    x := div(xxRound, b) // Set `x` to scaled `xxRound`.
                    // If `y` is odd:
                    if and(y, 1) {
                        let zx := mul(z, x) // Compute `z * x`.
                        let zxRound := add(zx, half) // Round to the nearest number.
                        // If `z * x` overflowed or `zx + half` overflowed:
                        if or(xor(div(zx, x), z), lt(zxRound, zx)) {
                            // Revert if `x` is non-zero.
                            if x {
                                mstore(0x00, 0x49f7642b) // `RPowOverflow()`.
                                revert(0x1c, 0x04)
                            }
                        }
                        z := div(zxRound, b) // Return properly scaled `zxRound`.
                    }
                }
            }
        }
    }

    /// @dev Returns the square root of `x`, rounded down.
    function sqrt(uint256 x) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            // `floor(sqrt(2**15)) = 181`. `sqrt(2**15) - 181 = 2.84`.
            z := 181 // The "correct" value is 1, but this saves a multiplication later.

            // This segment is to get a reasonable initial estimate for the Babylonian method. With a bad
            // start, the correct # of bits increases ~linearly each iteration instead of ~quadratically.

            // Let `y = x / 2**r`. We check `y >= 2**(k + 8)`
            // but shift right by `k` bits to ensure that if `x >= 256`, then `y >= 256`.
            let r := shl(7, lt(0xffffffffffffffffffffffffffffffffff, x))
            r := or(r, shl(6, lt(0xffffffffffffffffff, shr(r, x))))
            r := or(r, shl(5, lt(0xffffffffff, shr(r, x))))
            r := or(r, shl(4, lt(0xffffff, shr(r, x))))
            z := shl(shr(1, r), z)

            // Goal was to get `z*z*y` within a small factor of `x`. More iterations could
            // get y in a tighter range. Currently, we will have y in `[256, 256*(2**16))`.
            // We ensured `y >= 256` so that the relative difference between `y` and `y+1` is small.
            // That's not possible if `x < 256` but we can just verify those cases exhaustively.

            // Now, `z*z*y <= x < z*z*(y+1)`, and `y <= 2**(16+8)`, and either `y >= 256`, or `x < 256`.
            // Correctness can be checked exhaustively for `x < 256`, so we assume `y >= 256`.
            // Then `z*sqrt(y)` is within `sqrt(257)/sqrt(256)` of `sqrt(x)`, or about 20bps.

            // For `s` in the range `[1/256, 256]`, the estimate `f(s) = (181/1024) * (s+1)`
            // is in the range `(1/2.84 * sqrt(s), 2.84 * sqrt(s))`,
            // with largest error when `s = 1` and when `s = 256` or `1/256`.

            // Since `y` is in `[256, 256*(2**16))`, let `a = y/65536`, so that `a` is in `[1/256, 256)`.
            // Then we can estimate `sqrt(y)` using
            // `sqrt(65536) * 181/1024 * (a + 1) = 181/4 * (y + 65536)/65536 = 181 * (y + 65536)/2**18`.

            // There is no overflow risk here since `y < 2**136` after the first branch above.
            z := shr(18, mul(z, add(shr(r, x), 65536))) // A `mul()` is saved from starting `z` at 181.

            // Given the worst case multiplicative error of 2.84 above, 7 iterations should be enough.
            z := shr(1, add(z, div(x, z)))
            z := shr(1, add(z, div(x, z)))
            z := shr(1, add(z, div(x, z)))
            z := shr(1, add(z, div(x, z)))
            z := shr(1, add(z, div(x, z)))
            z := shr(1, add(z, div(x, z)))
            z := shr(1, add(z, div(x, z)))

            // If `x+1` is a perfect square, the Babylonian method cycles between
            // `floor(sqrt(x))` and `ceil(sqrt(x))`. This statement ensures we return floor.
            // See: https://en.wikipedia.org/wiki/Integer_square_root#Using_only_integer_division
            z := sub(z, lt(div(x, z), z))
        }
    }

    /// @dev Returns the cube root of `x`, rounded down.
    /// Credit to bout3fiddy and pcaversaccio under AGPLv3 license:
    /// https://github.com/pcaversaccio/snekmate/blob/main/src/utils/Math.vy
    function cbrt(uint256 x) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            let r := shl(7, lt(0xffffffffffffffffffffffffffffffff, x))
            r := or(r, shl(6, lt(0xffffffffffffffff, shr(r, x))))
            r := or(r, shl(5, lt(0xffffffff, shr(r, x))))
            r := or(r, shl(4, lt(0xffff, shr(r, x))))
            r := or(r, shl(3, lt(0xff, shr(r, x))))

            z := div(shl(div(r, 3), shl(lt(0xf, shr(r, x)), 0xf)), xor(7, mod(r, 3)))

            z := div(add(add(div(x, mul(z, z)), z), z), 3)
            z := div(add(add(div(x, mul(z, z)), z), z), 3)
            z := div(add(add(div(x, mul(z, z)), z), z), 3)
            z := div(add(add(div(x, mul(z, z)), z), z), 3)
            z := div(add(add(div(x, mul(z, z)), z), z), 3)
            z := div(add(add(div(x, mul(z, z)), z), z), 3)
            z := div(add(add(div(x, mul(z, z)), z), z), 3)

            z := sub(z, lt(div(x, mul(z, z)), z))
        }
    }

    /// @dev Returns the square root of `x`, denominated in `WAD`, rounded down.
    function sqrtWad(uint256 x) internal pure returns (uint256 z) {
        unchecked {
            if (x <= type(uint256).max / 10 ** 18) return sqrt(x * 10 ** 18);
            z = (1 + sqrt(x)) * 10 ** 9;
            z = (fullMulDivUnchecked(x, 10 ** 18, z) + z) >> 1;
        }
        /// @solidity memory-safe-assembly
        assembly {
            z := sub(z, gt(999999999999999999, sub(mulmod(z, z, x), 1)))
        }
    }

    /// @dev Returns the cube root of `x`, denominated in `WAD`, rounded down.
    function cbrtWad(uint256 x) internal pure returns (uint256 z) {
        unchecked {
            if (x <= type(uint256).max / 10 ** 36) return cbrt(x * 10 ** 36);
            z = (1 + cbrt(x)) * 10 ** 12;
            z = (fullMulDivUnchecked(x, 10 ** 36, z * z) + z + z) / 3;
            uint256 t = fullMulDivUnchecked(x, 10 ** 36, z * z);
            /// @solidity memory-safe-assembly
            assembly {
                z := sub(z, lt(t, z))
            }
        }
    }

    /// @dev Returns the factorial of `x`.
    function factorial(uint256 x) internal pure returns (uint256 result) {
        /// @solidity memory-safe-assembly
        assembly {
            result := 1
            if iszero(lt(x, 58)) {
                mstore(0x00, 0xaba0f2a2) // `FactorialOverflow()`.
                revert(0x1c, 0x04)
            }
            for {} x { x := sub(x, 1) } { result := mul(result, x) }
        }
    }

    /// @dev Returns the log2 of `x`.
    /// Equivalent to computing the index of the most significant bit (MSB) of `x`.
    /// Returns 0 if `x` is zero.
    function log2(uint256 x) internal pure returns (uint256 r) {
        /// @solidity memory-safe-assembly
        assembly {
            r := shl(7, lt(0xffffffffffffffffffffffffffffffff, x))
            r := or(r, shl(6, lt(0xffffffffffffffff, shr(r, x))))
            r := or(r, shl(5, lt(0xffffffff, shr(r, x))))
            r := or(r, shl(4, lt(0xffff, shr(r, x))))
            r := or(r, shl(3, lt(0xff, shr(r, x))))
            // forgefmt: disable-next-item
            r := or(r, byte(and(0x1f, shr(shr(r, x), 0x8421084210842108cc6318c6db6d54be)),
                0x0706060506020504060203020504030106050205030304010505030400000000))
        }
    }

    /// @dev Returns the log2 of `x`, rounded up.
    /// Returns 0 if `x` is zero.
    function log2Up(uint256 x) internal pure returns (uint256 r) {
        r = log2(x);
        /// @solidity memory-safe-assembly
        assembly {
            r := add(r, lt(shl(r, 1), x))
        }
    }

    /// @dev Returns the log10 of `x`.
    /// Returns 0 if `x` is zero.
    function log10(uint256 x) internal pure returns (uint256 r) {
        /// @solidity memory-safe-assembly
        assembly {
            if iszero(lt(x, 100000000000000000000000000000000000000)) {
                x := div(x, 100000000000000000000000000000000000000)
                r := 38
            }
            if iszero(lt(x, 100000000000000000000)) {
                x := div(x, 100000000000000000000)
                r := add(r, 20)
            }
            if iszero(lt(x, 10000000000)) {
                x := div(x, 10000000000)
                r := add(r, 10)
            }
            if iszero(lt(x, 100000)) {
                x := div(x, 100000)
                r := add(r, 5)
            }
            r := add(r, add(gt(x, 9), add(gt(x, 99), add(gt(x, 999), gt(x, 9999)))))
        }
    }

    /// @dev Returns the log10 of `x`, rounded up.
    /// Returns 0 if `x` is zero.
    function log10Up(uint256 x) internal pure returns (uint256 r) {
        r = log10(x);
        /// @solidity memory-safe-assembly
        assembly {
            r := add(r, lt(exp(10, r), x))
        }
    }

    /// @dev Returns the log256 of `x`.
    /// Returns 0 if `x` is zero.
    function log256(uint256 x) internal pure returns (uint256 r) {
        /// @solidity memory-safe-assembly
        assembly {
            r := shl(7, lt(0xffffffffffffffffffffffffffffffff, x))
            r := or(r, shl(6, lt(0xffffffffffffffff, shr(r, x))))
            r := or(r, shl(5, lt(0xffffffff, shr(r, x))))
            r := or(r, shl(4, lt(0xffff, shr(r, x))))
            r := or(shr(3, r), lt(0xff, shr(r, x)))
        }
    }

    /// @dev Returns the log256 of `x`, rounded up.
    /// Returns 0 if `x` is zero.
    function log256Up(uint256 x) internal pure returns (uint256 r) {
        r = log256(x);
        /// @solidity memory-safe-assembly
        assembly {
            r := add(r, lt(shl(shl(3, r), 1), x))
        }
    }

    /// @dev Returns the scientific notation format `mantissa * 10 ** exponent` of `x`.
    /// Useful for compressing prices (e.g. using 25 bit mantissa and 7 bit exponent).
    function sci(uint256 x) internal pure returns (uint256 mantissa, uint256 exponent) {
        /// @solidity memory-safe-assembly
        assembly {
            mantissa := x
            if mantissa {
                if iszero(mod(mantissa, 1000000000000000000000000000000000)) {
                    mantissa := div(mantissa, 1000000000000000000000000000000000)
                    exponent := 33
                }
                if iszero(mod(mantissa, 10000000000000000000)) {
                    mantissa := div(mantissa, 10000000000000000000)
                    exponent := add(exponent, 19)
                }
                if iszero(mod(mantissa, 1000000000000)) {
                    mantissa := div(mantissa, 1000000000000)
                    exponent := add(exponent, 12)
                }
                if iszero(mod(mantissa, 1000000)) {
                    mantissa := div(mantissa, 1000000)
                    exponent := add(exponent, 6)
                }
                if iszero(mod(mantissa, 10000)) {
                    mantissa := div(mantissa, 10000)
                    exponent := add(exponent, 4)
                }
                if iszero(mod(mantissa, 100)) {
                    mantissa := div(mantissa, 100)
                    exponent := add(exponent, 2)
                }
                if iszero(mod(mantissa, 10)) {
                    mantissa := div(mantissa, 10)
                    exponent := add(exponent, 1)
                }
            }
        }
    }

    /// @dev Convenience function for packing `x` into a smaller number using `sci`.
    /// The `mantissa` will be in bits [7..255] (the upper 249 bits).
    /// The `exponent` will be in bits [0..6] (the lower 7 bits).
    /// Use `SafeCastLib` to safely ensure that the `packed` number is small
    /// enough to fit in the desired unsigned integer type:
    /// ```
    ///     uint32 packed = SafeCastLib.toUint32(FixedPointMathLib.packSci(777 ether));
    /// ```
    function packSci(uint256 x) internal pure returns (uint256 packed) {
        (x, packed) = sci(x); // Reuse for `mantissa` and `exponent`.
        /// @solidity memory-safe-assembly
        assembly {
            if shr(249, x) {
                mstore(0x00, 0xce30380c) // `MantissaOverflow()`.
                revert(0x1c, 0x04)
            }
            packed := or(shl(7, x), packed)
        }
    }

    /// @dev Convenience function for unpacking a packed number from `packSci`.
    function unpackSci(uint256 packed) internal pure returns (uint256 unpacked) {
        unchecked {
            unpacked = (packed >> 7) * 10 ** (packed & 0x7f);
        }
    }

    /// @dev Returns the average of `x` and `y`. Rounds towards zero.
    function avg(uint256 x, uint256 y) internal pure returns (uint256 z) {
        unchecked {
            z = (x & y) + ((x ^ y) >> 1);
        }
    }

    /// @dev Returns the average of `x` and `y`. Rounds towards negative infinity.
    function avg(int256 x, int256 y) internal pure returns (int256 z) {
        unchecked {
            z = (x >> 1) + (y >> 1) + (x & y & 1);
        }
    }

    /// @dev Returns the absolute value of `x`.
    function abs(int256 x) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            z := xor(sar(255, x), add(sar(255, x), x))
        }
    }

    /// @dev Returns the absolute distance between `x` and `y`.
    function dist(uint256 x, uint256 y) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            z := xor(mul(xor(sub(y, x), sub(x, y)), gt(x, y)), sub(y, x))
        }
    }

    /// @dev Returns the absolute distance between `x` and `y`.
    function dist(int256 x, int256 y) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            z := xor(mul(xor(sub(y, x), sub(x, y)), sgt(x, y)), sub(y, x))
        }
    }

    /// @dev Returns the minimum of `x` and `y`.
    function min(uint256 x, uint256 y) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            z := xor(x, mul(xor(x, y), lt(y, x)))
        }
    }

    /// @dev Returns the minimum of `x` and `y`.
    function min(int256 x, int256 y) internal pure returns (int256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            z := xor(x, mul(xor(x, y), slt(y, x)))
        }
    }

    /// @dev Returns the maximum of `x` and `y`.
    function max(uint256 x, uint256 y) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            z := xor(x, mul(xor(x, y), gt(y, x)))
        }
    }

    /// @dev Returns the maximum of `x` and `y`.
    function max(int256 x, int256 y) internal pure returns (int256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            z := xor(x, mul(xor(x, y), sgt(y, x)))
        }
    }

    /// @dev Returns `x`, bounded to `minValue` and `maxValue`.
    function clamp(uint256 x, uint256 minValue, uint256 maxValue)
        internal
        pure
        returns (uint256 z)
    {
        /// @solidity memory-safe-assembly
        assembly {
            z := xor(x, mul(xor(x, minValue), gt(minValue, x)))
            z := xor(z, mul(xor(z, maxValue), lt(maxValue, z)))
        }
    }

    /// @dev Returns `x`, bounded to `minValue` and `maxValue`.
    function clamp(int256 x, int256 minValue, int256 maxValue) internal pure returns (int256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            z := xor(x, mul(xor(x, minValue), sgt(minValue, x)))
            z := xor(z, mul(xor(z, maxValue), slt(maxValue, z)))
        }
    }

    /// @dev Returns greatest common divisor of `x` and `y`.
    function gcd(uint256 x, uint256 y) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            for { z := x } y {} {
                let t := y
                y := mod(z, y)
                z := t
            }
        }
    }

    /// @dev Returns `a + (b - a) * (t - begin) / (end - begin)`,
    /// with `t` clamped between `begin` and `end` (inclusive).
    /// Agnostic to the order of (`a`, `b`) and (`end`, `begin`).
    /// Reverts if `begin` equals `end` (due to division by zero).
    function lerp(uint256 a, uint256 b, uint256 t, uint256 begin, uint256 end)
        internal
        pure
        returns (uint256)
    {
        if (begin >= end) {
            t = ~t;
            begin = ~begin;
            end = ~end;
        }
        if (t <= begin) return a;
        if (t >= end) return b;
        unchecked {
            if (b >= a) return a + fullMulDiv(b - a, t - begin, end - begin);
            return a - fullMulDiv(a - b, t - begin, end - begin);
        }
    }

    /// @dev Returns `a + (b - a) * (t - begin) / (end - begin)`.
    /// with `t` clamped between `begin` and `end` (inclusive).
    /// Agnostic to the order of (`a`, `b`) and (`end`, `begin`).
    /// Reverts if `begin` equals `end` (due to division by zero).
    function lerp(int256 a, int256 b, int256 t, int256 begin, int256 end)
        internal
        pure
        returns (int256)
    {
        if (begin >= end) {
            t = int256(~uint256(t));
            begin = int256(~uint256(begin));
            end = int256(~uint256(end));
        }
        if (t <= begin) return a;
        if (t >= end) return b;
        // forgefmt: disable-next-item
        unchecked {
            if (b >= a) return int256(uint256(a) + fullMulDiv(uint256(b) - uint256(a),
                uint256(t) - uint256(begin), uint256(end) - uint256(begin)));
            return int256(uint256(a) - fullMulDiv(uint256(a) - uint256(b),
                uint256(t) - uint256(begin), uint256(end) - uint256(begin)));
        }
    }

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                   RAW NUMBER OPERATIONS                    */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Returns `x + y`, without checking for overflow.
    function rawAdd(uint256 x, uint256 y) internal pure returns (uint256 z) {
        unchecked {
            z = x + y;
        }
    }

    /// @dev Returns `x + y`, without checking for overflow.
    function rawAdd(int256 x, int256 y) internal pure returns (int256 z) {
        unchecked {
            z = x + y;
        }
    }

    /// @dev Returns `x - y`, without checking for underflow.
    function rawSub(uint256 x, uint256 y) internal pure returns (uint256 z) {
        unchecked {
            z = x - y;
        }
    }

    /// @dev Returns `x - y`, without checking for underflow.
    function rawSub(int256 x, int256 y) internal pure returns (int256 z) {
        unchecked {
            z = x - y;
        }
    }

    /// @dev Returns `x * y`, without checking for overflow.
    function rawMul(uint256 x, uint256 y) internal pure returns (uint256 z) {
        unchecked {
            z = x * y;
        }
    }

    /// @dev Returns `x * y`, without checking for overflow.
    function rawMul(int256 x, int256 y) internal pure returns (int256 z) {
        unchecked {
            z = x * y;
        }
    }

    /// @dev Returns `x / y`, returning 0 if `y` is zero.
    function rawDiv(uint256 x, uint256 y) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            z := div(x, y)
        }
    }

    /// @dev Returns `x / y`, returning 0 if `y` is zero.
    function rawSDiv(int256 x, int256 y) internal pure returns (int256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            z := sdiv(x, y)
        }
    }

    /// @dev Returns `x % y`, returning 0 if `y` is zero.
    function rawMod(uint256 x, uint256 y) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            z := mod(x, y)
        }
    }

    /// @dev Returns `x % y`, returning 0 if `y` is zero.
    function rawSMod(int256 x, int256 y) internal pure returns (int256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            z := smod(x, y)
        }
    }

    /// @dev Returns `(x + y) % d`, return 0 if `d` if zero.
    function rawAddMod(uint256 x, uint256 y, uint256 d) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            z := addmod(x, y, d)
        }
    }

    /// @dev Returns `(x * y) % d`, return 0 if `d` if zero.
    function rawMulMod(uint256 x, uint256 y, uint256 d) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            z := mulmod(x, y, d)
        }
    }
}

File 7 of 9 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

/// @notice Reentrancy guard mixin.
/// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/ReentrancyGuard.sol)
abstract contract ReentrancyGuard {
    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                       CUSTOM ERRORS                        */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Unauthorized reentrant call.
    error Reentrancy();

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                          STORAGE                           */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Equivalent to: `uint72(bytes9(keccak256("_REENTRANCY_GUARD_SLOT")))`.
    /// 9 bytes is large enough to avoid collisions with lower slots,
    /// but not too large to result in excessive bytecode bloat.
    uint256 private constant _REENTRANCY_GUARD_SLOT = 0x929eee149b4bd21268;

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                      REENTRANCY GUARD                      */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Guards a function from reentrancy.
    modifier nonReentrant() virtual {
        /// @solidity memory-safe-assembly
        assembly {
            if eq(sload(_REENTRANCY_GUARD_SLOT), address()) {
                mstore(0x00, 0xab143c06) // `Reentrancy()`.
                revert(0x1c, 0x04)
            }
            sstore(_REENTRANCY_GUARD_SLOT, address())
        }
        _;
        /// @solidity memory-safe-assembly
        assembly {
            sstore(_REENTRANCY_GUARD_SLOT, codesize())
        }
    }

    /// @dev Guards a view function from read-only reentrancy.
    modifier nonReadReentrant() virtual {
        /// @solidity memory-safe-assembly
        assembly {
            if eq(sload(_REENTRANCY_GUARD_SLOT), address()) {
                mstore(0x00, 0xab143c06) // `Reentrancy()`.
                revert(0x1c, 0x04)
            }
        }
        _;
    }
}

File 8 of 9 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)

pragma solidity =0.8.25;

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

    function decimals() external view returns (uint8);
}

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

pragma solidity =0.8.25;

struct PoolArgs {
    address shareToken;
    address assetToken;
    address owner;
    address feeRecipient;
    uint256 assetsPerToken;
    uint256 sharesForSale;
    uint256 platformFeeWAD;
    uint256 swapFeeWAD;
    uint40 saleStart;
    uint40 saleEnd;
    uint40 redemptionTimestamp;
    uint256 totalSharesSold;
    bool closed;
    bool paused;
    bool canceled;
    bool canClose;
    uint256 userMaximumShares;
    uint256 minimumPurchaseAmount;
}

Settings
{
  "remappings": [
    "forge-std/=lib/forge-std/src/",
    "solady/=lib/solady/src/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "metadata": {
    "useLiteralContent": false,
    "bytecodeHash": "ipfs",
    "appendCBOR": true
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "paris",
  "viaIR": false,
  "libraries": {}
}

Contract Security Audit

Contract ABI

API
[{"inputs":[],"name":"PoolCreationFailed","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"poolAddress","type":"address"},{"indexed":false,"internalType":"enum FixedPriceFactory.PoolType","name":"poolType","type":"uint8"}],"name":"PoolCreated","type":"event"},{"inputs":[{"internalType":"address","name":"_shareToken","type":"address"},{"internalType":"address","name":"_assetToken","type":"address"},{"internalType":"uint256","name":"_assetsPerToken","type":"uint256"},{"internalType":"uint256","name":"_sharesForSale","type":"uint256"},{"internalType":"uint256","name":"_userMaxShares","type":"uint256"},{"internalType":"address","name":"_feeRecipient","type":"address"},{"internalType":"uint256","name":"_platformFeeWAD","type":"uint256"},{"internalType":"uint256","name":"_swapFeeWAD","type":"uint256"},{"internalType":"uint40","name":"_saleStart","type":"uint40"},{"internalType":"uint40","name":"_saleEnd","type":"uint40"},{"internalType":"uint40","name":"_redemptionTimestamp","type":"uint40"}],"name":"createFixedERC20","outputs":[{"internalType":"address","name":"pool","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_shareToken","type":"address"},{"internalType":"uint256","name":"_weiPerToken","type":"uint256"},{"internalType":"uint256","name":"_sharesForSale","type":"uint256"},{"internalType":"uint256","name":"_userMaxShares","type":"uint256"},{"internalType":"address","name":"_feeRecipient","type":"address"},{"internalType":"uint256","name":"_platformFeeWAD","type":"uint256"},{"internalType":"uint256","name":"_swapFeeWAD","type":"uint256"},{"internalType":"uint40","name":"_saleStart","type":"uint40"},{"internalType":"uint40","name":"_saleEnd","type":"uint40"},{"internalType":"uint40","name":"_redemptionTimestamp","type":"uint40"}],"name":"createFixedNative","outputs":[{"internalType":"address","name":"pool","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_shareToken","type":"address"},{"internalType":"address","name":"_assetToken","type":"address"},{"internalType":"uint256","name":"_assetsPerToken","type":"uint256"},{"internalType":"uint256","name":"_sharesForSale","type":"uint256"},{"internalType":"uint256","name":"_userMaximumShares","type":"uint256"},{"internalType":"address","name":"_feeRecipient","type":"address"},{"internalType":"uint256","name":"_platformFeeWAD","type":"uint256"},{"internalType":"uint256","name":"_swapFeeWAD","type":"uint256"},{"internalType":"uint40","name":"_saleStart","type":"uint40"},{"internalType":"uint40","name":"_saleEnd","type":"uint40"},{"internalType":"uint40","name":"_redemptionTimestamp","type":"uint40"}],"name":"getCreationBytecodeERC20","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_shareToken","type":"address"},{"internalType":"uint256","name":"_weiPerToken","type":"uint256"},{"internalType":"uint256","name":"_sharesForSale","type":"uint256"},{"internalType":"uint256","name":"_userMaximumShares","type":"uint256"},{"internalType":"address","name":"_feeRecipient","type":"address"},{"internalType":"uint256","name":"_platformFeeWAD","type":"uint256"},{"internalType":"uint256","name":"_swapFeeWAD","type":"uint256"},{"internalType":"uint40","name":"_saleStart","type":"uint40"},{"internalType":"uint40","name":"_saleEnd","type":"uint40"},{"internalType":"uint40","name":"_redemptionTimestamp","type":"uint40"}],"name":"getCreationBytecodeNative","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"_sender","type":"address"},{"internalType":"address","name":"_shareToken","type":"address"},{"internalType":"address","name":"_assetToken","type":"address"},{"internalType":"uint256","name":"_assetsPerToken","type":"uint256"},{"internalType":"uint256","name":"_sharesForSale","type":"uint256"},{"internalType":"uint256","name":"_userMaxShares","type":"uint256"},{"internalType":"address","name":"_feeRecipient","type":"address"},{"internalType":"uint256","name":"_platformFeeWAD","type":"uint256"},{"internalType":"uint256","name":"_swapFeeWAD","type":"uint256"},{"internalType":"uint40","name":"_saleStart","type":"uint40"},{"internalType":"uint40","name":"_saleEnd","type":"uint40"},{"internalType":"uint40","name":"_redemptionTimestamp","type":"uint40"}],"name":"getFixedERC20Address","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_sender","type":"address"},{"internalType":"address","name":"_shareToken","type":"address"},{"internalType":"uint256","name":"_weiPerToken","type":"uint256"},{"internalType":"uint256","name":"_sharesForSale","type":"uint256"},{"internalType":"uint256","name":"_userMaxShares","type":"uint256"},{"internalType":"address","name":"_feeRecipient","type":"address"},{"internalType":"uint256","name":"_platformFeeWAD","type":"uint256"},{"internalType":"uint256","name":"_swapFeeWAD","type":"uint256"},{"internalType":"uint40","name":"_saleStart","type":"uint40"},{"internalType":"uint40","name":"_saleEnd","type":"uint40"},{"internalType":"uint40","name":"_redemptionTimestamp","type":"uint40"}],"name":"getFixedNativeAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]

6080604052348015600f57600080fd5b506149d98061001f6000396000f3fe608060405234801561001057600080fd5b50600436106100625760003560e01c806312d601361461006757806337b9ac48146100905780633c6ddd3c146100bb5780635bd9f33b146100ce5780639882b72c146100e1578063e2baa3cc146100f4575b600080fd5b61007a61007536600461069b565b610107565b6040516100879190610778565b60405180910390f35b6100a361009e3660046107ab565b610208565b6040516001600160a01b039091168152602001610087565b6100a36100c936600461069b565b6102e1565b61007a6100dc366004610842565b61033e565b6100a36100ef366004610842565b610435565b6100a3610102366004610842565b61048f565b606060006040518060200161011b90610650565b6020820181038252601f19601f820116604052509050808e8e8e8e8e8e8e8e8e8e8e8e6040516020016101c89c9b9a999897969594939291906001600160a01b039c8d1681529a8c1660208c0152988b1660408b015260608a0197909752608089019590955260a0880193909352961660c086015260e085019590955261010084019490945264ffffffffff93841661012084015283166101408301529091166101608201526101800190565b60408051601f19818403018152908290526101e692916020016108eb565b6040516020818303038152906040529150509c9b505050505050505050505050565b600080338c8c8c8c8c8c8c8c8c8c6040516020016102309b9a9998979695949392919061091a565b60405160208183030381529060405280519060200120905061026761025e338e8e8e8e8e8e8e8e8e8e61033e565b82906000610563565b91506001600160a01b038216610290576040516337200b1d60e21b815260040160405180910390fd5b816001600160a01b03167f7c3072652d5407e4dcbe90ac1760509311e2511e531f5caf91859f3bc741670860006040516102ca91906109b3565b60405180910390a2509a9950505050505050505050565b6000808d8d8d8d8d8d8d8d8d8d8d8d60405160200161030b9c9b9a999897969594939291906109db565b60405160208183030381529060405280519060200120905061032c816105e4565b9e9d5050505050505050505050505050565b60606000604051806020016103529061065d565b6020820181038252601f19601f820116604052509050808d8d8d8d8d8d8d8d8d8d8d6040516020016103f69b9a999897969594939291906001600160a01b039b8c168152998b1660208b015260408a0198909852606089019690965260808801949094529190961660a086015260c085019590955260e084019490945264ffffffffff93841661010084015283166101208301529091166101408201526101600190565b60408051601f198184030181529082905261041492916020016108eb565b6040516020818303038152906040529150509b9a5050505050505050505050565b6000808c8c8c8c8c8c8c8c8c8c8c60405160200161045d9b9a9998979695949392919061091a565b60405160208183030381529060405280519060200120905061047e816105e4565b9d9c50505050505050505050505050565b600080338d8d8d8d8d8d8d8d8d8d8d6040516020016104b99c9b9a999897969594939291906109db565b6040516020818303038152906040528051906020012090506104e861025e338f8f8f8f8f8f8f8f8f8f8f610107565b91506001600160a01b038216610511576040516337200b1d60e21b815260040160405180910390fd5b816001600160a01b03167f7c3072652d5407e4dcbe90ac1760509311e2511e531f5caf91859f3bc7416708600160405161054b91906109b3565b60405180910390a2509b9a5050505050505050505050565b60006f67363d3d37363d34f03d5260086018f3600052836010806000f5806105935763301164256000526004601cfd5b8060145261d69460005260016034536017601e20915060008085516020870186855af16105c8576319b991a86000526004601cfd5b50803b6105dd576319b991a86000526004601cfd5b9392505050565b60006105f082306105f6565b92915050565b60006040518260005260ff600b53836020527f21c35dbe1b344a2488cf3321d6ce542f8e9f305544ff09e4993a62319a497c1f6040526055600b20601452806040525061d694600052600160345350506017601e20919050565b61209180610a9383390190565b611e8080612b2483390190565b80356001600160a01b038116811461068157600080fd5b919050565b803564ffffffffff8116811461068157600080fd5b6000806000806000806000806000806000806101808d8f0312156106be57600080fd5b6106c78d61066a565b9b506106d560208e0161066a565b9a506106e360408e0161066a565b995060608d0135985060808d0135975060a08d0135965061070660c08e0161066a565b955060e08d013594506101008d013593506107246101208e01610686565b92506107336101408e01610686565b91506107426101608e01610686565b90509295989b509295989b509295989b565b60005b8381101561076f578181015183820152602001610757565b50506000910152565b6020815260008251806020840152610797816040850160208701610754565b601f01601f19169190910160400192915050565b6000806000806000806000806000806101408b8d0312156107cb57600080fd5b6107d48b61066a565b995060208b0135985060408b0135975060608b013596506107f760808c0161066a565b955060a08b0135945060c08b0135935061081360e08c01610686565b92506108226101008c01610686565b91506108316101208c01610686565b90509295989b9194979a5092959850565b60008060008060008060008060008060006101608c8e03121561086457600080fd5b61086d8c61066a565b9a5061087b60208d0161066a565b995060408c0135985060608c0135975060808c0135965061089e60a08d0161066a565b955060c08c0135945060e08c013593506108bb6101008d01610686565b92506108ca6101208d01610686565b91506108d96101408d01610686565b90509295989b509295989b9093969950565b600083516108fd818460208801610754565b835190830190610911818360208801610754565b01949350505050565b60006bffffffffffffffffffffffff19808e60601b168352808d60601b1660148401528b60288401528a6048840152896068840152808960601b1660888401525086609c8301528560bc83015264ffffffffff60d81b808660d81b1660dc840152808560d81b1660e1840152506109a060e683018460d81b6001600160d81b0319169052565b5060eb019b9a5050505050505050505050565b60208101600283106109d557634e487b7160e01b600052602160045260246000fd5b91905290565b60006bffffffffffffffffffffffff19808f60601b168352808e60601b166014840152808d60601b1660288401528b603c8401528a605c84015289607c840152808960601b16609c840152508660b08301528560d0830152610a4c60f083018660d81b6001600160d81b0319169052565b610a6560f583018560d81b6001600160d81b0319169052565b610a7e60fa83018460d81b6001600160d81b0319169052565b5060ff019c9b50505050505050505050505056fe61024060405234801561001157600080fd5b506040516120913803806120918339810160408190526100309161035a565b6001600160a01b038b16158061004d57506001600160a01b038a16155b8061005f57506001600160a01b038616155b1561007d5760405163d92e233d60e01b815260040160405180910390fd5b8164ffffffffff168364ffffffffff161015806100a757508064ffffffffff168264ffffffffff16115b156100c55760405163364dd21b60e21b815260040160405180910390fd5b670de0b6b3a7640000851015806100e45750670de0b6b3a76400008410155b15610102576040516358d620b360e01b815260040160405180910390fd5b886000036101225760405162bfc92160e01b815260040160405180910390fd5b6001600160a01b03808c16610160528a81166101805260808a90528c81166101205260c086905260e085905286166101405264ffffffffff8084166101a0528281166101c05281166101e05260a08890528661018057600019610182565b865b6101005260a051610160516101a6916001600160a01b03909116908e9030906102cc565b610160516001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156101e7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061020b9190610413565b60ff166102208160ff1681525050610180516001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa15801561025a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061027e9190610413565b60ff166102005260a0516040519081527f6b9e4c2de0a9dd9c71d8102a31b5460936ff4259a4119802a01823a727b95c729060200160405180910390a150505050505050505050505061043d565b60405181606052826040528360601b602c526f23b872dd000000000000000000000000600c52602060006064601c6000895af13d15600160005114171661031b57637939f4246000526004601cfd5b600060605260405250505050565b80516001600160a01b038116811461034057600080fd5b919050565b805164ffffffffff8116811461034057600080fd5b6000806000806000806000806000806000806101808d8f03121561037d57600080fd5b6103868d610329565b9b5061039460208e01610329565b9a506103a260408e01610329565b995060608d0151985060808d0151975060a08d015196506103c560c08e01610329565b955060e08d015194506101008d015193506103e36101208e01610345565b92506103f26101408e01610345565b91506104016101608e01610345565b90509295989b509295989b509295989b565b60006020828403121561042557600080fd5b815160ff8116811461043657600080fd5b9392505050565b60805160a05160c05160e05161010051610120516101405161016051610180516101a0516101c0516101e0516102005161022051611a6461062d60003960008181610d0d01528181610d5b01526110ba015260008181610ce901528181610d3a015281816110e8015261114201526000818161024701528181610a670152610c0501526000818161046b01528181610a3e01528181610ed8015261151a01526000818161043301528181610a1101528181610ea101526113be0152600081816101ce01528181610596015281816106240152818161068001528181610708015281816108f8015261121d0152600081816103d401528181610791015281816108d301528181610c7a015261142801526000818161033f01528181610646015261094a0152600081816104040152818161072a015281816107b30152818161092001528181610dc601528181611330015261144a01526000818161021201528181610ada01528181610b2c0152610fe3015260008181610284015281816109e501526111920152600081816102ab0152818161056601526109bf0152600081816102f5015281816107580152818161099901528181610b6001528181610f7c0152818161124f0152818161146b01526114ef0152600081816103ad0152818161097301526111090152611a646000f3fe608060405234801561001057600080fd5b50600436106101c45760003560e01c80636c9fa59e116100f9578063c10b935811610097578063c669c07811610071578063c669c0781461049f578063e7e10490146104b2578063f12723e6146104ba578063f7049d78146104da57600080fd5b8063c10b935814610466578063c20ed6711461048d578063c4ae31681461049557600080fd5b8063aaa30c97116100d3578063aaa30c9714610426578063ab0bcc411461042e578063b9ccf21d14610455578063be040fb01461045e57600080fd5b80636c9fa59e146103cf57806373aff5af146103f65780638da5cb5b146103ff57600080fd5b806343d726d6116101665780635249cc52116101405780635249cc5214610376578063597e1fb5146103895780635c975abb146103965780636b71809a146103a857600080fd5b806343d726d614610317578063469048401461033a5780634e9b75b61461036157600080fd5b80631f2f2e1b116101a25780631f2f2e1b1461027f5780631f7d8c4a146102a65780633f9942ff146102cd57806342c22ff1146102f057600080fd5b80631083f761146101c957806319f76c181461020d5780631b23543714610242575b600080fd5b6101f07f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020015b60405180910390f35b6102347f000000000000000000000000000000000000000000000000000000000000000081565b604051908152602001610204565b6102697f000000000000000000000000000000000000000000000000000000000000000081565b60405164ffffffffff9091168152602001610204565b6102347f000000000000000000000000000000000000000000000000000000000000000081565b6102347f000000000000000000000000000000000000000000000000000000000000000081565b6002546102e09062010000900460ff1681565b6040519015158152602001610204565b6102347f000000000000000000000000000000000000000000000000000000000000000081565b61031f6104e2565b60408051938452602084019290925290820152606001610204565b6101f07f000000000000000000000000000000000000000000000000000000000000000081565b61036961082d565b6040516102049190611703565b610234610384366004611846565b610b0d565b6002546102e09060ff1681565b6002546102e090610100900460ff1681565b6102347f000000000000000000000000000000000000000000000000000000000000000081565b6101f07f000000000000000000000000000000000000000000000000000000000000000081565b61023460005481565b6101f07f000000000000000000000000000000000000000000000000000000000000000081565b610234610b56565b6102697f000000000000000000000000000000000000000000000000000000000000000081565b61023460015481565b610234610b89565b6102697f000000000000000000000000000000000000000000000000000000000000000081565b610234610ce5565b61049d610d90565b005b6102346104ad366004611868565b610e72565b61049d6112fa565b6102346104c8366004611846565b60036020526000908152604090205481565b6102e06114c6565b60008060003068929eee149b4bd2126854036105065763ab143c066000526004601cfd5b3068929eee149b4bd212685561051a6114c6565b6105375760405163f1d2165f60e01b815260040160405180910390fd5b6002805460ff19166001908117909155546040516370a0823160e01b815230600482015261060f919061060b907f0000000000000000000000000000000000000000000000000000000000000000906106059084906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906370a0823190602401602060405180830381865afa1580156105dd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106019190611894565b0390565b90611556565b0190565b9250821561066b5761066b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000167f000000000000000000000000000000000000000000000000000000000000000085611584565b6040516370a0823160e01b81523060048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa1580156106cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106f39190611894565b9150811561074f5761074f6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000167f000000000000000000000000000000000000000000000000000000000000000084611584565b60005461077c907f00000000000000000000000000000000000000000000000000000000000000006118c3565b905080156107d8576107d86001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000167f000000000000000000000000000000000000000000000000000000000000000083611584565b60005460408051848152602081019290925281018490527f95b630824ad6e94ddef40548c81e9ea6d2359c3c61fc11f37e1633bb7b1e3e259060600160405180910390a13868929eee149b4bd2126855909192565b6040805161024081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e08101829052610100810182905261012081018290526101408101829052610160810182905261018081018290526101a081018290526101c081018290526101e08101829052610200810182905261022081019190915260408051610240810182526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811682527f0000000000000000000000000000000000000000000000000000000000000000811660208301527f00000000000000000000000000000000000000000000000000000000000000008116928201929092527f000000000000000000000000000000000000000000000000000000000000000090911660608201527f000000000000000000000000000000000000000000000000000000000000000060808201527f000000000000000000000000000000000000000000000000000000000000000060a08201527f000000000000000000000000000000000000000000000000000000000000000060c08201527f000000000000000000000000000000000000000000000000000000000000000060e082015264ffffffffff7f00000000000000000000000000000000000000000000000000000000000000008116610100808401919091527f000000000000000000000000000000000000000000000000000000000000000082166101208401527f000000000000000000000000000000000000000000000000000000000000000090911661014083015260005461016083015260025460ff8082161515610180850152918104821615156101a08401526201000090041615156101c08201526101e08101610ad16114c6565b151581526020017f00000000000000000000000000000000000000000000000000000000000000008152602001610b06610ce5565b9052919050565b6001600160a01b038116600090815260036020526040812054610b50907f00000000000000000000000000000000000000000000000000000000000000006118c3565b92915050565b60008054610b84907f00000000000000000000000000000000000000000000000000000000000000006118c3565b905090565b60003068929eee149b4bd212685403610baa5763ab143c066000526004601cfd5b3068929eee149b4bd212685560025462010000900460ff1615610be0576040516338384cc160e21b815260040160405180910390fd5b60025460ff16610c035760405163f1d2165f60e01b815260040160405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000064ffffffffff164264ffffffffff161015610c52576040516312dbbce560e01b815260040160405180910390fd5b5033600090815260036020526040812080549190558015610ca157610ca16001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163383611584565b60405181815233907f4896181ff8f4543cc00db9fe9b6fb7e6f032b7eb772c72ab1ec1b4d2e03b93699060200160405180910390a23868929eee149b4bd212685590565b60007f000000000000000000000000000000000000000000000000000000000000000060ff167f000000000000000000000000000000000000000000000000000000000000000060ff161115610d8a57610d7f7f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006118d6565b610b8490600a6119d3565b50600090565b3068929eee149b4bd212685403610daf5763ab143c066000526004601cfd5b3068929eee149b4bd2126855336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610e04576040516330cd747160e01b815260040160405180910390fd5b6002805460ff610100808304821615810261ff001990931692909217928390556040517f9077d36bc00859b5c3f320310707208543dd35092cb0a0fe117d0c6a558b148b93610e5c9390049091161515815260200190565b60405180910390a13868929eee149b4bd2126855565b60003068929eee149b4bd212685403610e935763ab143c066000526004601cfd5b3068929eee149b4bd21268557f000000000000000000000000000000000000000000000000000000000000000064ffffffffff164264ffffffffff161080610f0957507f000000000000000000000000000000000000000000000000000000000000000064ffffffffff164264ffffffffff1610155b80610f16575060025460ff165b80610f29575060025462010000900460ff165b80610f3b5750600254610100900460ff165b15610f5957604051630fe219dd60e21b815260040160405180910390fd5b82600003610f7a57604051635b0b4c9160e01b815260040160405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000060005484610fa991906119e2565b1115610fc857604051637858758f60e11b815260040160405180910390fd5b6001600160a01b0382166000908152600360205260409020547f00000000000000000000000000000000000000000000000000000000000000009061100d90856119e2565b111561102c57604051631dc374f160e11b815260040160405180910390fd5b6001600160a01b0382166110535760405163d92e233d60e01b815260040160405180910390fd5b61105c836115ca565b6110795760405163c13a806160e01b815260040160405180910390fd5b611081610ce5565b8361108a610b56565b61109491906118c3565b10156110b35760405163162908e360e11b815260040160405180910390fd5b60006110df7f0000000000000000000000000000000000000000000000000000000000000000856115dd565b9050600061112d7f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006115dd565b9050600061113b8383611556565b90506111677f00000000000000000000000000000000000000000000000000000000000000008261164e565b93508360000361118a57604051635b0b4c9160e01b815260040160405180910390fd5b60006111b6857f0000000000000000000000000000000000000000000000000000000000000000611556565b9050866000808282546111c991906119e2565b90915550506001600160a01b038616600090815260036020526040812080548992906111f69084906119e2565b92505081905550806001600082825461120f91906119e2565b90915550509384019361124d7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163330886116af565b7f0000000000000000000000000000000000000000000000000000000000000000600054036112a0576040517fcd69fa9896c4546b6ceac642f9fc45bf9603651c212d512911d735dc97f99f7290600090a15b60408051888152602081018790526001600160a01b038816917f16481c457cfa97f1508c848b8ce22b67b27711f139806040aeb662abdfc4996b910160405180910390a2505050503868929eee149b4bd212685592915050565b3068929eee149b4bd2126854036113195763ab143c066000526004601cfd5b3068929eee149b4bd2126855336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461136e576040516330cd747160e01b815260040160405180910390fd5b60025460ff161561139257604051634d65bf2960e11b815260040160405180910390fd5b60025462010000900460ff16156113bc576040516338384cc160e21b815260040160405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000064ffffffffff164264ffffffffff161061140a5760405163f1d2165f60e01b815260040160405180910390fd5b6002805462ff000019166201000017905561148f6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000167f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000611584565b6040517f4717c1fcb8954ad4f0da8b5d368d4064a1c750f8639c89dc534ad6070697078290600090a13868929eee149b4bd2126855565b60025460009062010000900460ff16806114e2575060025460ff165b156114ed5750600090565b7f0000000000000000000000000000000000000000000000000000000000000000600054148061154b57507f000000000000000000000000000000000000000000000000000000000000000064ffffffffff164264ffffffffff1610155b15610d8a5750600190565b6000816000190483118202156115745763bac65e5b6000526004601cfd5b50670de0b6b3a764000091020490565b816014528060345263a9059cbb60601b60005260206000604460106000875af13d1560016000511417166115c0576390b8ec186000526004601cfd5b6000603452505050565b60006115d4610ce5565b90911015919050565b80601260ff841610156116165760006115f78460126118d6565b905061160481600a6119d3565b61160e90836119f5565b915050610b50565b60128360ff161115610b5057600061162f6012856118d6565b905061163c81600a6119d3565b6116469083611a0c565b949350505050565b80601260ff8416101561167f5760006116688460126118d6565b905061167581600a6119d3565b61160e9083611a0c565b60128360ff161115610b505760006116986012856118d6565b90506116a581600a6119d3565b61164690836119f5565b60405181606052826040528360601b602c526323b872dd60601b600c52602060006064601c6000895af13d1560016000511417166116f557637939f4246000526004601cfd5b600060605260405250505050565b81516001600160a01b031681526102408101602083015161172f60208401826001600160a01b03169052565b50604083015161174a60408401826001600160a01b03169052565b50606083015161176560608401826001600160a01b03169052565b506080830151608083015260a083015160a083015260c083015160c083015260e083015160e0830152610100808401516117a78285018264ffffffffff169052565b50506101208381015164ffffffffff9081169184019190915261014080850151909116908301526101608084015190830152610180808401511515908301526101a0808401511515908301526101c0808401511515908301526101e080840151151590830152610200808401519083015261022092830151929091019190915290565b80356001600160a01b038116811461184157600080fd5b919050565b60006020828403121561185857600080fd5b6118618261182a565b9392505050565b6000806040838503121561187b57600080fd5b8235915061188b6020840161182a565b90509250929050565b6000602082840312156118a657600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b81810381811115610b5057610b506118ad565b60ff8281168282160390811115610b5057610b506118ad565b600181815b8085111561192a578160001904821115611910576119106118ad565b8085161561191d57918102915b93841c93908002906118f4565b509250929050565b60008261194157506001610b50565b8161194e57506000610b50565b8160018114611964576002811461196e5761198a565b6001915050610b50565b60ff84111561197f5761197f6118ad565b50506001821b610b50565b5060208310610133831016604e8410600b84101617156119ad575081810a610b50565b6119b783836118ef565b80600019048211156119cb576119cb6118ad565b029392505050565b600061186160ff841683611932565b80820180821115610b5057610b506118ad565b8082028115828204841417610b5057610b506118ad565b600082611a2957634e487b7160e01b600052601260045260246000fd5b50049056fea26469706673582212201c7c85d1b88caa01950e94f69fcd266776dcc955e09d9b8cef15d023e88dbfab64736f6c6343000819003361020060405234801561001157600080fd5b50604051611e80380380611e80833981016040819052610030916102c2565b6001600160a01b038a16158061004d57506001600160a01b038616155b8061005f57506001600160a01b038b16155b1561007d5760405163d92e233d60e01b815260040160405180910390fd5b8164ffffffffff168364ffffffffff161015806100a757508064ffffffffff168264ffffffffff16115b156100c55760405163364dd21b60e21b815260040160405180910390fd5b670de0b6b3a7640000851015806100da575088155b806100ed5750670de0b6b3a76400008410155b1561010b576040516358d620b360e01b815260040160405180910390fd5b6001600160a01b03808b166101605260808a90528b81166101205260c086905260e085905286166101405264ffffffffff808416610180528281166101a05281166101c05260a08890528661016257600019610164565b865b6101008181525050610160516001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156101ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101d1919061036b565b60ff166101e052610160516101f1906001600160a01b03168c308b610234565b6040518881527f6b9e4c2de0a9dd9c71d8102a31b5460936ff4259a4119802a01823a727b95c729060200160405180910390a15050505050505050505050610395565b60405181606052826040528360601b602c526f23b872dd000000000000000000000000600c52602060006064601c6000895af13d15600160005114171661028357637939f4246000526004601cfd5b600060605260405250505050565b80516001600160a01b03811681146102a857600080fd5b919050565b805164ffffffffff811681146102a857600080fd5b60008060008060008060008060008060006101608c8e0312156102e457600080fd5b6102ed8c610291565b9a506102fb60208d01610291565b995060408c0151985060608c0151975060808c0151965061031e60a08d01610291565b955060c08c0151945060e08c0151935061033b6101008d016102ad565b925061034a6101208d016102ad565b91506103596101408d016102ad565b90509295989b509295989b9093969950565b60006020828403121561037d57600080fd5b815160ff8116811461038e57600080fd5b9392505050565b60805160a05160c05160e05161010051610120516101405161016051610180516101a0516101c0516101e05161195061053060003960008181610c6a01528181610c9901526110000152600081816101fa015281816109e50152610b840152600081816104f9015281816109bc01528181610e16015261141001526000818161049a0152818161098f01528181610ddf01526112b4015260008181610407015281816107300152818161087201528181610bf9015261131e0152600081816103400152818161069601526108ca015260008181610451015281816106c901528181610752015281816108a001528181610d040152818161122601526113400152600081816101b301528181610a5901528181610aab0152610f5001526000818161024401528181610963015261109a01526000818161027801528181610650015261093d0152600081816102dc015281816106f70152818161091701528181610adf01528181610ee9015281816111470152818161136101526113e501526000818161056c015281816108f1015261103001526119506000f3fe60806040526004361061019c5760003560e01c806373aff5af116100ec578063c20ed6711161008a578063dab8263a11610064578063dab8263a1461055a578063e7e104901461058e578063f12723e6146105a3578063f7049d78146105d057600080fd5b8063c20ed6711461051b578063c4ae316814610530578063c669c0781461054757600080fd5b8063ab0bcc41116100c6578063ab0bcc4114610488578063b9ccf21d146104bc578063be040fb0146104d2578063c10b9358146104e757600080fd5b806373aff5af146104295780638da5cb5b1461043f578063aaa30c971461047357600080fd5b806343d726d6116101595780635249cc52116101335780635249cc521461039c578063597e1fb5146103bc5780635c975abb146103d65780636c9fa59e146103f557600080fd5b806343d726d6146102fe578063469048401461032e5780634e9b75b61461037a57600080fd5b806319f76c18146101a15780631b235437146101e85780631f2f2e1b146102325780631f7d8c4a146102665780633f9942ff1461029a57806342c22ff1146102ca575b600080fd5b3480156101ad57600080fd5b506101d57f000000000000000000000000000000000000000000000000000000000000000081565b6040519081526020015b60405180910390f35b3480156101f457600080fd5b5061021c7f000000000000000000000000000000000000000000000000000000000000000081565b60405164ffffffffff90911681526020016101df565b34801561023e57600080fd5b506101d57f000000000000000000000000000000000000000000000000000000000000000081565b34801561027257600080fd5b506101d57f000000000000000000000000000000000000000000000000000000000000000081565b3480156102a657600080fd5b506002546102ba9062010000900460ff1681565b60405190151581526020016101df565b3480156102d657600080fd5b506101d57f000000000000000000000000000000000000000000000000000000000000000081565b34801561030a57600080fd5b506103136105e5565b604080519384526020840192909252908201526060016101df565b34801561033a57600080fd5b506103627f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016101df565b34801561038657600080fd5b5061038f6107cc565b6040516101df9190611608565b3480156103a857600080fd5b506101d56103b736600461174b565b610a8c565b3480156103c857600080fd5b506002546102ba9060ff1681565b3480156103e257600080fd5b506002546102ba90610100900460ff1681565b34801561040157600080fd5b506103627f000000000000000000000000000000000000000000000000000000000000000081565b34801561043557600080fd5b506101d560005481565b34801561044b57600080fd5b506103627f000000000000000000000000000000000000000000000000000000000000000081565b34801561047f57600080fd5b506101d5610ad5565b34801561049457600080fd5b5061021c7f000000000000000000000000000000000000000000000000000000000000000081565b3480156104c857600080fd5b506101d560015481565b3480156104de57600080fd5b506101d5610b08565b3480156104f357600080fd5b5061021c7f000000000000000000000000000000000000000000000000000000000000000081565b34801561052757600080fd5b506101d5610c64565b34801561053c57600080fd5b50610545610cce565b005b6101d561055536600461176d565b610db0565b34801561056657600080fd5b506101d57f000000000000000000000000000000000000000000000000000000000000000081565b34801561059a57600080fd5b506105456111f0565b3480156105af57600080fd5b506101d56105be36600461174b565b60036020526000908152604090205481565b3480156105dc57600080fd5b506102ba6113bc565b60008060003068929eee149b4bd2126854036106095763ab143c066000526004601cfd5b3068929eee149b4bd212685561061d6113bc565b61063a5760405163f1d2165f60e01b815260040160405180910390fd5b6002805460ff191660019081179091555461067f7f00000000000000000000000000000000000000000000000000000000000000006106794784900390565b9061144c565b61068991906117af565b925082156106bb576106bb7f00000000000000000000000000000000000000000000000000000000000000008461147a565b47915081156106ee576106ee7f00000000000000000000000000000000000000000000000000000000000000008361149a565b60005461071b907f00000000000000000000000000000000000000000000000000000000000000006117c2565b90508015610777576107776001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000167f0000000000000000000000000000000000000000000000000000000000000000836114dd565b60005460408051848152602081019290925281018490527f95b630824ad6e94ddef40548c81e9ea6d2359c3c61fc11f37e1633bb7b1e3e259060600160405180910390a13868929eee149b4bd2126855909192565b6040805161024081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e08101829052610100810182905261012081018290526101408101829052610160810182905261018081018290526101a081018290526101c081018290526101e08101829052610200810182905261022081019190915260408051610240810182526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811682526000602083018190527f00000000000000000000000000000000000000000000000000000000000000008216938301939093527f00000000000000000000000000000000000000000000000000000000000000001660608201527f000000000000000000000000000000000000000000000000000000000000000060808201527f000000000000000000000000000000000000000000000000000000000000000060a08201527f000000000000000000000000000000000000000000000000000000000000000060c08201527f000000000000000000000000000000000000000000000000000000000000000060e082015264ffffffffff7f00000000000000000000000000000000000000000000000000000000000000008116610100808401919091527f000000000000000000000000000000000000000000000000000000000000000082166101208401527f0000000000000000000000000000000000000000000000000000000000000000909116610140830152915461016082015260025460ff8082161515610180840152928104831615156101a083015262010000900490911615156101c08201526101e08101610a506113bc565b151581526020017f00000000000000000000000000000000000000000000000000000000000000008152602001610a85610c64565b9052919050565b6001600160a01b038116600090815260036020526040812054610acf907f00000000000000000000000000000000000000000000000000000000000000006117c2565b92915050565b60008054610b03907f00000000000000000000000000000000000000000000000000000000000000006117c2565b905090565b60003068929eee149b4bd212685403610b295763ab143c066000526004601cfd5b3068929eee149b4bd212685560025462010000900460ff1615610b5f576040516338384cc160e21b815260040160405180910390fd5b60025460ff16610b825760405163f1d2165f60e01b815260040160405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000064ffffffffff164264ffffffffff161015610bd1576040516312dbbce560e01b815260040160405180910390fd5b5033600090815260036020526040812080549190558015610c2057610c206001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001633836114dd565b60405181815233907f4896181ff8f4543cc00db9fe9b6fb7e6f032b7eb772c72ab1ec1b4d2e03b93699060200160405180910390a23868929eee149b4bd212685590565b600060127f000000000000000000000000000000000000000000000000000000000000000060ff161115610cc857610cbd60127f00000000000000000000000000000000000000000000000000000000000000006117d5565b610b0390600a6118d2565b50600090565b3068929eee149b4bd212685403610ced5763ab143c066000526004601cfd5b3068929eee149b4bd2126855336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610d42576040516330cd747160e01b815260040160405180910390fd5b6002805460ff610100808304821615810261ff001990931692909217928390556040517f9077d36bc00859b5c3f320310707208543dd35092cb0a0fe117d0c6a558b148b93610d9a9390049091161515815260200190565b60405180910390a13868929eee149b4bd2126855565b60003068929eee149b4bd212685403610dd15763ab143c066000526004601cfd5b3068929eee149b4bd21268557f000000000000000000000000000000000000000000000000000000000000000064ffffffffff164264ffffffffff161080610e4757507f000000000000000000000000000000000000000000000000000000000000000064ffffffffff164264ffffffffff1610155b80610e54575060025460ff165b80610e665750600254610100900460ff165b80610e79575060025462010000900460ff165b15610e9757604051630fe219dd60e21b815260040160405180910390fd5b821580610ea2575034155b15610ec057604051635b0b4c9160e01b815260040160405180910390fd5b6001600160a01b038216610ee75760405163d92e233d60e01b815260040160405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000060005484610f1691906117af565b1115610f3557604051637858758f60e11b815260040160405180910390fd5b6001600160a01b0382166000908152600360205260409020547f000000000000000000000000000000000000000000000000000000000000000090610f7a90856117af565b1115610f9957604051631dc374f160e11b815260040160405180910390fd5b610fa283611523565b610fbf5760405163c13a806160e01b815260040160405180910390fd5b610fc7610c64565b83610fd0610ad5565b610fda91906117c2565b1015610ff95760405163162908e360e11b815260040160405180910390fd5b60006110257f000000000000000000000000000000000000000000000000000000000000000085611536565b9050600061105460127f0000000000000000000000000000000000000000000000000000000000000000611536565b90506000611062838361144c565b905061106f6012826115a7565b93508360000361109257604051635b0b4c9160e01b815260040160405180910390fd5b60006110be857f000000000000000000000000000000000000000000000000000000000000000061144c565b90508481019450843410156110e65760405163356680b760e01b815260040160405180910390fd5b866000808282546110f791906117af565b90915550506001600160a01b038616600090815260036020526040812080548992906111249084906117af565b92505081905550806001600082825461113d91906117af565b90915550506000547f00000000000000000000000000000000000000000000000000000000000000009003611196576040517fcd69fa9896c4546b6ceac642f9fc45bf9603651c212d512911d735dc97f99f7290600090a15b60408051888152602081018790526001600160a01b038816917f16481c457cfa97f1508c848b8ce22b67b27711f139806040aeb662abdfc4996b910160405180910390a2505050503868929eee149b4bd212685592915050565b3068929eee149b4bd21268540361120f5763ab143c066000526004601cfd5b3068929eee149b4bd2126855336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614611264576040516330cd747160e01b815260040160405180910390fd5b60025460ff161561128857604051634d65bf2960e11b815260040160405180910390fd5b60025462010000900460ff16156112b2576040516338384cc160e21b815260040160405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000064ffffffffff164264ffffffffff16106113005760405163f1d2165f60e01b815260040160405180910390fd5b6002805462ff00001916620100001790556113856001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000167f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006114dd565b6040517f4717c1fcb8954ad4f0da8b5d368d4064a1c750f8639c89dc534ad6070697078290600090a13868929eee149b4bd2126855565b60025460009062010000900460ff16806113d8575060025460ff165b156113e35750600090565b7f0000000000000000000000000000000000000000000000000000000000000000600054148061144157507f000000000000000000000000000000000000000000000000000000000000000064ffffffffff164264ffffffffff1610155b15610cc85750600190565b60008160001904831182021561146a5763bac65e5b6000526004601cfd5b50670de0b6b3a764000091020490565b60003860003884865af16114965763b12d13eb6000526004601cfd5b5050565b804710156114b05763b12d13eb6000526004601cfd5b6000386000388486620186a0f161149657816000526073600b5360ff6020536016600b82f0611496573838fd5b816014528060345263a9059cbb60601b60005260206000604460106000875af13d156001600051141716611519576390b8ec186000526004601cfd5b6000603452505050565b600061152d610c64565b90911015919050565b80601260ff8416101561156f5760006115508460126117d5565b905061155d81600a6118d2565b61156790836118e1565b915050610acf565b60128360ff161115610acf5760006115886012856117d5565b905061159581600a6118d2565b61159f90836118f8565b949350505050565b80601260ff841610156115d85760006115c18460126117d5565b90506115ce81600a6118d2565b61156790836118f8565b60128360ff161115610acf5760006115f16012856117d5565b90506115fe81600a6118d2565b61159f90836118e1565b81516001600160a01b031681526102408101602083015161163460208401826001600160a01b03169052565b50604083015161164f60408401826001600160a01b03169052565b50606083015161166a60608401826001600160a01b03169052565b506080830151608083015260a083015160a083015260c083015160c083015260e083015160e0830152610100808401516116ac8285018264ffffffffff169052565b50506101208381015164ffffffffff9081169184019190915261014080850151909116908301526101608084015190830152610180808401511515908301526101a0808401511515908301526101c0808401511515908301526101e080840151151590830152610200808401519083015261022092830151929091019190915290565b80356001600160a01b038116811461174657600080fd5b919050565b60006020828403121561175d57600080fd5b6117668261172f565b9392505050565b6000806040838503121561178057600080fd5b823591506117906020840161172f565b90509250929050565b634e487b7160e01b600052601160045260246000fd5b80820180821115610acf57610acf611799565b81810381811115610acf57610acf611799565b60ff8281168282160390811115610acf57610acf611799565b600181815b8085111561182957816000190482111561180f5761180f611799565b8085161561181c57918102915b93841c93908002906117f3565b509250929050565b60008261184057506001610acf565b8161184d57506000610acf565b8160018114611863576002811461186d57611889565b6001915050610acf565b60ff84111561187e5761187e611799565b50506001821b610acf565b5060208310610133831016604e8410600b84101617156118ac575081810a610acf565b6118b683836117ee565b80600019048211156118ca576118ca611799565b029392505050565b600061176660ff841683611831565b8082028115828204841417610acf57610acf611799565b60008261191557634e487b7160e01b600052601260045260246000fd5b50049056fea264697066735822122008b029029afc8fa25291c8a7ecfa26bb058a7a34ba81e385c9efb58b78a12ee564736f6c63430008190033a2646970667358221220d5f2962c01a30e65cd07fe350d8abce3c36e06af246195a8149155a41cc2d9f964736f6c63430008190033

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106100625760003560e01c806312d601361461006757806337b9ac48146100905780633c6ddd3c146100bb5780635bd9f33b146100ce5780639882b72c146100e1578063e2baa3cc146100f4575b600080fd5b61007a61007536600461069b565b610107565b6040516100879190610778565b60405180910390f35b6100a361009e3660046107ab565b610208565b6040516001600160a01b039091168152602001610087565b6100a36100c936600461069b565b6102e1565b61007a6100dc366004610842565b61033e565b6100a36100ef366004610842565b610435565b6100a3610102366004610842565b61048f565b606060006040518060200161011b90610650565b6020820181038252601f19601f820116604052509050808e8e8e8e8e8e8e8e8e8e8e8e6040516020016101c89c9b9a999897969594939291906001600160a01b039c8d1681529a8c1660208c0152988b1660408b015260608a0197909752608089019590955260a0880193909352961660c086015260e085019590955261010084019490945264ffffffffff93841661012084015283166101408301529091166101608201526101800190565b60408051601f19818403018152908290526101e692916020016108eb565b6040516020818303038152906040529150509c9b505050505050505050505050565b600080338c8c8c8c8c8c8c8c8c8c6040516020016102309b9a9998979695949392919061091a565b60405160208183030381529060405280519060200120905061026761025e338e8e8e8e8e8e8e8e8e8e61033e565b82906000610563565b91506001600160a01b038216610290576040516337200b1d60e21b815260040160405180910390fd5b816001600160a01b03167f7c3072652d5407e4dcbe90ac1760509311e2511e531f5caf91859f3bc741670860006040516102ca91906109b3565b60405180910390a2509a9950505050505050505050565b6000808d8d8d8d8d8d8d8d8d8d8d8d60405160200161030b9c9b9a999897969594939291906109db565b60405160208183030381529060405280519060200120905061032c816105e4565b9e9d5050505050505050505050505050565b60606000604051806020016103529061065d565b6020820181038252601f19601f820116604052509050808d8d8d8d8d8d8d8d8d8d8d6040516020016103f69b9a999897969594939291906001600160a01b039b8c168152998b1660208b015260408a0198909852606089019690965260808801949094529190961660a086015260c085019590955260e084019490945264ffffffffff93841661010084015283166101208301529091166101408201526101600190565b60408051601f198184030181529082905261041492916020016108eb565b6040516020818303038152906040529150509b9a5050505050505050505050565b6000808c8c8c8c8c8c8c8c8c8c8c60405160200161045d9b9a9998979695949392919061091a565b60405160208183030381529060405280519060200120905061047e816105e4565b9d9c50505050505050505050505050565b600080338d8d8d8d8d8d8d8d8d8d8d6040516020016104b99c9b9a999897969594939291906109db565b6040516020818303038152906040528051906020012090506104e861025e338f8f8f8f8f8f8f8f8f8f8f610107565b91506001600160a01b038216610511576040516337200b1d60e21b815260040160405180910390fd5b816001600160a01b03167f7c3072652d5407e4dcbe90ac1760509311e2511e531f5caf91859f3bc7416708600160405161054b91906109b3565b60405180910390a2509b9a5050505050505050505050565b60006f67363d3d37363d34f03d5260086018f3600052836010806000f5806105935763301164256000526004601cfd5b8060145261d69460005260016034536017601e20915060008085516020870186855af16105c8576319b991a86000526004601cfd5b50803b6105dd576319b991a86000526004601cfd5b9392505050565b60006105f082306105f6565b92915050565b60006040518260005260ff600b53836020527f21c35dbe1b344a2488cf3321d6ce542f8e9f305544ff09e4993a62319a497c1f6040526055600b20601452806040525061d694600052600160345350506017601e20919050565b61209180610a9383390190565b611e8080612b2483390190565b80356001600160a01b038116811461068157600080fd5b919050565b803564ffffffffff8116811461068157600080fd5b6000806000806000806000806000806000806101808d8f0312156106be57600080fd5b6106c78d61066a565b9b506106d560208e0161066a565b9a506106e360408e0161066a565b995060608d0135985060808d0135975060a08d0135965061070660c08e0161066a565b955060e08d013594506101008d013593506107246101208e01610686565b92506107336101408e01610686565b91506107426101608e01610686565b90509295989b509295989b509295989b565b60005b8381101561076f578181015183820152602001610757565b50506000910152565b6020815260008251806020840152610797816040850160208701610754565b601f01601f19169190910160400192915050565b6000806000806000806000806000806101408b8d0312156107cb57600080fd5b6107d48b61066a565b995060208b0135985060408b0135975060608b013596506107f760808c0161066a565b955060a08b0135945060c08b0135935061081360e08c01610686565b92506108226101008c01610686565b91506108316101208c01610686565b90509295989b9194979a5092959850565b60008060008060008060008060008060006101608c8e03121561086457600080fd5b61086d8c61066a565b9a5061087b60208d0161066a565b995060408c0135985060608c0135975060808c0135965061089e60a08d0161066a565b955060c08c0135945060e08c013593506108bb6101008d01610686565b92506108ca6101208d01610686565b91506108d96101408d01610686565b90509295989b509295989b9093969950565b600083516108fd818460208801610754565b835190830190610911818360208801610754565b01949350505050565b60006bffffffffffffffffffffffff19808e60601b168352808d60601b1660148401528b60288401528a6048840152896068840152808960601b1660888401525086609c8301528560bc83015264ffffffffff60d81b808660d81b1660dc840152808560d81b1660e1840152506109a060e683018460d81b6001600160d81b0319169052565b5060eb019b9a5050505050505050505050565b60208101600283106109d557634e487b7160e01b600052602160045260246000fd5b91905290565b60006bffffffffffffffffffffffff19808f60601b168352808e60601b166014840152808d60601b1660288401528b603c8401528a605c84015289607c840152808960601b16609c840152508660b08301528560d0830152610a4c60f083018660d81b6001600160d81b0319169052565b610a6560f583018560d81b6001600160d81b0319169052565b610a7e60fa83018460d81b6001600160d81b0319169052565b5060ff019c9b50505050505050505050505056fe61024060405234801561001157600080fd5b506040516120913803806120918339810160408190526100309161035a565b6001600160a01b038b16158061004d57506001600160a01b038a16155b8061005f57506001600160a01b038616155b1561007d5760405163d92e233d60e01b815260040160405180910390fd5b8164ffffffffff168364ffffffffff161015806100a757508064ffffffffff168264ffffffffff16115b156100c55760405163364dd21b60e21b815260040160405180910390fd5b670de0b6b3a7640000851015806100e45750670de0b6b3a76400008410155b15610102576040516358d620b360e01b815260040160405180910390fd5b886000036101225760405162bfc92160e01b815260040160405180910390fd5b6001600160a01b03808c16610160528a81166101805260808a90528c81166101205260c086905260e085905286166101405264ffffffffff8084166101a0528281166101c05281166101e05260a08890528661018057600019610182565b865b6101005260a051610160516101a6916001600160a01b03909116908e9030906102cc565b610160516001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156101e7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061020b9190610413565b60ff166102208160ff1681525050610180516001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa15801561025a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061027e9190610413565b60ff166102005260a0516040519081527f6b9e4c2de0a9dd9c71d8102a31b5460936ff4259a4119802a01823a727b95c729060200160405180910390a150505050505050505050505061043d565b60405181606052826040528360601b602c526f23b872dd000000000000000000000000600c52602060006064601c6000895af13d15600160005114171661031b57637939f4246000526004601cfd5b600060605260405250505050565b80516001600160a01b038116811461034057600080fd5b919050565b805164ffffffffff8116811461034057600080fd5b6000806000806000806000806000806000806101808d8f03121561037d57600080fd5b6103868d610329565b9b5061039460208e01610329565b9a506103a260408e01610329565b995060608d0151985060808d0151975060a08d015196506103c560c08e01610329565b955060e08d015194506101008d015193506103e36101208e01610345565b92506103f26101408e01610345565b91506104016101608e01610345565b90509295989b509295989b509295989b565b60006020828403121561042557600080fd5b815160ff8116811461043657600080fd5b9392505050565b60805160a05160c05160e05161010051610120516101405161016051610180516101a0516101c0516101e0516102005161022051611a6461062d60003960008181610d0d01528181610d5b01526110ba015260008181610ce901528181610d3a015281816110e8015261114201526000818161024701528181610a670152610c0501526000818161046b01528181610a3e01528181610ed8015261151a01526000818161043301528181610a1101528181610ea101526113be0152600081816101ce01528181610596015281816106240152818161068001528181610708015281816108f8015261121d0152600081816103d401528181610791015281816108d301528181610c7a015261142801526000818161033f01528181610646015261094a0152600081816104040152818161072a015281816107b30152818161092001528181610dc601528181611330015261144a01526000818161021201528181610ada01528181610b2c0152610fe3015260008181610284015281816109e501526111920152600081816102ab0152818161056601526109bf0152600081816102f5015281816107580152818161099901528181610b6001528181610f7c0152818161124f0152818161146b01526114ef0152600081816103ad0152818161097301526111090152611a646000f3fe608060405234801561001057600080fd5b50600436106101c45760003560e01c80636c9fa59e116100f9578063c10b935811610097578063c669c07811610071578063c669c0781461049f578063e7e10490146104b2578063f12723e6146104ba578063f7049d78146104da57600080fd5b8063c10b935814610466578063c20ed6711461048d578063c4ae31681461049557600080fd5b8063aaa30c97116100d3578063aaa30c9714610426578063ab0bcc411461042e578063b9ccf21d14610455578063be040fb01461045e57600080fd5b80636c9fa59e146103cf57806373aff5af146103f65780638da5cb5b146103ff57600080fd5b806343d726d6116101665780635249cc52116101405780635249cc5214610376578063597e1fb5146103895780635c975abb146103965780636b71809a146103a857600080fd5b806343d726d614610317578063469048401461033a5780634e9b75b61461036157600080fd5b80631f2f2e1b116101a25780631f2f2e1b1461027f5780631f7d8c4a146102a65780633f9942ff146102cd57806342c22ff1146102f057600080fd5b80631083f761146101c957806319f76c181461020d5780631b23543714610242575b600080fd5b6101f07f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020015b60405180910390f35b6102347f000000000000000000000000000000000000000000000000000000000000000081565b604051908152602001610204565b6102697f000000000000000000000000000000000000000000000000000000000000000081565b60405164ffffffffff9091168152602001610204565b6102347f000000000000000000000000000000000000000000000000000000000000000081565b6102347f000000000000000000000000000000000000000000000000000000000000000081565b6002546102e09062010000900460ff1681565b6040519015158152602001610204565b6102347f000000000000000000000000000000000000000000000000000000000000000081565b61031f6104e2565b60408051938452602084019290925290820152606001610204565b6101f07f000000000000000000000000000000000000000000000000000000000000000081565b61036961082d565b6040516102049190611703565b610234610384366004611846565b610b0d565b6002546102e09060ff1681565b6002546102e090610100900460ff1681565b6102347f000000000000000000000000000000000000000000000000000000000000000081565b6101f07f000000000000000000000000000000000000000000000000000000000000000081565b61023460005481565b6101f07f000000000000000000000000000000000000000000000000000000000000000081565b610234610b56565b6102697f000000000000000000000000000000000000000000000000000000000000000081565b61023460015481565b610234610b89565b6102697f000000000000000000000000000000000000000000000000000000000000000081565b610234610ce5565b61049d610d90565b005b6102346104ad366004611868565b610e72565b61049d6112fa565b6102346104c8366004611846565b60036020526000908152604090205481565b6102e06114c6565b60008060003068929eee149b4bd2126854036105065763ab143c066000526004601cfd5b3068929eee149b4bd212685561051a6114c6565b6105375760405163f1d2165f60e01b815260040160405180910390fd5b6002805460ff19166001908117909155546040516370a0823160e01b815230600482015261060f919061060b907f0000000000000000000000000000000000000000000000000000000000000000906106059084906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906370a0823190602401602060405180830381865afa1580156105dd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106019190611894565b0390565b90611556565b0190565b9250821561066b5761066b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000167f000000000000000000000000000000000000000000000000000000000000000085611584565b6040516370a0823160e01b81523060048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa1580156106cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106f39190611894565b9150811561074f5761074f6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000167f000000000000000000000000000000000000000000000000000000000000000084611584565b60005461077c907f00000000000000000000000000000000000000000000000000000000000000006118c3565b905080156107d8576107d86001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000167f000000000000000000000000000000000000000000000000000000000000000083611584565b60005460408051848152602081019290925281018490527f95b630824ad6e94ddef40548c81e9ea6d2359c3c61fc11f37e1633bb7b1e3e259060600160405180910390a13868929eee149b4bd2126855909192565b6040805161024081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e08101829052610100810182905261012081018290526101408101829052610160810182905261018081018290526101a081018290526101c081018290526101e08101829052610200810182905261022081019190915260408051610240810182526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811682527f0000000000000000000000000000000000000000000000000000000000000000811660208301527f00000000000000000000000000000000000000000000000000000000000000008116928201929092527f000000000000000000000000000000000000000000000000000000000000000090911660608201527f000000000000000000000000000000000000000000000000000000000000000060808201527f000000000000000000000000000000000000000000000000000000000000000060a08201527f000000000000000000000000000000000000000000000000000000000000000060c08201527f000000000000000000000000000000000000000000000000000000000000000060e082015264ffffffffff7f00000000000000000000000000000000000000000000000000000000000000008116610100808401919091527f000000000000000000000000000000000000000000000000000000000000000082166101208401527f000000000000000000000000000000000000000000000000000000000000000090911661014083015260005461016083015260025460ff8082161515610180850152918104821615156101a08401526201000090041615156101c08201526101e08101610ad16114c6565b151581526020017f00000000000000000000000000000000000000000000000000000000000000008152602001610b06610ce5565b9052919050565b6001600160a01b038116600090815260036020526040812054610b50907f00000000000000000000000000000000000000000000000000000000000000006118c3565b92915050565b60008054610b84907f00000000000000000000000000000000000000000000000000000000000000006118c3565b905090565b60003068929eee149b4bd212685403610baa5763ab143c066000526004601cfd5b3068929eee149b4bd212685560025462010000900460ff1615610be0576040516338384cc160e21b815260040160405180910390fd5b60025460ff16610c035760405163f1d2165f60e01b815260040160405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000064ffffffffff164264ffffffffff161015610c52576040516312dbbce560e01b815260040160405180910390fd5b5033600090815260036020526040812080549190558015610ca157610ca16001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163383611584565b60405181815233907f4896181ff8f4543cc00db9fe9b6fb7e6f032b7eb772c72ab1ec1b4d2e03b93699060200160405180910390a23868929eee149b4bd212685590565b60007f000000000000000000000000000000000000000000000000000000000000000060ff167f000000000000000000000000000000000000000000000000000000000000000060ff161115610d8a57610d7f7f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006118d6565b610b8490600a6119d3565b50600090565b3068929eee149b4bd212685403610daf5763ab143c066000526004601cfd5b3068929eee149b4bd2126855336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610e04576040516330cd747160e01b815260040160405180910390fd5b6002805460ff610100808304821615810261ff001990931692909217928390556040517f9077d36bc00859b5c3f320310707208543dd35092cb0a0fe117d0c6a558b148b93610e5c9390049091161515815260200190565b60405180910390a13868929eee149b4bd2126855565b60003068929eee149b4bd212685403610e935763ab143c066000526004601cfd5b3068929eee149b4bd21268557f000000000000000000000000000000000000000000000000000000000000000064ffffffffff164264ffffffffff161080610f0957507f000000000000000000000000000000000000000000000000000000000000000064ffffffffff164264ffffffffff1610155b80610f16575060025460ff165b80610f29575060025462010000900460ff165b80610f3b5750600254610100900460ff165b15610f5957604051630fe219dd60e21b815260040160405180910390fd5b82600003610f7a57604051635b0b4c9160e01b815260040160405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000060005484610fa991906119e2565b1115610fc857604051637858758f60e11b815260040160405180910390fd5b6001600160a01b0382166000908152600360205260409020547f00000000000000000000000000000000000000000000000000000000000000009061100d90856119e2565b111561102c57604051631dc374f160e11b815260040160405180910390fd5b6001600160a01b0382166110535760405163d92e233d60e01b815260040160405180910390fd5b61105c836115ca565b6110795760405163c13a806160e01b815260040160405180910390fd5b611081610ce5565b8361108a610b56565b61109491906118c3565b10156110b35760405163162908e360e11b815260040160405180910390fd5b60006110df7f0000000000000000000000000000000000000000000000000000000000000000856115dd565b9050600061112d7f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006115dd565b9050600061113b8383611556565b90506111677f00000000000000000000000000000000000000000000000000000000000000008261164e565b93508360000361118a57604051635b0b4c9160e01b815260040160405180910390fd5b60006111b6857f0000000000000000000000000000000000000000000000000000000000000000611556565b9050866000808282546111c991906119e2565b90915550506001600160a01b038616600090815260036020526040812080548992906111f69084906119e2565b92505081905550806001600082825461120f91906119e2565b90915550509384019361124d7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163330886116af565b7f0000000000000000000000000000000000000000000000000000000000000000600054036112a0576040517fcd69fa9896c4546b6ceac642f9fc45bf9603651c212d512911d735dc97f99f7290600090a15b60408051888152602081018790526001600160a01b038816917f16481c457cfa97f1508c848b8ce22b67b27711f139806040aeb662abdfc4996b910160405180910390a2505050503868929eee149b4bd212685592915050565b3068929eee149b4bd2126854036113195763ab143c066000526004601cfd5b3068929eee149b4bd2126855336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461136e576040516330cd747160e01b815260040160405180910390fd5b60025460ff161561139257604051634d65bf2960e11b815260040160405180910390fd5b60025462010000900460ff16156113bc576040516338384cc160e21b815260040160405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000064ffffffffff164264ffffffffff161061140a5760405163f1d2165f60e01b815260040160405180910390fd5b6002805462ff000019166201000017905561148f6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000167f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000611584565b6040517f4717c1fcb8954ad4f0da8b5d368d4064a1c750f8639c89dc534ad6070697078290600090a13868929eee149b4bd2126855565b60025460009062010000900460ff16806114e2575060025460ff165b156114ed5750600090565b7f0000000000000000000000000000000000000000000000000000000000000000600054148061154b57507f000000000000000000000000000000000000000000000000000000000000000064ffffffffff164264ffffffffff1610155b15610d8a5750600190565b6000816000190483118202156115745763bac65e5b6000526004601cfd5b50670de0b6b3a764000091020490565b816014528060345263a9059cbb60601b60005260206000604460106000875af13d1560016000511417166115c0576390b8ec186000526004601cfd5b6000603452505050565b60006115d4610ce5565b90911015919050565b80601260ff841610156116165760006115f78460126118d6565b905061160481600a6119d3565b61160e90836119f5565b915050610b50565b60128360ff161115610b5057600061162f6012856118d6565b905061163c81600a6119d3565b6116469083611a0c565b949350505050565b80601260ff8416101561167f5760006116688460126118d6565b905061167581600a6119d3565b61160e9083611a0c565b60128360ff161115610b505760006116986012856118d6565b90506116a581600a6119d3565b61164690836119f5565b60405181606052826040528360601b602c526323b872dd60601b600c52602060006064601c6000895af13d1560016000511417166116f557637939f4246000526004601cfd5b600060605260405250505050565b81516001600160a01b031681526102408101602083015161172f60208401826001600160a01b03169052565b50604083015161174a60408401826001600160a01b03169052565b50606083015161176560608401826001600160a01b03169052565b506080830151608083015260a083015160a083015260c083015160c083015260e083015160e0830152610100808401516117a78285018264ffffffffff169052565b50506101208381015164ffffffffff9081169184019190915261014080850151909116908301526101608084015190830152610180808401511515908301526101a0808401511515908301526101c0808401511515908301526101e080840151151590830152610200808401519083015261022092830151929091019190915290565b80356001600160a01b038116811461184157600080fd5b919050565b60006020828403121561185857600080fd5b6118618261182a565b9392505050565b6000806040838503121561187b57600080fd5b8235915061188b6020840161182a565b90509250929050565b6000602082840312156118a657600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b81810381811115610b5057610b506118ad565b60ff8281168282160390811115610b5057610b506118ad565b600181815b8085111561192a578160001904821115611910576119106118ad565b8085161561191d57918102915b93841c93908002906118f4565b509250929050565b60008261194157506001610b50565b8161194e57506000610b50565b8160018114611964576002811461196e5761198a565b6001915050610b50565b60ff84111561197f5761197f6118ad565b50506001821b610b50565b5060208310610133831016604e8410600b84101617156119ad575081810a610b50565b6119b783836118ef565b80600019048211156119cb576119cb6118ad565b029392505050565b600061186160ff841683611932565b80820180821115610b5057610b506118ad565b8082028115828204841417610b5057610b506118ad565b600082611a2957634e487b7160e01b600052601260045260246000fd5b50049056fea26469706673582212201c7c85d1b88caa01950e94f69fcd266776dcc955e09d9b8cef15d023e88dbfab64736f6c6343000819003361020060405234801561001157600080fd5b50604051611e80380380611e80833981016040819052610030916102c2565b6001600160a01b038a16158061004d57506001600160a01b038616155b8061005f57506001600160a01b038b16155b1561007d5760405163d92e233d60e01b815260040160405180910390fd5b8164ffffffffff168364ffffffffff161015806100a757508064ffffffffff168264ffffffffff16115b156100c55760405163364dd21b60e21b815260040160405180910390fd5b670de0b6b3a7640000851015806100da575088155b806100ed5750670de0b6b3a76400008410155b1561010b576040516358d620b360e01b815260040160405180910390fd5b6001600160a01b03808b166101605260808a90528b81166101205260c086905260e085905286166101405264ffffffffff808416610180528281166101a05281166101c05260a08890528661016257600019610164565b865b6101008181525050610160516001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156101ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101d1919061036b565b60ff166101e052610160516101f1906001600160a01b03168c308b610234565b6040518881527f6b9e4c2de0a9dd9c71d8102a31b5460936ff4259a4119802a01823a727b95c729060200160405180910390a15050505050505050505050610395565b60405181606052826040528360601b602c526f23b872dd000000000000000000000000600c52602060006064601c6000895af13d15600160005114171661028357637939f4246000526004601cfd5b600060605260405250505050565b80516001600160a01b03811681146102a857600080fd5b919050565b805164ffffffffff811681146102a857600080fd5b60008060008060008060008060008060006101608c8e0312156102e457600080fd5b6102ed8c610291565b9a506102fb60208d01610291565b995060408c0151985060608c0151975060808c0151965061031e60a08d01610291565b955060c08c0151945060e08c0151935061033b6101008d016102ad565b925061034a6101208d016102ad565b91506103596101408d016102ad565b90509295989b509295989b9093969950565b60006020828403121561037d57600080fd5b815160ff8116811461038e57600080fd5b9392505050565b60805160a05160c05160e05161010051610120516101405161016051610180516101a0516101c0516101e05161195061053060003960008181610c6a01528181610c9901526110000152600081816101fa015281816109e50152610b840152600081816104f9015281816109bc01528181610e16015261141001526000818161049a0152818161098f01528181610ddf01526112b4015260008181610407015281816107300152818161087201528181610bf9015261131e0152600081816103400152818161069601526108ca015260008181610451015281816106c901528181610752015281816108a001528181610d040152818161122601526113400152600081816101b301528181610a5901528181610aab0152610f5001526000818161024401528181610963015261109a01526000818161027801528181610650015261093d0152600081816102dc015281816106f70152818161091701528181610adf01528181610ee9015281816111470152818161136101526113e501526000818161056c015281816108f1015261103001526119506000f3fe60806040526004361061019c5760003560e01c806373aff5af116100ec578063c20ed6711161008a578063dab8263a11610064578063dab8263a1461055a578063e7e104901461058e578063f12723e6146105a3578063f7049d78146105d057600080fd5b8063c20ed6711461051b578063c4ae316814610530578063c669c0781461054757600080fd5b8063ab0bcc41116100c6578063ab0bcc4114610488578063b9ccf21d146104bc578063be040fb0146104d2578063c10b9358146104e757600080fd5b806373aff5af146104295780638da5cb5b1461043f578063aaa30c971461047357600080fd5b806343d726d6116101595780635249cc52116101335780635249cc521461039c578063597e1fb5146103bc5780635c975abb146103d65780636c9fa59e146103f557600080fd5b806343d726d6146102fe578063469048401461032e5780634e9b75b61461037a57600080fd5b806319f76c18146101a15780631b235437146101e85780631f2f2e1b146102325780631f7d8c4a146102665780633f9942ff1461029a57806342c22ff1146102ca575b600080fd5b3480156101ad57600080fd5b506101d57f000000000000000000000000000000000000000000000000000000000000000081565b6040519081526020015b60405180910390f35b3480156101f457600080fd5b5061021c7f000000000000000000000000000000000000000000000000000000000000000081565b60405164ffffffffff90911681526020016101df565b34801561023e57600080fd5b506101d57f000000000000000000000000000000000000000000000000000000000000000081565b34801561027257600080fd5b506101d57f000000000000000000000000000000000000000000000000000000000000000081565b3480156102a657600080fd5b506002546102ba9062010000900460ff1681565b60405190151581526020016101df565b3480156102d657600080fd5b506101d57f000000000000000000000000000000000000000000000000000000000000000081565b34801561030a57600080fd5b506103136105e5565b604080519384526020840192909252908201526060016101df565b34801561033a57600080fd5b506103627f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016101df565b34801561038657600080fd5b5061038f6107cc565b6040516101df9190611608565b3480156103a857600080fd5b506101d56103b736600461174b565b610a8c565b3480156103c857600080fd5b506002546102ba9060ff1681565b3480156103e257600080fd5b506002546102ba90610100900460ff1681565b34801561040157600080fd5b506103627f000000000000000000000000000000000000000000000000000000000000000081565b34801561043557600080fd5b506101d560005481565b34801561044b57600080fd5b506103627f000000000000000000000000000000000000000000000000000000000000000081565b34801561047f57600080fd5b506101d5610ad5565b34801561049457600080fd5b5061021c7f000000000000000000000000000000000000000000000000000000000000000081565b3480156104c857600080fd5b506101d560015481565b3480156104de57600080fd5b506101d5610b08565b3480156104f357600080fd5b5061021c7f000000000000000000000000000000000000000000000000000000000000000081565b34801561052757600080fd5b506101d5610c64565b34801561053c57600080fd5b50610545610cce565b005b6101d561055536600461176d565b610db0565b34801561056657600080fd5b506101d57f000000000000000000000000000000000000000000000000000000000000000081565b34801561059a57600080fd5b506105456111f0565b3480156105af57600080fd5b506101d56105be36600461174b565b60036020526000908152604090205481565b3480156105dc57600080fd5b506102ba6113bc565b60008060003068929eee149b4bd2126854036106095763ab143c066000526004601cfd5b3068929eee149b4bd212685561061d6113bc565b61063a5760405163f1d2165f60e01b815260040160405180910390fd5b6002805460ff191660019081179091555461067f7f00000000000000000000000000000000000000000000000000000000000000006106794784900390565b9061144c565b61068991906117af565b925082156106bb576106bb7f00000000000000000000000000000000000000000000000000000000000000008461147a565b47915081156106ee576106ee7f00000000000000000000000000000000000000000000000000000000000000008361149a565b60005461071b907f00000000000000000000000000000000000000000000000000000000000000006117c2565b90508015610777576107776001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000167f0000000000000000000000000000000000000000000000000000000000000000836114dd565b60005460408051848152602081019290925281018490527f95b630824ad6e94ddef40548c81e9ea6d2359c3c61fc11f37e1633bb7b1e3e259060600160405180910390a13868929eee149b4bd2126855909192565b6040805161024081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e08101829052610100810182905261012081018290526101408101829052610160810182905261018081018290526101a081018290526101c081018290526101e08101829052610200810182905261022081019190915260408051610240810182526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811682526000602083018190527f00000000000000000000000000000000000000000000000000000000000000008216938301939093527f00000000000000000000000000000000000000000000000000000000000000001660608201527f000000000000000000000000000000000000000000000000000000000000000060808201527f000000000000000000000000000000000000000000000000000000000000000060a08201527f000000000000000000000000000000000000000000000000000000000000000060c08201527f000000000000000000000000000000000000000000000000000000000000000060e082015264ffffffffff7f00000000000000000000000000000000000000000000000000000000000000008116610100808401919091527f000000000000000000000000000000000000000000000000000000000000000082166101208401527f0000000000000000000000000000000000000000000000000000000000000000909116610140830152915461016082015260025460ff8082161515610180840152928104831615156101a083015262010000900490911615156101c08201526101e08101610a506113bc565b151581526020017f00000000000000000000000000000000000000000000000000000000000000008152602001610a85610c64565b9052919050565b6001600160a01b038116600090815260036020526040812054610acf907f00000000000000000000000000000000000000000000000000000000000000006117c2565b92915050565b60008054610b03907f00000000000000000000000000000000000000000000000000000000000000006117c2565b905090565b60003068929eee149b4bd212685403610b295763ab143c066000526004601cfd5b3068929eee149b4bd212685560025462010000900460ff1615610b5f576040516338384cc160e21b815260040160405180910390fd5b60025460ff16610b825760405163f1d2165f60e01b815260040160405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000064ffffffffff164264ffffffffff161015610bd1576040516312dbbce560e01b815260040160405180910390fd5b5033600090815260036020526040812080549190558015610c2057610c206001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001633836114dd565b60405181815233907f4896181ff8f4543cc00db9fe9b6fb7e6f032b7eb772c72ab1ec1b4d2e03b93699060200160405180910390a23868929eee149b4bd212685590565b600060127f000000000000000000000000000000000000000000000000000000000000000060ff161115610cc857610cbd60127f00000000000000000000000000000000000000000000000000000000000000006117d5565b610b0390600a6118d2565b50600090565b3068929eee149b4bd212685403610ced5763ab143c066000526004601cfd5b3068929eee149b4bd2126855336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610d42576040516330cd747160e01b815260040160405180910390fd5b6002805460ff610100808304821615810261ff001990931692909217928390556040517f9077d36bc00859b5c3f320310707208543dd35092cb0a0fe117d0c6a558b148b93610d9a9390049091161515815260200190565b60405180910390a13868929eee149b4bd2126855565b60003068929eee149b4bd212685403610dd15763ab143c066000526004601cfd5b3068929eee149b4bd21268557f000000000000000000000000000000000000000000000000000000000000000064ffffffffff164264ffffffffff161080610e4757507f000000000000000000000000000000000000000000000000000000000000000064ffffffffff164264ffffffffff1610155b80610e54575060025460ff165b80610e665750600254610100900460ff165b80610e79575060025462010000900460ff165b15610e9757604051630fe219dd60e21b815260040160405180910390fd5b821580610ea2575034155b15610ec057604051635b0b4c9160e01b815260040160405180910390fd5b6001600160a01b038216610ee75760405163d92e233d60e01b815260040160405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000060005484610f1691906117af565b1115610f3557604051637858758f60e11b815260040160405180910390fd5b6001600160a01b0382166000908152600360205260409020547f000000000000000000000000000000000000000000000000000000000000000090610f7a90856117af565b1115610f9957604051631dc374f160e11b815260040160405180910390fd5b610fa283611523565b610fbf5760405163c13a806160e01b815260040160405180910390fd5b610fc7610c64565b83610fd0610ad5565b610fda91906117c2565b1015610ff95760405163162908e360e11b815260040160405180910390fd5b60006110257f000000000000000000000000000000000000000000000000000000000000000085611536565b9050600061105460127f0000000000000000000000000000000000000000000000000000000000000000611536565b90506000611062838361144c565b905061106f6012826115a7565b93508360000361109257604051635b0b4c9160e01b815260040160405180910390fd5b60006110be857f000000000000000000000000000000000000000000000000000000000000000061144c565b90508481019450843410156110e65760405163356680b760e01b815260040160405180910390fd5b866000808282546110f791906117af565b90915550506001600160a01b038616600090815260036020526040812080548992906111249084906117af565b92505081905550806001600082825461113d91906117af565b90915550506000547f00000000000000000000000000000000000000000000000000000000000000009003611196576040517fcd69fa9896c4546b6ceac642f9fc45bf9603651c212d512911d735dc97f99f7290600090a15b60408051888152602081018790526001600160a01b038816917f16481c457cfa97f1508c848b8ce22b67b27711f139806040aeb662abdfc4996b910160405180910390a2505050503868929eee149b4bd212685592915050565b3068929eee149b4bd21268540361120f5763ab143c066000526004601cfd5b3068929eee149b4bd2126855336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614611264576040516330cd747160e01b815260040160405180910390fd5b60025460ff161561128857604051634d65bf2960e11b815260040160405180910390fd5b60025462010000900460ff16156112b2576040516338384cc160e21b815260040160405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000064ffffffffff164264ffffffffff16106113005760405163f1d2165f60e01b815260040160405180910390fd5b6002805462ff00001916620100001790556113856001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000167f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006114dd565b6040517f4717c1fcb8954ad4f0da8b5d368d4064a1c750f8639c89dc534ad6070697078290600090a13868929eee149b4bd2126855565b60025460009062010000900460ff16806113d8575060025460ff165b156113e35750600090565b7f0000000000000000000000000000000000000000000000000000000000000000600054148061144157507f000000000000000000000000000000000000000000000000000000000000000064ffffffffff164264ffffffffff1610155b15610cc85750600190565b60008160001904831182021561146a5763bac65e5b6000526004601cfd5b50670de0b6b3a764000091020490565b60003860003884865af16114965763b12d13eb6000526004601cfd5b5050565b804710156114b05763b12d13eb6000526004601cfd5b6000386000388486620186a0f161149657816000526073600b5360ff6020536016600b82f0611496573838fd5b816014528060345263a9059cbb60601b60005260206000604460106000875af13d156001600051141716611519576390b8ec186000526004601cfd5b6000603452505050565b600061152d610c64565b90911015919050565b80601260ff8416101561156f5760006115508460126117d5565b905061155d81600a6118d2565b61156790836118e1565b915050610acf565b60128360ff161115610acf5760006115886012856117d5565b905061159581600a6118d2565b61159f90836118f8565b949350505050565b80601260ff841610156115d85760006115c18460126117d5565b90506115ce81600a6118d2565b61156790836118f8565b60128360ff161115610acf5760006115f16012856117d5565b90506115fe81600a6118d2565b61159f90836118e1565b81516001600160a01b031681526102408101602083015161163460208401826001600160a01b03169052565b50604083015161164f60408401826001600160a01b03169052565b50606083015161166a60608401826001600160a01b03169052565b506080830151608083015260a083015160a083015260c083015160c083015260e083015160e0830152610100808401516116ac8285018264ffffffffff169052565b50506101208381015164ffffffffff9081169184019190915261014080850151909116908301526101608084015190830152610180808401511515908301526101a0808401511515908301526101c0808401511515908301526101e080840151151590830152610200808401519083015261022092830151929091019190915290565b80356001600160a01b038116811461174657600080fd5b919050565b60006020828403121561175d57600080fd5b6117668261172f565b9392505050565b6000806040838503121561178057600080fd5b823591506117906020840161172f565b90509250929050565b634e487b7160e01b600052601160045260246000fd5b80820180821115610acf57610acf611799565b81810381811115610acf57610acf611799565b60ff8281168282160390811115610acf57610acf611799565b600181815b8085111561182957816000190482111561180f5761180f611799565b8085161561181c57918102915b93841c93908002906117f3565b509250929050565b60008261184057506001610acf565b8161184d57506000610acf565b8160018114611863576002811461186d57611889565b6001915050610acf565b60ff84111561187e5761187e611799565b50506001821b610acf565b5060208310610133831016604e8410600b84101617156118ac575081810a610acf565b6118b683836117ee565b80600019048211156118ca576118ca611799565b029392505050565b600061176660ff841683611831565b8082028115828204841417610acf57610acf611799565b60008261191557634e487b7160e01b600052601260045260246000fd5b50049056fea264697066735822122008b029029afc8fa25291c8a7ecfa26bb058a7a34ba81e385c9efb58b78a12ee564736f6c63430008190033a2646970667358221220d5f2962c01a30e65cd07fe350d8abce3c36e06af246195a8149155a41cc2d9f964736f6c63430008190033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
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.