ETH Price: $2,850.37 (-3.09%)
 

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Block
From
To
Collect All Fees348520082025-08-29 18:49:23149 days ago1756493363IN
0x4EBc9002...76a569E06
0 ETH0.000002750.00460824
Deploy Token348128502025-08-28 21:04:07150 days ago1756415047IN
0x4EBc9002...76a569E06
0.00001 ETH0.000009010.00143024
Collect All Fees348079252025-08-28 18:19:57150 days ago1756405197IN
0x4EBc9002...76a569E06
0 ETH0.000003020.00365716
Deploy Token348040432025-08-28 16:10:33150 days ago1756397433IN
0x4EBc9002...76a569E06
0.0001 ETH0.000032150.00510404
Deploy Token348040152025-08-28 16:09:37150 days ago1756397377IN
0x4EBc9002...76a569E06
0.1 ETH0.000043360.00688234
Deploy Token348033832025-08-28 15:48:33150 days ago1756396113IN
0x4EBc9002...76a569E06
0.015 ETH0.000028750.00456349
Deploy Token348028152025-08-28 15:29:37150 days ago1756394977IN
0x4EBc9002...76a569E06
0.0001 ETH0.000068830.01086768

Latest 10 internal transactions

Parent Transaction Hash Block From To
348128502025-08-28 21:04:07150 days ago1756415047
0x4EBc9002...76a569E06
0.00001 ETH
348128502025-08-28 21:04:07150 days ago1756415047
0x4EBc9002...76a569E06
 Contract Creation0 ETH
348040432025-08-28 16:10:33150 days ago1756397433
0x4EBc9002...76a569E06
0.0001 ETH
348040432025-08-28 16:10:33150 days ago1756397433
0x4EBc9002...76a569E06
 Contract Creation0 ETH
348040152025-08-28 16:09:37150 days ago1756397377
0x4EBc9002...76a569E06
0.1 ETH
348040152025-08-28 16:09:37150 days ago1756397377
0x4EBc9002...76a569E06
 Contract Creation0 ETH
348033832025-08-28 15:48:33150 days ago1756396113
0x4EBc9002...76a569E06
0.015 ETH
348033832025-08-28 15:48:33150 days ago1756396113
0x4EBc9002...76a569E06
 Contract Creation0 ETH
348028152025-08-28 15:29:37150 days ago1756394977
0x4EBc9002...76a569E06
0.0001 ETH
348028152025-08-28 15:29:37150 days ago1756394977
0x4EBc9002...76a569E06
 Contract Creation0 ETH

Cross-Chain Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
Lester

Compiler Version
v0.8.27+commit.40a35a09

Optimization Enabled:
Yes with 200 runs

Other Settings:
paris EvmVersion
// SPDX-License-Identifier: MIT AND UNLICENSED
pragma solidity ^0.8.25;
// Website: https://lestervirtuals.xyz  
// Twitter: https://x.com/lestervirtuals

import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {Create2} from "@openzeppelin/contracts/utils/Create2.sol";
import {INonfungiblePositionManager, IUniswapV3Factory, ISwapRouter, IUniswapV3Pool} from "./interface.sol";
import {Bytes32AddressLib} from "./Bytes32AddressLib.sol";
import "./LesterMathLib.sol";
import "./Token.sol";

contract Lester is Ownable {
    using LesterMathLib for uint256;
    using LesterMathLib for int24;
    using Bytes32AddressLib for bytes32;

    error InvalidTokenOrder();
    error AddressAlreadyInTeam();
    error AddressNotInTeam();

    address public immutable weth = 0x4200000000000000000000000000000000000006;
    address public immutable usdc = 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913;
    address public immutable DEAD_ADDRESS = 0x000000000000000000000000000000000000dEaD;
    address[] public tokenList;
    mapping(address => uint256[]) public tokenPositions;

    // Team management
    mapping(address => bool) public isTeamMember;
    address[] public teamMembers;

    IUniswapV3Factory public immutable uniswapV3Factory;
    INonfungiblePositionManager public immutable positionManager;
    address public immutable swapRouter;

    int24 public constant TICK_SPACING = 200;

    event TokenCreated(
        address tokenAddress,
        address deployer,
        string name,
        string symbol,
        uint256 supply
    );

    event Debug(string message);

    event CreationStatusChanged(bool enabled);

    event TeamMemberAdded(address member);

    event TeamMemberRemoved(address member);

    bool public isCreationEnabled = true;

    modifier whenCreationEnabled() {
        require(isCreationEnabled, "Token creation is disabled");
        _;
    }

    modifier onlyLesterTeam() {
        require(isTeamMember[msg.sender] || msg.sender == owner(), "Not a team member");
        _;
    }

    constructor(
        address weth_,
        address uniswapV3Factory_,
        address positionManager_,
        address swapRouter_,
        address owner_
    ) Ownable(owner_) {
        weth = weth_;
        uniswapV3Factory = IUniswapV3Factory(uniswapV3Factory_);
        positionManager = INonfungiblePositionManager(positionManager_);
        swapRouter = swapRouter_;
    }


    function setCreationEnabled(bool enabled) external onlyLesterTeam {
        isCreationEnabled = enabled;
        emit CreationStatusChanged(enabled);
    }

    function calculateNumerator(uint256 supply, uint256 liquidity) public pure returns (uint256) {
        return LesterMathLib.calculateNumerator(supply, liquidity);
    }

    function calculateTickFromNumerator(uint256 numerator) public pure returns (int256) {
        return LesterMathLib.calculateTickFromNumerator(numerator);
    }

    function deployToken(
        string memory name,
        string memory symbol,
        uint256 supply,
        uint256 liquidity,
        uint24 fee,
        bytes32 salt,
        address deployer,
        uint256 maxWalletPercentage,
        uint256 firstBuyAmount,
        string memory twitterName,
        string memory websiteUrl
    ) external payable whenCreationEnabled {
        require(supply > 0, "Supply must be greater than 0");
        require(deployer != address(0), "Invalid deployer address");
        require(bytes(name).length > 0, "Name cannot be empty");
        require(bytes(symbol).length > 0, "Symbol cannot be empty");
        require(fee == 10000, "Invalid fee tier");
        require(bytes(twitterName).length > 0, "Twitter name cannot be empty");
        require(msg.value >= firstBuyAmount, "Insufficient ETH sent");

        string memory finalName = string(abi.encodePacked(name, " by Lester"));

        uint256 priceToken = calculateNumerator(supply, liquidity);
        int256 tick = calculateTickFromNumerator(priceToken);
        require(tick > 0, "Price < 0");
        int24 tickSpacing = uniswapV3Factory.feeAmountTickSpacing(fee);
        int24 maxTick = LesterMathLib.maxUsableTick(tickSpacing);
        int24 currentTick = -int24(int256(tick));
        if (currentTick % tickSpacing != 0) {
            currentTick = int24((currentTick / tickSpacing) * tickSpacing);
        }

        bytes32 create2Salt = salt;
        
        Token token = new Token{salt: create2Salt}(
            finalName,
            symbol,
            supply,
            deployer,
            address(uniswapV3Factory),
            address(positionManager),
            maxWalletPercentage,
            twitterName,
            websiteUrl
        );

        require(address(token) < weth, "Token address must be less than WETH");

        address pool = uniswapV3Factory.getPool(address(token), weth, fee);
        uint160 sqrtPriceX96 = LesterMathLib.getSqrtRatioAtTick(currentTick);
        if (pool == address(0)) {
            pool = uniswapV3Factory.createPool(address(token), weth, fee);
            IUniswapV3Pool(pool).initialize(sqrtPriceX96);  
        }
        require(uniswapV3Factory.getPool(address(token), weth, fee) == pool, "Pool not created");

        token.setPoolAddress(address(pool));

        token.approve(address(positionManager), type(uint256).max);
        token.transfer(address(this), supply);
        INonfungiblePositionManager.MintParams memory params = INonfungiblePositionManager.MintParams({
            token0: address(token),
            token1: weth,
            fee: fee,
            tickLower: currentTick,
            tickUpper: maxTick,
            amount0Desired: supply,
            amount1Desired: 0,
            amount0Min: 0,
            amount1Min: 0,
            recipient: address(this),
            deadline: block.timestamp + 60
        });

        (uint256 tokenId, , , ) = positionManager.mint(params);
        _addTokenPosition(address(token), tokenId);

        token.approve(address(positionManager), type(uint256).max);
        
        IWETH(weth).deposit{value: firstBuyAmount}();
        require(IERC20(weth).approve(swapRouter, firstBuyAmount), "Approve failed");

        ISwapRouter(swapRouter).exactInputSingle(
            ISwapRouter.ExactInputSingleParams({
                tokenIn: weth,
                tokenOut: address(token),
                fee: fee,
                recipient: msg.sender,
                amountIn: firstBuyAmount,
                amountOutMinimum: 0,
                sqrtPriceLimitX96: 0
            })
        );

        if (msg.value > firstBuyAmount) {
            (bool success, ) = msg.sender.call{value: msg.value - firstBuyAmount}("");
            require(success, "ETH refund failed");
        }

        emit TokenCreated(
            address(token),
            deployer,
            name,
            symbol,
            supply
        );
    }

    function predictToken(
        address deployer,
        string calldata name,
        string calldata symbol,
        uint256 supply,
        bytes32 salt,
        uint256 maxWalletPercentage,
        string calldata twitterName,
        string calldata websiteUrl
    ) public view returns (address) {
        string memory finalName = string(abi.encodePacked(name, " by Lester"));
        bytes memory bytecode = abi.encodePacked(
            type(Token).creationCode,
            abi.encode(
                finalName,
                symbol,
                supply,
                deployer,
                address(uniswapV3Factory),
                address(positionManager),
                maxWalletPercentage,
                twitterName,
                websiteUrl
            )
        );

        return Create2.computeAddress(
            salt,
            keccak256(bytecode),
            address(this)
        );
    }

    function generateSalt(
        address deployer,
        string calldata name,
        string calldata symbol,
        uint256 supply,
        uint256 maxWalletPercentage,
        string calldata twitterName,
        string calldata websiteUrl
    ) external view returns (bytes32 salt, address token) {
        uint256 i = 0;
        while (true) {
            bytes32 baseSalt = bytes32(i);
            token = predictToken(
                deployer,
                name,
                symbol,
                supply,
                baseSalt,
                maxWalletPercentage,
                twitterName,
                websiteUrl
            );
            if (uint160(token) < uint160(weth) && token.code.length == 0) {
                salt = baseSalt;
                break;
            }
            i++;
            require(i < 1000, "Could not find valid salt");
        }
    }

    function _addTokenPosition(address token, uint256 tokenId) internal {
        tokenPositions[token].push(tokenId);
        tokenList.push(token);
    }

    function collectFees(address token) public onlyLesterTeam {
        uint256[] memory positions = tokenPositions[token];
        require(positions.length > 0, "No positions for this token");

        positionManager.approve(owner(), positions[0]);

        for (uint i = 0; i < positions.length; i++) {
            uint256 tokenId = positions[i];
            INonfungiblePositionManager.CollectParams memory params = INonfungiblePositionManager.CollectParams({
                tokenId: tokenId,
                recipient: owner(),
                amount0Max: type(uint128).max,
                amount1Max: type(uint128).max
            });

            positionManager.collect(params);
        }
    }
    
    function collectAllFees() public onlyLesterTeam {
        address[] memory tokens = new address[](tokenList.length);
        uint256 count = 0;
        
        for (uint i = 0; i < tokenList.length; i++) {
            if (tokenPositions[tokenList[i]].length > 0) {
                tokens[count] = tokenList[i];
                count++;
            }
        }

        for (uint i = 0; i < count; i++) {
            collectFees(tokens[i]);
        }
    }

    function addTeamMember(address member) external onlyOwner {
        if (isTeamMember[member]) revert AddressAlreadyInTeam();
        isTeamMember[member] = true;
        teamMembers.push(member);
        emit TeamMemberAdded(member);
    }

    function removeTeamMember(address member) external onlyOwner {
        if (!isTeamMember[member]) revert AddressNotInTeam();
        isTeamMember[member] = false;
        
        // Remove from array
        for (uint256 i = 0; i < teamMembers.length; i++) {
            if (teamMembers[i] == member) {
                teamMembers[i] = teamMembers[teamMembers.length - 1];
                teamMembers.pop();
                break;
            }
        }
        emit TeamMemberRemoved(member);
    }

    function getTeamMembers() external view returns (address[] memory) {
        return teamMembers;
    }

    receive() external payable {}
}

interface IWETH {
    function deposit() external payable;
    function withdraw(uint256) external;
    function approve(address guy, uint256 wad) external returns (bool);
}

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

pragma solidity ^0.8.20;

import {Context} from "../utils/Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * The initial owner is set to the address provided by the deployer. This can
 * later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    /**
     * @dev The caller account is not authorized to perform an operation.
     */
    error OwnableUnauthorizedAccount(address account);

    /**
     * @dev The owner is not a valid owner account. (eg. `address(0)`)
     */
    error OwnableInvalidOwner(address owner);

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

    /**
     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
     */
    constructor(address initialOwner) {
        if (initialOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(initialOwner);
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

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

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        if (owner() != _msgSender()) {
            revert OwnableUnauthorizedAccount(_msgSender());
        }
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        if (newOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/draft-IERC6093.sol)
pragma solidity ^0.8.20;

/**
 * @dev Standard ERC-20 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-20 tokens.
 */
interface IERC20Errors {
    /**
     * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param balance Current balance for the interacting account.
     * @param needed Minimum amount required to perform a transfer.
     */
    error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC20InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC20InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.
     * @param spender Address that may be allowed to operate on tokens without being their owner.
     * @param allowance Amount of tokens a `spender` is allowed to operate with.
     * @param needed Minimum amount required to perform a transfer.
     */
    error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC20InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `spender` to be approved. Used in approvals.
     * @param spender Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC20InvalidSpender(address spender);
}

/**
 * @dev Standard ERC-721 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-721 tokens.
 */
interface IERC721Errors {
    /**
     * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in ERC-20.
     * Used in balance queries.
     * @param owner Address of the current owner of a token.
     */
    error ERC721InvalidOwner(address owner);

    /**
     * @dev Indicates a `tokenId` whose `owner` is the zero address.
     * @param tokenId Identifier number of a token.
     */
    error ERC721NonexistentToken(uint256 tokenId);

    /**
     * @dev Indicates an error related to the ownership over a particular token. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param tokenId Identifier number of a token.
     * @param owner Address of the current owner of a token.
     */
    error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC721InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC721InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `operator`’s approval. Used in transfers.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     * @param tokenId Identifier number of a token.
     */
    error ERC721InsufficientApproval(address operator, uint256 tokenId);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC721InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `operator` to be approved. Used in approvals.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC721InvalidOperator(address operator);
}

/**
 * @dev Standard ERC-1155 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-1155 tokens.
 */
interface IERC1155Errors {
    /**
     * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param balance Current balance for the interacting account.
     * @param needed Minimum amount required to perform a transfer.
     * @param tokenId Identifier number of a token.
     */
    error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC1155InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC1155InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `operator`’s approval. Used in transfers.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     * @param owner Address of the current owner of a token.
     */
    error ERC1155MissingApprovalForAll(address operator, address owner);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC1155InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `operator` to be approved. Used in approvals.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC1155InvalidOperator(address operator);

    /**
     * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.
     * Used in batch transfers.
     * @param idsLength Length of the array of token identifiers
     * @param valuesLength Length of the array of token amounts
     */
    error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}

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

pragma solidity ^0.8.20;

import {IERC20} from "./IERC20.sol";
import {IERC20Metadata} from "./extensions/IERC20Metadata.sol";
import {Context} from "../../utils/Context.sol";
import {IERC20Errors} from "../../interfaces/draft-IERC6093.sol";

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * The default value of {decimals} is 18. To change this, you should override
 * this function so it returns a different value.
 *
 * We have followed general OpenZeppelin Contracts guidelines: functions revert
 * instead returning `false` on failure. This behavior is nonetheless
 * conventional and does not conflict with the expectations of ERC-20
 * applications.
 */
abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {
    mapping(address account => uint256) private _balances;

    mapping(address account => mapping(address spender => uint256)) private _allowances;

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * All two of these values are immutable: they can only be set once during
     * construction.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

    /**
     * @dev Returns the name of the token.
     */
    function name() public view virtual returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the number of decimals used to get its user representation.
     * For example, if `decimals` equals `2`, a balance of `505` tokens should
     * be displayed to a user as `5.05` (`505 / 10 ** 2`).
     *
     * Tokens usually opt for a value of 18, imitating the relationship between
     * Ether and Wei. This is the default value returned by this function, unless
     * it's overridden.
     *
     * NOTE: This information is only used for _display_ purposes: it in
     * no way affects any of the arithmetic of the contract, including
     * {IERC20-balanceOf} and {IERC20-transfer}.
     */
    function decimals() public view virtual returns (uint8) {
        return 18;
    }

    /**
     * @dev See {IERC20-totalSupply}.
     */
    function totalSupply() public view virtual returns (uint256) {
        return _totalSupply;
    }

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view virtual returns (uint256) {
        return _balances[account];
    }

    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - the caller must have a balance of at least `value`.
     */
    function transfer(address to, uint256 value) public virtual returns (bool) {
        address owner = _msgSender();
        _transfer(owner, to, value);
        return true;
    }

    /**
     * @dev See {IERC20-allowance}.
     */
    function allowance(address owner, address spender) public view virtual returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @dev See {IERC20-approve}.
     *
     * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on
     * `transferFrom`. This is semantically equivalent to an infinite approval.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 value) public virtual returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, value);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Skips emitting an {Approval} event indicating an allowance update. This is not
     * required by the ERC. See {xref-ERC20-_approve-address-address-uint256-bool-}[_approve].
     *
     * NOTE: Does not update the allowance if the current allowance
     * is the maximum `uint256`.
     *
     * Requirements:
     *
     * - `from` and `to` cannot be the zero address.
     * - `from` must have a balance of at least `value`.
     * - the caller must have allowance for ``from``'s tokens of at least
     * `value`.
     */
    function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {
        address spender = _msgSender();
        _spendAllowance(from, spender, value);
        _transfer(from, to, value);
        return true;
    }

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to`.
     *
     * This internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * NOTE: This function is not virtual, {_update} should be overridden instead.
     */
    function _transfer(address from, address to, uint256 value) internal {
        if (from == address(0)) {
            revert ERC20InvalidSender(address(0));
        }
        if (to == address(0)) {
            revert ERC20InvalidReceiver(address(0));
        }
        _update(from, to, value);
    }

    /**
     * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`
     * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding
     * this function.
     *
     * Emits a {Transfer} event.
     */
    function _update(address from, address to, uint256 value) internal virtual {
        if (from == address(0)) {
            // Overflow check required: The rest of the code assumes that totalSupply never overflows
            _totalSupply += value;
        } else {
            uint256 fromBalance = _balances[from];
            if (fromBalance < value) {
                revert ERC20InsufficientBalance(from, fromBalance, value);
            }
            unchecked {
                // Overflow not possible: value <= fromBalance <= totalSupply.
                _balances[from] = fromBalance - value;
            }
        }

        if (to == address(0)) {
            unchecked {
                // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.
                _totalSupply -= value;
            }
        } else {
            unchecked {
                // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.
                _balances[to] += value;
            }
        }

        emit Transfer(from, to, value);
    }

    /**
     * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).
     * Relies on the `_update` mechanism
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * NOTE: This function is not virtual, {_update} should be overridden instead.
     */
    function _mint(address account, uint256 value) internal {
        if (account == address(0)) {
            revert ERC20InvalidReceiver(address(0));
        }
        _update(address(0), account, value);
    }

    /**
     * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.
     * Relies on the `_update` mechanism.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * NOTE: This function is not virtual, {_update} should be overridden instead
     */
    function _burn(address account, uint256 value) internal {
        if (account == address(0)) {
            revert ERC20InvalidSender(address(0));
        }
        _update(account, address(0), value);
    }

    /**
     * @dev Sets `value` as the allowance of `spender` over the `owner` s tokens.
     *
     * This internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     *
     * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
     */
    function _approve(address owner, address spender, uint256 value) internal {
        _approve(owner, spender, value, true);
    }

    /**
     * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.
     *
     * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by
     * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any
     * `Approval` event during `transferFrom` operations.
     *
     * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to
     * true using the following override:
     *
     * ```solidity
     * function _approve(address owner, address spender, uint256 value, bool) internal virtual override {
     *     super._approve(owner, spender, value, true);
     * }
     * ```
     *
     * Requirements are the same as {_approve}.
     */
    function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {
        if (owner == address(0)) {
            revert ERC20InvalidApprover(address(0));
        }
        if (spender == address(0)) {
            revert ERC20InvalidSpender(address(0));
        }
        _allowances[owner][spender] = value;
        if (emitEvent) {
            emit Approval(owner, spender, value);
        }
    }

    /**
     * @dev Updates `owner` s allowance for `spender` based on spent `value`.
     *
     * Does not update the allowance value in case of infinite allowance.
     * Revert if not enough allowance is available.
     *
     * Does not emit an {Approval} event.
     */
    function _spendAllowance(address owner, address spender, uint256 value) internal virtual {
        uint256 currentAllowance = allowance(owner, spender);
        if (currentAllowance != type(uint256).max) {
            if (currentAllowance < value) {
                revert ERC20InsufficientAllowance(spender, currentAllowance, value);
            }
            unchecked {
                _approve(owner, spender, currentAllowance - value, false);
            }
        }
    }
}

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

pragma solidity ^0.8.20;

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

/**
 * @dev Interface for the optional metadata functions from the ERC-20 standard.
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the symbol of the token.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}

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

pragma solidity ^0.8.20;

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.20;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

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

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

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

pragma solidity ^0.8.20;

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

/**
 * @dev Helper to make usage of the `CREATE2` EVM opcode easier and safer.
 * `CREATE2` can be used to compute in advance the address where a smart
 * contract will be deployed, which allows for interesting new mechanisms known
 * as 'counterfactual interactions'.
 *
 * See the https://eips.ethereum.org/EIPS/eip-1014#motivation[EIP] for more
 * information.
 */
library Create2 {
    /**
     * @dev There's no code to deploy.
     */
    error Create2EmptyBytecode();

    /**
     * @dev Deploys a contract using `CREATE2`. The address where the contract
     * will be deployed can be known in advance via {computeAddress}.
     *
     * The bytecode for a contract can be obtained from Solidity with
     * `type(contractName).creationCode`.
     *
     * Requirements:
     *
     * - `bytecode` must not be empty.
     * - `salt` must have not been used for `bytecode` already.
     * - the factory must have a balance of at least `amount`.
     * - if `amount` is non-zero, `bytecode` must have a `payable` constructor.
     */
    function deploy(uint256 amount, bytes32 salt, bytes memory bytecode) internal returns (address addr) {
        if (address(this).balance < amount) {
            revert Errors.InsufficientBalance(address(this).balance, amount);
        }
        if (bytecode.length == 0) {
            revert Create2EmptyBytecode();
        }
        assembly ("memory-safe") {
            addr := create2(amount, add(bytecode, 0x20), mload(bytecode), salt)
            // if no address was created, and returndata is not empty, bubble revert
            if and(iszero(addr), not(iszero(returndatasize()))) {
                let p := mload(0x40)
                returndatacopy(p, 0, returndatasize())
                revert(p, returndatasize())
            }
        }
        if (addr == address(0)) {
            revert Errors.FailedDeployment();
        }
    }

    /**
     * @dev Returns the address where a contract will be stored if deployed via {deploy}. Any change in the
     * `bytecodeHash` or `salt` will result in a new destination address.
     */
    function computeAddress(bytes32 salt, bytes32 bytecodeHash) internal view returns (address) {
        return computeAddress(salt, bytecodeHash, address(this));
    }

    /**
     * @dev Returns the address where a contract will be stored if deployed via {deploy} from a contract located at
     * `deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}.
     */
    function computeAddress(bytes32 salt, bytes32 bytecodeHash, address deployer) internal pure returns (address addr) {
        assembly ("memory-safe") {
            let ptr := mload(0x40) // Get free memory pointer

            // |                   | ↓ ptr ...  ↓ ptr + 0x0B (start) ...  ↓ ptr + 0x20 ...  ↓ ptr + 0x40 ...   |
            // |-------------------|---------------------------------------------------------------------------|
            // | bytecodeHash      |                                                        CCCCCCCCCCCCC...CC |
            // | salt              |                                      BBBBBBBBBBBBB...BB                   |
            // | deployer          | 000000...0000AAAAAAAAAAAAAAAAAAA...AA                                     |
            // | 0xFF              |            FF                                                             |
            // |-------------------|---------------------------------------------------------------------------|
            // | memory            | 000000...00FFAAAAAAAAAAAAAAAAAAA...AABBBBBBBBBBBBB...BBCCCCCCCCCCCCC...CC |
            // | keccak(start, 85) |            ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ |

            mstore(add(ptr, 0x40), bytecodeHash)
            mstore(add(ptr, 0x20), salt)
            mstore(ptr, deployer) // Right-aligned with 12 preceding garbage bytes
            let start := add(ptr, 0x0b) // The hashed data starts at the final garbage byte which we will set to 0xff
            mstore8(start, 0xff)
            addr := and(keccak256(start, 85), 0xffffffffffffffffffffffffffffffffffffffff)
        }
    }
}

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

pragma solidity ^0.8.20;

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

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

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

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

File 10 of 44 : Common.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.19;

// Common.sol
//
// Common mathematical functions used in both SD59x18 and UD60x18. Note that these global functions do not
// always operate with SD59x18 and UD60x18 numbers.

/*//////////////////////////////////////////////////////////////////////////
                                CUSTOM ERRORS
//////////////////////////////////////////////////////////////////////////*/

/// @notice Thrown when the resultant value in {mulDiv} overflows uint256.
error PRBMath_MulDiv_Overflow(uint256 x, uint256 y, uint256 denominator);

/// @notice Thrown when the resultant value in {mulDiv18} overflows uint256.
error PRBMath_MulDiv18_Overflow(uint256 x, uint256 y);

/// @notice Thrown when one of the inputs passed to {mulDivSigned} is `type(int256).min`.
error PRBMath_MulDivSigned_InputTooSmall();

/// @notice Thrown when the resultant value in {mulDivSigned} overflows int256.
error PRBMath_MulDivSigned_Overflow(int256 x, int256 y);

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

/// @dev The maximum value a uint128 number can have.
uint128 constant MAX_UINT128 = type(uint128).max;

/// @dev The maximum value a uint40 number can have.
uint40 constant MAX_UINT40 = type(uint40).max;

/// @dev The maximum value a uint64 number can have.
uint64 constant MAX_UINT64 = type(uint64).max;

/// @dev The unit number, which the decimal precision of the fixed-point types.
uint256 constant UNIT = 1e18;

/// @dev The unit number inverted mod 2^256.
uint256 constant UNIT_INVERSE = 78156646155174841979727994598816262306175212592076161876661_508869554232690281;

/// @dev The the largest power of two that divides the decimal value of `UNIT`. The logarithm of this value is the least significant
/// bit in the binary representation of `UNIT`.
uint256 constant UNIT_LPOTD = 262144;

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

/// @notice Calculates the binary exponent of x using the binary fraction method.
/// @dev Has to use 192.64-bit fixed-point numbers. See https://ethereum.stackexchange.com/a/96594/24693.
/// @param x The exponent as an unsigned 192.64-bit fixed-point number.
/// @return result The result as an unsigned 60.18-decimal fixed-point number.
/// @custom:smtchecker abstract-function-nondet
function exp2(uint256 x) pure returns (uint256 result) {
    unchecked {
        // Start from 0.5 in the 192.64-bit fixed-point format.
        result = 0x800000000000000000000000000000000000000000000000;

        // The following logic multiplies the result by $\sqrt{2^{-i}}$ when the bit at position i is 1. Key points:
        //
        // 1. Intermediate results will not overflow, as the starting point is 2^191 and all magic factors are under 2^65.
        // 2. The rationale for organizing the if statements into groups of 8 is gas savings. If the result of performing
        // a bitwise AND operation between x and any value in the array [0x80; 0x40; 0x20; 0x10; 0x08; 0x04; 0x02; 0x01] is 1,
        // we know that `x & 0xFF` is also 1.
        if (x & 0xFF00000000000000 > 0) {
            if (x & 0x8000000000000000 > 0) {
                result = (result * 0x16A09E667F3BCC909) >> 64;
            }
            if (x & 0x4000000000000000 > 0) {
                result = (result * 0x1306FE0A31B7152DF) >> 64;
            }
            if (x & 0x2000000000000000 > 0) {
                result = (result * 0x1172B83C7D517ADCE) >> 64;
            }
            if (x & 0x1000000000000000 > 0) {
                result = (result * 0x10B5586CF9890F62A) >> 64;
            }
            if (x & 0x800000000000000 > 0) {
                result = (result * 0x1059B0D31585743AE) >> 64;
            }
            if (x & 0x400000000000000 > 0) {
                result = (result * 0x102C9A3E778060EE7) >> 64;
            }
            if (x & 0x200000000000000 > 0) {
                result = (result * 0x10163DA9FB33356D8) >> 64;
            }
            if (x & 0x100000000000000 > 0) {
                result = (result * 0x100B1AFA5ABCBED61) >> 64;
            }
        }

        if (x & 0xFF000000000000 > 0) {
            if (x & 0x80000000000000 > 0) {
                result = (result * 0x10058C86DA1C09EA2) >> 64;
            }
            if (x & 0x40000000000000 > 0) {
                result = (result * 0x1002C605E2E8CEC50) >> 64;
            }
            if (x & 0x20000000000000 > 0) {
                result = (result * 0x100162F3904051FA1) >> 64;
            }
            if (x & 0x10000000000000 > 0) {
                result = (result * 0x1000B175EFFDC76BA) >> 64;
            }
            if (x & 0x8000000000000 > 0) {
                result = (result * 0x100058BA01FB9F96D) >> 64;
            }
            if (x & 0x4000000000000 > 0) {
                result = (result * 0x10002C5CC37DA9492) >> 64;
            }
            if (x & 0x2000000000000 > 0) {
                result = (result * 0x1000162E525EE0547) >> 64;
            }
            if (x & 0x1000000000000 > 0) {
                result = (result * 0x10000B17255775C04) >> 64;
            }
        }

        if (x & 0xFF0000000000 > 0) {
            if (x & 0x800000000000 > 0) {
                result = (result * 0x1000058B91B5BC9AE) >> 64;
            }
            if (x & 0x400000000000 > 0) {
                result = (result * 0x100002C5C89D5EC6D) >> 64;
            }
            if (x & 0x200000000000 > 0) {
                result = (result * 0x10000162E43F4F831) >> 64;
            }
            if (x & 0x100000000000 > 0) {
                result = (result * 0x100000B1721BCFC9A) >> 64;
            }
            if (x & 0x80000000000 > 0) {
                result = (result * 0x10000058B90CF1E6E) >> 64;
            }
            if (x & 0x40000000000 > 0) {
                result = (result * 0x1000002C5C863B73F) >> 64;
            }
            if (x & 0x20000000000 > 0) {
                result = (result * 0x100000162E430E5A2) >> 64;
            }
            if (x & 0x10000000000 > 0) {
                result = (result * 0x1000000B172183551) >> 64;
            }
        }

        if (x & 0xFF00000000 > 0) {
            if (x & 0x8000000000 > 0) {
                result = (result * 0x100000058B90C0B49) >> 64;
            }
            if (x & 0x4000000000 > 0) {
                result = (result * 0x10000002C5C8601CC) >> 64;
            }
            if (x & 0x2000000000 > 0) {
                result = (result * 0x1000000162E42FFF0) >> 64;
            }
            if (x & 0x1000000000 > 0) {
                result = (result * 0x10000000B17217FBB) >> 64;
            }
            if (x & 0x800000000 > 0) {
                result = (result * 0x1000000058B90BFCE) >> 64;
            }
            if (x & 0x400000000 > 0) {
                result = (result * 0x100000002C5C85FE3) >> 64;
            }
            if (x & 0x200000000 > 0) {
                result = (result * 0x10000000162E42FF1) >> 64;
            }
            if (x & 0x100000000 > 0) {
                result = (result * 0x100000000B17217F8) >> 64;
            }
        }

        if (x & 0xFF000000 > 0) {
            if (x & 0x80000000 > 0) {
                result = (result * 0x10000000058B90BFC) >> 64;
            }
            if (x & 0x40000000 > 0) {
                result = (result * 0x1000000002C5C85FE) >> 64;
            }
            if (x & 0x20000000 > 0) {
                result = (result * 0x100000000162E42FF) >> 64;
            }
            if (x & 0x10000000 > 0) {
                result = (result * 0x1000000000B17217F) >> 64;
            }
            if (x & 0x8000000 > 0) {
                result = (result * 0x100000000058B90C0) >> 64;
            }
            if (x & 0x4000000 > 0) {
                result = (result * 0x10000000002C5C860) >> 64;
            }
            if (x & 0x2000000 > 0) {
                result = (result * 0x1000000000162E430) >> 64;
            }
            if (x & 0x1000000 > 0) {
                result = (result * 0x10000000000B17218) >> 64;
            }
        }

        if (x & 0xFF0000 > 0) {
            if (x & 0x800000 > 0) {
                result = (result * 0x1000000000058B90C) >> 64;
            }
            if (x & 0x400000 > 0) {
                result = (result * 0x100000000002C5C86) >> 64;
            }
            if (x & 0x200000 > 0) {
                result = (result * 0x10000000000162E43) >> 64;
            }
            if (x & 0x100000 > 0) {
                result = (result * 0x100000000000B1721) >> 64;
            }
            if (x & 0x80000 > 0) {
                result = (result * 0x10000000000058B91) >> 64;
            }
            if (x & 0x40000 > 0) {
                result = (result * 0x1000000000002C5C8) >> 64;
            }
            if (x & 0x20000 > 0) {
                result = (result * 0x100000000000162E4) >> 64;
            }
            if (x & 0x10000 > 0) {
                result = (result * 0x1000000000000B172) >> 64;
            }
        }

        if (x & 0xFF00 > 0) {
            if (x & 0x8000 > 0) {
                result = (result * 0x100000000000058B9) >> 64;
            }
            if (x & 0x4000 > 0) {
                result = (result * 0x10000000000002C5D) >> 64;
            }
            if (x & 0x2000 > 0) {
                result = (result * 0x1000000000000162E) >> 64;
            }
            if (x & 0x1000 > 0) {
                result = (result * 0x10000000000000B17) >> 64;
            }
            if (x & 0x800 > 0) {
                result = (result * 0x1000000000000058C) >> 64;
            }
            if (x & 0x400 > 0) {
                result = (result * 0x100000000000002C6) >> 64;
            }
            if (x & 0x200 > 0) {
                result = (result * 0x10000000000000163) >> 64;
            }
            if (x & 0x100 > 0) {
                result = (result * 0x100000000000000B1) >> 64;
            }
        }

        if (x & 0xFF > 0) {
            if (x & 0x80 > 0) {
                result = (result * 0x10000000000000059) >> 64;
            }
            if (x & 0x40 > 0) {
                result = (result * 0x1000000000000002C) >> 64;
            }
            if (x & 0x20 > 0) {
                result = (result * 0x10000000000000016) >> 64;
            }
            if (x & 0x10 > 0) {
                result = (result * 0x1000000000000000B) >> 64;
            }
            if (x & 0x8 > 0) {
                result = (result * 0x10000000000000006) >> 64;
            }
            if (x & 0x4 > 0) {
                result = (result * 0x10000000000000003) >> 64;
            }
            if (x & 0x2 > 0) {
                result = (result * 0x10000000000000001) >> 64;
            }
            if (x & 0x1 > 0) {
                result = (result * 0x10000000000000001) >> 64;
            }
        }

        // In the code snippet below, two operations are executed simultaneously:
        //
        // 1. The result is multiplied by $(2^n + 1)$, where $2^n$ represents the integer part, and the additional 1
        // accounts for the initial guess of 0.5. This is achieved by subtracting from 191 instead of 192.
        // 2. The result is then converted to an unsigned 60.18-decimal fixed-point format.
        //
        // The underlying logic is based on the relationship $2^{191-ip} = 2^{ip} / 2^{191}$, where $ip$ denotes the,
        // integer part, $2^n$.
        result *= UNIT;
        result >>= (191 - (x >> 64));
    }
}

/// @notice Finds the zero-based index of the first 1 in the binary representation of x.
///
/// @dev See the note on "msb" in this Wikipedia article: https://en.wikipedia.org/wiki/Find_first_set
///
/// Each step in this implementation is equivalent to this high-level code:
///
/// ```solidity
/// if (x >= 2 ** 128) {
///     x >>= 128;
///     result += 128;
/// }
/// ```
///
/// Where 128 is replaced with each respective power of two factor. See the full high-level implementation here:
/// https://gist.github.com/PaulRBerg/f932f8693f2733e30c4d479e8e980948
///
/// The Yul instructions used below are:
///
/// - "gt" is "greater than"
/// - "or" is the OR bitwise operator
/// - "shl" is "shift left"
/// - "shr" is "shift right"
///
/// @param x The uint256 number for which to find the index of the most significant bit.
/// @return result The index of the most significant bit as a uint256.
/// @custom:smtchecker abstract-function-nondet
function msb(uint256 x) pure returns (uint256 result) {
    // 2^128
    assembly ("memory-safe") {
        let factor := shl(7, gt(x, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))
        x := shr(factor, x)
        result := or(result, factor)
    }
    // 2^64
    assembly ("memory-safe") {
        let factor := shl(6, gt(x, 0xFFFFFFFFFFFFFFFF))
        x := shr(factor, x)
        result := or(result, factor)
    }
    // 2^32
    assembly ("memory-safe") {
        let factor := shl(5, gt(x, 0xFFFFFFFF))
        x := shr(factor, x)
        result := or(result, factor)
    }
    // 2^16
    assembly ("memory-safe") {
        let factor := shl(4, gt(x, 0xFFFF))
        x := shr(factor, x)
        result := or(result, factor)
    }
    // 2^8
    assembly ("memory-safe") {
        let factor := shl(3, gt(x, 0xFF))
        x := shr(factor, x)
        result := or(result, factor)
    }
    // 2^4
    assembly ("memory-safe") {
        let factor := shl(2, gt(x, 0xF))
        x := shr(factor, x)
        result := or(result, factor)
    }
    // 2^2
    assembly ("memory-safe") {
        let factor := shl(1, gt(x, 0x3))
        x := shr(factor, x)
        result := or(result, factor)
    }
    // 2^1
    // No need to shift x any more.
    assembly ("memory-safe") {
        let factor := gt(x, 0x1)
        result := or(result, factor)
    }
}

/// @notice Calculates x*y÷denominator with 512-bit precision.
///
/// @dev Credits to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv.
///
/// Notes:
/// - The result is rounded toward zero.
///
/// Requirements:
/// - The denominator must not be zero.
/// - The result must fit in uint256.
///
/// @param x The multiplicand as a uint256.
/// @param y The multiplier as a uint256.
/// @param denominator The divisor as a uint256.
/// @return result The result as a uint256.
/// @custom:smtchecker abstract-function-nondet
function mulDiv(uint256 x, uint256 y, uint256 denominator) pure returns (uint256 result) {
    // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
    // use the Chinese Remainder Theorem to reconstruct the 512-bit result. The result is stored in two 256
    // variables such that product = prod1 * 2^256 + prod0.
    uint256 prod0; // Least significant 256 bits of the product
    uint256 prod1; // Most significant 256 bits of the product
    assembly ("memory-safe") {
        let mm := mulmod(x, y, not(0))
        prod0 := mul(x, y)
        prod1 := sub(sub(mm, prod0), lt(mm, prod0))
    }

    // Handle non-overflow cases, 256 by 256 division.
    if (prod1 == 0) {
        unchecked {
            return prod0 / denominator;
        }
    }

    // Make sure the result is less than 2^256. Also prevents denominator == 0.
    if (prod1 >= denominator) {
        revert PRBMath_MulDiv_Overflow(x, y, denominator);
    }

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

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

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

    unchecked {
        // Calculate the largest power of two divisor of the denominator using the unary operator ~. This operation cannot overflow
        // because the denominator cannot be zero at this point in the function execution. The result is always >= 1.
        // For more detail, see https://cs.stackexchange.com/q/138556/92363.
        uint256 lpotdod = denominator & (~denominator + 1);
        uint256 flippedLpotdod;

        assembly ("memory-safe") {
            // Factor powers of two out of denominator.
            denominator := div(denominator, lpotdod)

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

            // Get the flipped value `2^256 / lpotdod`. If the `lpotdod` is zero, the flipped value is one.
            // `sub(0, lpotdod)` produces the two's complement version of `lpotdod`, which is equivalent to flipping all the bits.
            // However, `div` interprets this value as an unsigned value: https://ethereum.stackexchange.com/q/147168/24693
            flippedLpotdod := add(div(sub(0, lpotdod), lpotdod), 1)
        }

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

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

        // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
        // in modular arithmetic, doubling the correct bits in each step.
        inverse *= 2 - denominator * inverse; // inverse mod 2^8
        inverse *= 2 - denominator * inverse; // inverse mod 2^16
        inverse *= 2 - denominator * inverse; // inverse mod 2^32
        inverse *= 2 - denominator * inverse; // inverse mod 2^64
        inverse *= 2 - denominator * inverse; // inverse mod 2^128
        inverse *= 2 - denominator * inverse; // inverse mod 2^256

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

/// @notice Calculates x*y÷1e18 with 512-bit precision.
///
/// @dev A variant of {mulDiv} with constant folding, i.e. in which the denominator is hard coded to 1e18.
///
/// Notes:
/// - The body is purposely left uncommented; to understand how this works, see the documentation in {mulDiv}.
/// - The result is rounded toward zero.
/// - We take as an axiom that the result cannot be `MAX_UINT256` when x and y solve the following system of equations:
///
/// $$
/// \begin{cases}
///     x * y = MAX\_UINT256 * UNIT \\
///     (x * y) \% UNIT \geq \frac{UNIT}{2}
/// \end{cases}
/// $$
///
/// Requirements:
/// - Refer to the requirements in {mulDiv}.
/// - The result must fit in uint256.
///
/// @param x The multiplicand as an unsigned 60.18-decimal fixed-point number.
/// @param y The multiplier as an unsigned 60.18-decimal fixed-point number.
/// @return result The result as an unsigned 60.18-decimal fixed-point number.
/// @custom:smtchecker abstract-function-nondet
function mulDiv18(uint256 x, uint256 y) pure returns (uint256 result) {
    uint256 prod0;
    uint256 prod1;
    assembly ("memory-safe") {
        let mm := mulmod(x, y, not(0))
        prod0 := mul(x, y)
        prod1 := sub(sub(mm, prod0), lt(mm, prod0))
    }

    if (prod1 == 0) {
        unchecked {
            return prod0 / UNIT;
        }
    }

    if (prod1 >= UNIT) {
        revert PRBMath_MulDiv18_Overflow(x, y);
    }

    uint256 remainder;
    assembly ("memory-safe") {
        remainder := mulmod(x, y, UNIT)
        result :=
            mul(
                or(
                    div(sub(prod0, remainder), UNIT_LPOTD),
                    mul(sub(prod1, gt(remainder, prod0)), add(div(sub(0, UNIT_LPOTD), UNIT_LPOTD), 1))
                ),
                UNIT_INVERSE
            )
    }
}

/// @notice Calculates x*y÷denominator with 512-bit precision.
///
/// @dev This is an extension of {mulDiv} for signed numbers, which works by computing the signs and the absolute values separately.
///
/// Notes:
/// - The result is rounded toward zero.
///
/// Requirements:
/// - Refer to the requirements in {mulDiv}.
/// - None of the inputs can be `type(int256).min`.
/// - The result must fit in int256.
///
/// @param x The multiplicand as an int256.
/// @param y The multiplier as an int256.
/// @param denominator The divisor as an int256.
/// @return result The result as an int256.
/// @custom:smtchecker abstract-function-nondet
function mulDivSigned(int256 x, int256 y, int256 denominator) pure returns (int256 result) {
    if (x == type(int256).min || y == type(int256).min || denominator == type(int256).min) {
        revert PRBMath_MulDivSigned_InputTooSmall();
    }

    // Get hold of the absolute values of x, y and the denominator.
    uint256 xAbs;
    uint256 yAbs;
    uint256 dAbs;
    unchecked {
        xAbs = x < 0 ? uint256(-x) : uint256(x);
        yAbs = y < 0 ? uint256(-y) : uint256(y);
        dAbs = denominator < 0 ? uint256(-denominator) : uint256(denominator);
    }

    // Compute the absolute value of x*y÷denominator. The result must fit in int256.
    uint256 resultAbs = mulDiv(xAbs, yAbs, dAbs);
    if (resultAbs > uint256(type(int256).max)) {
        revert PRBMath_MulDivSigned_Overflow(x, y);
    }

    // Get the signs of x, y and the denominator.
    uint256 sx;
    uint256 sy;
    uint256 sd;
    assembly ("memory-safe") {
        // "sgt" is the "signed greater than" assembly instruction and "sub(0,1)" is -1 in two's complement.
        sx := sgt(x, sub(0, 1))
        sy := sgt(y, sub(0, 1))
        sd := sgt(denominator, sub(0, 1))
    }

    // XOR over sx, sy and sd. What this does is to check whether there are 1 or 3 negative signs in the inputs.
    // If there are, the result should be negative. Otherwise, it should be positive.
    unchecked {
        result = sx ^ sy ^ sd == 0 ? -int256(resultAbs) : int256(resultAbs);
    }
}

/// @notice Calculates the square root of x using the Babylonian method.
///
/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.
///
/// Notes:
/// - If x is not a perfect square, the result is rounded down.
/// - Credits to OpenZeppelin for the explanations in comments below.
///
/// @param x The uint256 number for which to calculate the square root.
/// @return result The result as a uint256.
/// @custom:smtchecker abstract-function-nondet
function sqrt(uint256 x) pure returns (uint256 result) {
    if (x == 0) {
        return 0;
    }

    // For our first guess, we calculate the biggest power of 2 which is smaller than the square root of x.
    //
    // We know that the "msb" (most significant bit) of x is a power of 2 such that we have:
    //
    // $$
    // msb(x) <= x <= 2*msb(x)$
    // $$
    //
    // We write $msb(x)$ as $2^k$, and we get:
    //
    // $$
    // k = log_2(x)
    // $$
    //
    // Thus, we can write the initial inequality as:
    //
    // $$
    // 2^{log_2(x)} <= x <= 2*2^{log_2(x)+1} \\
    // sqrt(2^k) <= sqrt(x) < sqrt(2^{k+1}) \\
    // 2^{k/2} <= sqrt(x) < 2^{(k+1)/2} <= 2^{(k/2)+1}
    // $$
    //
    // Consequently, $2^{log_2(x) /2} is a good first approximation of sqrt(x) with at least one correct bit.
    uint256 xAux = uint256(x);
    result = 1;
    if (xAux >= 2 ** 128) {
        xAux >>= 128;
        result <<= 64;
    }
    if (xAux >= 2 ** 64) {
        xAux >>= 64;
        result <<= 32;
    }
    if (xAux >= 2 ** 32) {
        xAux >>= 32;
        result <<= 16;
    }
    if (xAux >= 2 ** 16) {
        xAux >>= 16;
        result <<= 8;
    }
    if (xAux >= 2 ** 8) {
        xAux >>= 8;
        result <<= 4;
    }
    if (xAux >= 2 ** 4) {
        xAux >>= 4;
        result <<= 2;
    }
    if (xAux >= 2 ** 2) {
        result <<= 1;
    }

    // At this point, `result` is an estimation with at least one bit of precision. We know the true value has at
    // most 128 bits, since it is the square root of a uint256. Newton's method converges quadratically (precision
    // doubles at every iteration). We thus need at most 7 iteration to turn our partial result with one bit of
    // precision into the expected uint128 result.
    unchecked {
        result = (result + x / result) >> 1;
        result = (result + x / result) >> 1;
        result = (result + x / result) >> 1;
        result = (result + x / result) >> 1;
        result = (result + x / result) >> 1;
        result = (result + x / result) >> 1;
        result = (result + x / result) >> 1;

        // If x is not a perfect square, round the result toward zero.
        uint256 roundedResult = x / result;
        if (result >= roundedResult) {
            result = roundedResult;
        }
    }
}

File 11 of 44 : Casting.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.19;

import "../Common.sol" as Common;
import "./Errors.sol" as CastingErrors;
import { SD59x18 } from "../sd59x18/ValueType.sol";
import { UD60x18 } from "../ud60x18/ValueType.sol";
import { SD1x18 } from "./ValueType.sol";

/// @notice Casts an SD1x18 number into SD59x18.
/// @dev There is no overflow check because SD1x18 ⊆ SD59x18.
function intoSD59x18(SD1x18 x) pure returns (SD59x18 result) {
    result = SD59x18.wrap(int256(SD1x18.unwrap(x)));
}

/// @notice Casts an SD1x18 number into UD60x18.
/// @dev Requirements:
/// - x ≥ 0
function intoUD60x18(SD1x18 x) pure returns (UD60x18 result) {
    int64 xInt = SD1x18.unwrap(x);
    if (xInt < 0) {
        revert CastingErrors.PRBMath_SD1x18_ToUD60x18_Underflow(x);
    }
    result = UD60x18.wrap(uint64(xInt));
}

/// @notice Casts an SD1x18 number into uint128.
/// @dev Requirements:
/// - x ≥ 0
function intoUint128(SD1x18 x) pure returns (uint128 result) {
    int64 xInt = SD1x18.unwrap(x);
    if (xInt < 0) {
        revert CastingErrors.PRBMath_SD1x18_ToUint128_Underflow(x);
    }
    result = uint128(uint64(xInt));
}

/// @notice Casts an SD1x18 number into uint256.
/// @dev Requirements:
/// - x ≥ 0
function intoUint256(SD1x18 x) pure returns (uint256 result) {
    int64 xInt = SD1x18.unwrap(x);
    if (xInt < 0) {
        revert CastingErrors.PRBMath_SD1x18_ToUint256_Underflow(x);
    }
    result = uint256(uint64(xInt));
}

/// @notice Casts an SD1x18 number into uint40.
/// @dev Requirements:
/// - x ≥ 0
/// - x ≤ MAX_UINT40
function intoUint40(SD1x18 x) pure returns (uint40 result) {
    int64 xInt = SD1x18.unwrap(x);
    if (xInt < 0) {
        revert CastingErrors.PRBMath_SD1x18_ToUint40_Underflow(x);
    }
    if (xInt > int64(uint64(Common.MAX_UINT40))) {
        revert CastingErrors.PRBMath_SD1x18_ToUint40_Overflow(x);
    }
    result = uint40(uint64(xInt));
}

/// @notice Alias for {wrap}.
function sd1x18(int64 x) pure returns (SD1x18 result) {
    result = SD1x18.wrap(x);
}

/// @notice Unwraps an SD1x18 number into int64.
function unwrap(SD1x18 x) pure returns (int64 result) {
    result = SD1x18.unwrap(x);
}

/// @notice Wraps an int64 number into SD1x18.
function wrap(int64 x) pure returns (SD1x18 result) {
    result = SD1x18.wrap(x);
}

File 12 of 44 : Constants.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.19;

import { SD1x18 } from "./ValueType.sol";

/// @dev Euler's number as an SD1x18 number.
SD1x18 constant E = SD1x18.wrap(2_718281828459045235);

/// @dev The maximum value an SD1x18 number can have.
int64 constant uMAX_SD1x18 = 9_223372036854775807;
SD1x18 constant MAX_SD1x18 = SD1x18.wrap(uMAX_SD1x18);

/// @dev The minimum value an SD1x18 number can have.
int64 constant uMIN_SD1x18 = -9_223372036854775808;
SD1x18 constant MIN_SD1x18 = SD1x18.wrap(uMIN_SD1x18);

/// @dev PI as an SD1x18 number.
SD1x18 constant PI = SD1x18.wrap(3_141592653589793238);

/// @dev The unit number, which gives the decimal precision of SD1x18.
SD1x18 constant UNIT = SD1x18.wrap(1e18);
int64 constant uUNIT = 1e18;

File 13 of 44 : Errors.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.19;

import { SD1x18 } from "./ValueType.sol";

/// @notice Thrown when trying to cast an SD1x18 number that doesn't fit in UD60x18.
error PRBMath_SD1x18_ToUD60x18_Underflow(SD1x18 x);

/// @notice Thrown when trying to cast an SD1x18 number that doesn't fit in uint128.
error PRBMath_SD1x18_ToUint128_Underflow(SD1x18 x);

/// @notice Thrown when trying to cast an SD1x18 number that doesn't fit in uint256.
error PRBMath_SD1x18_ToUint256_Underflow(SD1x18 x);

/// @notice Thrown when trying to cast an SD1x18 number that doesn't fit in uint40.
error PRBMath_SD1x18_ToUint40_Overflow(SD1x18 x);

/// @notice Thrown when trying to cast an SD1x18 number that doesn't fit in uint40.
error PRBMath_SD1x18_ToUint40_Underflow(SD1x18 x);

File 14 of 44 : ValueType.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.19;

import "./Casting.sol" as Casting;

/// @notice The signed 1.18-decimal fixed-point number representation, which can have up to 1 digit and up to 18
/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity
/// type int64. This is useful when end users want to use int64 to save gas, e.g. with tight variable packing in contract
/// storage.
type SD1x18 is int64;

/*//////////////////////////////////////////////////////////////////////////
                                    CASTING
//////////////////////////////////////////////////////////////////////////*/

using {
    Casting.intoSD59x18,
    Casting.intoUD60x18,
    Casting.intoUint128,
    Casting.intoUint256,
    Casting.intoUint40,
    Casting.unwrap
} for SD1x18 global;

File 15 of 44 : Casting.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.19;

import "../Common.sol" as Common;
import "./Errors.sol" as CastingErrors;
import { SD59x18 } from "../sd59x18/ValueType.sol";
import { UD60x18 } from "../ud60x18/ValueType.sol";
import { SD21x18 } from "./ValueType.sol";

/// @notice Casts an SD21x18 number into SD59x18.
/// @dev There is no overflow check because SD21x18 ⊆ SD59x18.
function intoSD59x18(SD21x18 x) pure returns (SD59x18 result) {
    result = SD59x18.wrap(int256(SD21x18.unwrap(x)));
}

/// @notice Casts an SD21x18 number into UD60x18.
/// @dev Requirements:
/// - x ≥ 0
function intoUD60x18(SD21x18 x) pure returns (UD60x18 result) {
    int128 xInt = SD21x18.unwrap(x);
    if (xInt < 0) {
        revert CastingErrors.PRBMath_SD21x18_ToUD60x18_Underflow(x);
    }
    result = UD60x18.wrap(uint128(xInt));
}

/// @notice Casts an SD21x18 number into uint128.
/// @dev Requirements:
/// - x ≥ 0
function intoUint128(SD21x18 x) pure returns (uint128 result) {
    int128 xInt = SD21x18.unwrap(x);
    if (xInt < 0) {
        revert CastingErrors.PRBMath_SD21x18_ToUint128_Underflow(x);
    }
    result = uint128(xInt);
}

/// @notice Casts an SD21x18 number into uint256.
/// @dev Requirements:
/// - x ≥ 0
function intoUint256(SD21x18 x) pure returns (uint256 result) {
    int128 xInt = SD21x18.unwrap(x);
    if (xInt < 0) {
        revert CastingErrors.PRBMath_SD21x18_ToUint256_Underflow(x);
    }
    result = uint256(uint128(xInt));
}

/// @notice Casts an SD21x18 number into uint40.
/// @dev Requirements:
/// - x ≥ 0
/// - x ≤ MAX_UINT40
function intoUint40(SD21x18 x) pure returns (uint40 result) {
    int128 xInt = SD21x18.unwrap(x);
    if (xInt < 0) {
        revert CastingErrors.PRBMath_SD21x18_ToUint40_Underflow(x);
    }
    if (xInt > int128(uint128(Common.MAX_UINT40))) {
        revert CastingErrors.PRBMath_SD21x18_ToUint40_Overflow(x);
    }
    result = uint40(uint128(xInt));
}

/// @notice Alias for {wrap}.
function sd21x18(int128 x) pure returns (SD21x18 result) {
    result = SD21x18.wrap(x);
}

/// @notice Unwraps an SD21x18 number into int128.
function unwrap(SD21x18 x) pure returns (int128 result) {
    result = SD21x18.unwrap(x);
}

/// @notice Wraps an int128 number into SD21x18.
function wrap(int128 x) pure returns (SD21x18 result) {
    result = SD21x18.wrap(x);
}

File 16 of 44 : Constants.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.19;

import { SD21x18 } from "./ValueType.sol";

/// @dev Euler's number as an SD21x18 number.
SD21x18 constant E = SD21x18.wrap(2_718281828459045235);

/// @dev The maximum value an SD21x18 number can have.
int128 constant uMAX_SD21x18 = 170141183460469231731_687303715884105727;
SD21x18 constant MAX_SD21x18 = SD21x18.wrap(uMAX_SD21x18);

/// @dev The minimum value an SD21x18 number can have.
int128 constant uMIN_SD21x18 = -170141183460469231731_687303715884105728;
SD21x18 constant MIN_SD21x18 = SD21x18.wrap(uMIN_SD21x18);

/// @dev PI as an SD21x18 number.
SD21x18 constant PI = SD21x18.wrap(3_141592653589793238);

/// @dev The unit number, which gives the decimal precision of SD21x18.
SD21x18 constant UNIT = SD21x18.wrap(1e18);
int128 constant uUNIT = 1e18;

File 17 of 44 : Errors.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.19;

import { SD21x18 } from "./ValueType.sol";

/// @notice Thrown when trying to cast an SD21x18 number that doesn't fit in uint128.
error PRBMath_SD21x18_ToUint128_Underflow(SD21x18 x);

/// @notice Thrown when trying to cast an SD21x18 number that doesn't fit in UD60x18.
error PRBMath_SD21x18_ToUD60x18_Underflow(SD21x18 x);

/// @notice Thrown when trying to cast an SD21x18 number that doesn't fit in uint256.
error PRBMath_SD21x18_ToUint256_Underflow(SD21x18 x);

/// @notice Thrown when trying to cast an SD21x18 number that doesn't fit in uint40.
error PRBMath_SD21x18_ToUint40_Overflow(SD21x18 x);

/// @notice Thrown when trying to cast an SD21x18 number that doesn't fit in uint40.
error PRBMath_SD21x18_ToUint40_Underflow(SD21x18 x);

File 18 of 44 : ValueType.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.19;

import "./Casting.sol" as Casting;

/// @notice The signed 21.18-decimal fixed-point number representation, which can have up to 21 digits and up to 18
/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity
/// type int128. This is useful when end users want to use int128 to save gas, e.g. with tight variable packing in contract
/// storage.
type SD21x18 is int128;

/*//////////////////////////////////////////////////////////////////////////
                                    CASTING
//////////////////////////////////////////////////////////////////////////*/

using {
    Casting.intoSD59x18,
    Casting.intoUD60x18,
    Casting.intoUint128,
    Casting.intoUint256,
    Casting.intoUint40,
    Casting.unwrap
} for SD21x18 global;

File 19 of 44 : SD59x18.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.19;

/*

██████╗ ██████╗ ██████╗ ███╗   ███╗ █████╗ ████████╗██╗  ██╗
██╔══██╗██╔══██╗██╔══██╗████╗ ████║██╔══██╗╚══██╔══╝██║  ██║
██████╔╝██████╔╝██████╔╝██╔████╔██║███████║   ██║   ███████║
██╔═══╝ ██╔══██╗██╔══██╗██║╚██╔╝██║██╔══██║   ██║   ██╔══██║
██║     ██║  ██║██████╔╝██║ ╚═╝ ██║██║  ██║   ██║   ██║  ██║
╚═╝     ╚═╝  ╚═╝╚═════╝ ╚═╝     ╚═╝╚═╝  ╚═╝   ╚═╝   ╚═╝  ╚═╝

███████╗██████╗ ███████╗ █████╗ ██╗  ██╗ ██╗ █████╗
██╔════╝██╔══██╗██╔════╝██╔══██╗╚██╗██╔╝███║██╔══██╗
███████╗██║  ██║███████╗╚██████║ ╚███╔╝ ╚██║╚█████╔╝
╚════██║██║  ██║╚════██║ ╚═══██║ ██╔██╗  ██║██╔══██╗
███████║██████╔╝███████║ █████╔╝██╔╝ ██╗ ██║╚█████╔╝
╚══════╝╚═════╝ ╚══════╝ ╚════╝ ╚═╝  ╚═╝ ╚═╝ ╚════╝

*/

import "./sd59x18/Casting.sol";
import "./sd59x18/Constants.sol";
import "./sd59x18/Conversions.sol";
import "./sd59x18/Errors.sol";
import "./sd59x18/Helpers.sol";
import "./sd59x18/Math.sol";
import "./sd59x18/ValueType.sol";

File 20 of 44 : Casting.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.19;

import "./Errors.sol" as CastingErrors;
import { MAX_UINT128, MAX_UINT40 } from "../Common.sol";
import { uMAX_SD1x18, uMIN_SD1x18 } from "../sd1x18/Constants.sol";
import { SD1x18 } from "../sd1x18/ValueType.sol";
import { uMAX_SD21x18, uMIN_SD21x18 } from "../sd21x18/Constants.sol";
import { SD21x18 } from "../sd21x18/ValueType.sol";
import { uMAX_UD2x18 } from "../ud2x18/Constants.sol";
import { UD2x18 } from "../ud2x18/ValueType.sol";
import { uMAX_UD21x18 } from "../ud21x18/Constants.sol";
import { UD21x18 } from "../ud21x18/ValueType.sol";
import { UD60x18 } from "../ud60x18/ValueType.sol";
import { SD59x18 } from "./ValueType.sol";

/// @notice Casts an SD59x18 number into int256.
/// @dev This is basically a functional alias for {unwrap}.
function intoInt256(SD59x18 x) pure returns (int256 result) {
    result = SD59x18.unwrap(x);
}

/// @notice Casts an SD59x18 number into SD1x18.
/// @dev Requirements:
/// - x ≥ uMIN_SD1x18
/// - x ≤ uMAX_SD1x18
function intoSD1x18(SD59x18 x) pure returns (SD1x18 result) {
    int256 xInt = SD59x18.unwrap(x);
    if (xInt < uMIN_SD1x18) {
        revert CastingErrors.PRBMath_SD59x18_IntoSD1x18_Underflow(x);
    }
    if (xInt > uMAX_SD1x18) {
        revert CastingErrors.PRBMath_SD59x18_IntoSD1x18_Overflow(x);
    }
    result = SD1x18.wrap(int64(xInt));
}

/// @notice Casts an SD59x18 number into SD21x18.
/// @dev Requirements:
/// - x ≥ uMIN_SD21x18
/// - x ≤ uMAX_SD21x18
function intoSD21x18(SD59x18 x) pure returns (SD21x18 result) {
    int256 xInt = SD59x18.unwrap(x);
    if (xInt < uMIN_SD21x18) {
        revert CastingErrors.PRBMath_SD59x18_IntoSD21x18_Underflow(x);
    }
    if (xInt > uMAX_SD21x18) {
        revert CastingErrors.PRBMath_SD59x18_IntoSD21x18_Overflow(x);
    }
    result = SD21x18.wrap(int128(xInt));
}

/// @notice Casts an SD59x18 number into UD2x18.
/// @dev Requirements:
/// - x ≥ 0
/// - x ≤ uMAX_UD2x18
function intoUD2x18(SD59x18 x) pure returns (UD2x18 result) {
    int256 xInt = SD59x18.unwrap(x);
    if (xInt < 0) {
        revert CastingErrors.PRBMath_SD59x18_IntoUD2x18_Underflow(x);
    }
    if (xInt > int256(uint256(uMAX_UD2x18))) {
        revert CastingErrors.PRBMath_SD59x18_IntoUD2x18_Overflow(x);
    }
    result = UD2x18.wrap(uint64(uint256(xInt)));
}

/// @notice Casts an SD59x18 number into UD21x18.
/// @dev Requirements:
/// - x ≥ 0
/// - x ≤ uMAX_UD21x18
function intoUD21x18(SD59x18 x) pure returns (UD21x18 result) {
    int256 xInt = SD59x18.unwrap(x);
    if (xInt < 0) {
        revert CastingErrors.PRBMath_SD59x18_IntoUD21x18_Underflow(x);
    }
    if (xInt > int256(uint256(uMAX_UD21x18))) {
        revert CastingErrors.PRBMath_SD59x18_IntoUD21x18_Overflow(x);
    }
    result = UD21x18.wrap(uint128(uint256(xInt)));
}

/// @notice Casts an SD59x18 number into UD60x18.
/// @dev Requirements:
/// - x ≥ 0
function intoUD60x18(SD59x18 x) pure returns (UD60x18 result) {
    int256 xInt = SD59x18.unwrap(x);
    if (xInt < 0) {
        revert CastingErrors.PRBMath_SD59x18_IntoUD60x18_Underflow(x);
    }
    result = UD60x18.wrap(uint256(xInt));
}

/// @notice Casts an SD59x18 number into uint256.
/// @dev Requirements:
/// - x ≥ 0
function intoUint256(SD59x18 x) pure returns (uint256 result) {
    int256 xInt = SD59x18.unwrap(x);
    if (xInt < 0) {
        revert CastingErrors.PRBMath_SD59x18_IntoUint256_Underflow(x);
    }
    result = uint256(xInt);
}

/// @notice Casts an SD59x18 number into uint128.
/// @dev Requirements:
/// - x ≥ 0
/// - x ≤ uMAX_UINT128
function intoUint128(SD59x18 x) pure returns (uint128 result) {
    int256 xInt = SD59x18.unwrap(x);
    if (xInt < 0) {
        revert CastingErrors.PRBMath_SD59x18_IntoUint128_Underflow(x);
    }
    if (xInt > int256(uint256(MAX_UINT128))) {
        revert CastingErrors.PRBMath_SD59x18_IntoUint128_Overflow(x);
    }
    result = uint128(uint256(xInt));
}

/// @notice Casts an SD59x18 number into uint40.
/// @dev Requirements:
/// - x ≥ 0
/// - x ≤ MAX_UINT40
function intoUint40(SD59x18 x) pure returns (uint40 result) {
    int256 xInt = SD59x18.unwrap(x);
    if (xInt < 0) {
        revert CastingErrors.PRBMath_SD59x18_IntoUint40_Underflow(x);
    }
    if (xInt > int256(uint256(MAX_UINT40))) {
        revert CastingErrors.PRBMath_SD59x18_IntoUint40_Overflow(x);
    }
    result = uint40(uint256(xInt));
}

/// @notice Alias for {wrap}.
function sd(int256 x) pure returns (SD59x18 result) {
    result = SD59x18.wrap(x);
}

/// @notice Alias for {wrap}.
function sd59x18(int256 x) pure returns (SD59x18 result) {
    result = SD59x18.wrap(x);
}

/// @notice Unwraps an SD59x18 number into int256.
function unwrap(SD59x18 x) pure returns (int256 result) {
    result = SD59x18.unwrap(x);
}

/// @notice Wraps an int256 number into SD59x18.
function wrap(int256 x) pure returns (SD59x18 result) {
    result = SD59x18.wrap(x);
}

File 21 of 44 : Constants.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.19;

import { SD59x18 } from "./ValueType.sol";

// NOTICE: the "u" prefix stands for "unwrapped".

/// @dev Euler's number as an SD59x18 number.
SD59x18 constant E = SD59x18.wrap(2_718281828459045235);

/// @dev The maximum input permitted in {exp}.
int256 constant uEXP_MAX_INPUT = 133_084258667509499440;
SD59x18 constant EXP_MAX_INPUT = SD59x18.wrap(uEXP_MAX_INPUT);

/// @dev Any value less than this returns 0 in {exp}.
int256 constant uEXP_MIN_THRESHOLD = -41_446531673892822322;
SD59x18 constant EXP_MIN_THRESHOLD = SD59x18.wrap(uEXP_MIN_THRESHOLD);

/// @dev The maximum input permitted in {exp2}.
int256 constant uEXP2_MAX_INPUT = 192e18 - 1;
SD59x18 constant EXP2_MAX_INPUT = SD59x18.wrap(uEXP2_MAX_INPUT);

/// @dev Any value less than this returns 0 in {exp2}.
int256 constant uEXP2_MIN_THRESHOLD = -59_794705707972522261;
SD59x18 constant EXP2_MIN_THRESHOLD = SD59x18.wrap(uEXP2_MIN_THRESHOLD);

/// @dev Half the UNIT number.
int256 constant uHALF_UNIT = 0.5e18;
SD59x18 constant HALF_UNIT = SD59x18.wrap(uHALF_UNIT);

/// @dev $log_2(10)$ as an SD59x18 number.
int256 constant uLOG2_10 = 3_321928094887362347;
SD59x18 constant LOG2_10 = SD59x18.wrap(uLOG2_10);

/// @dev $log_2(e)$ as an SD59x18 number.
int256 constant uLOG2_E = 1_442695040888963407;
SD59x18 constant LOG2_E = SD59x18.wrap(uLOG2_E);

/// @dev The maximum value an SD59x18 number can have.
int256 constant uMAX_SD59x18 = 57896044618658097711785492504343953926634992332820282019728_792003956564819967;
SD59x18 constant MAX_SD59x18 = SD59x18.wrap(uMAX_SD59x18);

/// @dev The maximum whole value an SD59x18 number can have.
int256 constant uMAX_WHOLE_SD59x18 = 57896044618658097711785492504343953926634992332820282019728_000000000000000000;
SD59x18 constant MAX_WHOLE_SD59x18 = SD59x18.wrap(uMAX_WHOLE_SD59x18);

/// @dev The minimum value an SD59x18 number can have.
int256 constant uMIN_SD59x18 = -57896044618658097711785492504343953926634992332820282019728_792003956564819968;
SD59x18 constant MIN_SD59x18 = SD59x18.wrap(uMIN_SD59x18);

/// @dev The minimum whole value an SD59x18 number can have.
int256 constant uMIN_WHOLE_SD59x18 = -57896044618658097711785492504343953926634992332820282019728_000000000000000000;
SD59x18 constant MIN_WHOLE_SD59x18 = SD59x18.wrap(uMIN_WHOLE_SD59x18);

/// @dev PI as an SD59x18 number.
SD59x18 constant PI = SD59x18.wrap(3_141592653589793238);

/// @dev The unit number, which gives the decimal precision of SD59x18.
int256 constant uUNIT = 1e18;
SD59x18 constant UNIT = SD59x18.wrap(1e18);

/// @dev The unit number squared.
int256 constant uUNIT_SQUARED = 1e36;
SD59x18 constant UNIT_SQUARED = SD59x18.wrap(uUNIT_SQUARED);

/// @dev Zero as an SD59x18 number.
SD59x18 constant ZERO = SD59x18.wrap(0);

File 22 of 44 : Conversions.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.19;

import { uMAX_SD59x18, uMIN_SD59x18, uUNIT } from "./Constants.sol";
import { PRBMath_SD59x18_Convert_Overflow, PRBMath_SD59x18_Convert_Underflow } from "./Errors.sol";
import { SD59x18 } from "./ValueType.sol";

/// @notice Converts a simple integer to SD59x18 by multiplying it by `UNIT`.
///
/// @dev Requirements:
/// - x ≥ `MIN_SD59x18 / UNIT`
/// - x ≤ `MAX_SD59x18 / UNIT`
///
/// @param x The basic integer to convert.
/// @return result The same number converted to SD59x18.
function convert(int256 x) pure returns (SD59x18 result) {
    if (x < uMIN_SD59x18 / uUNIT) {
        revert PRBMath_SD59x18_Convert_Underflow(x);
    }
    if (x > uMAX_SD59x18 / uUNIT) {
        revert PRBMath_SD59x18_Convert_Overflow(x);
    }
    unchecked {
        result = SD59x18.wrap(x * uUNIT);
    }
}

/// @notice Converts an SD59x18 number to a simple integer by dividing it by `UNIT`.
/// @dev The result is rounded toward zero.
/// @param x The SD59x18 number to convert.
/// @return result The same number as a simple integer.
function convert(SD59x18 x) pure returns (int256 result) {
    result = SD59x18.unwrap(x) / uUNIT;
}

File 23 of 44 : Errors.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.19;

import { SD59x18 } from "./ValueType.sol";

/// @notice Thrown when taking the absolute value of `MIN_SD59x18`.
error PRBMath_SD59x18_Abs_MinSD59x18();

/// @notice Thrown when ceiling a number overflows SD59x18.
error PRBMath_SD59x18_Ceil_Overflow(SD59x18 x);

/// @notice Thrown when converting a basic integer to the fixed-point format overflows SD59x18.
error PRBMath_SD59x18_Convert_Overflow(int256 x);

/// @notice Thrown when converting a basic integer to the fixed-point format underflows SD59x18.
error PRBMath_SD59x18_Convert_Underflow(int256 x);

/// @notice Thrown when dividing two numbers and one of them is `MIN_SD59x18`.
error PRBMath_SD59x18_Div_InputTooSmall();

/// @notice Thrown when dividing two numbers and one of the intermediary unsigned results overflows SD59x18.
error PRBMath_SD59x18_Div_Overflow(SD59x18 x, SD59x18 y);

/// @notice Thrown when taking the natural exponent of a base greater than 133_084258667509499441.
error PRBMath_SD59x18_Exp_InputTooBig(SD59x18 x);

/// @notice Thrown when taking the binary exponent of a base greater than 192e18.
error PRBMath_SD59x18_Exp2_InputTooBig(SD59x18 x);

/// @notice Thrown when flooring a number underflows SD59x18.
error PRBMath_SD59x18_Floor_Underflow(SD59x18 x);

/// @notice Thrown when taking the geometric mean of two numbers and their product is negative.
error PRBMath_SD59x18_Gm_NegativeProduct(SD59x18 x, SD59x18 y);

/// @notice Thrown when taking the geometric mean of two numbers and multiplying them overflows SD59x18.
error PRBMath_SD59x18_Gm_Overflow(SD59x18 x, SD59x18 y);

/// @notice Thrown when trying to cast an SD59x18 number that doesn't fit in SD1x18.
error PRBMath_SD59x18_IntoSD1x18_Overflow(SD59x18 x);

/// @notice Thrown when trying to cast an SD59x18 number that doesn't fit in SD1x18.
error PRBMath_SD59x18_IntoSD1x18_Underflow(SD59x18 x);

/// @notice Thrown when trying to cast an SD59x18 number that doesn't fit in SD21x18.
error PRBMath_SD59x18_IntoSD21x18_Overflow(SD59x18 x);

/// @notice Thrown when trying to cast an SD59x18 number that doesn't fit in SD21x18.
error PRBMath_SD59x18_IntoSD21x18_Underflow(SD59x18 x);

/// @notice Thrown when trying to cast an SD59x18 number that doesn't fit in UD2x18.
error PRBMath_SD59x18_IntoUD2x18_Overflow(SD59x18 x);

/// @notice Thrown when trying to cast an SD59x18 number that doesn't fit in UD2x18.
error PRBMath_SD59x18_IntoUD2x18_Underflow(SD59x18 x);

/// @notice Thrown when trying to cast an SD59x18 number that doesn't fit in UD21x18.
error PRBMath_SD59x18_IntoUD21x18_Overflow(SD59x18 x);

/// @notice Thrown when trying to cast an SD59x18 number that doesn't fit in UD21x18.
error PRBMath_SD59x18_IntoUD21x18_Underflow(SD59x18 x);

/// @notice Thrown when trying to cast an SD59x18 number that doesn't fit in UD60x18.
error PRBMath_SD59x18_IntoUD60x18_Underflow(SD59x18 x);

/// @notice Thrown when trying to cast an SD59x18 number that doesn't fit in uint128.
error PRBMath_SD59x18_IntoUint128_Overflow(SD59x18 x);

/// @notice Thrown when trying to cast an SD59x18 number that doesn't fit in uint128.
error PRBMath_SD59x18_IntoUint128_Underflow(SD59x18 x);

/// @notice Thrown when trying to cast an SD59x18 number that doesn't fit in uint256.
error PRBMath_SD59x18_IntoUint256_Underflow(SD59x18 x);

/// @notice Thrown when trying to cast an SD59x18 number that doesn't fit in uint40.
error PRBMath_SD59x18_IntoUint40_Overflow(SD59x18 x);

/// @notice Thrown when trying to cast an SD59x18 number that doesn't fit in uint40.
error PRBMath_SD59x18_IntoUint40_Underflow(SD59x18 x);

/// @notice Thrown when taking the logarithm of a number less than or equal to zero.
error PRBMath_SD59x18_Log_InputTooSmall(SD59x18 x);

/// @notice Thrown when multiplying two numbers and one of the inputs is `MIN_SD59x18`.
error PRBMath_SD59x18_Mul_InputTooSmall();

/// @notice Thrown when multiplying two numbers and the intermediary absolute result overflows SD59x18.
error PRBMath_SD59x18_Mul_Overflow(SD59x18 x, SD59x18 y);

/// @notice Thrown when raising a number to a power and the intermediary absolute result overflows SD59x18.
error PRBMath_SD59x18_Powu_Overflow(SD59x18 x, uint256 y);

/// @notice Thrown when taking the square root of a negative number.
error PRBMath_SD59x18_Sqrt_NegativeInput(SD59x18 x);

/// @notice Thrown when the calculating the square root overflows SD59x18.
error PRBMath_SD59x18_Sqrt_Overflow(SD59x18 x);

File 24 of 44 : Helpers.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.19;

import { wrap } from "./Casting.sol";
import { SD59x18 } from "./ValueType.sol";

/// @notice Implements the checked addition operation (+) in the SD59x18 type.
function add(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {
    return wrap(x.unwrap() + y.unwrap());
}

/// @notice Implements the AND (&) bitwise operation in the SD59x18 type.
function and(SD59x18 x, int256 bits) pure returns (SD59x18 result) {
    return wrap(x.unwrap() & bits);
}

/// @notice Implements the AND (&) bitwise operation in the SD59x18 type.
function and2(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {
    return wrap(x.unwrap() & y.unwrap());
}

/// @notice Implements the equal (=) operation in the SD59x18 type.
function eq(SD59x18 x, SD59x18 y) pure returns (bool result) {
    result = x.unwrap() == y.unwrap();
}

/// @notice Implements the greater than operation (>) in the SD59x18 type.
function gt(SD59x18 x, SD59x18 y) pure returns (bool result) {
    result = x.unwrap() > y.unwrap();
}

/// @notice Implements the greater than or equal to operation (>=) in the SD59x18 type.
function gte(SD59x18 x, SD59x18 y) pure returns (bool result) {
    result = x.unwrap() >= y.unwrap();
}

/// @notice Implements a zero comparison check function in the SD59x18 type.
function isZero(SD59x18 x) pure returns (bool result) {
    result = x.unwrap() == 0;
}

/// @notice Implements the left shift operation (<<) in the SD59x18 type.
function lshift(SD59x18 x, uint256 bits) pure returns (SD59x18 result) {
    result = wrap(x.unwrap() << bits);
}

/// @notice Implements the lower than operation (<) in the SD59x18 type.
function lt(SD59x18 x, SD59x18 y) pure returns (bool result) {
    result = x.unwrap() < y.unwrap();
}

/// @notice Implements the lower than or equal to operation (<=) in the SD59x18 type.
function lte(SD59x18 x, SD59x18 y) pure returns (bool result) {
    result = x.unwrap() <= y.unwrap();
}

/// @notice Implements the unchecked modulo operation (%) in the SD59x18 type.
function mod(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {
    result = wrap(x.unwrap() % y.unwrap());
}

/// @notice Implements the not equal operation (!=) in the SD59x18 type.
function neq(SD59x18 x, SD59x18 y) pure returns (bool result) {
    result = x.unwrap() != y.unwrap();
}

/// @notice Implements the NOT (~) bitwise operation in the SD59x18 type.
function not(SD59x18 x) pure returns (SD59x18 result) {
    result = wrap(~x.unwrap());
}

/// @notice Implements the OR (|) bitwise operation in the SD59x18 type.
function or(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {
    result = wrap(x.unwrap() | y.unwrap());
}

/// @notice Implements the right shift operation (>>) in the SD59x18 type.
function rshift(SD59x18 x, uint256 bits) pure returns (SD59x18 result) {
    result = wrap(x.unwrap() >> bits);
}

/// @notice Implements the checked subtraction operation (-) in the SD59x18 type.
function sub(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {
    result = wrap(x.unwrap() - y.unwrap());
}

/// @notice Implements the checked unary minus operation (-) in the SD59x18 type.
function unary(SD59x18 x) pure returns (SD59x18 result) {
    result = wrap(-x.unwrap());
}

/// @notice Implements the unchecked addition operation (+) in the SD59x18 type.
function uncheckedAdd(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {
    unchecked {
        result = wrap(x.unwrap() + y.unwrap());
    }
}

/// @notice Implements the unchecked subtraction operation (-) in the SD59x18 type.
function uncheckedSub(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {
    unchecked {
        result = wrap(x.unwrap() - y.unwrap());
    }
}

/// @notice Implements the unchecked unary minus operation (-) in the SD59x18 type.
function uncheckedUnary(SD59x18 x) pure returns (SD59x18 result) {
    unchecked {
        result = wrap(-x.unwrap());
    }
}

/// @notice Implements the XOR (^) bitwise operation in the SD59x18 type.
function xor(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {
    result = wrap(x.unwrap() ^ y.unwrap());
}

File 25 of 44 : Math.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.19;

import "../Common.sol" as Common;
import "./Errors.sol" as Errors;
import {
    uEXP_MAX_INPUT,
    uEXP2_MAX_INPUT,
    uEXP_MIN_THRESHOLD,
    uEXP2_MIN_THRESHOLD,
    uHALF_UNIT,
    uLOG2_10,
    uLOG2_E,
    uMAX_SD59x18,
    uMAX_WHOLE_SD59x18,
    uMIN_SD59x18,
    uMIN_WHOLE_SD59x18,
    UNIT,
    uUNIT,
    uUNIT_SQUARED,
    ZERO
} from "./Constants.sol";
import { wrap } from "./Helpers.sol";
import { SD59x18 } from "./ValueType.sol";

/// @notice Calculates the absolute value of x.
///
/// @dev Requirements:
/// - x > MIN_SD59x18.
///
/// @param x The SD59x18 number for which to calculate the absolute value.
/// @return result The absolute value of x as an SD59x18 number.
/// @custom:smtchecker abstract-function-nondet
function abs(SD59x18 x) pure returns (SD59x18 result) {
    int256 xInt = x.unwrap();
    if (xInt == uMIN_SD59x18) {
        revert Errors.PRBMath_SD59x18_Abs_MinSD59x18();
    }
    result = xInt < 0 ? wrap(-xInt) : x;
}

/// @notice Calculates the arithmetic average of x and y.
///
/// @dev Notes:
/// - The result is rounded toward zero.
///
/// @param x The first operand as an SD59x18 number.
/// @param y The second operand as an SD59x18 number.
/// @return result The arithmetic average as an SD59x18 number.
/// @custom:smtchecker abstract-function-nondet
function avg(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {
    int256 xInt = x.unwrap();
    int256 yInt = y.unwrap();

    unchecked {
        // This operation is equivalent to `x / 2 +  y / 2`, and it can never overflow.
        int256 sum = (xInt >> 1) + (yInt >> 1);

        if (sum < 0) {
            // If at least one of x and y is odd, add 1 to the result, because shifting negative numbers to the right
            // rounds toward negative infinity. The right part is equivalent to `sum + (x % 2 == 1 || y % 2 == 1)`.
            assembly ("memory-safe") {
                result := add(sum, and(or(xInt, yInt), 1))
            }
        } else {
            // Add 1 if both x and y are odd to account for the double 0.5 remainder truncated after shifting.
            result = wrap(sum + (xInt & yInt & 1));
        }
    }
}

/// @notice Yields the smallest whole number greater than or equal to x.
///
/// @dev Optimized for fractional value inputs, because every whole value has (1e18 - 1) fractional counterparts.
/// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.
///
/// Requirements:
/// - x ≤ MAX_WHOLE_SD59x18
///
/// @param x The SD59x18 number to ceil.
/// @return result The smallest whole number greater than or equal to x, as an SD59x18 number.
/// @custom:smtchecker abstract-function-nondet
function ceil(SD59x18 x) pure returns (SD59x18 result) {
    int256 xInt = x.unwrap();
    if (xInt > uMAX_WHOLE_SD59x18) {
        revert Errors.PRBMath_SD59x18_Ceil_Overflow(x);
    }

    int256 remainder = xInt % uUNIT;
    if (remainder == 0) {
        result = x;
    } else {
        unchecked {
            // Solidity uses C fmod style, which returns a modulus with the same sign as x.
            int256 resultInt = xInt - remainder;
            if (xInt > 0) {
                resultInt += uUNIT;
            }
            result = wrap(resultInt);
        }
    }
}

/// @notice Divides two SD59x18 numbers, returning a new SD59x18 number.
///
/// @dev This is an extension of {Common.mulDiv} for signed numbers, which works by computing the signs and the absolute
/// values separately.
///
/// Notes:
/// - Refer to the notes in {Common.mulDiv}.
/// - The result is rounded toward zero.
///
/// Requirements:
/// - Refer to the requirements in {Common.mulDiv}.
/// - None of the inputs can be `MIN_SD59x18`.
/// - The denominator must not be zero.
/// - The result must fit in SD59x18.
///
/// @param x The numerator as an SD59x18 number.
/// @param y The denominator as an SD59x18 number.
/// @return result The quotient as an SD59x18 number.
/// @custom:smtchecker abstract-function-nondet
function div(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {
    int256 xInt = x.unwrap();
    int256 yInt = y.unwrap();
    if (xInt == uMIN_SD59x18 || yInt == uMIN_SD59x18) {
        revert Errors.PRBMath_SD59x18_Div_InputTooSmall();
    }

    // Get hold of the absolute values of x and y.
    uint256 xAbs;
    uint256 yAbs;
    unchecked {
        xAbs = xInt < 0 ? uint256(-xInt) : uint256(xInt);
        yAbs = yInt < 0 ? uint256(-yInt) : uint256(yInt);
    }

    // Compute the absolute value (x*UNIT÷y). The resulting value must fit in SD59x18.
    uint256 resultAbs = Common.mulDiv(xAbs, uint256(uUNIT), yAbs);
    if (resultAbs > uint256(uMAX_SD59x18)) {
        revert Errors.PRBMath_SD59x18_Div_Overflow(x, y);
    }

    // Check if x and y have the same sign using two's complement representation. The left-most bit represents the sign (1 for
    // negative, 0 for positive or zero).
    bool sameSign = (xInt ^ yInt) > -1;

    // If the inputs have the same sign, the result should be positive. Otherwise, it should be negative.
    unchecked {
        result = wrap(sameSign ? int256(resultAbs) : -int256(resultAbs));
    }
}

/// @notice Calculates the natural exponent of x using the following formula:
///
/// $$
/// e^x = 2^{x * log_2{e}}
/// $$
///
/// @dev Notes:
/// - Refer to the notes in {exp2}.
///
/// Requirements:
/// - Refer to the requirements in {exp2}.
/// - x < 133_084258667509499441.
///
/// @param x The exponent as an SD59x18 number.
/// @return result The result as an SD59x18 number.
/// @custom:smtchecker abstract-function-nondet
function exp(SD59x18 x) pure returns (SD59x18 result) {
    int256 xInt = x.unwrap();

    // Any input less than the threshold returns zero.
    // This check also prevents an overflow for very small numbers.
    if (xInt < uEXP_MIN_THRESHOLD) {
        return ZERO;
    }

    // This check prevents values greater than 192e18 from being passed to {exp2}.
    if (xInt > uEXP_MAX_INPUT) {
        revert Errors.PRBMath_SD59x18_Exp_InputTooBig(x);
    }

    unchecked {
        // Inline the fixed-point multiplication to save gas.
        int256 doubleUnitProduct = xInt * uLOG2_E;
        result = exp2(wrap(doubleUnitProduct / uUNIT));
    }
}

/// @notice Calculates the binary exponent of x using the binary fraction method using the following formula:
///
/// $$
/// 2^{-x} = \frac{1}{2^x}
/// $$
///
/// @dev See https://ethereum.stackexchange.com/q/79903/24693.
///
/// Notes:
/// - If x < -59_794705707972522261, the result is zero.
///
/// Requirements:
/// - x < 192e18.
/// - The result must fit in SD59x18.
///
/// @param x The exponent as an SD59x18 number.
/// @return result The result as an SD59x18 number.
/// @custom:smtchecker abstract-function-nondet
function exp2(SD59x18 x) pure returns (SD59x18 result) {
    int256 xInt = x.unwrap();
    if (xInt < 0) {
        // The inverse of any number less than the threshold is truncated to zero.
        if (xInt < uEXP2_MIN_THRESHOLD) {
            return ZERO;
        }

        unchecked {
            // Inline the fixed-point inversion to save gas.
            result = wrap(uUNIT_SQUARED / exp2(wrap(-xInt)).unwrap());
        }
    } else {
        // Numbers greater than or equal to 192e18 don't fit in the 192.64-bit format.
        if (xInt > uEXP2_MAX_INPUT) {
            revert Errors.PRBMath_SD59x18_Exp2_InputTooBig(x);
        }

        unchecked {
            // Convert x to the 192.64-bit fixed-point format.
            uint256 x_192x64 = uint256((xInt << 64) / uUNIT);

            // It is safe to cast the result to int256 due to the checks above.
            result = wrap(int256(Common.exp2(x_192x64)));
        }
    }
}

/// @notice Yields the greatest whole number less than or equal to x.
///
/// @dev Optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional
/// counterparts. See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.
///
/// Requirements:
/// - x ≥ MIN_WHOLE_SD59x18
///
/// @param x The SD59x18 number to floor.
/// @return result The greatest whole number less than or equal to x, as an SD59x18 number.
/// @custom:smtchecker abstract-function-nondet
function floor(SD59x18 x) pure returns (SD59x18 result) {
    int256 xInt = x.unwrap();
    if (xInt < uMIN_WHOLE_SD59x18) {
        revert Errors.PRBMath_SD59x18_Floor_Underflow(x);
    }

    int256 remainder = xInt % uUNIT;
    if (remainder == 0) {
        result = x;
    } else {
        unchecked {
            // Solidity uses C fmod style, which returns a modulus with the same sign as x.
            int256 resultInt = xInt - remainder;
            if (xInt < 0) {
                resultInt -= uUNIT;
            }
            result = wrap(resultInt);
        }
    }
}

/// @notice Yields the excess beyond the floor of x for positive numbers and the part of the number to the right.
/// of the radix point for negative numbers.
/// @dev Based on the odd function definition. https://en.wikipedia.org/wiki/Fractional_part
/// @param x The SD59x18 number to get the fractional part of.
/// @return result The fractional part of x as an SD59x18 number.
function frac(SD59x18 x) pure returns (SD59x18 result) {
    result = wrap(x.unwrap() % uUNIT);
}

/// @notice Calculates the geometric mean of x and y, i.e. $\sqrt{x * y}$.
///
/// @dev Notes:
/// - The result is rounded toward zero.
///
/// Requirements:
/// - x * y must fit in SD59x18.
/// - x * y must not be negative, since complex numbers are not supported.
///
/// @param x The first operand as an SD59x18 number.
/// @param y The second operand as an SD59x18 number.
/// @return result The result as an SD59x18 number.
/// @custom:smtchecker abstract-function-nondet
function gm(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {
    int256 xInt = x.unwrap();
    int256 yInt = y.unwrap();
    if (xInt == 0 || yInt == 0) {
        return ZERO;
    }

    unchecked {
        // Equivalent to `xy / x != y`. Checking for overflow this way is faster than letting Solidity do it.
        int256 xyInt = xInt * yInt;
        if (xyInt / xInt != yInt) {
            revert Errors.PRBMath_SD59x18_Gm_Overflow(x, y);
        }

        // The product must not be negative, since complex numbers are not supported.
        if (xyInt < 0) {
            revert Errors.PRBMath_SD59x18_Gm_NegativeProduct(x, y);
        }

        // We don't need to multiply the result by `UNIT` here because the x*y product picked up a factor of `UNIT`
        // during multiplication. See the comments in {Common.sqrt}.
        uint256 resultUint = Common.sqrt(uint256(xyInt));
        result = wrap(int256(resultUint));
    }
}

/// @notice Calculates the inverse of x.
///
/// @dev Notes:
/// - The result is rounded toward zero.
///
/// Requirements:
/// - x must not be zero.
///
/// @param x The SD59x18 number for which to calculate the inverse.
/// @return result The inverse as an SD59x18 number.
/// @custom:smtchecker abstract-function-nondet
function inv(SD59x18 x) pure returns (SD59x18 result) {
    result = wrap(uUNIT_SQUARED / x.unwrap());
}

/// @notice Calculates the natural logarithm of x using the following formula:
///
/// $$
/// ln{x} = log_2{x} / log_2{e}
/// $$
///
/// @dev Notes:
/// - Refer to the notes in {log2}.
/// - The precision isn't sufficiently fine-grained to return exactly `UNIT` when the input is `E`.
///
/// Requirements:
/// - Refer to the requirements in {log2}.
///
/// @param x The SD59x18 number for which to calculate the natural logarithm.
/// @return result The natural logarithm as an SD59x18 number.
/// @custom:smtchecker abstract-function-nondet
function ln(SD59x18 x) pure returns (SD59x18 result) {
    // Inline the fixed-point multiplication to save gas. This is overflow-safe because the maximum value that
    // {log2} can return is ~195_205294292027477728.
    result = wrap(log2(x).unwrap() * uUNIT / uLOG2_E);
}

/// @notice Calculates the common logarithm of x using the following formula:
///
/// $$
/// log_{10}{x} = log_2{x} / log_2{10}
/// $$
///
/// However, if x is an exact power of ten, a hard coded value is returned.
///
/// @dev Notes:
/// - Refer to the notes in {log2}.
///
/// Requirements:
/// - Refer to the requirements in {log2}.
///
/// @param x The SD59x18 number for which to calculate the common logarithm.
/// @return result The common logarithm as an SD59x18 number.
/// @custom:smtchecker abstract-function-nondet
function log10(SD59x18 x) pure returns (SD59x18 result) {
    int256 xInt = x.unwrap();
    if (xInt < 0) {
        revert Errors.PRBMath_SD59x18_Log_InputTooSmall(x);
    }

    // Note that the `mul` in this block is the standard multiplication operation, not {SD59x18.mul}.
    // prettier-ignore
    assembly ("memory-safe") {
        switch x
        case 1 { result := mul(uUNIT, sub(0, 18)) }
        case 10 { result := mul(uUNIT, sub(1, 18)) }
        case 100 { result := mul(uUNIT, sub(2, 18)) }
        case 1000 { result := mul(uUNIT, sub(3, 18)) }
        case 10000 { result := mul(uUNIT, sub(4, 18)) }
        case 100000 { result := mul(uUNIT, sub(5, 18)) }
        case 1000000 { result := mul(uUNIT, sub(6, 18)) }
        case 10000000 { result := mul(uUNIT, sub(7, 18)) }
        case 100000000 { result := mul(uUNIT, sub(8, 18)) }
        case 1000000000 { result := mul(uUNIT, sub(9, 18)) }
        case 10000000000 { result := mul(uUNIT, sub(10, 18)) }
        case 100000000000 { result := mul(uUNIT, sub(11, 18)) }
        case 1000000000000 { result := mul(uUNIT, sub(12, 18)) }
        case 10000000000000 { result := mul(uUNIT, sub(13, 18)) }
        case 100000000000000 { result := mul(uUNIT, sub(14, 18)) }
        case 1000000000000000 { result := mul(uUNIT, sub(15, 18)) }
        case 10000000000000000 { result := mul(uUNIT, sub(16, 18)) }
        case 100000000000000000 { result := mul(uUNIT, sub(17, 18)) }
        case 1000000000000000000 { result := 0 }
        case 10000000000000000000 { result := uUNIT }
        case 100000000000000000000 { result := mul(uUNIT, 2) }
        case 1000000000000000000000 { result := mul(uUNIT, 3) }
        case 10000000000000000000000 { result := mul(uUNIT, 4) }
        case 100000000000000000000000 { result := mul(uUNIT, 5) }
        case 1000000000000000000000000 { result := mul(uUNIT, 6) }
        case 10000000000000000000000000 { result := mul(uUNIT, 7) }
        case 100000000000000000000000000 { result := mul(uUNIT, 8) }
        case 1000000000000000000000000000 { result := mul(uUNIT, 9) }
        case 10000000000000000000000000000 { result := mul(uUNIT, 10) }
        case 100000000000000000000000000000 { result := mul(uUNIT, 11) }
        case 1000000000000000000000000000000 { result := mul(uUNIT, 12) }
        case 10000000000000000000000000000000 { result := mul(uUNIT, 13) }
        case 100000000000000000000000000000000 { result := mul(uUNIT, 14) }
        case 1000000000000000000000000000000000 { result := mul(uUNIT, 15) }
        case 10000000000000000000000000000000000 { result := mul(uUNIT, 16) }
        case 100000000000000000000000000000000000 { result := mul(uUNIT, 17) }
        case 1000000000000000000000000000000000000 { result := mul(uUNIT, 18) }
        case 10000000000000000000000000000000000000 { result := mul(uUNIT, 19) }
        case 100000000000000000000000000000000000000 { result := mul(uUNIT, 20) }
        case 1000000000000000000000000000000000000000 { result := mul(uUNIT, 21) }
        case 10000000000000000000000000000000000000000 { result := mul(uUNIT, 22) }
        case 100000000000000000000000000000000000000000 { result := mul(uUNIT, 23) }
        case 1000000000000000000000000000000000000000000 { result := mul(uUNIT, 24) }
        case 10000000000000000000000000000000000000000000 { result := mul(uUNIT, 25) }
        case 100000000000000000000000000000000000000000000 { result := mul(uUNIT, 26) }
        case 1000000000000000000000000000000000000000000000 { result := mul(uUNIT, 27) }
        case 10000000000000000000000000000000000000000000000 { result := mul(uUNIT, 28) }
        case 100000000000000000000000000000000000000000000000 { result := mul(uUNIT, 29) }
        case 1000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 30) }
        case 10000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 31) }
        case 100000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 32) }
        case 1000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 33) }
        case 10000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 34) }
        case 100000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 35) }
        case 1000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 36) }
        case 10000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 37) }
        case 100000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 38) }
        case 1000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 39) }
        case 10000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 40) }
        case 100000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 41) }
        case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 42) }
        case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 43) }
        case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 44) }
        case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 45) }
        case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 46) }
        case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 47) }
        case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 48) }
        case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 49) }
        case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 50) }
        case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 51) }
        case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 52) }
        case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 53) }
        case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 54) }
        case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 55) }
        case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 56) }
        case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 57) }
        case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 58) }
        default { result := uMAX_SD59x18 }
    }

    if (result.unwrap() == uMAX_SD59x18) {
        unchecked {
            // Inline the fixed-point division to save gas.
            result = wrap(log2(x).unwrap() * uUNIT / uLOG2_10);
        }
    }
}

/// @notice Calculates the binary logarithm of x using the iterative approximation algorithm:
///
/// $$
/// log_2{x} = n + log_2{y}, \text{ where } y = x*2^{-n}, \ y \in [1, 2)
/// $$
///
/// For $0 \leq x \lt 1$, the input is inverted:
///
/// $$
/// log_2{x} = -log_2{\frac{1}{x}}
/// $$
///
/// @dev See https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation.
///
/// Notes:
/// - Due to the lossy precision of the iterative approximation, the results are not perfectly accurate to the last decimal.
///
/// Requirements:
/// - x > 0
///
/// @param x The SD59x18 number for which to calculate the binary logarithm.
/// @return result The binary logarithm as an SD59x18 number.
/// @custom:smtchecker abstract-function-nondet
function log2(SD59x18 x) pure returns (SD59x18 result) {
    int256 xInt = x.unwrap();
    if (xInt <= 0) {
        revert Errors.PRBMath_SD59x18_Log_InputTooSmall(x);
    }

    unchecked {
        int256 sign;
        if (xInt >= uUNIT) {
            sign = 1;
        } else {
            sign = -1;
            // Inline the fixed-point inversion to save gas.
            xInt = uUNIT_SQUARED / xInt;
        }

        // Calculate the integer part of the logarithm.
        uint256 n = Common.msb(uint256(xInt / uUNIT));

        // This is the integer part of the logarithm as an SD59x18 number. The operation can't overflow
        // because n is at most 255, `UNIT` is 1e18, and the sign is either 1 or -1.
        int256 resultInt = int256(n) * uUNIT;

        // Calculate $y = x * 2^{-n}$.
        int256 y = xInt >> n;

        // If y is the unit number, the fractional part is zero.
        if (y == uUNIT) {
            return wrap(resultInt * sign);
        }

        // Calculate the fractional part via the iterative approximation.
        // The `delta >>= 1` part is equivalent to `delta /= 2`, but shifting bits is more gas efficient.
        int256 DOUBLE_UNIT = 2e18;
        for (int256 delta = uHALF_UNIT; delta > 0; delta >>= 1) {
            y = (y * y) / uUNIT;

            // Is y^2 >= 2e18 and so in the range [2e18, 4e18)?
            if (y >= DOUBLE_UNIT) {
                // Add the 2^{-m} factor to the logarithm.
                resultInt = resultInt + delta;

                // Halve y, which corresponds to z/2 in the Wikipedia article.
                y >>= 1;
            }
        }
        resultInt *= sign;
        result = wrap(resultInt);
    }
}

/// @notice Multiplies two SD59x18 numbers together, returning a new SD59x18 number.
///
/// @dev Notes:
/// - Refer to the notes in {Common.mulDiv18}.
///
/// Requirements:
/// - Refer to the requirements in {Common.mulDiv18}.
/// - None of the inputs can be `MIN_SD59x18`.
/// - The result must fit in SD59x18.
///
/// @param x The multiplicand as an SD59x18 number.
/// @param y The multiplier as an SD59x18 number.
/// @return result The product as an SD59x18 number.
/// @custom:smtchecker abstract-function-nondet
function mul(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {
    int256 xInt = x.unwrap();
    int256 yInt = y.unwrap();
    if (xInt == uMIN_SD59x18 || yInt == uMIN_SD59x18) {
        revert Errors.PRBMath_SD59x18_Mul_InputTooSmall();
    }

    // Get hold of the absolute values of x and y.
    uint256 xAbs;
    uint256 yAbs;
    unchecked {
        xAbs = xInt < 0 ? uint256(-xInt) : uint256(xInt);
        yAbs = yInt < 0 ? uint256(-yInt) : uint256(yInt);
    }

    // Compute the absolute value (x*y÷UNIT). The resulting value must fit in SD59x18.
    uint256 resultAbs = Common.mulDiv18(xAbs, yAbs);
    if (resultAbs > uint256(uMAX_SD59x18)) {
        revert Errors.PRBMath_SD59x18_Mul_Overflow(x, y);
    }

    // Check if x and y have the same sign using two's complement representation. The left-most bit represents the sign (1 for
    // negative, 0 for positive or zero).
    bool sameSign = (xInt ^ yInt) > -1;

    // If the inputs have the same sign, the result should be positive. Otherwise, it should be negative.
    unchecked {
        result = wrap(sameSign ? int256(resultAbs) : -int256(resultAbs));
    }
}

/// @notice Raises x to the power of y using the following formula:
///
/// $$
/// x^y = 2^{log_2{x} * y}
/// $$
///
/// @dev Notes:
/// - Refer to the notes in {exp2}, {log2}, and {mul}.
/// - Returns `UNIT` for 0^0.
///
/// Requirements:
/// - Refer to the requirements in {exp2}, {log2}, and {mul}.
///
/// @param x The base as an SD59x18 number.
/// @param y Exponent to raise x to, as an SD59x18 number
/// @return result x raised to power y, as an SD59x18 number.
/// @custom:smtchecker abstract-function-nondet
function pow(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {
    int256 xInt = x.unwrap();
    int256 yInt = y.unwrap();

    // If both x and y are zero, the result is `UNIT`. If just x is zero, the result is always zero.
    if (xInt == 0) {
        return yInt == 0 ? UNIT : ZERO;
    }
    // If x is `UNIT`, the result is always `UNIT`.
    else if (xInt == uUNIT) {
        return UNIT;
    }

    // If y is zero, the result is always `UNIT`.
    if (yInt == 0) {
        return UNIT;
    }
    // If y is `UNIT`, the result is always x.
    else if (yInt == uUNIT) {
        return x;
    }

    // Calculate the result using the formula.
    result = exp2(mul(log2(x), y));
}

/// @notice Raises x (an SD59x18 number) to the power y (an unsigned basic integer) using the well-known
/// algorithm "exponentiation by squaring".
///
/// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring.
///
/// Notes:
/// - Refer to the notes in {Common.mulDiv18}.
/// - Returns `UNIT` for 0^0.
///
/// Requirements:
/// - Refer to the requirements in {abs} and {Common.mulDiv18}.
/// - The result must fit in SD59x18.
///
/// @param x The base as an SD59x18 number.
/// @param y The exponent as a uint256.
/// @return result The result as an SD59x18 number.
/// @custom:smtchecker abstract-function-nondet
function powu(SD59x18 x, uint256 y) pure returns (SD59x18 result) {
    uint256 xAbs = uint256(abs(x).unwrap());

    // Calculate the first iteration of the loop in advance.
    uint256 resultAbs = y & 1 > 0 ? xAbs : uint256(uUNIT);

    // Equivalent to `for(y /= 2; y > 0; y /= 2)`.
    uint256 yAux = y;
    for (yAux >>= 1; yAux > 0; yAux >>= 1) {
        xAbs = Common.mulDiv18(xAbs, xAbs);

        // Equivalent to `y % 2 == 1`.
        if (yAux & 1 > 0) {
            resultAbs = Common.mulDiv18(resultAbs, xAbs);
        }
    }

    // The result must fit in SD59x18.
    if (resultAbs > uint256(uMAX_SD59x18)) {
        revert Errors.PRBMath_SD59x18_Powu_Overflow(x, y);
    }

    unchecked {
        // Is the base negative and the exponent odd? If yes, the result should be negative.
        int256 resultInt = int256(resultAbs);
        bool isNegative = x.unwrap() < 0 && y & 1 == 1;
        if (isNegative) {
            resultInt = -resultInt;
        }
        result = wrap(resultInt);
    }
}

/// @notice Calculates the square root of x using the Babylonian method.
///
/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.
///
/// Notes:
/// - Only the positive root is returned.
/// - The result is rounded toward zero.
///
/// Requirements:
/// - x ≥ 0, since complex numbers are not supported.
/// - x ≤ MAX_SD59x18 / UNIT
///
/// @param x The SD59x18 number for which to calculate the square root.
/// @return result The result as an SD59x18 number.
/// @custom:smtchecker abstract-function-nondet
function sqrt(SD59x18 x) pure returns (SD59x18 result) {
    int256 xInt = x.unwrap();
    if (xInt < 0) {
        revert Errors.PRBMath_SD59x18_Sqrt_NegativeInput(x);
    }
    if (xInt > uMAX_SD59x18 / uUNIT) {
        revert Errors.PRBMath_SD59x18_Sqrt_Overflow(x);
    }

    unchecked {
        // Multiply x by `UNIT` to account for the factor of `UNIT` picked up when multiplying two SD59x18 numbers.
        // In this case, the two numbers are both the square root.
        uint256 resultUint = Common.sqrt(uint256(xInt * uUNIT));
        result = wrap(int256(resultUint));
    }
}

File 26 of 44 : ValueType.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.19;

import "./Casting.sol" as Casting;
import "./Helpers.sol" as Helpers;
import "./Math.sol" as Math;

/// @notice The signed 59.18-decimal fixed-point number representation, which can have up to 59 digits and up to 18
/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity
/// type int256.
type SD59x18 is int256;

/*//////////////////////////////////////////////////////////////////////////
                                    CASTING
//////////////////////////////////////////////////////////////////////////*/

using {
    Casting.intoInt256,
    Casting.intoSD1x18,
    Casting.intoSD21x18,
    Casting.intoUD2x18,
    Casting.intoUD21x18,
    Casting.intoUD60x18,
    Casting.intoUint256,
    Casting.intoUint128,
    Casting.intoUint40,
    Casting.unwrap
} for SD59x18 global;

/*//////////////////////////////////////////////////////////////////////////
                            MATHEMATICAL FUNCTIONS
//////////////////////////////////////////////////////////////////////////*/

using {
    Math.abs,
    Math.avg,
    Math.ceil,
    Math.div,
    Math.exp,
    Math.exp2,
    Math.floor,
    Math.frac,
    Math.gm,
    Math.inv,
    Math.log10,
    Math.log2,
    Math.ln,
    Math.mul,
    Math.pow,
    Math.powu,
    Math.sqrt
} for SD59x18 global;

/*//////////////////////////////////////////////////////////////////////////
                                HELPER FUNCTIONS
//////////////////////////////////////////////////////////////////////////*/

using {
    Helpers.add,
    Helpers.and,
    Helpers.eq,
    Helpers.gt,
    Helpers.gte,
    Helpers.isZero,
    Helpers.lshift,
    Helpers.lt,
    Helpers.lte,
    Helpers.mod,
    Helpers.neq,
    Helpers.not,
    Helpers.or,
    Helpers.rshift,
    Helpers.sub,
    Helpers.uncheckedAdd,
    Helpers.uncheckedSub,
    Helpers.uncheckedUnary,
    Helpers.xor
} for SD59x18 global;

/*//////////////////////////////////////////////////////////////////////////
                                    OPERATORS
//////////////////////////////////////////////////////////////////////////*/

// The global "using for" directive makes it possible to use these operators on the SD59x18 type.
using {
    Helpers.add as +,
    Helpers.and2 as &,
    Math.div as /,
    Helpers.eq as ==,
    Helpers.gt as >,
    Helpers.gte as >=,
    Helpers.lt as <,
    Helpers.lte as <=,
    Helpers.mod as %,
    Math.mul as *,
    Helpers.neq as !=,
    Helpers.not as ~,
    Helpers.or as |,
    Helpers.sub as -,
    Helpers.unary as -,
    Helpers.xor as ^
} for SD59x18 global;

File 27 of 44 : Casting.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.19;

import "../Common.sol" as Common;
import "./Errors.sol" as Errors;
import { SD59x18 } from "../sd59x18/ValueType.sol";
import { UD60x18 } from "../ud60x18/ValueType.sol";
import { UD21x18 } from "./ValueType.sol";

/// @notice Casts a UD21x18 number into SD59x18.
/// @dev There is no overflow check because UD21x18 ⊆ SD59x18.
function intoSD59x18(UD21x18 x) pure returns (SD59x18 result) {
    result = SD59x18.wrap(int256(uint256(UD21x18.unwrap(x))));
}

/// @notice Casts a UD21x18 number into UD60x18.
/// @dev There is no overflow check because UD21x18 ⊆ UD60x18.
function intoUD60x18(UD21x18 x) pure returns (UD60x18 result) {
    result = UD60x18.wrap(UD21x18.unwrap(x));
}

/// @notice Casts a UD21x18 number into uint128.
/// @dev This is basically an alias for {unwrap}.
function intoUint128(UD21x18 x) pure returns (uint128 result) {
    result = UD21x18.unwrap(x);
}

/// @notice Casts a UD21x18 number into uint256.
/// @dev There is no overflow check because UD21x18 ⊆ uint256.
function intoUint256(UD21x18 x) pure returns (uint256 result) {
    result = uint256(UD21x18.unwrap(x));
}

/// @notice Casts a UD21x18 number into uint40.
/// @dev Requirements:
/// - x ≤ MAX_UINT40
function intoUint40(UD21x18 x) pure returns (uint40 result) {
    uint128 xUint = UD21x18.unwrap(x);
    if (xUint > uint128(Common.MAX_UINT40)) {
        revert Errors.PRBMath_UD21x18_IntoUint40_Overflow(x);
    }
    result = uint40(xUint);
}

/// @notice Alias for {wrap}.
function ud21x18(uint128 x) pure returns (UD21x18 result) {
    result = UD21x18.wrap(x);
}

/// @notice Unwrap a UD21x18 number into uint128.
function unwrap(UD21x18 x) pure returns (uint128 result) {
    result = UD21x18.unwrap(x);
}

/// @notice Wraps a uint128 number into UD21x18.
function wrap(uint128 x) pure returns (UD21x18 result) {
    result = UD21x18.wrap(x);
}

File 28 of 44 : Constants.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.19;

import { UD21x18 } from "./ValueType.sol";

/// @dev Euler's number as a UD21x18 number.
UD21x18 constant E = UD21x18.wrap(2_718281828459045235);

/// @dev The maximum value a UD21x18 number can have.
uint128 constant uMAX_UD21x18 = 340282366920938463463_374607431768211455;
UD21x18 constant MAX_UD21x18 = UD21x18.wrap(uMAX_UD21x18);

/// @dev PI as a UD21x18 number.
UD21x18 constant PI = UD21x18.wrap(3_141592653589793238);

/// @dev The unit number, which gives the decimal precision of UD21x18.
uint256 constant uUNIT = 1e18;
UD21x18 constant UNIT = UD21x18.wrap(1e18);

File 29 of 44 : Errors.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.19;

import { UD21x18 } from "./ValueType.sol";

/// @notice Thrown when trying to cast a UD21x18 number that doesn't fit in uint40.
error PRBMath_UD21x18_IntoUint40_Overflow(UD21x18 x);

File 30 of 44 : ValueType.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.19;

import "./Casting.sol" as Casting;

/// @notice The unsigned 21.18-decimal fixed-point number representation, which can have up to 21 digits and up to 18
/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity
/// type uint128. This is useful when end users want to use uint128 to save gas, e.g. with tight variable packing in contract
/// storage.
type UD21x18 is uint128;

/*//////////////////////////////////////////////////////////////////////////
                                    CASTING
//////////////////////////////////////////////////////////////////////////*/

using {
    Casting.intoSD59x18,
    Casting.intoUD60x18,
    Casting.intoUint128,
    Casting.intoUint256,
    Casting.intoUint40,
    Casting.unwrap
} for UD21x18 global;

File 31 of 44 : Casting.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.19;

import "../Common.sol" as Common;
import "./Errors.sol" as Errors;
import { SD59x18 } from "../sd59x18/ValueType.sol";
import { UD60x18 } from "../ud60x18/ValueType.sol";
import { UD2x18 } from "./ValueType.sol";

/// @notice Casts a UD2x18 number into SD59x18.
/// @dev There is no overflow check because UD2x18 ⊆ SD59x18.
function intoSD59x18(UD2x18 x) pure returns (SD59x18 result) {
    result = SD59x18.wrap(int256(uint256(UD2x18.unwrap(x))));
}

/// @notice Casts a UD2x18 number into UD60x18.
/// @dev There is no overflow check because UD2x18 ⊆ UD60x18.
function intoUD60x18(UD2x18 x) pure returns (UD60x18 result) {
    result = UD60x18.wrap(UD2x18.unwrap(x));
}

/// @notice Casts a UD2x18 number into uint128.
/// @dev There is no overflow check because UD2x18 ⊆ uint128.
function intoUint128(UD2x18 x) pure returns (uint128 result) {
    result = uint128(UD2x18.unwrap(x));
}

/// @notice Casts a UD2x18 number into uint256.
/// @dev There is no overflow check because UD2x18 ⊆ uint256.
function intoUint256(UD2x18 x) pure returns (uint256 result) {
    result = uint256(UD2x18.unwrap(x));
}

/// @notice Casts a UD2x18 number into uint40.
/// @dev Requirements:
/// - x ≤ MAX_UINT40
function intoUint40(UD2x18 x) pure returns (uint40 result) {
    uint64 xUint = UD2x18.unwrap(x);
    if (xUint > uint64(Common.MAX_UINT40)) {
        revert Errors.PRBMath_UD2x18_IntoUint40_Overflow(x);
    }
    result = uint40(xUint);
}

/// @notice Alias for {wrap}.
function ud2x18(uint64 x) pure returns (UD2x18 result) {
    result = UD2x18.wrap(x);
}

/// @notice Unwrap a UD2x18 number into uint64.
function unwrap(UD2x18 x) pure returns (uint64 result) {
    result = UD2x18.unwrap(x);
}

/// @notice Wraps a uint64 number into UD2x18.
function wrap(uint64 x) pure returns (UD2x18 result) {
    result = UD2x18.wrap(x);
}

File 32 of 44 : Constants.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.19;

import { UD2x18 } from "./ValueType.sol";

/// @dev Euler's number as a UD2x18 number.
UD2x18 constant E = UD2x18.wrap(2_718281828459045235);

/// @dev The maximum value a UD2x18 number can have.
uint64 constant uMAX_UD2x18 = 18_446744073709551615;
UD2x18 constant MAX_UD2x18 = UD2x18.wrap(uMAX_UD2x18);

/// @dev PI as a UD2x18 number.
UD2x18 constant PI = UD2x18.wrap(3_141592653589793238);

/// @dev The unit number, which gives the decimal precision of UD2x18.
UD2x18 constant UNIT = UD2x18.wrap(1e18);
uint64 constant uUNIT = 1e18;

File 33 of 44 : Errors.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.19;

import { UD2x18 } from "./ValueType.sol";

/// @notice Thrown when trying to cast a UD2x18 number that doesn't fit in uint40.
error PRBMath_UD2x18_IntoUint40_Overflow(UD2x18 x);

File 34 of 44 : ValueType.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.19;

import "./Casting.sol" as Casting;

/// @notice The unsigned 2.18-decimal fixed-point number representation, which can have up to 2 digits and up to 18
/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity
/// type uint64. This is useful when end users want to use uint64 to save gas, e.g. with tight variable packing in contract
/// storage.
type UD2x18 is uint64;

/*//////////////////////////////////////////////////////////////////////////
                                    CASTING
//////////////////////////////////////////////////////////////////////////*/

using {
    Casting.intoSD59x18,
    Casting.intoUD60x18,
    Casting.intoUint128,
    Casting.intoUint256,
    Casting.intoUint40,
    Casting.unwrap
} for UD2x18 global;

File 35 of 44 : Casting.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.19;

import "./Errors.sol" as CastingErrors;
import { MAX_UINT128, MAX_UINT40 } from "../Common.sol";
import { uMAX_SD1x18 } from "../sd1x18/Constants.sol";
import { SD1x18 } from "../sd1x18/ValueType.sol";
import { uMAX_SD21x18 } from "../sd21x18/Constants.sol";
import { SD21x18 } from "../sd21x18/ValueType.sol";
import { uMAX_SD59x18 } from "../sd59x18/Constants.sol";
import { SD59x18 } from "../sd59x18/ValueType.sol";
import { uMAX_UD2x18 } from "../ud2x18/Constants.sol";
import { uMAX_UD21x18 } from "../ud21x18/Constants.sol";
import { UD2x18 } from "../ud2x18/ValueType.sol";
import { UD21x18 } from "../ud21x18/ValueType.sol";
import { UD60x18 } from "./ValueType.sol";

/// @notice Casts a UD60x18 number into SD1x18.
/// @dev Requirements:
/// - x ≤ uMAX_SD1x18
function intoSD1x18(UD60x18 x) pure returns (SD1x18 result) {
    uint256 xUint = UD60x18.unwrap(x);
    if (xUint > uint256(int256(uMAX_SD1x18))) {
        revert CastingErrors.PRBMath_UD60x18_IntoSD1x18_Overflow(x);
    }
    result = SD1x18.wrap(int64(uint64(xUint)));
}

/// @notice Casts a UD60x18 number into SD21x18.
/// @dev Requirements:
/// - x ≤ uMAX_SD21x18
function intoSD21x18(UD60x18 x) pure returns (SD21x18 result) {
    uint256 xUint = UD60x18.unwrap(x);
    if (xUint > uint256(int256(uMAX_SD21x18))) {
        revert CastingErrors.PRBMath_UD60x18_IntoSD21x18_Overflow(x);
    }
    result = SD21x18.wrap(int128(uint128(xUint)));
}

/// @notice Casts a UD60x18 number into UD2x18.
/// @dev Requirements:
/// - x ≤ uMAX_UD2x18
function intoUD2x18(UD60x18 x) pure returns (UD2x18 result) {
    uint256 xUint = UD60x18.unwrap(x);
    if (xUint > uMAX_UD2x18) {
        revert CastingErrors.PRBMath_UD60x18_IntoUD2x18_Overflow(x);
    }
    result = UD2x18.wrap(uint64(xUint));
}

/// @notice Casts a UD60x18 number into UD21x18.
/// @dev Requirements:
/// - x ≤ uMAX_UD21x18
function intoUD21x18(UD60x18 x) pure returns (UD21x18 result) {
    uint256 xUint = UD60x18.unwrap(x);
    if (xUint > uMAX_UD21x18) {
        revert CastingErrors.PRBMath_UD60x18_IntoUD21x18_Overflow(x);
    }
    result = UD21x18.wrap(uint128(xUint));
}

/// @notice Casts a UD60x18 number into SD59x18.
/// @dev Requirements:
/// - x ≤ uMAX_SD59x18
function intoSD59x18(UD60x18 x) pure returns (SD59x18 result) {
    uint256 xUint = UD60x18.unwrap(x);
    if (xUint > uint256(uMAX_SD59x18)) {
        revert CastingErrors.PRBMath_UD60x18_IntoSD59x18_Overflow(x);
    }
    result = SD59x18.wrap(int256(xUint));
}

/// @notice Casts a UD60x18 number into uint128.
/// @dev This is basically an alias for {unwrap}.
function intoUint256(UD60x18 x) pure returns (uint256 result) {
    result = UD60x18.unwrap(x);
}

/// @notice Casts a UD60x18 number into uint128.
/// @dev Requirements:
/// - x ≤ MAX_UINT128
function intoUint128(UD60x18 x) pure returns (uint128 result) {
    uint256 xUint = UD60x18.unwrap(x);
    if (xUint > MAX_UINT128) {
        revert CastingErrors.PRBMath_UD60x18_IntoUint128_Overflow(x);
    }
    result = uint128(xUint);
}

/// @notice Casts a UD60x18 number into uint40.
/// @dev Requirements:
/// - x ≤ MAX_UINT40
function intoUint40(UD60x18 x) pure returns (uint40 result) {
    uint256 xUint = UD60x18.unwrap(x);
    if (xUint > MAX_UINT40) {
        revert CastingErrors.PRBMath_UD60x18_IntoUint40_Overflow(x);
    }
    result = uint40(xUint);
}

/// @notice Alias for {wrap}.
function ud(uint256 x) pure returns (UD60x18 result) {
    result = UD60x18.wrap(x);
}

/// @notice Alias for {wrap}.
function ud60x18(uint256 x) pure returns (UD60x18 result) {
    result = UD60x18.wrap(x);
}

/// @notice Unwraps a UD60x18 number into uint256.
function unwrap(UD60x18 x) pure returns (uint256 result) {
    result = UD60x18.unwrap(x);
}

/// @notice Wraps a uint256 number into the UD60x18 value type.
function wrap(uint256 x) pure returns (UD60x18 result) {
    result = UD60x18.wrap(x);
}

File 36 of 44 : Constants.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.19;

import { UD60x18 } from "./ValueType.sol";

// NOTICE: the "u" prefix stands for "unwrapped".

/// @dev Euler's number as a UD60x18 number.
UD60x18 constant E = UD60x18.wrap(2_718281828459045235);

/// @dev The maximum input permitted in {exp}.
uint256 constant uEXP_MAX_INPUT = 133_084258667509499440;
UD60x18 constant EXP_MAX_INPUT = UD60x18.wrap(uEXP_MAX_INPUT);

/// @dev The maximum input permitted in {exp2}.
uint256 constant uEXP2_MAX_INPUT = 192e18 - 1;
UD60x18 constant EXP2_MAX_INPUT = UD60x18.wrap(uEXP2_MAX_INPUT);

/// @dev Half the UNIT number.
uint256 constant uHALF_UNIT = 0.5e18;
UD60x18 constant HALF_UNIT = UD60x18.wrap(uHALF_UNIT);

/// @dev $log_2(10)$ as a UD60x18 number.
uint256 constant uLOG2_10 = 3_321928094887362347;
UD60x18 constant LOG2_10 = UD60x18.wrap(uLOG2_10);

/// @dev $log_2(e)$ as a UD60x18 number.
uint256 constant uLOG2_E = 1_442695040888963407;
UD60x18 constant LOG2_E = UD60x18.wrap(uLOG2_E);

/// @dev The maximum value a UD60x18 number can have.
uint256 constant uMAX_UD60x18 = 115792089237316195423570985008687907853269984665640564039457_584007913129639935;
UD60x18 constant MAX_UD60x18 = UD60x18.wrap(uMAX_UD60x18);

/// @dev The maximum whole value a UD60x18 number can have.
uint256 constant uMAX_WHOLE_UD60x18 = 115792089237316195423570985008687907853269984665640564039457_000000000000000000;
UD60x18 constant MAX_WHOLE_UD60x18 = UD60x18.wrap(uMAX_WHOLE_UD60x18);

/// @dev PI as a UD60x18 number.
UD60x18 constant PI = UD60x18.wrap(3_141592653589793238);

/// @dev The unit number, which gives the decimal precision of UD60x18.
uint256 constant uUNIT = 1e18;
UD60x18 constant UNIT = UD60x18.wrap(uUNIT);

/// @dev The unit number squared.
uint256 constant uUNIT_SQUARED = 1e36;
UD60x18 constant UNIT_SQUARED = UD60x18.wrap(uUNIT_SQUARED);

/// @dev Zero as a UD60x18 number.
UD60x18 constant ZERO = UD60x18.wrap(0);

File 37 of 44 : Errors.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.19;

import { UD60x18 } from "./ValueType.sol";

/// @notice Thrown when ceiling a number overflows UD60x18.
error PRBMath_UD60x18_Ceil_Overflow(UD60x18 x);

/// @notice Thrown when converting a basic integer to the fixed-point format overflows UD60x18.
error PRBMath_UD60x18_Convert_Overflow(uint256 x);

/// @notice Thrown when taking the natural exponent of a base greater than 133_084258667509499441.
error PRBMath_UD60x18_Exp_InputTooBig(UD60x18 x);

/// @notice Thrown when taking the binary exponent of a base greater than 192e18.
error PRBMath_UD60x18_Exp2_InputTooBig(UD60x18 x);

/// @notice Thrown when taking the geometric mean of two numbers and multiplying them overflows UD60x18.
error PRBMath_UD60x18_Gm_Overflow(UD60x18 x, UD60x18 y);

/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.
error PRBMath_UD60x18_IntoSD1x18_Overflow(UD60x18 x);

/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD21x18.
error PRBMath_UD60x18_IntoSD21x18_Overflow(UD60x18 x);

/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD59x18.
error PRBMath_UD60x18_IntoSD59x18_Overflow(UD60x18 x);

/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.
error PRBMath_UD60x18_IntoUD2x18_Overflow(UD60x18 x);

/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD21x18.
error PRBMath_UD60x18_IntoUD21x18_Overflow(UD60x18 x);

/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.
error PRBMath_UD60x18_IntoUint128_Overflow(UD60x18 x);

/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.
error PRBMath_UD60x18_IntoUint40_Overflow(UD60x18 x);

/// @notice Thrown when taking the logarithm of a number less than UNIT.
error PRBMath_UD60x18_Log_InputTooSmall(UD60x18 x);

/// @notice Thrown when calculating the square root overflows UD60x18.
error PRBMath_UD60x18_Sqrt_Overflow(UD60x18 x);

File 38 of 44 : Helpers.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.19;

import { wrap } from "./Casting.sol";
import { UD60x18 } from "./ValueType.sol";

/// @notice Implements the checked addition operation (+) in the UD60x18 type.
function add(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {
    result = wrap(x.unwrap() + y.unwrap());
}

/// @notice Implements the AND (&) bitwise operation in the UD60x18 type.
function and(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {
    result = wrap(x.unwrap() & bits);
}

/// @notice Implements the AND (&) bitwise operation in the UD60x18 type.
function and2(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {
    result = wrap(x.unwrap() & y.unwrap());
}

/// @notice Implements the equal operation (==) in the UD60x18 type.
function eq(UD60x18 x, UD60x18 y) pure returns (bool result) {
    result = x.unwrap() == y.unwrap();
}

/// @notice Implements the greater than operation (>) in the UD60x18 type.
function gt(UD60x18 x, UD60x18 y) pure returns (bool result) {
    result = x.unwrap() > y.unwrap();
}

/// @notice Implements the greater than or equal to operation (>=) in the UD60x18 type.
function gte(UD60x18 x, UD60x18 y) pure returns (bool result) {
    result = x.unwrap() >= y.unwrap();
}

/// @notice Implements a zero comparison check function in the UD60x18 type.
function isZero(UD60x18 x) pure returns (bool result) {
    // This wouldn't work if x could be negative.
    result = x.unwrap() == 0;
}

/// @notice Implements the left shift operation (<<) in the UD60x18 type.
function lshift(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {
    result = wrap(x.unwrap() << bits);
}

/// @notice Implements the lower than operation (<) in the UD60x18 type.
function lt(UD60x18 x, UD60x18 y) pure returns (bool result) {
    result = x.unwrap() < y.unwrap();
}

/// @notice Implements the lower than or equal to operation (<=) in the UD60x18 type.
function lte(UD60x18 x, UD60x18 y) pure returns (bool result) {
    result = x.unwrap() <= y.unwrap();
}

/// @notice Implements the checked modulo operation (%) in the UD60x18 type.
function mod(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {
    result = wrap(x.unwrap() % y.unwrap());
}

/// @notice Implements the not equal operation (!=) in the UD60x18 type.
function neq(UD60x18 x, UD60x18 y) pure returns (bool result) {
    result = x.unwrap() != y.unwrap();
}

/// @notice Implements the NOT (~) bitwise operation in the UD60x18 type.
function not(UD60x18 x) pure returns (UD60x18 result) {
    result = wrap(~x.unwrap());
}

/// @notice Implements the OR (|) bitwise operation in the UD60x18 type.
function or(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {
    result = wrap(x.unwrap() | y.unwrap());
}

/// @notice Implements the right shift operation (>>) in the UD60x18 type.
function rshift(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {
    result = wrap(x.unwrap() >> bits);
}

/// @notice Implements the checked subtraction operation (-) in the UD60x18 type.
function sub(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {
    result = wrap(x.unwrap() - y.unwrap());
}

/// @notice Implements the unchecked addition operation (+) in the UD60x18 type.
function uncheckedAdd(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {
    unchecked {
        result = wrap(x.unwrap() + y.unwrap());
    }
}

/// @notice Implements the unchecked subtraction operation (-) in the UD60x18 type.
function uncheckedSub(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {
    unchecked {
        result = wrap(x.unwrap() - y.unwrap());
    }
}

/// @notice Implements the XOR (^) bitwise operation in the UD60x18 type.
function xor(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {
    result = wrap(x.unwrap() ^ y.unwrap());
}

File 39 of 44 : Math.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.19;

import "../Common.sol" as Common;
import "./Errors.sol" as Errors;
import { wrap } from "./Casting.sol";
import {
    uEXP_MAX_INPUT,
    uEXP2_MAX_INPUT,
    uHALF_UNIT,
    uLOG2_10,
    uLOG2_E,
    uMAX_UD60x18,
    uMAX_WHOLE_UD60x18,
    UNIT,
    uUNIT,
    uUNIT_SQUARED,
    ZERO
} from "./Constants.sol";
import { UD60x18 } from "./ValueType.sol";

/*//////////////////////////////////////////////////////////////////////////
                            MATHEMATICAL FUNCTIONS
//////////////////////////////////////////////////////////////////////////*/

/// @notice Calculates the arithmetic average of x and y using the following formula:
///
/// $$
/// avg(x, y) = (x & y) + ((xUint ^ yUint) / 2)
/// $$
///
/// In English, this is what this formula does:
///
/// 1. AND x and y.
/// 2. Calculate half of XOR x and y.
/// 3. Add the two results together.
///
/// This technique is known as SWAR, which stands for "SIMD within a register". You can read more about it here:
/// https://devblogs.microsoft.com/oldnewthing/20220207-00/?p=106223
///
/// @dev Notes:
/// - The result is rounded toward zero.
///
/// @param x The first operand as a UD60x18 number.
/// @param y The second operand as a UD60x18 number.
/// @return result The arithmetic average as a UD60x18 number.
/// @custom:smtchecker abstract-function-nondet
function avg(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {
    uint256 xUint = x.unwrap();
    uint256 yUint = y.unwrap();
    unchecked {
        result = wrap((xUint & yUint) + ((xUint ^ yUint) >> 1));
    }
}

/// @notice Yields the smallest whole number greater than or equal to x.
///
/// @dev This is optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional
/// counterparts. See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.
///
/// Requirements:
/// - x ≤ MAX_WHOLE_UD60x18
///
/// @param x The UD60x18 number to ceil.
/// @return result The smallest whole number greater than or equal to x, as a UD60x18 number.
/// @custom:smtchecker abstract-function-nondet
function ceil(UD60x18 x) pure returns (UD60x18 result) {
    uint256 xUint = x.unwrap();
    if (xUint > uMAX_WHOLE_UD60x18) {
        revert Errors.PRBMath_UD60x18_Ceil_Overflow(x);
    }

    assembly ("memory-safe") {
        // Equivalent to `x % UNIT`.
        let remainder := mod(x, uUNIT)

        // Equivalent to `UNIT - remainder`.
        let delta := sub(uUNIT, remainder)

        // Equivalent to `x + remainder > 0 ? delta : 0`.
        result := add(x, mul(delta, gt(remainder, 0)))
    }
}

/// @notice Divides two UD60x18 numbers, returning a new UD60x18 number.
///
/// @dev Uses {Common.mulDiv} to enable overflow-safe multiplication and division.
///
/// Notes:
/// - Refer to the notes in {Common.mulDiv}.
///
/// Requirements:
/// - Refer to the requirements in {Common.mulDiv}.
///
/// @param x The numerator as a UD60x18 number.
/// @param y The denominator as a UD60x18 number.
/// @return result The quotient as a UD60x18 number.
/// @custom:smtchecker abstract-function-nondet
function div(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {
    result = wrap(Common.mulDiv(x.unwrap(), uUNIT, y.unwrap()));
}

/// @notice Calculates the natural exponent of x using the following formula:
///
/// $$
/// e^x = 2^{x * log_2{e}}
/// $$
///
/// @dev Requirements:
/// - x ≤ 133_084258667509499440
///
/// @param x The exponent as a UD60x18 number.
/// @return result The result as a UD60x18 number.
/// @custom:smtchecker abstract-function-nondet
function exp(UD60x18 x) pure returns (UD60x18 result) {
    uint256 xUint = x.unwrap();

    // This check prevents values greater than 192e18 from being passed to {exp2}.
    if (xUint > uEXP_MAX_INPUT) {
        revert Errors.PRBMath_UD60x18_Exp_InputTooBig(x);
    }

    unchecked {
        // Inline the fixed-point multiplication to save gas.
        uint256 doubleUnitProduct = xUint * uLOG2_E;
        result = exp2(wrap(doubleUnitProduct / uUNIT));
    }
}

/// @notice Calculates the binary exponent of x using the binary fraction method.
///
/// @dev See https://ethereum.stackexchange.com/q/79903/24693
///
/// Requirements:
/// - x < 192e18
/// - The result must fit in UD60x18.
///
/// @param x The exponent as a UD60x18 number.
/// @return result The result as a UD60x18 number.
/// @custom:smtchecker abstract-function-nondet
function exp2(UD60x18 x) pure returns (UD60x18 result) {
    uint256 xUint = x.unwrap();

    // Numbers greater than or equal to 192e18 don't fit in the 192.64-bit format.
    if (xUint > uEXP2_MAX_INPUT) {
        revert Errors.PRBMath_UD60x18_Exp2_InputTooBig(x);
    }

    // Convert x to the 192.64-bit fixed-point format.
    uint256 x_192x64 = (xUint << 64) / uUNIT;

    // Pass x to the {Common.exp2} function, which uses the 192.64-bit fixed-point number representation.
    result = wrap(Common.exp2(x_192x64));
}

/// @notice Yields the greatest whole number less than or equal to x.
/// @dev Optimized for fractional value inputs, because every whole value has (1e18 - 1) fractional counterparts.
/// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.
/// @param x The UD60x18 number to floor.
/// @return result The greatest whole number less than or equal to x, as a UD60x18 number.
/// @custom:smtchecker abstract-function-nondet
function floor(UD60x18 x) pure returns (UD60x18 result) {
    assembly ("memory-safe") {
        // Equivalent to `x % UNIT`.
        let remainder := mod(x, uUNIT)

        // Equivalent to `x - remainder > 0 ? remainder : 0)`.
        result := sub(x, mul(remainder, gt(remainder, 0)))
    }
}

/// @notice Yields the excess beyond the floor of x using the odd function definition.
/// @dev See https://en.wikipedia.org/wiki/Fractional_part.
/// @param x The UD60x18 number to get the fractional part of.
/// @return result The fractional part of x as a UD60x18 number.
/// @custom:smtchecker abstract-function-nondet
function frac(UD60x18 x) pure returns (UD60x18 result) {
    assembly ("memory-safe") {
        result := mod(x, uUNIT)
    }
}

/// @notice Calculates the geometric mean of x and y, i.e. $\sqrt{x * y}$, rounding down.
///
/// @dev Requirements:
/// - x * y must fit in UD60x18.
///
/// @param x The first operand as a UD60x18 number.
/// @param y The second operand as a UD60x18 number.
/// @return result The result as a UD60x18 number.
/// @custom:smtchecker abstract-function-nondet
function gm(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {
    uint256 xUint = x.unwrap();
    uint256 yUint = y.unwrap();
    if (xUint == 0 || yUint == 0) {
        return ZERO;
    }

    unchecked {
        // Checking for overflow this way is faster than letting Solidity do it.
        uint256 xyUint = xUint * yUint;
        if (xyUint / xUint != yUint) {
            revert Errors.PRBMath_UD60x18_Gm_Overflow(x, y);
        }

        // We don't need to multiply the result by `UNIT` here because the x*y product picked up a factor of `UNIT`
        // during multiplication. See the comments in {Common.sqrt}.
        result = wrap(Common.sqrt(xyUint));
    }
}

/// @notice Calculates the inverse of x.
///
/// @dev Notes:
/// - The result is rounded toward zero.
///
/// Requirements:
/// - x must not be zero.
///
/// @param x The UD60x18 number for which to calculate the inverse.
/// @return result The inverse as a UD60x18 number.
/// @custom:smtchecker abstract-function-nondet
function inv(UD60x18 x) pure returns (UD60x18 result) {
    unchecked {
        result = wrap(uUNIT_SQUARED / x.unwrap());
    }
}

/// @notice Calculates the natural logarithm of x using the following formula:
///
/// $$
/// ln{x} = log_2{x} / log_2{e}
/// $$
///
/// @dev Notes:
/// - Refer to the notes in {log2}.
/// - The precision isn't sufficiently fine-grained to return exactly `UNIT` when the input is `E`.
///
/// Requirements:
/// - Refer to the requirements in {log2}.
///
/// @param x The UD60x18 number for which to calculate the natural logarithm.
/// @return result The natural logarithm as a UD60x18 number.
/// @custom:smtchecker abstract-function-nondet
function ln(UD60x18 x) pure returns (UD60x18 result) {
    unchecked {
        // Inline the fixed-point multiplication to save gas. This is overflow-safe because the maximum value that
        // {log2} can return is ~196_205294292027477728.
        result = wrap(log2(x).unwrap() * uUNIT / uLOG2_E);
    }
}

/// @notice Calculates the common logarithm of x using the following formula:
///
/// $$
/// log_{10}{x} = log_2{x} / log_2{10}
/// $$
///
/// However, if x is an exact power of ten, a hard coded value is returned.
///
/// @dev Notes:
/// - Refer to the notes in {log2}.
///
/// Requirements:
/// - Refer to the requirements in {log2}.
///
/// @param x The UD60x18 number for which to calculate the common logarithm.
/// @return result The common logarithm as a UD60x18 number.
/// @custom:smtchecker abstract-function-nondet
function log10(UD60x18 x) pure returns (UD60x18 result) {
    uint256 xUint = x.unwrap();
    if (xUint < uUNIT) {
        revert Errors.PRBMath_UD60x18_Log_InputTooSmall(x);
    }

    // Note that the `mul` in this assembly block is the standard multiplication operation, not {UD60x18.mul}.
    // prettier-ignore
    assembly ("memory-safe") {
        switch x
        case 1 { result := mul(uUNIT, sub(0, 18)) }
        case 10 { result := mul(uUNIT, sub(1, 18)) }
        case 100 { result := mul(uUNIT, sub(2, 18)) }
        case 1000 { result := mul(uUNIT, sub(3, 18)) }
        case 10000 { result := mul(uUNIT, sub(4, 18)) }
        case 100000 { result := mul(uUNIT, sub(5, 18)) }
        case 1000000 { result := mul(uUNIT, sub(6, 18)) }
        case 10000000 { result := mul(uUNIT, sub(7, 18)) }
        case 100000000 { result := mul(uUNIT, sub(8, 18)) }
        case 1000000000 { result := mul(uUNIT, sub(9, 18)) }
        case 10000000000 { result := mul(uUNIT, sub(10, 18)) }
        case 100000000000 { result := mul(uUNIT, sub(11, 18)) }
        case 1000000000000 { result := mul(uUNIT, sub(12, 18)) }
        case 10000000000000 { result := mul(uUNIT, sub(13, 18)) }
        case 100000000000000 { result := mul(uUNIT, sub(14, 18)) }
        case 1000000000000000 { result := mul(uUNIT, sub(15, 18)) }
        case 10000000000000000 { result := mul(uUNIT, sub(16, 18)) }
        case 100000000000000000 { result := mul(uUNIT, sub(17, 18)) }
        case 1000000000000000000 { result := 0 }
        case 10000000000000000000 { result := uUNIT }
        case 100000000000000000000 { result := mul(uUNIT, 2) }
        case 1000000000000000000000 { result := mul(uUNIT, 3) }
        case 10000000000000000000000 { result := mul(uUNIT, 4) }
        case 100000000000000000000000 { result := mul(uUNIT, 5) }
        case 1000000000000000000000000 { result := mul(uUNIT, 6) }
        case 10000000000000000000000000 { result := mul(uUNIT, 7) }
        case 100000000000000000000000000 { result := mul(uUNIT, 8) }
        case 1000000000000000000000000000 { result := mul(uUNIT, 9) }
        case 10000000000000000000000000000 { result := mul(uUNIT, 10) }
        case 100000000000000000000000000000 { result := mul(uUNIT, 11) }
        case 1000000000000000000000000000000 { result := mul(uUNIT, 12) }
        case 10000000000000000000000000000000 { result := mul(uUNIT, 13) }
        case 100000000000000000000000000000000 { result := mul(uUNIT, 14) }
        case 1000000000000000000000000000000000 { result := mul(uUNIT, 15) }
        case 10000000000000000000000000000000000 { result := mul(uUNIT, 16) }
        case 100000000000000000000000000000000000 { result := mul(uUNIT, 17) }
        case 1000000000000000000000000000000000000 { result := mul(uUNIT, 18) }
        case 10000000000000000000000000000000000000 { result := mul(uUNIT, 19) }
        case 100000000000000000000000000000000000000 { result := mul(uUNIT, 20) }
        case 1000000000000000000000000000000000000000 { result := mul(uUNIT, 21) }
        case 10000000000000000000000000000000000000000 { result := mul(uUNIT, 22) }
        case 100000000000000000000000000000000000000000 { result := mul(uUNIT, 23) }
        case 1000000000000000000000000000000000000000000 { result := mul(uUNIT, 24) }
        case 10000000000000000000000000000000000000000000 { result := mul(uUNIT, 25) }
        case 100000000000000000000000000000000000000000000 { result := mul(uUNIT, 26) }
        case 1000000000000000000000000000000000000000000000 { result := mul(uUNIT, 27) }
        case 10000000000000000000000000000000000000000000000 { result := mul(uUNIT, 28) }
        case 100000000000000000000000000000000000000000000000 { result := mul(uUNIT, 29) }
        case 1000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 30) }
        case 10000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 31) }
        case 100000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 32) }
        case 1000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 33) }
        case 10000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 34) }
        case 100000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 35) }
        case 1000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 36) }
        case 10000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 37) }
        case 100000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 38) }
        case 1000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 39) }
        case 10000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 40) }
        case 100000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 41) }
        case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 42) }
        case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 43) }
        case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 44) }
        case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 45) }
        case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 46) }
        case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 47) }
        case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 48) }
        case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 49) }
        case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 50) }
        case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 51) }
        case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 52) }
        case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 53) }
        case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 54) }
        case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 55) }
        case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 56) }
        case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 57) }
        case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 58) }
        case 100000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 59) }
        default { result := uMAX_UD60x18 }
    }

    if (result.unwrap() == uMAX_UD60x18) {
        unchecked {
            // Inline the fixed-point division to save gas.
            result = wrap(log2(x).unwrap() * uUNIT / uLOG2_10);
        }
    }
}

/// @notice Calculates the binary logarithm of x using the iterative approximation algorithm:
///
/// $$
/// log_2{x} = n + log_2{y}, \text{ where } y = x*2^{-n}, \ y \in [1, 2)
/// $$
///
/// For $0 \leq x \lt 1$, the input is inverted:
///
/// $$
/// log_2{x} = -log_2{\frac{1}{x}}
/// $$
///
/// @dev See https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation
///
/// Notes:
/// - Due to the lossy precision of the iterative approximation, the results are not perfectly accurate to the last decimal.
///
/// Requirements:
/// - x ≥ UNIT
///
/// @param x The UD60x18 number for which to calculate the binary logarithm.
/// @return result The binary logarithm as a UD60x18 number.
/// @custom:smtchecker abstract-function-nondet
function log2(UD60x18 x) pure returns (UD60x18 result) {
    uint256 xUint = x.unwrap();

    if (xUint < uUNIT) {
        revert Errors.PRBMath_UD60x18_Log_InputTooSmall(x);
    }

    unchecked {
        // Calculate the integer part of the logarithm.
        uint256 n = Common.msb(xUint / uUNIT);

        // This is the integer part of the logarithm as a UD60x18 number. The operation can't overflow because n
        // n is at most 255 and UNIT is 1e18.
        uint256 resultUint = n * uUNIT;

        // Calculate $y = x * 2^{-n}$.
        uint256 y = xUint >> n;

        // If y is the unit number, the fractional part is zero.
        if (y == uUNIT) {
            return wrap(resultUint);
        }

        // Calculate the fractional part via the iterative approximation.
        // The `delta >>= 1` part is equivalent to `delta /= 2`, but shifting bits is more gas efficient.
        uint256 DOUBLE_UNIT = 2e18;
        for (uint256 delta = uHALF_UNIT; delta > 0; delta >>= 1) {
            y = (y * y) / uUNIT;

            // Is y^2 >= 2e18 and so in the range [2e18, 4e18)?
            if (y >= DOUBLE_UNIT) {
                // Add the 2^{-m} factor to the logarithm.
                resultUint += delta;

                // Halve y, which corresponds to z/2 in the Wikipedia article.
                y >>= 1;
            }
        }
        result = wrap(resultUint);
    }
}

/// @notice Multiplies two UD60x18 numbers together, returning a new UD60x18 number.
///
/// @dev Uses {Common.mulDiv} to enable overflow-safe multiplication and division.
///
/// Notes:
/// - Refer to the notes in {Common.mulDiv}.
///
/// Requirements:
/// - Refer to the requirements in {Common.mulDiv}.
///
/// @dev See the documentation in {Common.mulDiv18}.
/// @param x The multiplicand as a UD60x18 number.
/// @param y The multiplier as a UD60x18 number.
/// @return result The product as a UD60x18 number.
/// @custom:smtchecker abstract-function-nondet
function mul(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {
    result = wrap(Common.mulDiv18(x.unwrap(), y.unwrap()));
}

/// @notice Raises x to the power of y.
///
/// For $1 \leq x \leq \infty$, the following standard formula is used:
///
/// $$
/// x^y = 2^{log_2{x} * y}
/// $$
///
/// For $0 \leq x \lt 1$, since the unsigned {log2} is undefined, an equivalent formula is used:
///
/// $$
/// i = \frac{1}{x}
/// w = 2^{log_2{i} * y}
/// x^y = \frac{1}{w}
/// $$
///
/// @dev Notes:
/// - Refer to the notes in {log2} and {mul}.
/// - Returns `UNIT` for 0^0.
/// - It may not perform well with very small values of x. Consider using SD59x18 as an alternative.
///
/// Requirements:
/// - Refer to the requirements in {exp2}, {log2}, and {mul}.
///
/// @param x The base as a UD60x18 number.
/// @param y The exponent as a UD60x18 number.
/// @return result The result as a UD60x18 number.
/// @custom:smtchecker abstract-function-nondet
function pow(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {
    uint256 xUint = x.unwrap();
    uint256 yUint = y.unwrap();

    // If both x and y are zero, the result is `UNIT`. If just x is zero, the result is always zero.
    if (xUint == 0) {
        return yUint == 0 ? UNIT : ZERO;
    }
    // If x is `UNIT`, the result is always `UNIT`.
    else if (xUint == uUNIT) {
        return UNIT;
    }

    // If y is zero, the result is always `UNIT`.
    if (yUint == 0) {
        return UNIT;
    }
    // If y is `UNIT`, the result is always x.
    else if (yUint == uUNIT) {
        return x;
    }

    // If x is > UNIT, use the standard formula.
    if (xUint > uUNIT) {
        result = exp2(mul(log2(x), y));
    }
    // Conversely, if x < UNIT, use the equivalent formula.
    else {
        UD60x18 i = wrap(uUNIT_SQUARED / xUint);
        UD60x18 w = exp2(mul(log2(i), y));
        result = wrap(uUNIT_SQUARED / w.unwrap());
    }
}

/// @notice Raises x (a UD60x18 number) to the power y (an unsigned basic integer) using the well-known
/// algorithm "exponentiation by squaring".
///
/// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring.
///
/// Notes:
/// - Refer to the notes in {Common.mulDiv18}.
/// - Returns `UNIT` for 0^0.
///
/// Requirements:
/// - The result must fit in UD60x18.
///
/// @param x The base as a UD60x18 number.
/// @param y The exponent as a uint256.
/// @return result The result as a UD60x18 number.
/// @custom:smtchecker abstract-function-nondet
function powu(UD60x18 x, uint256 y) pure returns (UD60x18 result) {
    // Calculate the first iteration of the loop in advance.
    uint256 xUint = x.unwrap();
    uint256 resultUint = y & 1 > 0 ? xUint : uUNIT;

    // Equivalent to `for(y /= 2; y > 0; y /= 2)`.
    for (y >>= 1; y > 0; y >>= 1) {
        xUint = Common.mulDiv18(xUint, xUint);

        // Equivalent to `y % 2 == 1`.
        if (y & 1 > 0) {
            resultUint = Common.mulDiv18(resultUint, xUint);
        }
    }
    result = wrap(resultUint);
}

/// @notice Calculates the square root of x using the Babylonian method.
///
/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.
///
/// Notes:
/// - The result is rounded toward zero.
///
/// Requirements:
/// - x ≤ MAX_UD60x18 / UNIT
///
/// @param x The UD60x18 number for which to calculate the square root.
/// @return result The result as a UD60x18 number.
/// @custom:smtchecker abstract-function-nondet
function sqrt(UD60x18 x) pure returns (UD60x18 result) {
    uint256 xUint = x.unwrap();

    unchecked {
        if (xUint > uMAX_UD60x18 / uUNIT) {
            revert Errors.PRBMath_UD60x18_Sqrt_Overflow(x);
        }
        // Multiply x by `UNIT` to account for the factor of `UNIT` picked up when multiplying two UD60x18 numbers.
        // In this case, the two numbers are both the square root.
        result = wrap(Common.sqrt(xUint * uUNIT));
    }
}

File 40 of 44 : ValueType.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.19;

import "./Casting.sol" as Casting;
import "./Helpers.sol" as Helpers;
import "./Math.sol" as Math;

/// @notice The unsigned 60.18-decimal fixed-point number representation, which can have up to 60 digits and up to 18
/// decimals. The values of this are bound by the minimum and the maximum values permitted by the Solidity type uint256.
/// @dev The value type is defined here so it can be imported in all other files.
type UD60x18 is uint256;

/*//////////////////////////////////////////////////////////////////////////
                                    CASTING
//////////////////////////////////////////////////////////////////////////*/

using {
    Casting.intoSD1x18,
    Casting.intoSD21x18,
    Casting.intoSD59x18,
    Casting.intoUD2x18,
    Casting.intoUD21x18,
    Casting.intoUint128,
    Casting.intoUint256,
    Casting.intoUint40,
    Casting.unwrap
} for UD60x18 global;

/*//////////////////////////////////////////////////////////////////////////
                            MATHEMATICAL FUNCTIONS
//////////////////////////////////////////////////////////////////////////*/

// The global "using for" directive makes the functions in this library callable on the UD60x18 type.
using {
    Math.avg,
    Math.ceil,
    Math.div,
    Math.exp,
    Math.exp2,
    Math.floor,
    Math.frac,
    Math.gm,
    Math.inv,
    Math.ln,
    Math.log10,
    Math.log2,
    Math.mul,
    Math.pow,
    Math.powu,
    Math.sqrt
} for UD60x18 global;

/*//////////////////////////////////////////////////////////////////////////
                                HELPER FUNCTIONS
//////////////////////////////////////////////////////////////////////////*/

// The global "using for" directive makes the functions in this library callable on the UD60x18 type.
using {
    Helpers.add,
    Helpers.and,
    Helpers.eq,
    Helpers.gt,
    Helpers.gte,
    Helpers.isZero,
    Helpers.lshift,
    Helpers.lt,
    Helpers.lte,
    Helpers.mod,
    Helpers.neq,
    Helpers.not,
    Helpers.or,
    Helpers.rshift,
    Helpers.sub,
    Helpers.uncheckedAdd,
    Helpers.uncheckedSub,
    Helpers.xor
} for UD60x18 global;

/*//////////////////////////////////////////////////////////////////////////
                                    OPERATORS
//////////////////////////////////////////////////////////////////////////*/

// The global "using for" directive makes it possible to use these operators on the UD60x18 type.
using {
    Helpers.add as +,
    Helpers.and2 as &,
    Math.div as /,
    Helpers.eq as ==,
    Helpers.gt as >,
    Helpers.gte as >=,
    Helpers.lt as <,
    Helpers.lte as <=,
    Helpers.or as |,
    Helpers.mod as %,
    Math.mul as *,
    Helpers.neq as !=,
    Helpers.not as ~,
    Helpers.sub as -,
    Helpers.xor as ^
} for UD60x18 global;

File 41 of 44 : Bytes32AddressLib.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;

/// @notice Library for converting between addresses and bytes32 values.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/Bytes32AddressLib.sol)
library Bytes32AddressLib {
    function fromLast20Bytes(
        bytes32 bytesValue
    ) internal pure returns (address) {
        return address(uint160(uint256(bytesValue)));
    }
}

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

interface IUniswapV3Factory {
    function createPool(
        address tokenA,
        address tokenB,
        uint24 fee
    ) external returns (address pool);

    function getPool(
        address tokenA,
        address tokenB,
        uint24 fee
    ) external view returns (address pool);

    function feeAmountTickSpacing(uint24 fee) external view returns (int24);

    function initialize(uint160 sqrtPriceX96) external;
}
interface IWETH {
    function deposit() external payable;
    function withdraw(uint256) external;
    function approve(address guy, uint256 wad) external returns (bool);
}

interface INonfungiblePositionManager {
    struct MintParams {
        address token0;
        address token1;
        uint24 fee;
        int24 tickLower;
        int24 tickUpper;
        uint256 amount0Desired;
        uint256 amount1Desired;
        uint256 amount0Min;
        uint256 amount1Min;
        address recipient;
        uint256 deadline;
    }

    function mint(MintParams calldata params)
        external
        payable
        returns (
            uint256 tokenId,
            uint128 liquidity,
            uint256 amount0,
            uint256 amount1
        );
        
    function positions(uint256 tokenId)
        external
        view
        returns (
            uint96 nonce,
            address operator,
            address token0,
            address token1,
            uint24 fee,
            int24 tickLower,
            int24 tickUpper,
            uint128 liquidity,
            uint256 feeGrowthInside0LastX128,
            uint256 feeGrowthInside1LastX128,
            uint128 tokensOwed0,
            uint128 tokensOwed1
        );

    function approve(address to, uint256 tokenId) external;
    function ownerOf(uint256 tokenId) external view returns (address);
    
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    function collect(CollectParams calldata params)
        external
        returns (uint256 amount0, uint256 amount1);

    struct CollectParams {
        uint256 tokenId;
        address recipient;
        uint128 amount0Max;
        uint128 amount1Max;
    }
}

interface ISwapRouter {
    struct ExactInputSingleParams {
        address tokenIn;
        address tokenOut;
        uint24 fee;
        address recipient;
        uint256 amountIn;
        uint256 amountOutMinimum;
        uint160 sqrtPriceLimitX96;
    }

    function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);
    function unwrapWETH9(uint256 amountMinimum, address recipient) external payable;
}

interface IUniswapV3Pool {
    function slot0()
        external
        view
        returns (
            uint160 sqrtPriceX96,
            int24 tick,
            uint16 observationIndex,
            uint16 observationCardinality,
            uint16 observationCardinalityNext,
            uint8 feeProtocol,
            bool unlocked
        );

    function initialize(uint160 sqrtPriceX96) external;
}

interface IQuoterV2 {
    function quoteExactInputSingle(
        IQuoterV2.QuoteExactInputSingleParams memory params
    ) external returns (
        uint256 amountOut,
        uint160 sqrtPriceX96After,
        uint32 initializedTicksCrossed,
        uint256 gasEstimate
    );

    struct QuoteExactInputSingleParams {
        address tokenIn;
        address tokenOut;
        uint256 amountIn;
        uint24 fee;
        uint160 sqrtPriceLimitX96;
    }
}

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

import {SD59x18} from "@prb/math/src/SD59x18.sol";
import {convert} from "@prb/math/src/sd59x18/Conversions.sol";

library LesterMathLib {
    uint256 constant LN10001 = 99995000330000;

    function sqrt(uint256 x) internal pure returns (uint256 y) {
        uint256 z = (x + 1) / 2;
        y = x;
        while (z < y) {
            y = z;
            z = (x / z + z) / 2;
        }
    }
    int24 internal constant MIN_TICK = -887272;
    uint256 internal constant MAX_TICK = 887272;

    uint160 internal constant MIN_SQRT_RATIO = 4295128739;
    uint160 internal constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342;

    function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) {
        uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick));
        require(absTick <= MAX_TICK, 'T');

        uint256 ratio = absTick & 0x1 != 0 ? 0xfffcb933bd6fad37aa2d162d1a594001 : 0x100000000000000000000000000000000;
        if (absTick & 0x2 != 0) ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128;
        if (absTick & 0x4 != 0) ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128;
        if (absTick & 0x8 != 0) ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128;
        if (absTick & 0x10 != 0) ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644) >> 128;
        if (absTick & 0x20 != 0) ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0) >> 128;
        if (absTick & 0x40 != 0) ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861) >> 128;
        if (absTick & 0x80 != 0) ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053) >> 128;
        if (absTick & 0x100 != 0) ratio = (ratio * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128;
        if (absTick & 0x200 != 0) ratio = (ratio * 0xf987a7253ac413176f2b074cf7815e54) >> 128;
        if (absTick & 0x400 != 0) ratio = (ratio * 0xf3392b0822b70005940c7a398e4b70f3) >> 128;
        if (absTick & 0x800 != 0) ratio = (ratio * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128;
        if (absTick & 0x1000 != 0) ratio = (ratio * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128;
        if (absTick & 0x2000 != 0) ratio = (ratio * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128;
        if (absTick & 0x4000 != 0) ratio = (ratio * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128;
        if (absTick & 0x8000 != 0) ratio = (ratio * 0x31be135f97d08fd981231505542fcfa6) >> 128;
        if (absTick & 0x10000 != 0) ratio = (ratio * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128;
        if (absTick & 0x20000 != 0) ratio = (ratio * 0x5d6af8dedb81196699c329225ee604) >> 128;
        if (absTick & 0x40000 != 0) ratio = (ratio * 0x2216e584f5fa1ea926041bedfe98) >> 128;
        if (absTick & 0x80000 != 0) ratio = (ratio * 0x48a170391f7dc42444e8fa2) >> 128;

        if (tick > 0) ratio = type(uint256).max / ratio;
        sqrtPriceX96 = uint160((ratio >> 32) + (ratio % (1 << 32) == 0 ? 0 : 1));
    }

    function maxUsableTick(int24 tickSpacing) internal pure returns (int24) {
        int24 maxTick = 887272;
        return maxTick - (maxTick % tickSpacing);
    }

    function calculateNumerator(uint256 supply, uint256 liquidity) public pure returns (uint256) {
        return uint256(computeLn(supply/liquidity)*1e18);
    }

    function calculateTickFromNumerator(uint256 numerator) internal pure returns (int256) {
        int256 tick = (int256(numerator) / int256(LN10001)) / 10**18;
        return tick;
    }

    function computeLog10(uint256 x) internal pure returns (int256) {
        SD59x18 num = convert(int256(x * 10**18));
        return num.log10().unwrap();
    }

    function computeLn(uint256 x) internal pure returns (int256) {
        SD59x18 num = convert(int256(x * 10**18));
        int256 lnOffset = 41446531673892822311; // ln(10^18)
        return num.ln().unwrap() - lnOffset;
    }

    function uint2str(uint256 _i) internal pure returns (string memory) {
        if (_i == 0) return "0";
        uint256 j = _i;
        uint256 length;
        while (j != 0) {
            length++;
            j /= 10;
        }
        bytes memory bstr = new bytes(length);
        uint256 k = length;
        j = _i;
        while (j != 0) {
            bstr[--k] = bytes1(uint8(48 + j % 10));
            j /= 10;
        }
        return string(bstr);
    }

    function parseInt(string memory _value) internal pure returns (uint256) {
        bytes memory b = bytes(_value);
        uint256 result = 0;
        for(uint256 i = 0; i < b.length; i++) {
            result = result * 10 + uint8(b[i]) - 48;
        }
        return result;
    }

    function substring(string memory str, uint256 startIndex, uint256 endIndex) internal pure returns (string memory) {
        bytes memory strBytes = bytes(str);
        bytes memory result = new bytes(endIndex-startIndex);
        for(uint256 i = startIndex; i < endIndex; i++) {
            result[i-startIndex] = strBytes[i];
        }
        return string(result);
    }
}

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

import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";

contract Token is ERC20, Ownable {
    address private _deployer;
    address public lester;
    address public immutable uniswapV3Factory;
    address public immutable positionManager;
    address public poolAddress;
    uint256 public maxWalletPercentage;
    address payable public feeDistributor;
    string public twitterName;
    string public websiteUrl;

    modifier onlyDeployer() {
        require(msg.sender == _deployer, "Only Deployer can call this function");
        _;
    }

    constructor(
        string memory name_,
        string memory symbol_,
        uint256 maxSupply_,
        address deployer_,
        address _uniswapV3Factory,
        address _positionManager,
        uint256 _maxWalletPercentage,
        string memory _twitterName,
        string memory _websiteUrl
    ) ERC20(name_, symbol_) Ownable(deployer_) {
        _deployer = deployer_;
        lester = msg.sender;
        uniswapV3Factory = _uniswapV3Factory;
        positionManager = _positionManager;
        _mint(msg.sender, maxSupply_);
        maxWalletPercentage = _maxWalletPercentage;
        twitterName = _twitterName;
        websiteUrl = _websiteUrl;
    }

    function _update(
        address from,
        address to,
        uint256 amount
    ) internal override {
        if (to != address(0) &&
            from != address(0) &&
            to != lester &&
            from != lester &&
            to != uniswapV3Factory &&
            to != positionManager &&
            to != poolAddress) {
            uint256 maxWalletAmount = (totalSupply() * maxWalletPercentage) / 1000;
            require(
                balanceOf(to) + amount <= maxWalletAmount,
                "Max wallet percentage exceeded"
            );
        }
        super._update(from, to, amount);
    }

    function setPoolAddress(address _poolAddress) external {
        require(msg.sender == lester, "Only Lester can set pool address");
        poolAddress = _poolAddress;
    }

    function deployer() public view returns (address) {
        return _deployer;
    }

    function transferOwnership(address /* newOwner */) public virtual override {
        revert("Ownership transfer is disabled");
    }
}

Settings
{
  "viaIR": true,
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "evmVersion": "paris",
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {
    "contracts/Lester.sol": {
      "LesterMathLib": "0xa1e439a765f42f9de43681dfa67b6a66f7907b7a"
    }
  }
}

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"address","name":"weth_","type":"address"},{"internalType":"address","name":"uniswapV3Factory_","type":"address"},{"internalType":"address","name":"positionManager_","type":"address"},{"internalType":"address","name":"swapRouter_","type":"address"},{"internalType":"address","name":"owner_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AddressAlreadyInTeam","type":"error"},{"inputs":[],"name":"AddressNotInTeam","type":"error"},{"inputs":[],"name":"InvalidTokenOrder","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"enabled","type":"bool"}],"name":"CreationStatusChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"message","type":"string"}],"name":"Debug","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"member","type":"address"}],"name":"TeamMemberAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"member","type":"address"}],"name":"TeamMemberRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"tokenAddress","type":"address"},{"indexed":false,"internalType":"address","name":"deployer","type":"address"},{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"symbol","type":"string"},{"indexed":false,"internalType":"uint256","name":"supply","type":"uint256"}],"name":"TokenCreated","type":"event"},{"inputs":[],"name":"DEAD_ADDRESS","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TICK_SPACING","outputs":[{"internalType":"int24","name":"","type":"int24"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"member","type":"address"}],"name":"addTeamMember","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"supply","type":"uint256"},{"internalType":"uint256","name":"liquidity","type":"uint256"}],"name":"calculateNumerator","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"numerator","type":"uint256"}],"name":"calculateTickFromNumerator","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"collectAllFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"collectFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"uint256","name":"supply","type":"uint256"},{"internalType":"uint256","name":"liquidity","type":"uint256"},{"internalType":"uint24","name":"fee","type":"uint24"},{"internalType":"bytes32","name":"salt","type":"bytes32"},{"internalType":"address","name":"deployer","type":"address"},{"internalType":"uint256","name":"maxWalletPercentage","type":"uint256"},{"internalType":"uint256","name":"firstBuyAmount","type":"uint256"},{"internalType":"string","name":"twitterName","type":"string"},{"internalType":"string","name":"websiteUrl","type":"string"}],"name":"deployToken","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"deployer","type":"address"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"uint256","name":"supply","type":"uint256"},{"internalType":"uint256","name":"maxWalletPercentage","type":"uint256"},{"internalType":"string","name":"twitterName","type":"string"},{"internalType":"string","name":"websiteUrl","type":"string"}],"name":"generateSalt","outputs":[{"internalType":"bytes32","name":"salt","type":"bytes32"},{"internalType":"address","name":"token","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTeamMembers","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isCreationEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isTeamMember","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"positionManager","outputs":[{"internalType":"contract INonfungiblePositionManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"deployer","type":"address"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"uint256","name":"supply","type":"uint256"},{"internalType":"bytes32","name":"salt","type":"bytes32"},{"internalType":"uint256","name":"maxWalletPercentage","type":"uint256"},{"internalType":"string","name":"twitterName","type":"string"},{"internalType":"string","name":"websiteUrl","type":"string"}],"name":"predictToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"member","type":"address"}],"name":"removeTeamMember","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"enabled","type":"bool"}],"name":"setCreationEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"swapRouter","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"teamMembers","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"tokenList","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"tokenPositions","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"uniswapV3Factory","outputs":[{"internalType":"contract IUniswapV3Factory","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"usdc","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"weth","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]

6101403461021b57601f6146f238819003918201601f19168301916001600160401b038311848410176102205780849260a09460405283398101031261021b5761004881610236565b9061005560208201610236565b61006160408301610236565b9061006e60608401610236565b926001600160a01b039061008490608001610236565b1693841561020557600080546001600160a01b031981168717825560405196916001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09080a373833589fcd6edb6e08f4c7c32d4f71b54bda0291360a05261dead60c0526005805460ff191660011790556080526001600160a01b0390811660e0521661010052610120526144a7908161024b823960805181818161021401528181610e3b0152818161143701528181611480015281816116600152818161181401528181611a3f01528181611a8701528181611b1201528181611b790152611fc7015260a05181610f77015260c05181610dda015260e051818181610cc2015281816112b2015281816113ac015281816114be0152818161169f0152818161200a0152612d0a01526101005181818161060a01528181610876015281816109fe015281816113d4015281816117490152818161191e015281816119f30152612d320152610120518181816104b70152611acd0152f35b631e4fbdf760e01b600052600060045260246000fd5b600080fd5b634e487b7160e01b600052604160045260246000fd5b51906001600160a01b038216820361021b5756fe6080604052600436101561001b575b361561001957600080fd5b005b6000803560e01c80630d9a444614612a2557806313a9e9d91461112257806314eba02614610fa65780633e413bee14610f615780633eb2b5ad14610e6a5780633fc8cef314610e2557806346ca626b14610e095780634e6fd6c414610dc4578063599b261e14610cf15780635b54918214610cac578063686f2c901461098d5780636a5dab9f146108ff578063715018a6146108a5578063791b98bc146108605780638da5cb5b146108395780639ead72221461080e578063a10b521b146107eb578063a480ca791461057c578063bbe9f99d1461053d578063c0dd7cd5146104e6578063c31c9c07146104a1578063c43cb3fb14610477578063e75f7ddb14610433578063efded1471461036b578063f2fde38b146102e55763fd8b3c9d14610145575061000e565b346102e25760e03660031901126102e25761015e612b0b565b906024356001600160401b0381116102e05761017e903690600401612b21565b916044356001600160401b0381116102e05761019e903690600401612b21565b92909360a4356001600160401b0381116102dc576101c0903690600401612b21565b92909160c435976001600160401b0389116102d8578261020a85899b98886101ee8d9c9b3690600401612b21565b9c819c848f969395509788915b608435938c606435938d612c52565b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811690821610806102cf575b6102b5575061024d90612e7d565b986103e88a10156102705761020a988a919a888888848f94959e958a8f966101fb565b60405162461bcd60e51b815260206004820152601960248201527f436f756c64206e6f742066696e642076616c69642073616c74000000000000006044820152606490fd5b604080519283526001600160a01b03909116602083015290f35b50803b1561023f565b8580fd5b8380fd5b505b80fd5b50346102e25760203660031901126102e2576102ff612b0b565b610307612f25565b6001600160a01b031680156103575781546001600160a01b03198116821783556001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08380a380f35b631e4fbdf760e01b82526004829052602482fd5b50346102e257806003193601126102e25760405180602060045491828152018091600485527f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b90855b81811061041457505050826103ca910383612a88565b604051928392602084019060208552518091526040840192915b8181106103f2575050500390f35b82516001600160a01b03168452859450602093840193909201916001016103e4565b82546001600160a01b03168452602090930192600192830192016103b4565b50346102e25760203660031901126102e257600435906004548210156102e257602061045e83612b4e565b905460405160039290921b1c6001600160a01b03168152f35b50346102e25760403660031901126102e2576020610499602435600435612ea2565b604051908152f35b50346102e257806003193601126102e2576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b50346102e25760403660031901126102e257610500612b0b565b6001600160a01b03168152600260205260408120805460243592908310156102e257602061052e8484612b9a565b90549060031b1c604051908152f35b50346102e25760203660031901126102e25760209060ff906040906001600160a01b03610568612b0b565b168152600384522054166040519015158152f35b50346102e25760203660031901126102e257610596612b0b565b338252600360205260ff60408320541680156107d8575b6105b690612e05565b60018060a01b031681526002602052604081206040518082602082945493848152019085526020852092855b8181106107bf5750506105f792500382612a88565b80511561077a5781546001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081169184911661063884612e5c565b5190833b1561076b5760405163095ea7b360e01b81526001600160a01b039190911660048201526024810191909152818160448183875af1801561076f57610756575b505b8251811015610752576106908184612e69565b518454604051916001600160801b03916001600160a01b0316906106b384612a57565b835260208301908152604080840183815260608501848152825163fc6f786560e01b81529551600487015292516001600160a01b031660248601525183166044850152905190911660648301528160848188875af180156107475761071c575b5060010161067d565b604090813d8111610740575b6107328183612a88565b810103126102dc5738610713565b503d610728565b6040513d87823e3d90fd5b8380f35b8161076091612a88565b61076b57823861067b565b8280fd5b6040513d84823e3d90fd5b60405162461bcd60e51b815260206004820152601b60248201527f4e6f20706f736974696f6e7320666f72207468697320746f6b656e00000000006044820152606490fd5b84548352600194850194869450602090930192016105e2565b5081546001600160a01b031633146105ad565b50346102e257806003193601126102e257602060ff600554166040519015158152f35b50346102e25760203660031901126102e257600435906001548210156102e257602061045e83612b7f565b50346102e257806003193601126102e257546040516001600160a01b039091168152602090f35b50346102e257806003193601126102e2576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b50346102e257806003193601126102e2576108be612f25565b80546001600160a01b03198116825581906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b50346102e25760203660031901126102e2576004358015158091036102e05760207f1a3f40fae3a310ca113098ad34d161433ab7e470c2a167b60a190a80364043bc913384526003825260ff604085205416801561097a575b61096190612e05565b60ff196005541660ff821617600555604051908152a180f35b5083546001600160a01b03163314610958565b50346102e257806003193601126102e257338152600360205260ff6040822054168015610c99575b6109be90612e05565b6001546109ca81612e45565b906109d86040519283612a88565b808252601f196109e782612e45565b013660208401378290835b818110610c2f575083927f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169291505b818410610a35578480f35b6001600160a01b03610a478583612e69565b5116338652600360205260ff6040872054168015610c1c575b610a6990612e05565b85526002602052604085209160405180938491602082549182815201918952602089209089905b808210610c045750505090610aa6910384612a88565b82511561077a57855486906001600160a01b0316610ac385612e5c565b5190863b1561076b5760405163095ea7b360e01b81526001600160a01b0391909116600482015260248101919091528181604481838a5af1801561076f57610bef575b505b8351811015610be157610b1b8185612e69565b518754604051916001600160801b03916001600160a01b031690610b3e84612a57565b835260208301908152604080840183815260608501848152825163fc6f786560e01b81529551600487015292516001600160a01b03166024860152518316604485015290519091166064830152816084818b8a5af18015610bd657610ba7575b50600101610b08565b604090813d8111610bcf575b610bbd8183612a88565b81010312610bcb5738610b9e565b8680fd5b503d610bb3565b6040513d8a823e3d90fd5b506001909401939150610a2a565b81610bf991612a88565b6102d8578538610b06565b90919260016020819286548152019401920190610a90565b5085546001600160a01b03163314610a60565b610c3881612b7f565b905460039190911b1c6001600160a01b0316855260026020526040852054610c63575b6001016109f2565b91610c91600191610c7385612b7f565b848060a01b0391549060031b1c16610c8b8288612e69565b52612e7d565b929050610c5b565b5080546001600160a01b031633146109b5565b50346102e257806003193601126102e2576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b50346102e2576101003660031901126102e257610d0c612b0b565b906024356001600160401b0381116102e057610d2c903690600401612b21565b9290916044356001600160401b0381116102e057610d4e903690600401612b21565b94909360c4356001600160401b0381116102dc57610d70903690600401612b21565b94909360e435906001600160401b0382116102e2576020610db28a8a8a8a8a8a8a610d9e3660048d01612b21565b97909660a435946084359460643594612c52565b6040516001600160a01b039091168152f35b50346102e257806003193601126102e2576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b50346102e257806003193601126102e257602060405160c88152f35b50346102e257806003193601126102e2576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b50346102e25760203660031901126102e257610e84612b0b565b610e8c612f25565b6001600160a01b0381168083526003602052604083205490919060ff16610f4f57818352600360205260408320805460ff19166001179055600454600160401b811015610f3b5791610f31602092610f0d8560017fcb5d35f3d58007ab65c22252d42a544314d3bf8e16e71d153996fd99735653de97016004556004612b9a565b81546001600160a01b0393841660039290921b91821b9390911b1916919091179055565b604051908152a180f35b634e487b7160e01b84526041600452602484fd5b6001622d600560e11b03198352600483fd5b50346102e257806003193601126102e2576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b50346102e25760203660031901126102e257610fc0612b0b565b610fc8612f25565b6001600160a01b03168082526003602052604082205460ff161561111357808252600360205260408220805460ff19169055815b600454808210156110e8578261101183612b4e565b905460039190911b1c6001600160a01b0316146110315750600101610ffc565b60001981019081116110d45790610f0d61104d61106593612b4e565b905460039190911b1c6001600160a01b031691612b4e565b60045480156110c0577f113ac15d1e9d35bbc48c65ac66da9d44808929220056e22450b3c48222e8ec7391602091600019016110a081612b4e565b81549060018060a01b039060031b1b19169055600455604051908152a180f35b634e487b7160e01b83526031600452602483fd5b634e487b7160e01b84526011600452602484fd5b505060207f113ac15d1e9d35bbc48c65ac66da9d44808929220056e22450b3c48222e8ec7391610f31565b6306278fb360e21b8252600482fd5b506101603660031901126102e2576004356001600160401b0381116102e05761114f903690600401612ac4565b6024356001600160401b03811161076b5761116e903690600401612ac4565b9062ffffff608435166084350361076b5760c435906001600160a01b03821682036102dc57610124356001600160401b038111611e41576111b3903690600401612ac4565b90610144356001600160401b0381116102d8576111d4903690600401612ac4565b9160ff60055416156129e0576044351561299b576001600160a01b038416156129565781511561291a578451156128dc5761271062ffffff60843516036128a45780511561285f576101043534106128225760405192611267600a602086865161124381848401858b01612bb2565b81016910313c902632b9ba32b960b11b838201520301601519810187520185612a88565b670de0b6b3a7640000655af1e6795710611285606435604435612ea2565b050591878313156127f1576040516322afcccb60e01b815260843562ffffff1660048201526020816024817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165afa908115611f9d5789916127b1575b5060020b94851561279d5785620d89e80793627fffff8560020b620d89e80313627fffff198660020b620d89e80312176120bf5760020b627fffff1981146120bf578903958660020b81810760020b61276e575b50506040519161152391828401928484106001600160401b0385111761275a576114229261139261138487969461140f94612f4f89396101208652610120860190612bd5565b84810360208601528d612bd5565b60443560408501526001600160a01b038c811660608601527f0000000000000000000000000000000000000000000000000000000000000000811660808601527f00000000000000000000000000000000000000000000000000000000000000001660a085015260e43560c085015283810360e085015290612bd5565b9061010081830391015260a43594612bd5565b039088f5928315611d9d576001600160a01b037f00000000000000000000000000000000000000000000000000000000000000008116908516101561270957604051630b4c774160e11b81526001600160a01b0385811660048301527f000000000000000000000000000000000000000000000000000000000000000016602482015262ffffff608435166044820152602081806064810103817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165afa908115610bd65788916126ea575b5080888360020b126000146126e057600283900b600160ff1b146126cc578260020b8903905b620d89e882116126a3576001821615612691576001600160881b036ffffcb933bd6fad37aa2d162d1a5940015b169160028116612646575b600481166125fb575b600881166125b0575b60108116612565575b6020811661251a575b604081166124cf575b60808116612484575b6101008116612439575b61020081166123ee575b61040081166123a3575b6108008116612358575b611000811661230d575b61200081166122c2575b6140008116612277575b618000811661222c575b6201000081166121e1575b620200008116612199575b620400008116612140575b6208000016612101575b898460020b136120dc575b63ffffffff8260201c9216156000146120d35760ff8a5b1682018092116120bf576001600160a01b031615611fa8575b50604051630b4c774160e11b81526001600160a01b0386811660048301527f000000000000000000000000000000000000000000000000000000000000000016602482015262ffffff60843516604482015290602082806064810103817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165afa918215611f9d578992611f6c575b506001600160a01b039081169116819003611f345787906001600160a01b0386163b156102e05760405163e9e15b4f60e01b815260048101919091528181602481836001600160a01b038b165af1801561076f57611f1f575b505060405163095ea7b360e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811660048301526000196024830152602090829060449082908c908a165af18015610bd657611f02575b5060405163a9059cbb60e01b81523060048201526044803560248301526020908290818b6001600160a01b038a165af18015610bd657611ee5575b50603c420190814211611ed1576040519261016084018481106001600160401b03821117611ebd5790899160405260018060a01b0387168552602085019260018060a01b037f0000000000000000000000000000000000000000000000000000000000000000168452604086019162ffffff608435168352606087019160020b8252608087019060020b620d89e80360020b815260a0870190604435825260c088019285845262ffffff60e08a01958787526101008b019788526101208b0198308a526101408c019a8b526040519b634418b22b60e11b8d5260018060a01b0390511660048d015260018060a01b0390511660248c0152511660448a01525160020b60648901525160020b60848801525160a48701525160c48601525160e48501525161010484015260018060a01b0390511661012483015251610144820152608081610164818960018060a01b037f0000000000000000000000000000000000000000000000000000000000000000165af1908115611d9d578691611e76575b506001600160a01b0383168652600260205260408620805490600160401b821015611da8579061198391600182018155612b9a565b819291549060031b91821b91600019901b1916179055600154600160401b811015611e62576119bd8160016119dc93016001556001612b9a565b81546001600160a01b0386811660039390931b92831b921b1916179055565b60405163095ea7b360e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811660048301526000196024830152602090829060449082908a9088165af18015611d9d57611e45575b507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163b15611e4157604051630d0e30db60e41b815285908181600481610104357f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165af1801561076f57611e2c575b505060405163095ea7b360e01b81527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b038116600483015261010435602483015290602081806044810103818a7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165af1908115611e21578791611df2575b5015611dbc5760405160e081018181106001600160401b03821117611da8579060209160405260018060a01b037f000000000000000000000000000000000000000000000000000000000000000016815260e48282019160018060a01b038716835289604082019562ffffff608435168752606083013381526080840161010435815260a085019084825260c086019285845262ffffff6040519b8c9a8b996304e45aaf60e01b8b5260018060a01b0390511660048b015260018060a01b0390511660248a01525116604488015260018060a01b0390511660648701525160848601525160a485015260018060a01b0390511660c484015260018060a01b03165af18015611d9d57611d69575b50610104353411611cd6575b7f6e6ae68e7d7d45fbd855c40d1eaafa8de46c5fbec3ee26f1af88730e400bc92c93611cba611cc89260405195869560018060a01b0316865260018060a01b0316602086015260a0604086015260a0850190612bd5565b908382036060850152612bd5565b60443560808301520390a180f35b610104353403348111611d55578580808093335af13d15611d50573d611cfb81612aa9565b90611d096040519283612a88565b81528660203d92013e5b611c635760405162461bcd60e51b8152602060048201526011602482015270115512081c99599d5b990819985a5b1959607a1b6044820152606490fd5b611d13565b634e487b7160e01b86526011600452602486fd5b6020813d602011611d95575b81611d8260209383612a88565b81010312611d905751611c57565b600080fd5b3d9150611d75565b6040513d88823e3d90fd5b634e487b7160e01b88526041600452602488fd5b60405162461bcd60e51b815260206004820152600e60248201526d105c1c1c9bdd994819985a5b195960921b6044820152606490fd5b611e14915060203d602011611e1a575b611e0c8183612a88565b810190612c19565b38611b4a565b503d611e02565b6040513d89823e3d90fd5b81611e3691612a88565b611e41578438611abc565b8480fd5b611e5d9060203d602011611e1a57611e0c8183612a88565b611a3c565b634e487b7160e01b86526041600452602486fd5b90506080813d608011611eb5575b81611e9160809383612a88565b810103126102d857602081519101516001600160801b038116036102d8573861194e565b3d9150611e84565b634e487b7160e01b8a52604160045260248afd5b634e487b7160e01b88526011600452602488fd5b611efd9060203d602011611e1a57611e0c8183612a88565b6117cd565b611f1a9060203d602011611e1a57611e0c8183612a88565b611792565b81611f2991612a88565b610bcb578638611730565b60405162461bcd60e51b815260206004820152601060248201526f141bdbdb081b9bdd0818dc99585d195960821b6044820152606490fd5b611f8f91925060203d602011611f96575b611f878183612a88565b810190612bfa565b90386116d7565b503d611f7d565b6040513d8b823e3d90fd5b60405163a167129560e01b81526001600160a01b0387811660048301527f000000000000000000000000000000000000000000000000000000000000000016602482015262ffffff6084351660448201529150889060208380606481010381857f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165af192831561076f57829361209e575b50826001600160a01b0381163b1561076b5760405163f637731d60e01b81526001600160a01b0392831660048201529291839160249183918591165af18015611f9d5715611640578861209791999299612a88565b9638611640565b6120b891935060203d602011611f9657611f878183612a88565b9138612042565b634e487b7160e01b8a52601160045260248afd5b60ff6001611627565b9080156120ed576000190490611610565b634e487b7160e01b8a52601260045260248afd5b90806b048a170391f7dc42444e8fa28102046b048a170391f7dc42444e8fa214811517156120bf576b048a170391f7dc42444e8fa20260801c90611605565b91806d2216e584f5fa1ea926041bedfe988102046d2216e584f5fa1ea926041bedfe981481151715612185576d2216e584f5fa1ea926041bedfe980260801c916115fb565b634e487b7160e01b8b52601160045260248bfd5b91806e5d6af8dedb81196699c329225ee6048102046e5d6af8dedb81196699c329225ee6041481151715612185576e5d6af8dedb81196699c329225ee6040260801c916115f0565b91806f09aa508b5b7a84e1c677de54f3e99bc98102046f09aa508b5b7a84e1c677de54f3e99bc91481151715612185576f09aa508b5b7a84e1c677de54f3e99bc90260801c916115e5565b91806f31be135f97d08fd981231505542fcfa68102046f31be135f97d08fd981231505542fcfa61481151715612185576f31be135f97d08fd981231505542fcfa60260801c916115da565b91806f70d869a156d2a1b890bb3df62baf32f78102046f70d869a156d2a1b890bb3df62baf32f71481151715612185576f70d869a156d2a1b890bb3df62baf32f70260801c916115d0565b91806fa9f746462d870fdf8a65dc1f90e061e58102046fa9f746462d870fdf8a65dc1f90e061e51481151715612185576fa9f746462d870fdf8a65dc1f90e061e50260801c916115c6565b91806fd097f3bdfd2022b8845ad8f792aa58258102046fd097f3bdfd2022b8845ad8f792aa58251481151715612185576fd097f3bdfd2022b8845ad8f792aa58250260801c916115bc565b91806fe7159475a2c29b7443b29c7fa6e889d98102046fe7159475a2c29b7443b29c7fa6e889d91481151715612185576fe7159475a2c29b7443b29c7fa6e889d90260801c916115b2565b91806ff3392b0822b70005940c7a398e4b70f38102046ff3392b0822b70005940c7a398e4b70f31481151715612185576ff3392b0822b70005940c7a398e4b70f30260801c916115a8565b91806ff987a7253ac413176f2b074cf7815e548102046ff987a7253ac413176f2b074cf7815e541481151715612185576ff987a7253ac413176f2b074cf7815e540260801c9161159e565b91806ffcbe86c7900a88aedcffc83b479aa3a48102046ffcbe86c7900a88aedcffc83b479aa3a41481151715612185576ffcbe86c7900a88aedcffc83b479aa3a40260801c91611594565b91806ffe5dee046a99a2a811c461f1969c30538102046ffe5dee046a99a2a811c461f1969c30531481151715612185576ffe5dee046a99a2a811c461f1969c30530260801c9161158a565b91806fff2ea16466c96a3843ec78b326b528618102046fff2ea16466c96a3843ec78b326b528611481151715612185576fff2ea16466c96a3843ec78b326b528610260801c91611581565b91806fff973b41fa98c081472e6896dfb254c08102046fff973b41fa98c081472e6896dfb254c01481151715612185576fff973b41fa98c081472e6896dfb254c00260801c91611578565b91806fffcb9843d60f6159c9db58835c9266448102046fffcb9843d60f6159c9db58835c9266441481151715612185576fffcb9843d60f6159c9db58835c9266440260801c9161156f565b91806fffe5caca7e10e4e61c3624eaa0941cd08102046fffe5caca7e10e4e61c3624eaa0941cd01481151715612185576fffe5caca7e10e4e61c3624eaa0941cd00260801c91611566565b91806ffff2e50f5f656932ef12357cf3c7fdcc8102046ffff2e50f5f656932ef12357cf3c7fdcc1481151715612185576ffff2e50f5f656932ef12357cf3c7fdcc0260801c9161155d565b91806ffff97272373d413259a46990580e213a8102046ffff97272373d413259a46990580e213a1481151715612185576ffff97272373d413259a46990580e213a0260801c91611554565b6001600160881b03600160801b611549565b60405162461bcd60e51b81526020600482015260016024820152601560fa1b6044820152606490fd5b634e487b7160e01b89526011600452602489fd5b8260020b9061151c565b612703915060203d602011611f9657611f878183612a88565b386114f6565b60405162461bcd60e51b8152602060048201526024808201527f546f6b656e2061646472657373206d757374206265206c657373207468616e206044820152630ae8aa8960e31b6064820152608490fd5b634e487b7160e01b8c52604160045260248cfd5b91965090627fffff1981146000198314166120bf5781900560020b028060020b9081036126cc5794388061133e565b634e487b7160e01b89526012600452602489fd5b90506020813d6020116127e9575b816127cc60209383612a88565b810103126127e557518060020b81036127e557386112ea565b8880fd5b3d91506127bf565b60405162461bcd60e51b815260206004820152600960248201526805072696365203c20360bc1b6044820152606490fd5b60405162461bcd60e51b8152602060048201526015602482015274125b9cdd59999a58da595b9d08115512081cd95b9d605a1b6044820152606490fd5b60405162461bcd60e51b815260206004820152601c60248201527f54776974746572206e616d652063616e6e6f7420626520656d707479000000006044820152606490fd5b60405162461bcd60e51b815260206004820152601060248201526f24b73b30b634b2103332b2903a34b2b960811b6044820152606490fd5b60405162461bcd60e51b815260206004820152601660248201527553796d626f6c2063616e6e6f7420626520656d70747960501b6044820152606490fd5b60405162461bcd60e51b81526020600482015260146024820152734e616d652063616e6e6f7420626520656d70747960601b6044820152606490fd5b60405162461bcd60e51b815260206004820152601860248201527f496e76616c6964206465706c6f796572206164647265737300000000000000006044820152606490fd5b60405162461bcd60e51b815260206004820152601d60248201527f537570706c79206d7573742062652067726561746572207468616e20300000006044820152606490fd5b60405162461bcd60e51b815260206004820152601a60248201527f546f6b656e206372656174696f6e2069732064697361626c65640000000000006044820152606490fd5b50346102e25760203660031901126102e25750604051670de0b6b3a7640000655af1e679571060043505058152602090f35b608081019081106001600160401b03821117612a7257604052565b634e487b7160e01b600052604160045260246000fd5b90601f801991011681019081106001600160401b03821117612a7257604052565b6001600160401b038111612a7257601f01601f191660200190565b81601f82011215611d9057803590612adb82612aa9565b92612ae96040519485612a88565b82845260208383010111611d9057816000926020809301838601378301015290565b600435906001600160a01b0382168203611d9057565b9181601f84011215611d90578235916001600160401b038311611d905760208381860195010111611d9057565b600454811015612b6957600460005260206000200190600090565b634e487b7160e01b600052603260045260246000fd5b600154811015612b6957600160005260206000200190600090565b8054821015612b695760005260206000200190600090565b60005b838110612bc55750506000910152565b8181015183820152602001612bb5565b90602091612bee81518092818552858086019101612bb2565b601f01601f1916010190565b90816020910312611d9057516001600160a01b0381168103611d905790565b90816020910312611d9057518015158103611d905790565b908060209392818452848401376000828201840152601f01601f1916010190565b979298909a93959a99949196998760405198899260208401378101602081016910313c902632b9ba32b960b11b90520360200160151981018852600a01612c999088612a88565b611523996040519860208c01612caf908b612a88565b8b8a5260208a019b612f4f8d396040519a8b9860208a019a6101208c526101408b01612cda91612bd5565b90601f198b83030160408c0152612cf092612c31565b60608901949094526001600160a01b0390811660808901527f0000000000000000000000000000000000000000000000000000000000000000811660a08901527f00000000000000000000000000000000000000000000000000000000000000001660c088015260e0870152858203601f1901610100870152612d7292612c31565b90601f1984830301610120850152612d8992612c31565b03601f1981018452612d9b9084612a88565b60405192839260208401958691518092612db492612bb2565b83019051918260208301612dc792612bb2565b0103808252612dd99060200182612a88565b519020906040519160408301526020820152308152600b0160ff8153605590206001600160a01b031690565b15612e0c57565b60405162461bcd60e51b81526020600482015260116024820152702737ba1030903a32b0b69036b2b6b132b960791b6044820152606490fd5b6001600160401b038111612a725760051b60200190565b805115612b695760200190565b8051821015612b695760209160051b010190565b6000198114612e8c5760010190565b634e487b7160e01b600052601160045260246000fd5b906040519163c43cb3fb60e01b83526004830152602482015260208160448173a1e439a765f42f9de43681dfa67b6a66f7907b7a5af4908115612f1957600091612eea575090565b90506020813d602011612f11575b81612f0560209383612a88565b81010312611d90575190565b3d9150612ef8565b6040513d6000823e3d90fd5b6000546001600160a01b03163303612f3957565b63118cdaa760e01b6000523360045260246000fdfe60c0604052346107b35761152380380380610019816107b8565b928339810190610120818303126107b35780516001600160401b0381116107b357826100469183016107dd565b60208201519091906001600160401b0381116107b357836100689183016107dd565b9060408101519161007b60608301610848565b61008760808401610848565b9061009460a08501610848565b9260c08501519460e081015160018060401b0381116107b357896100b99183016107dd565b6101008201519099906001600160401b0381116107b3576100da92016107dd565b875190976001600160401b0382116106b05760035490600182811c921680156107a9575b60208310146106905781601f849311610739575b50602090601f83116001146106d1576000926106c6575b50508160011b916000199060031b1c1916176003555b8051906001600160401b0382116106b05760045490600182811c921680156106a6575b60208310146106905781601f849311610620575b50602090601f83116001146105b8576000926105ad575b50508160011b916000199060031b1c1916176004555b6001600160a01b0316801561059757600580546001600160a01b03198116831790915581906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a360018060a01b031960065416176006553360018060a01b0319600754161760075560805260a05233156105815760009160025481810180911161056d576002553383528260205260408320818154019055604051908152827fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60203393a360095582516001600160401b03811161055957600b54600181811c9116801561054f575b602082101461053b57601f81116104d8575b506020601f82116001146104755782939482939261046a575b50508160011b916000199060031b1c191617600b555b8151906001600160401b03821161045657600c54600181811c9116801561044c575b602082101461043857601f81116103d5575b50602090601f831160011461037457919283610369575b50508160011b916000199060031b1c191617600c555b604051610cc6908161085d82396080518181816106070152610c1f015260a0518181816104e80152610bec0152f35b015190503880610324565b90601f19831693600c8352818320925b8581106103bd575083600195106103a4575b505050811b01600c5561033a565b015160001960f88460031b161c19169055388080610396565b91926020600181928685015181550194019201610384565b600c82527fdf6966c971051c3d54ec59162606531493a51404a002842f56009d7e5cf4a8c7601f840160051c8101916020851061042e575b601f0160051c01905b818110610423575061030d565b828155600101610416565b909150819061040d565b634e487b7160e01b82526022600452602482fd5b90607f16906102fb565b634e487b7160e01b81526041600452602490fd5b0151905038806102c3565b600b835280832090601f198316845b8181106104c0575095836001959697106104a7575b505050811b01600b556102d9565b015160001960f88460031b161c19169055388080610499565b9192602060018192868b015181550194019201610484565b600b83527f0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01db9601f830160051c81019160208410610531575b601f0160051c01905b81811061052657506102aa565b838155600101610519565b9091508190610510565b634e487b7160e01b83526022600452602483fd5b90607f1690610298565b634e487b7160e01b82526041600452602482fd5b634e487b7160e01b84526011600452602484fd5b63ec442f0560e01b600052600060045260246000fd5b631e4fbdf760e01b600052600060045260246000fd5b01519050388061018d565b600460009081528281209350601f198516905b81811061060857509084600195949392106105ef575b505050811b016004556101a3565b015160001960f88460031b161c191690553880806105e1565b929360206001819287860151815501950193016105cb565b60046000529091507f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b601f840160051c81019160208510610686575b90601f859493920160051c01905b8181106106775750610176565b6000815584935060010161066a565b909150819061065c565b634e487b7160e01b600052602260045260246000fd5b91607f1691610162565b634e487b7160e01b600052604160045260246000fd5b015190503880610129565b600360009081528281209350601f198516905b8181106107215750908460019594939210610708575b505050811b0160035561013f565b015160001960f88460031b161c191690553880806106fa565b929360206001819287860151815501950193016106e4565b60036000529091507fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b601f840160051c8101916020851061079f575b90601f859493920160051c01905b8181106107905750610112565b60008155849350600101610783565b9091508190610775565b91607f16916100fe565b600080fd5b6040519190601f01601f191682016001600160401b038111838210176106b057604052565b81601f820112156107b3578051906001600160401b0382116106b05761080c601f8301601f19166020016107b8565b92828452602083830101116107b35760005b82811061083357505060206000918301015290565b8060208092840101518282870101520161081e565b51906001600160a01b03821682036107b35756fe6080604052600436101561001257600080fd5b60003560e01c806306fdde031461092b578063095ea7b3146108a55780630d43e8ad1461087c5780631755ff211461085357806318160ddd1461083557806323b872dd14610748578063313ce5671461072c5780634d669f8714610654578063599ca397146106365780635b549182146105f15780635f438c5a146105c857806370a082311461058e578063715018a614610517578063791b98bc146104d25780638da5cb5b146104a957806395d89b41146103d1578063a9059cbb146103a0578063abb5ca091461027d578063d5f3948814610254578063dd62ed3e14610203578063e9e15b4f146101725763f2fde38b1461010e57600080fd5b3461016d57602036600319011261016d57610127610a4c565b5060405162461bcd60e51b815260206004820152601e60248201527f4f776e657273686970207472616e736665722069732064697361626c656400006044820152606490fd5b600080fd5b3461016d57602036600319011261016d5761018b610a4c565b6007546001600160a01b031633036101bf57600880546001600160a01b0319166001600160a01b0392909216919091179055005b606460405162461bcd60e51b815260206004820152602060248201527f4f6e6c79204c65737465722063616e2073657420706f6f6c20616464726573736044820152fd5b3461016d57604036600319011261016d5761021c610a4c565b610224610a62565b6001600160a01b039182166000908152600160209081526040808320949093168252928352819020549051908152f35b3461016d57600036600319011261016d576006546040516001600160a01b039091168152602090f35b3461016d57600036600319011261016d576040516000600c548060011c90600181168015610396575b60208310811461038257828552908115610366575060011461030f575b50819003601f01601f191681019067ffffffffffffffff8211818310176102f957604082905281906102f59082610a03565b0390f35b634e487b7160e01b600052604160045260246000fd5b600c60009081529091507fdf6966c971051c3d54ec59162606531493a51404a002842f56009d7e5cf4a8c75b828210610350575060209150820101826102c3565b600181602092548385880101520191019061033b565b90506020925060ff191682840152151560051b820101826102c3565b634e487b7160e01b84526022600452602484fd5b91607f16916102a6565b3461016d57604036600319011261016d576103c66103bc610a4c565b6024359033610a78565b602060405160018152f35b3461016d57600036600319011261016d5760405160006004548060011c9060018116801561049f575b6020831081146103825782855290811561036657506001146104485750819003601f01601f191681019067ffffffffffffffff8211818310176102f957604082905281906102f59082610a03565b600460009081529091507f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b5b828210610489575060209150820101826102c3565b6001816020925483858801015201910190610474565b91607f16916103fa565b3461016d57600036600319011261016d576005546040516001600160a01b039091168152602090f35b3461016d57600036600319011261016d576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b3461016d57600036600319011261016d576005546001600160a01b038116338103610579576000916bffffffffffffffffffffffff60a01b166005557f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a3005b63118cdaa760e01b6000523360045260246000fd5b3461016d57602036600319011261016d576001600160a01b036105af610a4c565b1660005260006020526020604060002054604051908152f35b3461016d57600036600319011261016d576007546040516001600160a01b039091168152602090f35b3461016d57600036600319011261016d576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b3461016d57600036600319011261016d576020600954604051908152f35b3461016d57600036600319011261016d576040516000600b548060011c90600181168015610722575b6020831081146103825782855290811561036657506001146106cb5750819003601f01601f191681019067ffffffffffffffff8211818310176102f957604082905281906102f59082610a03565b600b60009081529091507f0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01db95b82821061070c575060209150820101826102c3565b60018160209254838588010152019101906106f7565b91607f169161067d565b3461016d57600036600319011261016d57602060405160128152f35b3461016d57606036600319011261016d57610761610a4c565b610769610a62565b6001600160a01b03821660008181526001602081815260408084203385529091529091205491936044359392909181016107a9575b506103c69350610a78565b8381106108185784156108025733156107ec576103c6946000526001602052604060002060018060a01b033316600052602052836040600020910390558461079e565b634a1406b160e11b600052600060045260246000fd5b63e602df0560e01b600052600060045260246000fd5b8390637dc7a0d960e11b6000523360045260245260445260646000fd5b3461016d57600036600319011261016d576020600254604051908152f35b3461016d57600036600319011261016d576008546040516001600160a01b039091168152602090f35b3461016d57600036600319011261016d57600a546040516001600160a01b039091168152602090f35b3461016d57604036600319011261016d576108be610a4c565b602435903315610802576001600160a01b03169081156107ec57336000526001602052604060002082600052602052806040600020556040519081527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560203392a3602060405160018152f35b3461016d57600036600319011261016d5760405160006003548060011c906001811680156109f9575b6020831081146103825782855290811561036657506001146109a25750819003601f01601f191681019067ffffffffffffffff8211818310176102f957604082905281906102f59082610a03565b600360009081529091507fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b5b8282106109e3575060209150820101826102c3565b60018160209254838588010152019101906109ce565b91607f1691610954565b91909160208152825180602083015260005b818110610a36575060409293506000838284010152601f8019910116010190565b8060208092870101516040828601015201610a15565b600435906001600160a01b038216820361016d57565b602435906001600160a01b038216820361016d57565b6001600160a01b0316908115610c7a576001600160a01b0316918215610c64576007546001600160a01b031683141580610c4f575b80610c1c575b80610be9575b80610bd4575b610b3d575b6000828152806020526040812054828110610b235791604082827fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef958760209652828652038282205586815280845220818154019055604051908152a3565b916064928463391434e360e21b8452600452602452604452fd5b60025460095490818102918183041490151715610bbe5783600052600060205260406000205490828201809211610bbe576103e890041015610ac45760405162461bcd60e51b815260206004820152601e60248201527f4d61782077616c6c65742070657263656e7461676520657863656564656400006044820152606490fd5b634e487b7160e01b600052601160045260246000fd5b506008546001600160a01b0316831415610abf565b507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316831415610ab9565b507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316831415610ab3565b506007546001600160a01b0316821415610aad565b63ec442f0560e01b600052600060045260246000fd5b634b637e8f60e11b600052600060045260246000fdfea26469706673582212203164054787ae8ee84b6a68f57d4dad5838b79c532963ea942aaf34a9d725685364736f6c634300081b0033a264697066735822122051bf944aaf1890692803dbe9f1973486abf5144b69cd99ce06237e5e9cad604364736f6c634300081b0033000000000000000000000000420000000000000000000000000000000000000600000000000000000000000033128a8fc17869897dce68ed026d694621f6fdfd00000000000000000000000003a520b32c04bf3beef7beb72e919cf822ed34f10000000000000000000000002626664c2603336e57b271c5c0b26f421741e481000000000000000000000000673fafcd2eb926c39cba9fef2a4c9749d74f3c86

Deployed Bytecode

0x6080604052600436101561001b575b361561001957600080fd5b005b6000803560e01c80630d9a444614612a2557806313a9e9d91461112257806314eba02614610fa65780633e413bee14610f615780633eb2b5ad14610e6a5780633fc8cef314610e2557806346ca626b14610e095780634e6fd6c414610dc4578063599b261e14610cf15780635b54918214610cac578063686f2c901461098d5780636a5dab9f146108ff578063715018a6146108a5578063791b98bc146108605780638da5cb5b146108395780639ead72221461080e578063a10b521b146107eb578063a480ca791461057c578063bbe9f99d1461053d578063c0dd7cd5146104e6578063c31c9c07146104a1578063c43cb3fb14610477578063e75f7ddb14610433578063efded1471461036b578063f2fde38b146102e55763fd8b3c9d14610145575061000e565b346102e25760e03660031901126102e25761015e612b0b565b906024356001600160401b0381116102e05761017e903690600401612b21565b916044356001600160401b0381116102e05761019e903690600401612b21565b92909360a4356001600160401b0381116102dc576101c0903690600401612b21565b92909160c435976001600160401b0389116102d8578261020a85899b98886101ee8d9c9b3690600401612b21565b9c819c848f969395509788915b608435938c606435938d612c52565b6001600160a01b037f0000000000000000000000004200000000000000000000000000000000000006811690821610806102cf575b6102b5575061024d90612e7d565b986103e88a10156102705761020a988a919a888888848f94959e958a8f966101fb565b60405162461bcd60e51b815260206004820152601960248201527f436f756c64206e6f742066696e642076616c69642073616c74000000000000006044820152606490fd5b604080519283526001600160a01b03909116602083015290f35b50803b1561023f565b8580fd5b8380fd5b505b80fd5b50346102e25760203660031901126102e2576102ff612b0b565b610307612f25565b6001600160a01b031680156103575781546001600160a01b03198116821783556001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08380a380f35b631e4fbdf760e01b82526004829052602482fd5b50346102e257806003193601126102e25760405180602060045491828152018091600485527f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b90855b81811061041457505050826103ca910383612a88565b604051928392602084019060208552518091526040840192915b8181106103f2575050500390f35b82516001600160a01b03168452859450602093840193909201916001016103e4565b82546001600160a01b03168452602090930192600192830192016103b4565b50346102e25760203660031901126102e257600435906004548210156102e257602061045e83612b4e565b905460405160039290921b1c6001600160a01b03168152f35b50346102e25760403660031901126102e2576020610499602435600435612ea2565b604051908152f35b50346102e257806003193601126102e2576040517f0000000000000000000000002626664c2603336e57b271c5c0b26f421741e4816001600160a01b03168152602090f35b50346102e25760403660031901126102e257610500612b0b565b6001600160a01b03168152600260205260408120805460243592908310156102e257602061052e8484612b9a565b90549060031b1c604051908152f35b50346102e25760203660031901126102e25760209060ff906040906001600160a01b03610568612b0b565b168152600384522054166040519015158152f35b50346102e25760203660031901126102e257610596612b0b565b338252600360205260ff60408320541680156107d8575b6105b690612e05565b60018060a01b031681526002602052604081206040518082602082945493848152019085526020852092855b8181106107bf5750506105f792500382612a88565b80511561077a5781546001600160a01b037f00000000000000000000000003a520b32c04bf3beef7beb72e919cf822ed34f181169184911661063884612e5c565b5190833b1561076b5760405163095ea7b360e01b81526001600160a01b039190911660048201526024810191909152818160448183875af1801561076f57610756575b505b8251811015610752576106908184612e69565b518454604051916001600160801b03916001600160a01b0316906106b384612a57565b835260208301908152604080840183815260608501848152825163fc6f786560e01b81529551600487015292516001600160a01b031660248601525183166044850152905190911660648301528160848188875af180156107475761071c575b5060010161067d565b604090813d8111610740575b6107328183612a88565b810103126102dc5738610713565b503d610728565b6040513d87823e3d90fd5b8380f35b8161076091612a88565b61076b57823861067b565b8280fd5b6040513d84823e3d90fd5b60405162461bcd60e51b815260206004820152601b60248201527f4e6f20706f736974696f6e7320666f72207468697320746f6b656e00000000006044820152606490fd5b84548352600194850194869450602090930192016105e2565b5081546001600160a01b031633146105ad565b50346102e257806003193601126102e257602060ff600554166040519015158152f35b50346102e25760203660031901126102e257600435906001548210156102e257602061045e83612b7f565b50346102e257806003193601126102e257546040516001600160a01b039091168152602090f35b50346102e257806003193601126102e2576040517f00000000000000000000000003a520b32c04bf3beef7beb72e919cf822ed34f16001600160a01b03168152602090f35b50346102e257806003193601126102e2576108be612f25565b80546001600160a01b03198116825581906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b50346102e25760203660031901126102e2576004358015158091036102e05760207f1a3f40fae3a310ca113098ad34d161433ab7e470c2a167b60a190a80364043bc913384526003825260ff604085205416801561097a575b61096190612e05565b60ff196005541660ff821617600555604051908152a180f35b5083546001600160a01b03163314610958565b50346102e257806003193601126102e257338152600360205260ff6040822054168015610c99575b6109be90612e05565b6001546109ca81612e45565b906109d86040519283612a88565b808252601f196109e782612e45565b013660208401378290835b818110610c2f575083927f00000000000000000000000003a520b32c04bf3beef7beb72e919cf822ed34f16001600160a01b03169291505b818410610a35578480f35b6001600160a01b03610a478583612e69565b5116338652600360205260ff6040872054168015610c1c575b610a6990612e05565b85526002602052604085209160405180938491602082549182815201918952602089209089905b808210610c045750505090610aa6910384612a88565b82511561077a57855486906001600160a01b0316610ac385612e5c565b5190863b1561076b5760405163095ea7b360e01b81526001600160a01b0391909116600482015260248101919091528181604481838a5af1801561076f57610bef575b505b8351811015610be157610b1b8185612e69565b518754604051916001600160801b03916001600160a01b031690610b3e84612a57565b835260208301908152604080840183815260608501848152825163fc6f786560e01b81529551600487015292516001600160a01b03166024860152518316604485015290519091166064830152816084818b8a5af18015610bd657610ba7575b50600101610b08565b604090813d8111610bcf575b610bbd8183612a88565b81010312610bcb5738610b9e565b8680fd5b503d610bb3565b6040513d8a823e3d90fd5b506001909401939150610a2a565b81610bf991612a88565b6102d8578538610b06565b90919260016020819286548152019401920190610a90565b5085546001600160a01b03163314610a60565b610c3881612b7f565b905460039190911b1c6001600160a01b0316855260026020526040852054610c63575b6001016109f2565b91610c91600191610c7385612b7f565b848060a01b0391549060031b1c16610c8b8288612e69565b52612e7d565b929050610c5b565b5080546001600160a01b031633146109b5565b50346102e257806003193601126102e2576040517f00000000000000000000000033128a8fc17869897dce68ed026d694621f6fdfd6001600160a01b03168152602090f35b50346102e2576101003660031901126102e257610d0c612b0b565b906024356001600160401b0381116102e057610d2c903690600401612b21565b9290916044356001600160401b0381116102e057610d4e903690600401612b21565b94909360c4356001600160401b0381116102dc57610d70903690600401612b21565b94909360e435906001600160401b0382116102e2576020610db28a8a8a8a8a8a8a610d9e3660048d01612b21565b97909660a435946084359460643594612c52565b6040516001600160a01b039091168152f35b50346102e257806003193601126102e2576040517f000000000000000000000000000000000000000000000000000000000000dead6001600160a01b03168152602090f35b50346102e257806003193601126102e257602060405160c88152f35b50346102e257806003193601126102e2576040517f00000000000000000000000042000000000000000000000000000000000000066001600160a01b03168152602090f35b50346102e25760203660031901126102e257610e84612b0b565b610e8c612f25565b6001600160a01b0381168083526003602052604083205490919060ff16610f4f57818352600360205260408320805460ff19166001179055600454600160401b811015610f3b5791610f31602092610f0d8560017fcb5d35f3d58007ab65c22252d42a544314d3bf8e16e71d153996fd99735653de97016004556004612b9a565b81546001600160a01b0393841660039290921b91821b9390911b1916919091179055565b604051908152a180f35b634e487b7160e01b84526041600452602484fd5b6001622d600560e11b03198352600483fd5b50346102e257806003193601126102e2576040517f000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda029136001600160a01b03168152602090f35b50346102e25760203660031901126102e257610fc0612b0b565b610fc8612f25565b6001600160a01b03168082526003602052604082205460ff161561111357808252600360205260408220805460ff19169055815b600454808210156110e8578261101183612b4e565b905460039190911b1c6001600160a01b0316146110315750600101610ffc565b60001981019081116110d45790610f0d61104d61106593612b4e565b905460039190911b1c6001600160a01b031691612b4e565b60045480156110c0577f113ac15d1e9d35bbc48c65ac66da9d44808929220056e22450b3c48222e8ec7391602091600019016110a081612b4e565b81549060018060a01b039060031b1b19169055600455604051908152a180f35b634e487b7160e01b83526031600452602483fd5b634e487b7160e01b84526011600452602484fd5b505060207f113ac15d1e9d35bbc48c65ac66da9d44808929220056e22450b3c48222e8ec7391610f31565b6306278fb360e21b8252600482fd5b506101603660031901126102e2576004356001600160401b0381116102e05761114f903690600401612ac4565b6024356001600160401b03811161076b5761116e903690600401612ac4565b9062ffffff608435166084350361076b5760c435906001600160a01b03821682036102dc57610124356001600160401b038111611e41576111b3903690600401612ac4565b90610144356001600160401b0381116102d8576111d4903690600401612ac4565b9160ff60055416156129e0576044351561299b576001600160a01b038416156129565781511561291a578451156128dc5761271062ffffff60843516036128a45780511561285f576101043534106128225760405192611267600a602086865161124381848401858b01612bb2565b81016910313c902632b9ba32b960b11b838201520301601519810187520185612a88565b670de0b6b3a7640000655af1e6795710611285606435604435612ea2565b050591878313156127f1576040516322afcccb60e01b815260843562ffffff1660048201526020816024817f00000000000000000000000033128a8fc17869897dce68ed026d694621f6fdfd6001600160a01b03165afa908115611f9d5789916127b1575b5060020b94851561279d5785620d89e80793627fffff8560020b620d89e80313627fffff198660020b620d89e80312176120bf5760020b627fffff1981146120bf578903958660020b81810760020b61276e575b50506040519161152391828401928484106001600160401b0385111761275a576114229261139261138487969461140f94612f4f89396101208652610120860190612bd5565b84810360208601528d612bd5565b60443560408501526001600160a01b038c811660608601527f00000000000000000000000033128a8fc17869897dce68ed026d694621f6fdfd811660808601527f00000000000000000000000003a520b32c04bf3beef7beb72e919cf822ed34f11660a085015260e43560c085015283810360e085015290612bd5565b9061010081830391015260a43594612bd5565b039088f5928315611d9d576001600160a01b037f00000000000000000000000042000000000000000000000000000000000000068116908516101561270957604051630b4c774160e11b81526001600160a01b0385811660048301527f000000000000000000000000420000000000000000000000000000000000000616602482015262ffffff608435166044820152602081806064810103817f00000000000000000000000033128a8fc17869897dce68ed026d694621f6fdfd6001600160a01b03165afa908115610bd65788916126ea575b5080888360020b126000146126e057600283900b600160ff1b146126cc578260020b8903905b620d89e882116126a3576001821615612691576001600160881b036ffffcb933bd6fad37aa2d162d1a5940015b169160028116612646575b600481166125fb575b600881166125b0575b60108116612565575b6020811661251a575b604081166124cf575b60808116612484575b6101008116612439575b61020081166123ee575b61040081166123a3575b6108008116612358575b611000811661230d575b61200081166122c2575b6140008116612277575b618000811661222c575b6201000081166121e1575b620200008116612199575b620400008116612140575b6208000016612101575b898460020b136120dc575b63ffffffff8260201c9216156000146120d35760ff8a5b1682018092116120bf576001600160a01b031615611fa8575b50604051630b4c774160e11b81526001600160a01b0386811660048301527f000000000000000000000000420000000000000000000000000000000000000616602482015262ffffff60843516604482015290602082806064810103817f00000000000000000000000033128a8fc17869897dce68ed026d694621f6fdfd6001600160a01b03165afa918215611f9d578992611f6c575b506001600160a01b039081169116819003611f345787906001600160a01b0386163b156102e05760405163e9e15b4f60e01b815260048101919091528181602481836001600160a01b038b165af1801561076f57611f1f575b505060405163095ea7b360e01b81526001600160a01b037f00000000000000000000000003a520b32c04bf3beef7beb72e919cf822ed34f1811660048301526000196024830152602090829060449082908c908a165af18015610bd657611f02575b5060405163a9059cbb60e01b81523060048201526044803560248301526020908290818b6001600160a01b038a165af18015610bd657611ee5575b50603c420190814211611ed1576040519261016084018481106001600160401b03821117611ebd5790899160405260018060a01b0387168552602085019260018060a01b037f0000000000000000000000004200000000000000000000000000000000000006168452604086019162ffffff608435168352606087019160020b8252608087019060020b620d89e80360020b815260a0870190604435825260c088019285845262ffffff60e08a01958787526101008b019788526101208b0198308a526101408c019a8b526040519b634418b22b60e11b8d5260018060a01b0390511660048d015260018060a01b0390511660248c0152511660448a01525160020b60648901525160020b60848801525160a48701525160c48601525160e48501525161010484015260018060a01b0390511661012483015251610144820152608081610164818960018060a01b037f00000000000000000000000003a520b32c04bf3beef7beb72e919cf822ed34f1165af1908115611d9d578691611e76575b506001600160a01b0383168652600260205260408620805490600160401b821015611da8579061198391600182018155612b9a565b819291549060031b91821b91600019901b1916179055600154600160401b811015611e62576119bd8160016119dc93016001556001612b9a565b81546001600160a01b0386811660039390931b92831b921b1916179055565b60405163095ea7b360e01b81526001600160a01b037f00000000000000000000000003a520b32c04bf3beef7beb72e919cf822ed34f1811660048301526000196024830152602090829060449082908a9088165af18015611d9d57611e45575b507f00000000000000000000000042000000000000000000000000000000000000066001600160a01b03163b15611e4157604051630d0e30db60e41b815285908181600481610104357f00000000000000000000000042000000000000000000000000000000000000066001600160a01b03165af1801561076f57611e2c575b505060405163095ea7b360e01b81527f0000000000000000000000002626664c2603336e57b271c5c0b26f421741e4816001600160a01b038116600483015261010435602483015290602081806044810103818a7f00000000000000000000000042000000000000000000000000000000000000066001600160a01b03165af1908115611e21578791611df2575b5015611dbc5760405160e081018181106001600160401b03821117611da8579060209160405260018060a01b037f000000000000000000000000420000000000000000000000000000000000000616815260e48282019160018060a01b038716835289604082019562ffffff608435168752606083013381526080840161010435815260a085019084825260c086019285845262ffffff6040519b8c9a8b996304e45aaf60e01b8b5260018060a01b0390511660048b015260018060a01b0390511660248a01525116604488015260018060a01b0390511660648701525160848601525160a485015260018060a01b0390511660c484015260018060a01b03165af18015611d9d57611d69575b50610104353411611cd6575b7f6e6ae68e7d7d45fbd855c40d1eaafa8de46c5fbec3ee26f1af88730e400bc92c93611cba611cc89260405195869560018060a01b0316865260018060a01b0316602086015260a0604086015260a0850190612bd5565b908382036060850152612bd5565b60443560808301520390a180f35b610104353403348111611d55578580808093335af13d15611d50573d611cfb81612aa9565b90611d096040519283612a88565b81528660203d92013e5b611c635760405162461bcd60e51b8152602060048201526011602482015270115512081c99599d5b990819985a5b1959607a1b6044820152606490fd5b611d13565b634e487b7160e01b86526011600452602486fd5b6020813d602011611d95575b81611d8260209383612a88565b81010312611d905751611c57565b600080fd5b3d9150611d75565b6040513d88823e3d90fd5b634e487b7160e01b88526041600452602488fd5b60405162461bcd60e51b815260206004820152600e60248201526d105c1c1c9bdd994819985a5b195960921b6044820152606490fd5b611e14915060203d602011611e1a575b611e0c8183612a88565b810190612c19565b38611b4a565b503d611e02565b6040513d89823e3d90fd5b81611e3691612a88565b611e41578438611abc565b8480fd5b611e5d9060203d602011611e1a57611e0c8183612a88565b611a3c565b634e487b7160e01b86526041600452602486fd5b90506080813d608011611eb5575b81611e9160809383612a88565b810103126102d857602081519101516001600160801b038116036102d8573861194e565b3d9150611e84565b634e487b7160e01b8a52604160045260248afd5b634e487b7160e01b88526011600452602488fd5b611efd9060203d602011611e1a57611e0c8183612a88565b6117cd565b611f1a9060203d602011611e1a57611e0c8183612a88565b611792565b81611f2991612a88565b610bcb578638611730565b60405162461bcd60e51b815260206004820152601060248201526f141bdbdb081b9bdd0818dc99585d195960821b6044820152606490fd5b611f8f91925060203d602011611f96575b611f878183612a88565b810190612bfa565b90386116d7565b503d611f7d565b6040513d8b823e3d90fd5b60405163a167129560e01b81526001600160a01b0387811660048301527f000000000000000000000000420000000000000000000000000000000000000616602482015262ffffff6084351660448201529150889060208380606481010381857f00000000000000000000000033128a8fc17869897dce68ed026d694621f6fdfd6001600160a01b03165af192831561076f57829361209e575b50826001600160a01b0381163b1561076b5760405163f637731d60e01b81526001600160a01b0392831660048201529291839160249183918591165af18015611f9d5715611640578861209791999299612a88565b9638611640565b6120b891935060203d602011611f9657611f878183612a88565b9138612042565b634e487b7160e01b8a52601160045260248afd5b60ff6001611627565b9080156120ed576000190490611610565b634e487b7160e01b8a52601260045260248afd5b90806b048a170391f7dc42444e8fa28102046b048a170391f7dc42444e8fa214811517156120bf576b048a170391f7dc42444e8fa20260801c90611605565b91806d2216e584f5fa1ea926041bedfe988102046d2216e584f5fa1ea926041bedfe981481151715612185576d2216e584f5fa1ea926041bedfe980260801c916115fb565b634e487b7160e01b8b52601160045260248bfd5b91806e5d6af8dedb81196699c329225ee6048102046e5d6af8dedb81196699c329225ee6041481151715612185576e5d6af8dedb81196699c329225ee6040260801c916115f0565b91806f09aa508b5b7a84e1c677de54f3e99bc98102046f09aa508b5b7a84e1c677de54f3e99bc91481151715612185576f09aa508b5b7a84e1c677de54f3e99bc90260801c916115e5565b91806f31be135f97d08fd981231505542fcfa68102046f31be135f97d08fd981231505542fcfa61481151715612185576f31be135f97d08fd981231505542fcfa60260801c916115da565b91806f70d869a156d2a1b890bb3df62baf32f78102046f70d869a156d2a1b890bb3df62baf32f71481151715612185576f70d869a156d2a1b890bb3df62baf32f70260801c916115d0565b91806fa9f746462d870fdf8a65dc1f90e061e58102046fa9f746462d870fdf8a65dc1f90e061e51481151715612185576fa9f746462d870fdf8a65dc1f90e061e50260801c916115c6565b91806fd097f3bdfd2022b8845ad8f792aa58258102046fd097f3bdfd2022b8845ad8f792aa58251481151715612185576fd097f3bdfd2022b8845ad8f792aa58250260801c916115bc565b91806fe7159475a2c29b7443b29c7fa6e889d98102046fe7159475a2c29b7443b29c7fa6e889d91481151715612185576fe7159475a2c29b7443b29c7fa6e889d90260801c916115b2565b91806ff3392b0822b70005940c7a398e4b70f38102046ff3392b0822b70005940c7a398e4b70f31481151715612185576ff3392b0822b70005940c7a398e4b70f30260801c916115a8565b91806ff987a7253ac413176f2b074cf7815e548102046ff987a7253ac413176f2b074cf7815e541481151715612185576ff987a7253ac413176f2b074cf7815e540260801c9161159e565b91806ffcbe86c7900a88aedcffc83b479aa3a48102046ffcbe86c7900a88aedcffc83b479aa3a41481151715612185576ffcbe86c7900a88aedcffc83b479aa3a40260801c91611594565b91806ffe5dee046a99a2a811c461f1969c30538102046ffe5dee046a99a2a811c461f1969c30531481151715612185576ffe5dee046a99a2a811c461f1969c30530260801c9161158a565b91806fff2ea16466c96a3843ec78b326b528618102046fff2ea16466c96a3843ec78b326b528611481151715612185576fff2ea16466c96a3843ec78b326b528610260801c91611581565b91806fff973b41fa98c081472e6896dfb254c08102046fff973b41fa98c081472e6896dfb254c01481151715612185576fff973b41fa98c081472e6896dfb254c00260801c91611578565b91806fffcb9843d60f6159c9db58835c9266448102046fffcb9843d60f6159c9db58835c9266441481151715612185576fffcb9843d60f6159c9db58835c9266440260801c9161156f565b91806fffe5caca7e10e4e61c3624eaa0941cd08102046fffe5caca7e10e4e61c3624eaa0941cd01481151715612185576fffe5caca7e10e4e61c3624eaa0941cd00260801c91611566565b91806ffff2e50f5f656932ef12357cf3c7fdcc8102046ffff2e50f5f656932ef12357cf3c7fdcc1481151715612185576ffff2e50f5f656932ef12357cf3c7fdcc0260801c9161155d565b91806ffff97272373d413259a46990580e213a8102046ffff97272373d413259a46990580e213a1481151715612185576ffff97272373d413259a46990580e213a0260801c91611554565b6001600160881b03600160801b611549565b60405162461bcd60e51b81526020600482015260016024820152601560fa1b6044820152606490fd5b634e487b7160e01b89526011600452602489fd5b8260020b9061151c565b612703915060203d602011611f9657611f878183612a88565b386114f6565b60405162461bcd60e51b8152602060048201526024808201527f546f6b656e2061646472657373206d757374206265206c657373207468616e206044820152630ae8aa8960e31b6064820152608490fd5b634e487b7160e01b8c52604160045260248cfd5b91965090627fffff1981146000198314166120bf5781900560020b028060020b9081036126cc5794388061133e565b634e487b7160e01b89526012600452602489fd5b90506020813d6020116127e9575b816127cc60209383612a88565b810103126127e557518060020b81036127e557386112ea565b8880fd5b3d91506127bf565b60405162461bcd60e51b815260206004820152600960248201526805072696365203c20360bc1b6044820152606490fd5b60405162461bcd60e51b8152602060048201526015602482015274125b9cdd59999a58da595b9d08115512081cd95b9d605a1b6044820152606490fd5b60405162461bcd60e51b815260206004820152601c60248201527f54776974746572206e616d652063616e6e6f7420626520656d707479000000006044820152606490fd5b60405162461bcd60e51b815260206004820152601060248201526f24b73b30b634b2103332b2903a34b2b960811b6044820152606490fd5b60405162461bcd60e51b815260206004820152601660248201527553796d626f6c2063616e6e6f7420626520656d70747960501b6044820152606490fd5b60405162461bcd60e51b81526020600482015260146024820152734e616d652063616e6e6f7420626520656d70747960601b6044820152606490fd5b60405162461bcd60e51b815260206004820152601860248201527f496e76616c6964206465706c6f796572206164647265737300000000000000006044820152606490fd5b60405162461bcd60e51b815260206004820152601d60248201527f537570706c79206d7573742062652067726561746572207468616e20300000006044820152606490fd5b60405162461bcd60e51b815260206004820152601a60248201527f546f6b656e206372656174696f6e2069732064697361626c65640000000000006044820152606490fd5b50346102e25760203660031901126102e25750604051670de0b6b3a7640000655af1e679571060043505058152602090f35b608081019081106001600160401b03821117612a7257604052565b634e487b7160e01b600052604160045260246000fd5b90601f801991011681019081106001600160401b03821117612a7257604052565b6001600160401b038111612a7257601f01601f191660200190565b81601f82011215611d9057803590612adb82612aa9565b92612ae96040519485612a88565b82845260208383010111611d9057816000926020809301838601378301015290565b600435906001600160a01b0382168203611d9057565b9181601f84011215611d90578235916001600160401b038311611d905760208381860195010111611d9057565b600454811015612b6957600460005260206000200190600090565b634e487b7160e01b600052603260045260246000fd5b600154811015612b6957600160005260206000200190600090565b8054821015612b695760005260206000200190600090565b60005b838110612bc55750506000910152565b8181015183820152602001612bb5565b90602091612bee81518092818552858086019101612bb2565b601f01601f1916010190565b90816020910312611d9057516001600160a01b0381168103611d905790565b90816020910312611d9057518015158103611d905790565b908060209392818452848401376000828201840152601f01601f1916010190565b979298909a93959a99949196998760405198899260208401378101602081016910313c902632b9ba32b960b11b90520360200160151981018852600a01612c999088612a88565b611523996040519860208c01612caf908b612a88565b8b8a5260208a019b612f4f8d396040519a8b9860208a019a6101208c526101408b01612cda91612bd5565b90601f198b83030160408c0152612cf092612c31565b60608901949094526001600160a01b0390811660808901527f00000000000000000000000033128a8fc17869897dce68ed026d694621f6fdfd811660a08901527f00000000000000000000000003a520b32c04bf3beef7beb72e919cf822ed34f11660c088015260e0870152858203601f1901610100870152612d7292612c31565b90601f1984830301610120850152612d8992612c31565b03601f1981018452612d9b9084612a88565b60405192839260208401958691518092612db492612bb2565b83019051918260208301612dc792612bb2565b0103808252612dd99060200182612a88565b519020906040519160408301526020820152308152600b0160ff8153605590206001600160a01b031690565b15612e0c57565b60405162461bcd60e51b81526020600482015260116024820152702737ba1030903a32b0b69036b2b6b132b960791b6044820152606490fd5b6001600160401b038111612a725760051b60200190565b805115612b695760200190565b8051821015612b695760209160051b010190565b6000198114612e8c5760010190565b634e487b7160e01b600052601160045260246000fd5b906040519163c43cb3fb60e01b83526004830152602482015260208160448173a1e439a765f42f9de43681dfa67b6a66f7907b7a5af4908115612f1957600091612eea575090565b90506020813d602011612f11575b81612f0560209383612a88565b81010312611d90575190565b3d9150612ef8565b6040513d6000823e3d90fd5b6000546001600160a01b03163303612f3957565b63118cdaa760e01b6000523360045260246000fdfe60c0604052346107b35761152380380380610019816107b8565b928339810190610120818303126107b35780516001600160401b0381116107b357826100469183016107dd565b60208201519091906001600160401b0381116107b357836100689183016107dd565b9060408101519161007b60608301610848565b61008760808401610848565b9061009460a08501610848565b9260c08501519460e081015160018060401b0381116107b357896100b99183016107dd565b6101008201519099906001600160401b0381116107b3576100da92016107dd565b875190976001600160401b0382116106b05760035490600182811c921680156107a9575b60208310146106905781601f849311610739575b50602090601f83116001146106d1576000926106c6575b50508160011b916000199060031b1c1916176003555b8051906001600160401b0382116106b05760045490600182811c921680156106a6575b60208310146106905781601f849311610620575b50602090601f83116001146105b8576000926105ad575b50508160011b916000199060031b1c1916176004555b6001600160a01b0316801561059757600580546001600160a01b03198116831790915581906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a360018060a01b031960065416176006553360018060a01b0319600754161760075560805260a05233156105815760009160025481810180911161056d576002553383528260205260408320818154019055604051908152827fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60203393a360095582516001600160401b03811161055957600b54600181811c9116801561054f575b602082101461053b57601f81116104d8575b506020601f82116001146104755782939482939261046a575b50508160011b916000199060031b1c191617600b555b8151906001600160401b03821161045657600c54600181811c9116801561044c575b602082101461043857601f81116103d5575b50602090601f831160011461037457919283610369575b50508160011b916000199060031b1c191617600c555b604051610cc6908161085d82396080518181816106070152610c1f015260a0518181816104e80152610bec0152f35b015190503880610324565b90601f19831693600c8352818320925b8581106103bd575083600195106103a4575b505050811b01600c5561033a565b015160001960f88460031b161c19169055388080610396565b91926020600181928685015181550194019201610384565b600c82527fdf6966c971051c3d54ec59162606531493a51404a002842f56009d7e5cf4a8c7601f840160051c8101916020851061042e575b601f0160051c01905b818110610423575061030d565b828155600101610416565b909150819061040d565b634e487b7160e01b82526022600452602482fd5b90607f16906102fb565b634e487b7160e01b81526041600452602490fd5b0151905038806102c3565b600b835280832090601f198316845b8181106104c0575095836001959697106104a7575b505050811b01600b556102d9565b015160001960f88460031b161c19169055388080610499565b9192602060018192868b015181550194019201610484565b600b83527f0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01db9601f830160051c81019160208410610531575b601f0160051c01905b81811061052657506102aa565b838155600101610519565b9091508190610510565b634e487b7160e01b83526022600452602483fd5b90607f1690610298565b634e487b7160e01b82526041600452602482fd5b634e487b7160e01b84526011600452602484fd5b63ec442f0560e01b600052600060045260246000fd5b631e4fbdf760e01b600052600060045260246000fd5b01519050388061018d565b600460009081528281209350601f198516905b81811061060857509084600195949392106105ef575b505050811b016004556101a3565b015160001960f88460031b161c191690553880806105e1565b929360206001819287860151815501950193016105cb565b60046000529091507f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b601f840160051c81019160208510610686575b90601f859493920160051c01905b8181106106775750610176565b6000815584935060010161066a565b909150819061065c565b634e487b7160e01b600052602260045260246000fd5b91607f1691610162565b634e487b7160e01b600052604160045260246000fd5b015190503880610129565b600360009081528281209350601f198516905b8181106107215750908460019594939210610708575b505050811b0160035561013f565b015160001960f88460031b161c191690553880806106fa565b929360206001819287860151815501950193016106e4565b60036000529091507fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b601f840160051c8101916020851061079f575b90601f859493920160051c01905b8181106107905750610112565b60008155849350600101610783565b9091508190610775565b91607f16916100fe565b600080fd5b6040519190601f01601f191682016001600160401b038111838210176106b057604052565b81601f820112156107b3578051906001600160401b0382116106b05761080c601f8301601f19166020016107b8565b92828452602083830101116107b35760005b82811061083357505060206000918301015290565b8060208092840101518282870101520161081e565b51906001600160a01b03821682036107b35756fe6080604052600436101561001257600080fd5b60003560e01c806306fdde031461092b578063095ea7b3146108a55780630d43e8ad1461087c5780631755ff211461085357806318160ddd1461083557806323b872dd14610748578063313ce5671461072c5780634d669f8714610654578063599ca397146106365780635b549182146105f15780635f438c5a146105c857806370a082311461058e578063715018a614610517578063791b98bc146104d25780638da5cb5b146104a957806395d89b41146103d1578063a9059cbb146103a0578063abb5ca091461027d578063d5f3948814610254578063dd62ed3e14610203578063e9e15b4f146101725763f2fde38b1461010e57600080fd5b3461016d57602036600319011261016d57610127610a4c565b5060405162461bcd60e51b815260206004820152601e60248201527f4f776e657273686970207472616e736665722069732064697361626c656400006044820152606490fd5b600080fd5b3461016d57602036600319011261016d5761018b610a4c565b6007546001600160a01b031633036101bf57600880546001600160a01b0319166001600160a01b0392909216919091179055005b606460405162461bcd60e51b815260206004820152602060248201527f4f6e6c79204c65737465722063616e2073657420706f6f6c20616464726573736044820152fd5b3461016d57604036600319011261016d5761021c610a4c565b610224610a62565b6001600160a01b039182166000908152600160209081526040808320949093168252928352819020549051908152f35b3461016d57600036600319011261016d576006546040516001600160a01b039091168152602090f35b3461016d57600036600319011261016d576040516000600c548060011c90600181168015610396575b60208310811461038257828552908115610366575060011461030f575b50819003601f01601f191681019067ffffffffffffffff8211818310176102f957604082905281906102f59082610a03565b0390f35b634e487b7160e01b600052604160045260246000fd5b600c60009081529091507fdf6966c971051c3d54ec59162606531493a51404a002842f56009d7e5cf4a8c75b828210610350575060209150820101826102c3565b600181602092548385880101520191019061033b565b90506020925060ff191682840152151560051b820101826102c3565b634e487b7160e01b84526022600452602484fd5b91607f16916102a6565b3461016d57604036600319011261016d576103c66103bc610a4c565b6024359033610a78565b602060405160018152f35b3461016d57600036600319011261016d5760405160006004548060011c9060018116801561049f575b6020831081146103825782855290811561036657506001146104485750819003601f01601f191681019067ffffffffffffffff8211818310176102f957604082905281906102f59082610a03565b600460009081529091507f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b5b828210610489575060209150820101826102c3565b6001816020925483858801015201910190610474565b91607f16916103fa565b3461016d57600036600319011261016d576005546040516001600160a01b039091168152602090f35b3461016d57600036600319011261016d576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b3461016d57600036600319011261016d576005546001600160a01b038116338103610579576000916bffffffffffffffffffffffff60a01b166005557f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a3005b63118cdaa760e01b6000523360045260246000fd5b3461016d57602036600319011261016d576001600160a01b036105af610a4c565b1660005260006020526020604060002054604051908152f35b3461016d57600036600319011261016d576007546040516001600160a01b039091168152602090f35b3461016d57600036600319011261016d576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b3461016d57600036600319011261016d576020600954604051908152f35b3461016d57600036600319011261016d576040516000600b548060011c90600181168015610722575b6020831081146103825782855290811561036657506001146106cb5750819003601f01601f191681019067ffffffffffffffff8211818310176102f957604082905281906102f59082610a03565b600b60009081529091507f0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01db95b82821061070c575060209150820101826102c3565b60018160209254838588010152019101906106f7565b91607f169161067d565b3461016d57600036600319011261016d57602060405160128152f35b3461016d57606036600319011261016d57610761610a4c565b610769610a62565b6001600160a01b03821660008181526001602081815260408084203385529091529091205491936044359392909181016107a9575b506103c69350610a78565b8381106108185784156108025733156107ec576103c6946000526001602052604060002060018060a01b033316600052602052836040600020910390558461079e565b634a1406b160e11b600052600060045260246000fd5b63e602df0560e01b600052600060045260246000fd5b8390637dc7a0d960e11b6000523360045260245260445260646000fd5b3461016d57600036600319011261016d576020600254604051908152f35b3461016d57600036600319011261016d576008546040516001600160a01b039091168152602090f35b3461016d57600036600319011261016d57600a546040516001600160a01b039091168152602090f35b3461016d57604036600319011261016d576108be610a4c565b602435903315610802576001600160a01b03169081156107ec57336000526001602052604060002082600052602052806040600020556040519081527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560203392a3602060405160018152f35b3461016d57600036600319011261016d5760405160006003548060011c906001811680156109f9575b6020831081146103825782855290811561036657506001146109a25750819003601f01601f191681019067ffffffffffffffff8211818310176102f957604082905281906102f59082610a03565b600360009081529091507fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b5b8282106109e3575060209150820101826102c3565b60018160209254838588010152019101906109ce565b91607f1691610954565b91909160208152825180602083015260005b818110610a36575060409293506000838284010152601f8019910116010190565b8060208092870101516040828601015201610a15565b600435906001600160a01b038216820361016d57565b602435906001600160a01b038216820361016d57565b6001600160a01b0316908115610c7a576001600160a01b0316918215610c64576007546001600160a01b031683141580610c4f575b80610c1c575b80610be9575b80610bd4575b610b3d575b6000828152806020526040812054828110610b235791604082827fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef958760209652828652038282205586815280845220818154019055604051908152a3565b916064928463391434e360e21b8452600452602452604452fd5b60025460095490818102918183041490151715610bbe5783600052600060205260406000205490828201809211610bbe576103e890041015610ac45760405162461bcd60e51b815260206004820152601e60248201527f4d61782077616c6c65742070657263656e7461676520657863656564656400006044820152606490fd5b634e487b7160e01b600052601160045260246000fd5b506008546001600160a01b0316831415610abf565b507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316831415610ab9565b507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316831415610ab3565b506007546001600160a01b0316821415610aad565b63ec442f0560e01b600052600060045260246000fd5b634b637e8f60e11b600052600060045260246000fdfea26469706673582212203164054787ae8ee84b6a68f57d4dad5838b79c532963ea942aaf34a9d725685364736f6c634300081b0033a264697066735822122051bf944aaf1890692803dbe9f1973486abf5144b69cd99ce06237e5e9cad604364736f6c634300081b0033

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

000000000000000000000000420000000000000000000000000000000000000600000000000000000000000033128a8fc17869897dce68ed026d694621f6fdfd00000000000000000000000003a520b32c04bf3beef7beb72e919cf822ed34f10000000000000000000000002626664c2603336e57b271c5c0b26f421741e481000000000000000000000000673fafcd2eb926c39cba9fef2a4c9749d74f3c86

-----Decoded View---------------
Arg [0] : weth_ (address): 0x4200000000000000000000000000000000000006
Arg [1] : uniswapV3Factory_ (address): 0x33128a8fC17869897dcE68Ed026d694621f6FDfD
Arg [2] : positionManager_ (address): 0x03a520b32C04BF3bEEf7BEb72E919cf822Ed34f1
Arg [3] : swapRouter_ (address): 0x2626664c2603336E57B271c5C0b26F421741e481
Arg [4] : owner_ (address): 0x673faFcD2eb926c39CBa9Fef2a4c9749d74F3C86

-----Encoded View---------------
5 Constructor Arguments found :
Arg [0] : 0000000000000000000000004200000000000000000000000000000000000006
Arg [1] : 00000000000000000000000033128a8fc17869897dce68ed026d694621f6fdfd
Arg [2] : 00000000000000000000000003a520b32c04bf3beef7beb72e919cf822ed34f1
Arg [3] : 0000000000000000000000002626664c2603336e57b271c5c0b26f421741e481
Arg [4] : 000000000000000000000000673fafcd2eb926c39cba9fef2a4c9749d74f3c86


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
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.