ETH Price: $3,169.63 (-2.57%)

Contract

0x82Fbc848eeCeC6D0a2eBdC8A9420826AE8d2952d
 

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Remove Liquidity...210832272024-10-31 4:27:2313 days ago1730348843IN
0x82Fbc848...AE8d2952d
0 ETH0.002699638.03815838
Add Liquidity210473422024-10-26 4:14:4718 days ago1729916087IN
0x82Fbc848...AE8d2952d
0 ETH0.001109463.97454687
Remove Liquidity210409792024-10-25 6:56:5919 days ago1729839419IN
0x82Fbc848...AE8d2952d
0 ETH0.001275815.33030817
Remove Liquidity...210409542024-10-25 6:51:5919 days ago1729839119IN
0x82Fbc848...AE8d2952d
0 ETH0.001569894.66470171
Remove Liquidity...210380632024-10-24 21:11:1119 days ago1729804271IN
0x82Fbc848...AE8d2952d
0 ETH0.0040361612.62898504
Add Liquidity210352572024-10-24 11:47:5920 days ago1729770479IN
0x82Fbc848...AE8d2952d
0 ETH0.0041227910.1865089
Add Liquidity210343702024-10-24 8:49:5920 days ago1729759799IN
0x82Fbc848...AE8d2952d
0 ETH0.0048749811.97655697
Update Rates210312742024-10-23 22:27:1120 days ago1729722431IN
0x82Fbc848...AE8d2952d
0 ETH0.004360277.35321095
Update Rates210271452024-10-23 8:38:4721 days ago1729672727IN
0x82Fbc848...AE8d2952d
0 ETH0.004851398.2135698
Add Liquidity210109992024-10-21 2:35:1123 days ago1729478111IN
0x82Fbc848...AE8d2952d
0 ETH0.002747937.53413005
Remove Liquidity...209943222024-10-18 18:44:4725 days ago1729277087IN
0x82Fbc848...AE8d2952d
0 ETH0.0047717414.44152679
Add Liquidity209810202024-10-16 22:11:1127 days ago1729116671IN
0x82Fbc848...AE8d2952d
0 ETH0.002707069.85106126
Add Liquidity209810072024-10-16 22:08:3527 days ago1729116515IN
0x82Fbc848...AE8d2952d
0 ETH0.003158210.60542741
Remove Liquidity...209661482024-10-14 20:19:3529 days ago1728937175IN
0x82Fbc848...AE8d2952d
0 ETH0.0067603121.11676024
Remove Liquidity...209660862024-10-14 20:07:1129 days ago1728936431IN
0x82Fbc848...AE8d2952d
0 ETH0.0077436524.48051963
Add Liquidity209583762024-10-13 18:15:1130 days ago1728843311IN
0x82Fbc848...AE8d2952d
0 ETH0.002785979.58661873
Swap209442902024-10-11 18:52:5932 days ago1728672779IN
0x82Fbc848...AE8d2952d
0 ETH0.0092399615.7754273
Swap209420562024-10-11 11:23:2333 days ago1728645803IN
0x82Fbc848...AE8d2952d
0 ETH0.0062027712.50559879
Update Rates209265322024-10-09 7:26:3535 days ago1728458795IN
0x82Fbc848...AE8d2952d
0 ETH0.00526568.88854739
Add Liquidity208919662024-10-04 11:49:3540 days ago1728042575IN
0x82Fbc848...AE8d2952d
0 ETH0.003188264.81332738
Add Liquidity208757752024-10-02 5:39:1142 days ago1727847551IN
0x82Fbc848...AE8d2952d
0 ETH0.001741595.98275789
Add Liquidity208308492024-09-25 23:17:3548 days ago1727306255IN
0x82Fbc848...AE8d2952d
0 ETH0.0045510515.54836908
Remove Liquidity207519192024-09-14 22:45:5959 days ago1726353959IN
0x82Fbc848...AE8d2952d
0 ETH0.000299871.16985207
Add Liquidity207406232024-09-13 8:52:4761 days ago1726217567IN
0x82Fbc848...AE8d2952d
0 ETH0.00127834.477534
Set Rate Provide...207364002024-09-12 18:43:5961 days ago1726166639IN
0x82Fbc848...AE8d2952d
0 ETH0.002213526.89229506
View all transactions

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
Pool

Compiler Version
v0.8.26+commit.8a97fa7a

Optimization Enabled:
Yes with 100 runs

Other Settings:
cancun EvmVersion
File 1 of 9 : Pool.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.24;

import {Ownable} from "solady/auth/Ownable.sol";
import {ERC20} from "solady/tokens/ERC20.sol";
import {ReentrancyGuard} from "solady/utils/ReentrancyGuard.sol";
import {FixedPointMathLib} from "solady/utils/FixedPointMathLib.sol";
import {SafeTransferLib} from "solady/utils/SafeTransferLib.sol";

import {IRateProvider} from "./RateProvider/IRateProvider.sol";
import {LogExpMath} from "./BalancerLibCode/LogExpMath.sol";
import {PoolToken} from "./PoolToken.sol";

contract Pool is Ownable, ReentrancyGuard {
    uint256 constant PRECISION = 1_000_000_000_000_000_000;
    uint256 constant MAX_NUM_TOKENS = 32;
    uint256 constant ALL_TOKENS_FLAG =
        14_528_991_250_861_404_666_834_535_435_384_615_765_856_667_510_756_806_797_353_855_100_662_256_435_713; // sum((i+1) << 8*i)
    uint256 constant POOL_VB_MASK = 2 ** 128 - 1;
    uint128 constant POOL_VB_SHIFT = 128;

    uint256 constant VB_MASK = 2 ** 96 - 1;
    uint256 constant RATE_MASK = 2 ** 80 - 1;
    uint128 constant RATE_SHIFT = 96;
    uint128 constant PACKED_WEIGHT_SHIFT = 176;

    uint256 constant WEIGHT_SCALE = 1_000_000_000_000;
    uint256 constant WEIGHT_MASK = 2 ** 20 - 1;
    uint128 constant TARGET_WEIGHT_SHIFT = 20;
    uint128 constant LOWER_BAND_SHIFT = 40;
    uint128 constant UPPER_BAND_SHIFT = 60;
    uint256 constant MAX_POW_REL_ERR = 100; // 1e-16

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

    error Pool__InputOutputTokensSame();
    error Pool__IndexOutOfBounds();
    error Pool__MaxLimitExceeded();
    error Pool__ZeroAmount();
    error Pool__MustBeInitiatedWithMoreThanOneToken();
    error Pool__MustBeInitiatedWithAGreaterThanZero();
    error Pool__InvalidParams();
    error Pool__CannotBeZeroAddress();
    error Pool__InvalidDecimals();
    error Pool__SumOfWeightsMustBeOne();
    error Pool__InvalidRateProvided();
    error Pool__NoConvergence();
    error Pool__RatioBelowLowerBound();
    error Pool__RatioAboveUpperBound();
    error Pool__SlippageLimitExceeded();
    error Pool__NeedToDepositAtleastOneToken();
    error Pool__InitialDepositAmountMustBeNonZero();
    error Pool__AmountsMustBeNonZero();
    error Pool__WeightOutOfBounds();
    error Pool__PoolIsFull();
    error Pool__RampActive();
    error Pool__PoolIsEmpty();
    error Pool__TokenAlreadyPartOfPool();
    error Pool__CannotRescuePoolToken();
    error Pool__BandsOutOfBounds();
    error Pool__WeightsDoNotAddUp();
    error Pool__AlreadyPaused();
    error Pool__NotPaused();
    error Pool__Killed();
    error Pool__NoSurplus();
    error Pool__NoRate();
    error Pool__Paused();

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                           EVENTS                           */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
    event Swap(
        address indexed caller, address receiver, uint256 tokenIn, uint256 tokenOut, uint256 amountIn, uint256 amountOut
    );
    event AddLiquidity(address indexed caller, address receiver, uint256[] amountsIn, uint256 lpAmount);
    event RemoveLiquidity(address indexed caller, address receiver, uint256 lpAmount);
    event RemoveLiquiditySingle(
        address indexed caller, address receiver, uint256 token, uint256 amountOut, uint256 lpAmount
    );
    event RateUpdate(uint256 indexed token, uint256 rate);
    event Pause(address indexed caller);
    event Unpause(address indexed caller);
    event Kill();
    event AddToken(uint256 index, address token, address rateProvider, uint256 rate, uint256 weight, uint256 amount);
    event SetSwapFeeRate(uint256 rate);
    event SetWeightBand(uint256 indexed token, uint256 lower, uint256 upper);
    event SetRateProvider(uint256 token, address rateProvider);
    event SetRamp(uint256 amplification, uint256[] weights, uint256 duration, uint256 start);
    event SetRampStep(uint256 rampStep);
    event StopRamp();
    event SetStaking(address stakingAddress);
    event SetGuardian(address indexed caller, address guardian);

    uint256 public amplification; // A * f**n
    uint256 public numTokens;
    uint256 public supply;
    address public tokenAddress;
    address public stakingAddress;
    address[MAX_NUM_TOKENS] public tokens;
    address[MAX_NUM_TOKENS] public rateProviders;
    uint256[MAX_NUM_TOKENS] public packedVirtualBalances; // x_i = b_i r_i (96) | r_i (80) | w_i (20) | target w_i (20) | lower (20) | upper (20)
    bool public paused;
    bool public killed;
    uint256 public swapFeeRate;
    uint256 public rampStep;
    uint256 public rampLastTime;
    uint256 public rampStopTime;
    uint256 public targetAmplification;
    uint256 packedPoolVirtualBalance; // vbProd (128) | vbSum (128)
    // vbProd: pi, product term `product((w_i * D / x_i)^(w_i n))`
    // vbSum: sigma, sum term `sum(x_i)`

    /// @notice constructor
    /// @dev sum of all weights
    /// @dev rebasing tokens not supported
    /// @param tokenAddress_ address of the poolToken
    /// @param amplification_ the pool amplification factor (in 18 decimals)
    /// @param tokens_ array of addresses of tokens in the pool
    /// @param rateProviders_ array of addresses of rate providers for the tokens in the pool
    /// @param weights_ weight of each token (in 18 decimals)
    constructor(
        address tokenAddress_,
        uint256 amplification_,
        address[] memory tokens_,
        address[] memory rateProviders_,
        uint256[] memory weights_,
        address owner_
    ) {
        if (tokenAddress_ == address(0)) revert Pool__InvalidParams();
        uint256 _numTokens = tokens_.length;

        if (_numTokens > MAX_NUM_TOKENS) revert Pool__MaxLimitExceeded();

        if (_numTokens < 2) {
            revert Pool__MustBeInitiatedWithMoreThanOneToken();
        }
        if (rateProviders_.length != _numTokens || weights_.length != _numTokens) {
            revert Pool__InvalidParams();
        }
        if (amplification_ < PRECISION) {
            revert Pool__MustBeInitiatedWithAGreaterThanZero();
        }

        amplification = amplification_;
        numTokens = _numTokens;

        uint256 weightSum;

        for (uint256 t = 0; t < MAX_NUM_TOKENS; t++) {
            if (t == _numTokens) break;
            if (tokens_[t] == address(0)) {
                revert Pool__CannotBeZeroAddress();
            }
            if (ERC20(tokens_[t]).decimals() != 18) {
                revert Pool__InvalidDecimals();
            }
            tokens[t] = tokens_[t];
            if (rateProviders_[t] == address(0)) {
                revert Pool__CannotBeZeroAddress();
            }
            rateProviders[t] = rateProviders_[t];
            if (weights_[t] == 0) {
                revert Pool__InvalidParams();
            }
            uint256 _packedWeight = _packWeight(weights_[t], weights_[t], PRECISION, PRECISION);

            packedVirtualBalances[t] = _packVirtualBalance(0, 0, _packedWeight);

            weightSum += weights_[t];
        }

        if (weightSum != PRECISION) {
            revert Pool__SumOfWeightsMustBeOne();
        }

        rampStep = 1;
        _setOwner(owner_);

        tokenAddress = tokenAddress_;
    }

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                       POOL FUNCTIONS                       */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @notice swap one pool token for another
    /// @param tokenIn_ index of the input token
    /// @param tokenOut_ index of the output token
    /// @param tokenInAmount_ amount of input token to take from the caller
    /// @param minTokenOutAmount_ minimum amount of output token to send
    /// @param receiver_ account to receive the output token
    /// @return the amount of output token
    function swap(
        uint256 tokenIn_,
        uint256 tokenOut_,
        uint256 tokenInAmount_,
        uint256 minTokenOutAmount_,
        address receiver_
    ) external nonReentrant returns (uint256) {
        uint256 _numTokens = numTokens;
        if (tokenIn_ == tokenOut_) revert Pool__InputOutputTokensSame();
        if (tokenIn_ >= _numTokens || tokenOut_ >= _numTokens) revert Pool__IndexOutOfBounds();
        if (tokenInAmount_ == 0) revert Pool__ZeroAmount();

        // update rates for from and to tokens
        (uint256 _virtualBalanceProd, uint256 _virtualBalanceSum) = _unpackPoolVirtualBalance(packedPoolVirtualBalance);
        (_virtualBalanceProd, _virtualBalanceSum) = _updateRates(
            FixedPointMathLib.rawAdd(tokenIn_, 1) | (FixedPointMathLib.rawAdd(tokenOut_, 1) << 8),
            _virtualBalanceProd,
            _virtualBalanceSum
        );

        uint256 _prevVirtualBalanceSum = _virtualBalanceSum;

        (uint256 _prevVirtualBalanceX, uint256 _rateX, uint256 _packedWeightX) =
            _unpackVirtualBalance(packedVirtualBalances[tokenIn_]);
        uint256 _weightTimesNOfX = _unpackWeightTimesN(_packedWeightX, _numTokens);

        (uint256 _prevVirtualBalanceY, uint256 _rateY, uint256 _packedWeightY) =
            _unpackVirtualBalance(packedVirtualBalances[tokenOut_]);
        uint256 _weightTimesNOfY = _unpackWeightTimesN(_packedWeightY, _numTokens);

        uint256 _tokenInFee = (tokenInAmount_ * swapFeeRate) / PRECISION;
        uint256 _changeInVirtualBalanceTokenIn = ((tokenInAmount_ - _tokenInFee) * _rateX) / PRECISION;
        uint256 _virtualBalanceX = _prevVirtualBalanceX + _changeInVirtualBalanceTokenIn;

        // update x_i and remove x_j from variables
        _virtualBalanceProd = _virtualBalanceProd * _powUp(_prevVirtualBalanceY, _weightTimesNOfY)
            / _powDown((_virtualBalanceX * PRECISION) / _prevVirtualBalanceX, _weightTimesNOfX);
        _virtualBalanceSum = _virtualBalanceSum + _changeInVirtualBalanceTokenIn - _prevVirtualBalanceY;

        // calculate new balance of out token
        uint256 _virtualBalanceY = _calculateVirtualBalance(
            _weightTimesNOfY, _prevVirtualBalanceY, supply, amplification, _virtualBalanceProd, _virtualBalanceSum
        );

        _virtualBalanceSum += _virtualBalanceY;

        // check bands
        _checkBands(
            (_prevVirtualBalanceX * PRECISION) / _prevVirtualBalanceSum,
            (_virtualBalanceX * PRECISION) / _virtualBalanceSum,
            _packedWeightX
        );
        _checkBands(
            (_prevVirtualBalanceY * PRECISION) / _prevVirtualBalanceSum,
            (_virtualBalanceY * PRECISION) / _virtualBalanceSum,
            _packedWeightY
        );

        uint256 _tokenOutAmount = ((_prevVirtualBalanceY - _virtualBalanceY) * PRECISION) / _rateY;
        if (_tokenOutAmount < minTokenOutAmount_) {
            revert Pool__SlippageLimitExceeded();
        }

        if (_tokenInFee > 0) {
            // add fee to pool
            _changeInVirtualBalanceTokenIn = (_tokenInFee * _rateX) / PRECISION;
            _virtualBalanceProd = (_virtualBalanceProd * PRECISION)
                / _powDown(
                    (_virtualBalanceX + _changeInVirtualBalanceTokenIn) * PRECISION / _virtualBalanceX, _weightTimesNOfX
                );
            _virtualBalanceX += _changeInVirtualBalanceTokenIn;
            _virtualBalanceSum += _changeInVirtualBalanceTokenIn;
        }

        // update variables
        packedVirtualBalances[tokenIn_] = _packVirtualBalance(_virtualBalanceX, _rateX, _packedWeightX);
        packedVirtualBalances[tokenOut_] = _packVirtualBalance(_virtualBalanceY, _rateY, _packedWeightY);
        _virtualBalanceProd = (_virtualBalanceProd * PRECISION) / _powUp(_virtualBalanceY, _weightTimesNOfY);

        // mint fees
        if (_tokenInFee > 0) {
            uint256 _supply;
            (_supply, _virtualBalanceProd) = _updateSupply(supply, _virtualBalanceProd, _virtualBalanceSum);
        }

        packedPoolVirtualBalance = _packPoolVirtualBalance(_virtualBalanceProd, _virtualBalanceSum);

        // transfer tokens
        SafeTransferLib.safeTransferFrom(tokens[tokenIn_], msg.sender, address(this), tokenInAmount_);
        SafeTransferLib.safeTransfer(tokens[tokenOut_], receiver_, _tokenOutAmount);
        emit Swap(msg.sender, receiver_, tokenIn_, tokenOut_, tokenInAmount_, _tokenOutAmount);

        return _tokenOutAmount;
    }

    /// @notice deposit tokens into the pool
    /// @param amounts_ array of the amount for each token to take from caller
    /// @param minLpAmount_ minimum amount of lp tokens to mint
    /// @param receiver_ account to receive the lp tokens
    /// @return amount of LP tokens minted
    function addLiquidity(uint256[] calldata amounts_, uint256 minLpAmount_, address receiver_)
        external
        nonReentrant
        returns (uint256)
    {
        uint256 _numTokens = numTokens;
        if (amounts_.length != _numTokens) revert Pool__InvalidParams();

        (uint256 _virtualBalanceProd, uint256 _virtualBalanceSum) = _unpackPoolVirtualBalance(packedPoolVirtualBalance);

        uint256 _prevVirtualBalance;
        uint256 _rate;
        uint256 _packedWeight;

        // find lowest relative increase in balance
        uint256 _tokens = 0;
        uint256 _lowest = type(uint256).max;
        uint256 _sh;

        for (uint256 t = 0; t < MAX_NUM_TOKENS; t++) {
            if (t == _numTokens) break;

            uint256 __amount = amounts_[t];

            if (__amount > 0) {
                _tokens = _tokens | (FixedPointMathLib.rawAdd(t, 1) << _sh);
                _sh = FixedPointMathLib.rawAdd(_sh, 8);
                if (_virtualBalanceSum > 0 && _lowest > 0) {
                    (_prevVirtualBalance, _rate, _packedWeight) = _unpackVirtualBalance(packedVirtualBalances[t]);
                    _lowest = FixedPointMathLib.min(__amount * _rate / _prevVirtualBalance, _lowest);
                }
            } else {
                _lowest = 0;
            }
        }
        if (_sh == 0) revert Pool__NeedToDepositAtleastOneToken();

        // update rates
        (_virtualBalanceProd, _virtualBalanceSum) = _updateRates(_tokens, _virtualBalanceProd, _virtualBalanceSum);
        uint256 _prevSupply = supply;

        uint256 _virtualBalanceProdFinal = _virtualBalanceProd;
        uint256 _virtualBalanceSumFinal = _virtualBalanceSum;
        uint256 _prevVirtualBalanceSum = _virtualBalanceSum;
        uint256[] memory _prevRatios = new uint256[](_numTokens);
        uint256 _virtualBalance;

        for (uint256 t = 0; t < MAX_NUM_TOKENS; t++) {
            if (t == _numTokens) break;

            uint256 __amount = amounts_[t];

            if (__amount == 0) {
                if (!(_prevSupply > 0)) {
                    revert Pool__InitialDepositAmountMustBeNonZero();
                }
                continue;
            }

            // update stored virtual balance
            (_prevVirtualBalance, _rate, _packedWeight) = _unpackVirtualBalance(packedVirtualBalances[t]);
            uint256 _changeInVirtualBalance = (__amount * _rate) / PRECISION;
            _virtualBalance = _prevVirtualBalance + _changeInVirtualBalance;
            packedVirtualBalances[t] = _packVirtualBalance(_virtualBalance, _rate, _packedWeight);

            if (_prevSupply > 0) {
                _prevRatios[t] = (_prevVirtualBalance * PRECISION) / _prevVirtualBalanceSum;
                uint256 _weightTimesN = _unpackWeightTimesN(_packedWeight, _numTokens);

                // update product and sum of virtual balances
                _virtualBalanceProdFinal = (
                    _virtualBalanceProdFinal
                        * _powUp((_prevVirtualBalance * PRECISION) / _virtualBalance, _weightTimesN)
                ) / PRECISION;

                // the `D^n` factor will be updated in `_calculateSupply()`
                _virtualBalanceSumFinal += _changeInVirtualBalance;

                // remove fees from balance and recalculate sum and product
                uint256 _fee = (
                    (_changeInVirtualBalance - (_prevVirtualBalance * _lowest) / PRECISION) * (swapFeeRate / 2)
                ) / PRECISION;
                _virtualBalanceProd = (
                    _virtualBalanceProd
                        * _powUp((_prevVirtualBalance * PRECISION) / (_virtualBalance - _fee), _weightTimesN)
                ) / PRECISION;
                _virtualBalanceSum += _changeInVirtualBalance - _fee;
            }

            SafeTransferLib.safeTransferFrom(tokens[t], msg.sender, address(this), __amount);
        }

        uint256 _supply = _prevSupply;
        if (_prevSupply == 0) {
            // initial deposit, calculate necessary variables
            (_virtualBalanceProd, _virtualBalanceSum) = _calculateVirtualBalanceProdSum();
            if (!(_virtualBalanceProd > 0)) revert Pool__AmountsMustBeNonZero();
            _supply = _virtualBalanceSum;
        } else {
            // check bands
            for (uint256 t = 0; t < MAX_NUM_TOKENS; t++) {
                if (t == _numTokens) break;
                if (amounts_[t] == 0) continue;
                (_virtualBalance, _rate, _packedWeight) = _unpackVirtualBalance(packedVirtualBalances[t]);
                _checkBands(_prevRatios[t], (_virtualBalance * PRECISION) / _virtualBalanceSumFinal, _packedWeight);
            }
        }

        // mint LP tokens
        (_supply, _virtualBalanceProd) = _calculateSupply(
            _numTokens, _supply, amplification, _virtualBalanceProd, _virtualBalanceSum, _prevSupply == 0
        );
        uint256 _toMint = _supply - _prevSupply;

        if (!(_toMint > 0 && _toMint >= minLpAmount_)) {
            revert Pool__SlippageLimitExceeded();
        }
        PoolToken(tokenAddress).mint(receiver_, _toMint);
        emit AddLiquidity(msg.sender, receiver_, amounts_, _toMint);

        uint256 _supplyFinal = _supply;
        if (_prevSupply > 0) {
            // mint fees
            (_supplyFinal, _virtualBalanceProdFinal) = _calculateSupply(
                _numTokens, _prevSupply, amplification, _virtualBalanceProdFinal, _virtualBalanceSumFinal, true
            );
            PoolToken(tokenAddress).mint(stakingAddress, _supplyFinal - _supply);
        } else {
            _virtualBalanceProdFinal = _virtualBalanceProd;
            _virtualBalanceSumFinal = _virtualBalanceSum;
        }
        supply = _supplyFinal;

        packedPoolVirtualBalance = _packPoolVirtualBalance(_virtualBalanceProdFinal, _virtualBalanceSumFinal);
        return _toMint;
    }

    /// @notice withdraw tokens from the pool in a balanced manner
    /// @param lpAmount_ amount of lp tokens to burn
    /// @param minAmounts_ array of minimum amount of each token to send
    /// @param receiver_ account to receive the tokens
    function removeLiquidity(uint256 lpAmount_, uint256[] calldata minAmounts_, address receiver_)
        external
        nonReentrant
    {
        uint256 _numTokens = numTokens;

        if (minAmounts_.length != _numTokens || minAmounts_.length > MAX_NUM_TOKENS) revert Pool__InvalidParams();

        // update supply
        uint256 _prevSupply = supply;
        uint256 _supply = _prevSupply - lpAmount_;
        supply = _supply;
        PoolToken(tokenAddress).burn(msg.sender, lpAmount_);
        emit RemoveLiquidity(msg.sender, receiver_, lpAmount_);

        // update variables and transfer tokens
        uint256 _virtualBalanceProd = PRECISION;
        uint256 _virtualBalanceSum = 0;

        uint256 _prevVirtualBalance;
        uint256 _rate;
        uint256 _packedWeight;
        for (uint256 t = 0; t < MAX_NUM_TOKENS; t++) {
            if (t == _numTokens) break;

            (_prevVirtualBalance, _rate, _packedWeight) = _unpackVirtualBalance(packedVirtualBalances[t]);

            uint256 __weight = _unpackWeightTimesN(_packedWeight, 1);

            uint256 dVb = (_prevVirtualBalance * lpAmount_) / _prevSupply;
            uint256 vb = _prevVirtualBalance - dVb;
            packedVirtualBalances[t] = _packVirtualBalance(vb, _rate, _packedWeight);

            _virtualBalanceProd = FixedPointMathLib.rawDiv(
                FixedPointMathLib.rawMul(
                    _virtualBalanceProd,
                    _powDown(
                        FixedPointMathLib.rawDiv(FixedPointMathLib.rawMul(_supply, __weight), vb),
                        FixedPointMathLib.rawMul(__weight, _numTokens)
                    )
                ),
                PRECISION
            );
            _virtualBalanceSum = FixedPointMathLib.rawAdd(_virtualBalanceSum, vb);

            uint256 amount = (dVb * PRECISION) / _rate;
            if (amount < minAmounts_[t]) revert Pool__SlippageLimitExceeded();
            SafeTransferLib.safeTransfer(tokens[t], receiver_, amount);
        }

        packedPoolVirtualBalance = _packPoolVirtualBalance(_virtualBalanceProd, _virtualBalanceSum);
    }

    /// @notice withdraw a single token from the pool
    /// @param token_ index of the token to withdraw
    /// @param lpAmount_ amount of lp tokens to burn
    /// @param minTokenOutAmount_ minimum amount of tokens to send
    /// @param receiver_ account to receive the token
    /// @return the amount of the token sent
    function removeLiquiditySingle(uint256 token_, uint256 lpAmount_, uint256 minTokenOutAmount_, address receiver_)
        external
        nonReentrant
        returns (uint256)
    {
        uint256 _numTokens = numTokens;
        if (token_ >= _numTokens) revert Pool__InvalidParams();

        // update rate
        (uint256 _virtualBalanceProd, uint256 _virtualBalanceSum) = _unpackPoolVirtualBalance(packedPoolVirtualBalance);
        (_virtualBalanceProd, _virtualBalanceSum) =
            _updateRates(FixedPointMathLib.rawAdd(token_, 1), _virtualBalanceProd, _virtualBalanceSum);
        uint256 _prevVirtualBalanceSum = _virtualBalanceSum;

        // update supply
        uint256 _prevSupply = supply;
        uint256 _newSupply = _prevSupply - lpAmount_;
        supply = _newSupply;
        PoolToken(tokenAddress).burn(msg.sender, lpAmount_);

        (uint256 _prevVirtualBalance, uint256 _rate, uint256 _packedWeight) =
            _unpackVirtualBalance(packedVirtualBalances[token_]);
        uint256 _weightTimesN = _unpackWeightTimesN(_packedWeight, _numTokens);

        // update variables
        _virtualBalanceProd = (_virtualBalanceProd * _powUp(_prevVirtualBalance, _weightTimesN)) / PRECISION;
        for (uint256 t = 0; t < MAX_NUM_TOKENS; t++) {
            if (t == _numTokens) break;
            _virtualBalanceProd = (_virtualBalanceProd * _newSupply) / _prevSupply;
        }
        _virtualBalanceSum = _virtualBalanceSum - _prevVirtualBalance;

        // calculate new balance of token
        uint256 _virtualBalance = _calculateVirtualBalance(
            _weightTimesN, _prevVirtualBalance, _newSupply, amplification, _virtualBalanceProd, _virtualBalanceSum
        );
        uint256 _changeInVirtualBalance = _prevVirtualBalance - _virtualBalance;
        uint256 _fee = _changeInVirtualBalance * swapFeeRate / 2 / PRECISION;
        _changeInVirtualBalance -= _fee;
        _virtualBalance += _fee;
        uint256 _tokenOutAmount = (_changeInVirtualBalance * PRECISION) / _rate;
        if (_tokenOutAmount < minTokenOutAmount_) {
            revert Pool__SlippageLimitExceeded();
        }

        // update variables
        packedVirtualBalances[token_] = _packVirtualBalance(_virtualBalance, _rate, _packedWeight);
        _virtualBalanceProd = (_virtualBalanceProd * PRECISION) / _powUp(_virtualBalance, _weightTimesN);
        _virtualBalanceSum = _virtualBalanceSum + _virtualBalance;

        for (uint256 t = 0; t < MAX_NUM_TOKENS; t++) {
            if (t == _numTokens) break;
            if (t == token_) {
                _checkBands(
                    (_prevVirtualBalance * PRECISION) / _prevVirtualBalanceSum,
                    (_virtualBalance * PRECISION) / _virtualBalanceSum,
                    _packedWeight
                );
            } else {
                (uint256 _virtualBalanceLoop,, uint256 _packedWeightLoop) =
                    _unpackVirtualBalance(packedVirtualBalances[t]);
                _checkBands(
                    (_virtualBalanceLoop * PRECISION) / _prevVirtualBalanceSum,
                    (_virtualBalanceLoop * PRECISION) / _virtualBalanceSum,
                    _packedWeightLoop
                );
            }
        }

        if (_fee > 0) {
            // mint fee
            (_newSupply, _virtualBalanceProd) = _updateSupply(_newSupply, _virtualBalanceProd, _virtualBalanceSum);
        }

        packedPoolVirtualBalance = _packPoolVirtualBalance(_virtualBalanceProd, _virtualBalanceSum);

        SafeTransferLib.safeTransfer(tokens[token_], receiver_, _tokenOutAmount);

        emit RemoveLiquiditySingle(msg.sender, receiver_, token_, _tokenOutAmount, lpAmount_);
        return _tokenOutAmount;
    }

    /// @notice update the stored rate of any of the pool's tokens
    /// @dev if no assets are passed in, every asset will be updated
    /// @param tokens_ array of indices of tokens to update
    function updateRates(uint256[] calldata tokens_) external {
        uint256 _numTokens = numTokens;

        uint256 _tokens;
        for (uint256 t = 0; t < MAX_NUM_TOKENS; t++) {
            if (t == tokens_.length) break;
            if (tokens_[t] >= _numTokens) revert Pool__IndexOutOfBounds();
            _tokens = _tokens | ((tokens_[t] + 1) << (FixedPointMathLib.rawMul(8, t)));
        }

        if (tokens_.length == 0) _tokens = ALL_TOKENS_FLAG;
        (uint256 _virtualBalanceProd, uint256 _virtualBalanceSum) = _unpackPoolVirtualBalance(packedPoolVirtualBalance);
        (_virtualBalanceProd, _virtualBalanceSum) = _updateRates(_tokens, _virtualBalanceProd, _virtualBalanceSum);
        packedPoolVirtualBalance = _packPoolVirtualBalance(_virtualBalanceProd, _virtualBalanceSum);
    }

    /// @notice update weights and amplification factor, if possible
    /// @dev will only update the weights if a ramp is active and at least the minimum time step has been reached
    /// @return boolean to indicate whether the weights and amplification factor have been updated
    function updateWeights() external returns (bool) {
        _checkIfPaused();
        bool _updated = false;
        (uint256 _virtualBalanceProd, uint256 _virtualBalanceSum) = _unpackPoolVirtualBalance(packedPoolVirtualBalance);
        (_virtualBalanceProd, _updated) = _updateWeights(_virtualBalanceProd);
        if (_updated && _virtualBalanceSum > 0) {
            (, _virtualBalanceProd) = _updateSupply(supply, _virtualBalanceProd, _virtualBalanceSum);
            packedPoolVirtualBalance = _packPoolVirtualBalance(_virtualBalanceProd, _virtualBalanceSum);
        }
        return _updated;
    }

    /// @notice get the pool's virtual balance product (pi) and sum (sigma)
    /// @return tuple with product and sum
    function virtualBalanceProdSum() external view returns (uint256, uint256) {
        return _unpackPoolVirtualBalance(packedPoolVirtualBalance);
    }

    /// @notice get the virtual balance of a token
    /// @param token_ index of the token in the pool
    /// @return virtual balance of the token
    function virtualBalance(uint256 token_) external view returns (uint256) {
        if (token_ >= numTokens) revert Pool__IndexOutOfBounds();
        return packedVirtualBalances[token_] & VB_MASK;
    }

    /// @notice get the rate of an token
    /// @param token_ index of the token
    /// @return rate of the token
    function rate(uint256 token_) external view returns (uint256) {
        if (token_ >= numTokens) revert Pool__IndexOutOfBounds();
        return (packedVirtualBalances[token_] >> RATE_SHIFT) & RATE_MASK;
    }

    /// @notice get the weight of a token
    /// @dev does not take into account any active ramp
    /// @param token_ index of the token
    /// @return tuple with weight, target weight, lower band width, upper weight band width
    function weight(uint256 token_) external view returns (uint256, uint256, uint256, uint256) {
        if (token_ >= numTokens) revert Pool__IndexOutOfBounds();
        (uint256 _weight, uint256 _target, uint256 _lower, uint256 _upper) =
            _unpackWeight(packedVirtualBalances[token_] >> PACKED_WEIGHT_SHIFT);
        if (rampLastTime == 0) _target = _weight;
        return (_weight, _target, _lower, _upper);
    }

    /// @notice get the packed weight of a token in a packed format
    /// @dev does not take into account any active ramp
    /// @param token_ index of the token
    /// @return weight in packed format
    function packedWeight(uint256 token_) external view returns (uint256) {
        if (token_ >= numTokens) revert Pool__IndexOutOfBounds();
        return packedVirtualBalances[token_] >> PACKED_WEIGHT_SHIFT;
    }

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                      ADMIN FUNCTIONS                       */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @notice pause the pool
    function pause() external onlyOwner {
        if (paused) revert Pool__AlreadyPaused();
        paused = true;
        emit Pause(msg.sender);
    }

    /// @notice unpause the pool
    function unpause() external onlyOwner {
        if (!paused) revert Pool__NotPaused();
        if (killed) revert Pool__Killed();
        paused = false;
        emit Unpause(msg.sender);
    }

    /// @notice kill the pool
    function kill() external onlyOwner {
        if (!paused) revert Pool__NotPaused();
        if (killed) revert Pool__Killed();
        killed = true;
        emit Kill();
    }

    /// @notice add a new token to the pool
    /// @dev can only be called if no ramp is currently active
    /// @dev every other token will their weight reduced pro rata
    /// @dev caller should assure that amplification before and after the call are the same
    /// @param token_ address of the token to add
    /// @param rateProvider_ rate provider for the token
    /// @param weight_ weight of the new token
    /// @param lower_ lower band width
    /// @param upper_ upper band width
    /// @param amount_ amount of tokens
    /// @param amplification_ new pool amplification factor
    /// @param receiver_ account to receive the lp tokens minted
    function addToken(
        address token_,
        address rateProvider_,
        uint256 weight_,
        uint256 lower_,
        uint256 upper_,
        uint256 amount_,
        uint256 amplification_,
        uint256 minLpAmount_,
        address receiver_
    ) external onlyOwner {
        if (amount_ == 0) revert Pool__ZeroAmount();
        uint256 _prevNumTokens = numTokens;
        if (_prevNumTokens >= MAX_NUM_TOKENS) revert Pool__PoolIsFull();
        if (amplification_ == 0) revert Pool__ZeroAmount();
        if (rampLastTime != 0) revert Pool__RampActive();
        if (supply == 0) revert Pool__PoolIsEmpty();

        if (!(weight_ > 0 && weight_ <= PRECISION / 100)) {
            revert Pool__InvalidParams();
        }
        if (lower_ > PRECISION || upper_ > PRECISION) {
            revert Pool__InvalidParams();
        }

        // update weights for existing tokens
        uint256 _numTokens = _prevNumTokens + 1;
        uint256 _virtualBalance;
        uint256 _rate;
        uint256 _packedWeight;
        uint256 _prevWeight;
        uint256 _target;
        uint256 _lower;
        uint256 _upper;

        for (uint256 t = 0; t < MAX_NUM_TOKENS; t++) {
            if (t == _prevNumTokens) break;
            if (tokens[t] == token_) revert Pool__TokenAlreadyPartOfPool();
            (_virtualBalance, _rate, _packedWeight) = _unpackVirtualBalance(packedVirtualBalances[t]);
            (_prevWeight, _target, _lower, _upper) = _unpackWeight(_packedWeight);
            _packedWeight = _packWeight(
                FixedPointMathLib.rawSub(
                    _prevWeight, FixedPointMathLib.rawDiv(FixedPointMathLib.rawMul(_prevWeight, weight_), PRECISION)
                ),
                _target,
                _lower,
                _upper
            );
            packedVirtualBalances[t] = _packVirtualBalance(_virtualBalance, _rate, _packedWeight);
        }

        if (ERC20(token_).decimals() != 18) revert Pool__InvalidParams();
        _rate = IRateProvider(rateProvider_).rate(token_);
        if (_rate == 0) revert Pool__NoRate();

        _virtualBalance = (amount_ * _rate) / PRECISION;
        _packedWeight = _packWeight(weight_, weight_, _lower, _upper);

        // set parameters for new token
        numTokens = _numTokens;
        tokens[_prevNumTokens] = token_;
        rateProviders[_prevNumTokens] = rateProvider_;
        packedVirtualBalances[_prevNumTokens] = _packVirtualBalance(_virtualBalance, _rate, _packedWeight);

        // recalculate variables
        (uint256 _virtualBalanceProd, uint256 _virtualBalanceSum) = _calculateVirtualBalanceProdSum();

        // update supply
        uint256 _prevSupply = supply;
        uint256 __supply;
        (__supply, _virtualBalanceProd) = _calculateSupply(
            _numTokens, _virtualBalanceSum, amplification_, _virtualBalanceProd, _virtualBalanceSum, true
        );

        amplification = amplification_;
        supply = __supply;
        packedPoolVirtualBalance = _packPoolVirtualBalance(_virtualBalanceProd, _virtualBalanceSum);

        SafeTransferLib.safeTransferFrom(token_, msg.sender, address(this), amount_);
        if (__supply <= _prevSupply) revert Pool__InvalidParams();
        uint256 _lpAmount = FixedPointMathLib.rawSub(__supply, _prevSupply);
        if (_lpAmount < minLpAmount_) revert Pool__InvalidParams();
        PoolToken(tokenAddress).mint(receiver_, _lpAmount);
        emit AddToken(_prevNumTokens, token_, rateProvider_, _rate, weight_, amount_);
    }

    /// @notice rescue tokens from this contract
    /// @dev cannot be used to rescue pool tokens
    /// @param token_ the token to be rescued
    /// @param receiver_ receiver of the rescued tokens
    function rescue(address token_, address receiver_) external onlyOwner {
        uint256 _numTokens = numTokens;
        for (uint256 t = 0; t < MAX_NUM_TOKENS; t++) {
            if (t == _numTokens) break;
            if (!(token_ != tokens[t])) revert Pool__CannotRescuePoolToken();
        }
        uint256 _amount = ERC20(token_).balanceOf(address(this));
        SafeTransferLib.safeTransfer(token_, receiver_, _amount);
    }

    /// @notice skim surplus of a pool token
    /// @param token_ index of the token
    /// @param receiver_ receiver of the skimmed tokens
    function skim(uint256 token_, address receiver_) external onlyOwner {
        if (token_ >= numTokens) revert Pool__IndexOutOfBounds();
        (uint256 _virtualBalance, uint256 _rate,) = _unpackVirtualBalance(packedVirtualBalances[token_]);
        uint256 _expected = (_virtualBalance * PRECISION) / _rate + 1;
        address _token = tokens[token_];
        uint256 _actual = ERC20(_token).balanceOf(address(this));
        if (_actual <= _expected) revert Pool__NoSurplus();
        SafeTransferLib.safeTransfer(_token, receiver_, _actual - _expected);
    }

    /// @notice set new swap fee rate
    /// @param feeRate_ new swap fee rate (in 18 decimals)
    function setSwapFeeRate(uint256 feeRate_) external onlyOwner {
        if (feeRate_ > PRECISION / 100) revert Pool__InvalidParams();
        swapFeeRate = feeRate_;
        emit SetSwapFeeRate(feeRate_);
    }

    /// @notice set safeft weight bands, if any user operation puts the weight outside of the bands, the transaction will revert
    /// @param tokens_ array of indices of the tokens to set the bands for
    /// @param lower_ array of widths of the lower band
    /// @param upper_ array of widths of the upper band
    function setWeightBands(uint256[] calldata tokens_, uint256[] calldata lower_, uint256[] calldata upper_)
        external
        onlyOwner
    {
        if (!(lower_.length == tokens_.length && upper_.length == tokens_.length)) revert Pool__InvalidParams();

        uint256 _numTokens = numTokens;
        for (uint256 t = 0; t < MAX_NUM_TOKENS; t++) {
            if (t == tokens_.length) break;
            uint256 _token = tokens_[t];
            if (_token >= _numTokens) revert Pool__IndexOutOfBounds();
            if (!(lower_[t] <= PRECISION && upper_[t] <= PRECISION)) {
                revert Pool__BandsOutOfBounds();
            }

            (uint256 _virtualBalance, uint256 _rate, uint256 _packedWeight) =
                _unpackVirtualBalance(packedVirtualBalances[_token]);
            (uint256 _weight, uint256 _target,,) = _unpackWeight(_packedWeight);
            _packedWeight = _packWeight(_weight, _target, lower_[t], upper_[t]);
            packedVirtualBalances[_token] = _packVirtualBalance(_virtualBalance, _rate, _packedWeight);
            emit SetWeightBand(_token, lower_[t], upper_[t]);
        }
    }

    /// @notice set a rate provider for a token
    /// @param token_ index of the token
    /// @param rateProvider_ new rate provider for the token
    function setRateProvider(uint256 token_, address rateProvider_) external onlyOwner {
        if (token_ >= numTokens) revert Pool__IndexOutOfBounds();

        rateProviders[token_] = rateProvider_;
        (uint256 _virtualBalanceProd, uint256 _virtualBalanceSum) = _unpackPoolVirtualBalance(packedPoolVirtualBalance);
        (_virtualBalanceProd, _virtualBalanceSum) = _updateRates(token_ + 1, _virtualBalanceProd, _virtualBalanceSum);
        packedPoolVirtualBalance = _packPoolVirtualBalance(_virtualBalanceProd, _virtualBalanceSum);
        emit SetRateProvider(token_, rateProvider_);
    }

    /// @notice schedule an amplification and/or weight change
    /// @dev effective amplification at any time is `amplification/f^n`
    /// @param amplification_ new amplification factor (in 18 decimals)
    /// @param weights_ array of the new weight for each token (in 18 decimals)
    /// @param duration_ duration of the ramp (in seconds)
    /// @param start_ ramp start time
    function setRamp(uint256 amplification_, uint256[] calldata weights_, uint256 duration_, uint256 start_)
        external
        onlyOwner
    {
        uint256 _numTokens = numTokens;
        if (amplification_ == 0) revert Pool__InvalidParams();
        if (weights_.length != _numTokens) revert Pool__InvalidParams();
        if (start_ < block.timestamp) revert Pool__InvalidParams();

        bool _updated;
        (uint256 _virtualBalanceProd, uint256 _virtualBalanceSum) = _unpackPoolVirtualBalance(packedPoolVirtualBalance);
        (_virtualBalanceProd, _updated) = _updateWeights(_virtualBalanceProd);
        if (_updated) {
            uint256 _supply;
            (_supply, _virtualBalanceProd) = _updateSupply(supply, _virtualBalanceProd, _virtualBalanceSum);
            packedPoolVirtualBalance = _packPoolVirtualBalance(_virtualBalanceProd, _virtualBalanceSum);
        }

        if (rampLastTime != 0) revert Pool__RampActive();

        rampLastTime = start_;
        rampStopTime = start_ + duration_;

        targetAmplification = amplification_;

        uint256 _total;

        for (uint256 t = 0; t < MAX_NUM_TOKENS; t++) {
            if (t == _numTokens) break;
            uint256 _newWeight = weights_[t];
            if (_newWeight >= PRECISION) revert Pool__WeightOutOfBounds();
            _total += _newWeight;

            (uint256 _virtualBalance, uint256 _rate, uint256 _packedWeight) =
                _unpackVirtualBalance(packedVirtualBalances[t]);

            (uint256 _weight,, uint256 _lower, uint256 _upper) = _unpackWeight(_packedWeight);

            _packedWeight = _packWeight(_weight, _newWeight, _lower, _upper);
            packedVirtualBalances[t] = _packVirtualBalance(_virtualBalance, _rate, _packedWeight);
        }

        if (_total != PRECISION) revert Pool__WeightsDoNotAddUp();
        emit SetRamp(amplification_, weights_, duration_, start_);
    }

    /// @notice set the minimum time b/w ramp step
    /// @param rampStep_ minimum step time (in seconds)
    function setRampStep(uint256 rampStep_) external onlyOwner {
        if (rampStep_ == 0) revert Pool__InvalidParams();
        rampStep = rampStep_;
        emit SetRampStep(rampStep_);
    }

    /// @notice stop an active ramp
    function stopRamp() external onlyOwner {
        rampLastTime = 0;
        rampStopTime = 0;
        emit StopRamp();
    }

    /// @notice set the address that receives yield, slashings and swap fees
    /// @param stakingAddress_ new staking address
    function setStaking(address stakingAddress_) external onlyOwner {
        if (stakingAddress_ == address(0)) revert Pool__InvalidParams();
        stakingAddress = stakingAddress_;
        emit SetStaking(stakingAddress_);
    }

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                     INTERNAL FUNCTIONS                     */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @notice update rates of specific tokens
    /// @dev loops through the bytes in `token_` until a zero or a number larger than the number of assets is encountered
    /// @dev update weights (if needed) prior to checking any rates
    /// @dev will recalculate supply and mint/burn to staking contract if any weight or rate has updated
    /// @dev will revert if any rate increases by more than 10%, unless called by management
    /// @param tokens_ integer where each byte represents a token index offset by one
    /// @param virtualBalanceProd_ product term (pi) before update
    /// @param virtualBalanceSum_ sum term (sigma) before update
    /// @return tuple with new product and sum term
    function _updateRates(uint256 tokens_, uint256 virtualBalanceProd_, uint256 virtualBalanceSum_)
        internal
        returns (uint256, uint256)
    {
        _checkIfPaused();

        uint256 _virtualBalanceSum = virtualBalanceSum_;
        (uint256 _virtualBalanceProd, bool _updated) = _updateWeights(virtualBalanceProd_);

        uint256 _numTokens = numTokens;
        for (uint256 t = 0; t < MAX_NUM_TOKENS; t++) {
            uint256 token = (tokens_ >> FixedPointMathLib.rawMul(8, t)) & 255;
            if (token == 0 || token > _numTokens) {
                break;
            }
            token = FixedPointMathLib.rawSub(token, 1);
            address provider = rateProviders[token];

            (uint256 _prevVirtualBalance, uint256 _prevRate, uint256 _packedWeight) =
                _unpackVirtualBalance(packedVirtualBalances[token]);

            uint256 _rate = IRateProvider(provider).rate(tokens[token]);

            if (!(_rate > 0)) revert Pool__InvalidRateProvided();

            // no rate change
            if (_rate == _prevRate) continue;

            // cap upward rate movement to 10%
            if (_rate > (_prevRate * 11) / 10 && _prevRate > 0) {
                _checkOwner();
            }

            uint256 _virtualBalance;
            if (_prevRate > 0 && _virtualBalanceSum > 0) {
                // factor out old rate and factor in new rate
                uint256 weightTimesN = _unpackWeightTimesN(_packedWeight, _numTokens);
                _virtualBalanceProd =
                    (_virtualBalanceProd * _powUp((_prevRate * PRECISION) / _rate, weightTimesN)) / PRECISION;
                _virtualBalance = (_prevVirtualBalance * _rate) / _prevRate;
                _virtualBalanceSum = _virtualBalanceSum + _virtualBalance - _prevVirtualBalance;
            }

            packedVirtualBalances[token] = _packVirtualBalance(_virtualBalance, _rate, _packedWeight);
            emit RateUpdate(token, _rate);
        }

        if (!_updated && _virtualBalanceProd == virtualBalanceProd_ && _virtualBalanceSum == virtualBalanceSum_) {
            return (_virtualBalanceProd, _virtualBalanceSum);
        }

        // recalculate supply and mint/burn token to staking address
        uint256 _supply;
        (_supply, _virtualBalanceProd) = _updateSupply(supply, _virtualBalanceProd, _virtualBalanceSum);
        return (_virtualBalanceProd, _virtualBalanceSum);
    }

    /// @notice apply a step in amplitude and weight ramp, if applicable
    /// @dev caller is reponsible for updating supply if a step has been taken
    /// @param vbProd_ product term(pi) before update
    /// @return tuple with new product term and flag indicating if a step has been taken
    function _updateWeights(uint256 vbProd_) internal returns (uint256, bool) {
        uint256 _span = rampLastTime;
        uint256 _duration = rampStopTime;
        if (
            _span == 0 || _span > block.timestamp || (block.timestamp - _span < rampStep && _duration > block.timestamp)
        ) {
            // scenarios:
            //  1) no ramp is active
            //  2) ramp is scheduled for in the future
            //  3) weights have been updated too recently and ramp hasnt finished yet
            return (vbProd_, false);
        }

        if (block.timestamp < _duration) {
            // ramp in progress
            _duration -= _span;
            rampLastTime = block.timestamp;
        } else {
            // ramp has finished
            _duration = 0;
            rampLastTime = 0;
            rampStopTime = 0;
        }

        _span = block.timestamp - _span;

        // update amplification
        uint256 _current = amplification;
        uint256 _target = targetAmplification;

        if (_duration == 0) {
            _current = _target;
        } else {
            if (_current > _target) {
                _current = _current - ((_current - _target) * _span) / _duration;
            } else {
                _current = _current + ((_target - _current) * _span) / _duration;
            }
        }
        amplification = _current;

        // update weights
        uint256 _virtualBalance = 0;
        uint256 _rate = 0;
        uint256 _packedWeight = 0;
        uint256 _lower = 0;
        uint256 _upper = 0;
        for (uint256 t = 0; t < MAX_NUM_TOKENS; t++) {
            if (t == numTokens) break;
            (_virtualBalance, _rate, _packedWeight) = _unpackVirtualBalance(packedVirtualBalances[t]);
            (_current, _target, _lower, _upper) = _unpackWeight(_packedWeight);
            if (_duration == 0) {
                _current = _target;
            } else {
                if (_current > _target) {
                    _current -= ((_current - _target) * _span) / _duration;
                } else {
                    _current += ((_target - _current) * _span) / _duration;
                }
            }
            _packedWeight = _packWeight(_current, _target, _lower, _upper);
            packedVirtualBalances[t] = _packVirtualBalance(_virtualBalance, _rate, _packedWeight);
        }

        uint256 vbProd = 0;
        uint256 _supply = supply;
        if (_supply > 0) {
            vbProd = _calculateVirtualBalanceProd(_supply);
        }
        return (vbProd, true);
    }

    /// @notice calculate supply and burn or mint difference from the staking contract
    /// @param supply_ previous supply
    /// @param vbProd_ product term (pi)
    /// @param vbSum_ sum term (sigma)
    /// @return tuple with new supply and product term
    function _updateSupply(uint256 supply_, uint256 vbProd_, uint256 vbSum_) internal returns (uint256, uint256) {
        if (supply_ == 0) return (0, vbProd_);

        (uint256 _supply, uint256 _virtualBalanceProd) =
            _calculateSupply(numTokens, supply_, amplification, vbProd_, vbSum_, true);

        if (_supply > supply_) {
            PoolToken(tokenAddress).mint(stakingAddress, _supply - supply_);
        } else if (_supply < supply_) {
            PoolToken(tokenAddress).burn(stakingAddress, supply_ - _supply);
        }
        supply = _supply;
        return (_supply, _virtualBalanceProd);
    }

    /// @notice check whether asset is within safety band, or if previously outside, moves closer to it
    /// @dev reverts if conditions are not met
    /// @param prevRatio_ token ratio before user action
    /// @param ratio_ token ratio after user action
    /// @param packedWeight_ packed weight
    function _checkBands(uint256 prevRatio_, uint256 ratio_, uint256 packedWeight_) internal pure {
        uint256 _weight = FixedPointMathLib.rawMul(packedWeight_ & WEIGHT_MASK, WEIGHT_SCALE);

        // lower limit check
        uint256 limit = FixedPointMathLib.rawMul((packedWeight_ >> LOWER_BAND_SHIFT) & WEIGHT_MASK, WEIGHT_SCALE);
        if (limit > _weight) {
            limit = 0;
        } else {
            limit = FixedPointMathLib.rawSub(_weight, limit);
        }
        if (ratio_ < limit) {
            if (ratio_ <= prevRatio_) {
                revert Pool__RatioBelowLowerBound();
            }
            return;
        }

        // upper limit check
        limit = FixedPointMathLib.min(
            FixedPointMathLib.rawAdd(_weight, FixedPointMathLib.rawMul(packedWeight_ >> UPPER_BAND_SHIFT, WEIGHT_SCALE)),
            PRECISION
        );
        if (ratio_ > limit) {
            if (ratio_ >= prevRatio_) {
                revert Pool__RatioAboveUpperBound();
            }
        }
    }

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                        MATH FUNCTIONS                      */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @notice calculate product term (pi) and sum term (sigma)
    /// @return tuple with product and sum term
    function _calculateVirtualBalanceProdSum() internal view returns (uint256, uint256) {
        uint256 s = 0;
        for (uint256 t = 0; t < MAX_NUM_TOKENS; t++) {
            if (t == numTokens) {
                break;
            }
            s = FixedPointMathLib.rawAdd(s, packedVirtualBalances[t] & VB_MASK);
        }
        uint256 p = _calculateVirtualBalanceProd(s);
        return (p, s);
    }

    /// @notice calculate product term (pi)
    /// @param supply_ supply to use in product term
    /// @return product term
    function _calculateVirtualBalanceProd(uint256 supply_) internal view returns (uint256) {
        uint256 _numTokens = numTokens;
        uint256 _p = PRECISION;
        for (uint256 t = 0; t < MAX_NUM_TOKENS; ++t) {
            if (t == _numTokens) {
                break;
            }
            uint256 _virtualBalance;
            uint256 _packedWeight;
            (_virtualBalance,, _packedWeight) = _unpackVirtualBalance(packedVirtualBalances[t]);
            uint256 _weight = _unpackWeightTimesN(_packedWeight, 1);

            if (!(_weight > 0 && _virtualBalance > 0)) revert Pool__InvalidParams();

            // p = product((D * w_i / vb_i)^(w_i * n))
            _p = FixedPointMathLib.rawDiv(
                FixedPointMathLib.rawMul(
                    _p,
                    _powDown(
                        FixedPointMathLib.rawDiv(FixedPointMathLib.rawMul(supply_, _weight), _virtualBalance),
                        FixedPointMathLib.rawMul(_weight, _numTokens)
                    )
                ),
                PRECISION
            );
        }
        return _p;
    }

    /// @notice calculate supply iteratively
    /// @param numTokens_ number of tokens in the pool
    /// @param supply_ supply as used in product term
    /// @param amplification_ amplification factor (A f^n)
    /// @param virtualBalanceProd_ product term (pi)
    /// @param virtualBalanceSum_ sum term (sigma)
    /// @param up_ whether to round up
    /// @return tuple with new supply and product term
    function _calculateSupply(
        uint256 numTokens_,
        uint256 supply_,
        uint256 amplification_,
        uint256 virtualBalanceProd_,
        uint256 virtualBalanceSum_,
        bool up_
    ) internal pure returns (uint256, uint256) {
        // D[m+1] = (A f^n sigma - D[m] pi[m] )) / (A f^n - 1)
        //        = (_l - _s _r) / _d

        uint256 _l = amplification_; // left: A f^n sigma
        uint256 _d = _l - PRECISION; // denominator: A f*n - 1
        _l = _l * virtualBalanceSum_;
        uint256 _s = supply_; // supply: D[m]
        uint256 _r = virtualBalanceProd_; // right: pi[m]

        for (uint256 i = 0; i < 256; i++) {
            if (!(_s > 0)) {
                revert Pool__InvalidParams();
            }
            uint256 _sp = FixedPointMathLib.rawDiv(FixedPointMathLib.rawSub(_l, FixedPointMathLib.rawMul(_s, _r)), _d); // D[m+1] = (_l - _s * _r) / _d
            // update product term pi[m+1] = (D[m+1]/D[m])^n pi(m)
            for (uint256 t = 0; t < MAX_NUM_TOKENS; t++) {
                if (t == numTokens_) {
                    break;
                }
                _r = FixedPointMathLib.rawDiv(FixedPointMathLib.rawMul(_r, _sp), _s); // _r * _sp / _s
            }
            uint256 _delta = 0;
            if (_sp >= _s) {
                _delta = FixedPointMathLib.rawSub(_sp, _s);
            } else {
                _delta = FixedPointMathLib.rawSub(_s, _sp);
            }

            if (FixedPointMathLib.rawDiv(FixedPointMathLib.rawMul(_delta, PRECISION), _s) <= MAX_POW_REL_ERR) {
                _delta = FixedPointMathLib.rawDiv(FixedPointMathLib.rawMul(_sp, MAX_POW_REL_ERR), PRECISION);
                if (up_) {
                    _sp += _delta;
                } else {
                    _sp -= _delta;
                }
                return (_sp, _r);
            }

            _s = _sp;
        }

        revert Pool__NoConvergence();
    }

    /// @notice calculate a single token's virtual balance iteratively using newton's method
    /// @param wn_ token weight times number of tokens
    /// @param y_ starting value
    /// @param supply_ supply
    /// @param amplification_ amplification factor `A f^n`
    /// @param vbProd_ intermediary product term (pi~), pi with previous balances factored out and new balance factored in
    /// @param vbSum_ intermediary sum term (sigma~), sigma with previous balances subtracted and new balance added
    /// @return new token virtual balance
    function _calculateVirtualBalance(
        uint256 wn_,
        uint256 y_,
        uint256 supply_,
        uint256 amplification_,
        uint256 vbProd_,
        uint256 vbSum_
    ) internal pure returns (uint256) {
        // y = x_j, sum' = sum(x_i, i != j), prod' = D^n w_j^(v_j) prod((w_i/x_i)^v_i, i != j)
        // Iteratively find root of g(y) using Newton's method
        // g(y) = y^(v_j + 1) + (sum' + (1 / (A f^n) - 1) D) y^(v_j) - D prod' / (A f^n)
        //      = y^(v_j + 1) + b y^(v_j) - c
        // y[n+1] = y[n] - g(y[n])/g'(y[n])
        //        = (y[n]^2 + b (1 - q) y[n] + c q y[n]^(1 - v_j)) / ((q + 1) y[n] + b))

        uint256 b = (supply_ * PRECISION) / amplification_; // b' = sigma + D / (A f^n)
        uint256 c = (vbProd_ * b) / PRECISION; // c' = D / (A f^n) * pi
        b += vbSum_;
        uint256 q = (PRECISION * PRECISION) / wn_; // q = 1 / v_i = 1 / (w_i n)

        uint256 y = y_;
        for (uint256 i = 0; i < 256; i++) {
            if (!(y > 0)) revert Pool__InvalidParams();

            uint256 yp = (y + b + supply_ * q / PRECISION + c * q / _powUp(y, wn_) - b * q / PRECISION - supply_) * y
                / (q * y / PRECISION + y + b - supply_);
            uint256 delta = 0;
            if (yp >= y) {
                delta = yp - y;
            } else {
                delta = y - yp;
            }

            if (FixedPointMathLib.rawDiv(FixedPointMathLib.rawMul(delta, PRECISION), y) <= MAX_POW_REL_ERR) {
                yp += FixedPointMathLib.rawDiv(FixedPointMathLib.rawMul(yp, MAX_POW_REL_ERR), PRECISION);
                return yp;
            }
            y = yp;
        }

        revert Pool__NoConvergence();
    }

    /// @notice pack virtual balance of a token along with other related variables
    /// @param virtualBalance_ virtual balance of a token
    /// @param rate_ token rate
    /// @param packedWeight_ packed weight of a token
    /// @return packed variable
    function _packVirtualBalance(uint256 virtualBalance_, uint256 rate_, uint256 packedWeight_)
        internal
        pure
        returns (uint256)
    {
        if (virtualBalance_ > VB_MASK || rate_ > RATE_MASK) {
            revert Pool__InvalidParams();
        }

        return virtualBalance_ | (rate_ << RATE_SHIFT) | (packedWeight_ << PACKED_WEIGHT_SHIFT);
    }

    /// @notice unpack variable to it's components
    /// @param packed_ packed variable
    /// @return tuple with virtual balance, rate and packed weight
    function _unpackVirtualBalance(uint256 packed_) internal pure returns (uint256, uint256, uint256) {
        return (packed_ & VB_MASK, (packed_ >> RATE_SHIFT) & RATE_MASK, packed_ >> PACKED_WEIGHT_SHIFT);
    }

    /// @notice pack weight with target and bands
    /// @param weight_ weight with 18 decimals
    /// @param target_ target weight with 18 decimals
    /// @param lower_ lower band with 18 decimals, allowed distance from weight in negative direction
    /// @param upper_ upper band with 18 decimal, allowed distance  from weight in positive direction
    function _packWeight(uint256 weight_, uint256 target_, uint256 lower_, uint256 upper_)
        internal
        pure
        returns (uint256)
    {
        return (
            (FixedPointMathLib.rawDiv(weight_, WEIGHT_SCALE))
                | (FixedPointMathLib.rawDiv(target_, WEIGHT_SCALE) << TARGET_WEIGHT_SHIFT)
                | (FixedPointMathLib.rawDiv(lower_, WEIGHT_SCALE) << LOWER_BAND_SHIFT)
                | (FixedPointMathLib.rawDiv(upper_, WEIGHT_SCALE) << UPPER_BAND_SHIFT)
        );
    }

    /// @notice unpack weight to its components
    /// @param packed_ packed weight
    /// @return tuple with weight, target weight, lower band and upper band (all in 18 decimals)
    function _unpackWeight(uint256 packed_) internal pure returns (uint256, uint256, uint256, uint256) {
        return (
            FixedPointMathLib.rawMul(packed_ & WEIGHT_MASK, WEIGHT_SCALE),
            FixedPointMathLib.rawMul((packed_ >> TARGET_WEIGHT_SHIFT) & WEIGHT_MASK, WEIGHT_SCALE),
            FixedPointMathLib.rawMul((packed_ >> LOWER_BAND_SHIFT) & WEIGHT_MASK, WEIGHT_SCALE),
            FixedPointMathLib.rawMul(packed_ >> UPPER_BAND_SHIFT, WEIGHT_SCALE)
        );
    }

    /// @notice unpack weight and multiply by number of tokens
    /// @param packed_ packed weight
    /// @param numTokens_ number of tokens
    /// @return weight multiplied by number of tokens (18 decimals)
    function _unpackWeightTimesN(uint256 packed_, uint256 numTokens_) internal pure returns (uint256) {
        return FixedPointMathLib.rawMul(FixedPointMathLib.rawMul(packed_ & WEIGHT_MASK, WEIGHT_SCALE), numTokens_);
    }

    /// @notice pack pool product and sum term
    /// @param prod_ Product term (pi)
    /// @param sum_ Sum term (sigma)
    /// @return packed term
    function _packPoolVirtualBalance(uint256 prod_, uint256 sum_) internal pure returns (uint256) {
        if (prod_ <= POOL_VB_MASK && sum_ <= POOL_VB_MASK) {
            return prod_ | (sum_ << POOL_VB_SHIFT);
        }
        revert Pool__InvalidParams();
    }

    /// @notice unpack pool product and sum term
    /// @param packed_ packed terms
    /// @return tuple with pool product term (pi) and pool sum term (sigma)
    function _unpackPoolVirtualBalance(uint256 packed_) internal pure returns (uint256, uint256) {
        return (packed_ & POOL_VB_MASK, packed_ >> POOL_VB_SHIFT);
    }

    function _checkIfPaused() internal view {
        if (paused == true) {
            revert Pool__Paused();
        }
    }

    function _powUp(uint256 x, uint256 y) internal pure returns (uint256) {
        uint256 p = LogExpMath.pow(x, y);
        // uint256 p = FixedPointMathLib.rpow(x, y, 1);
        if (p == 0) return 0;
        // p + (p * MAX_POW_REL_ERR - 1) / PRECISION + 1
        return FixedPointMathLib.rawAdd(
            FixedPointMathLib.rawAdd(
                p,
                FixedPointMathLib.rawDiv(
                    FixedPointMathLib.rawSub(FixedPointMathLib.rawMul(p, MAX_POW_REL_ERR), 1), PRECISION
                )
            ),
            1
        );
    }

    function _powDown(uint256 x, uint256 y) internal pure returns (uint256) {
        uint256 p = LogExpMath.pow(x, y);
        // uint256 p = FixedPointMathLib.rpow(x, y, 1);
        if (p == 0) return 0;
        // (p * MAX_POW_REL_ERR - 1) / PRECISION + 1
        uint256 e = FixedPointMathLib.rawAdd(
            FixedPointMathLib.rawDiv(
                FixedPointMathLib.rawSub(FixedPointMathLib.rawMul(p, MAX_POW_REL_ERR), 1), PRECISION
            ),
            1
        );
        if (p < e) return 0;
        return FixedPointMathLib.rawSub(p, e);
    }
}

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

/// @notice Simple single owner authorization mixin.
/// @author Solady (https://github.com/vectorized/solady/blob/main/src/auth/Ownable.sol)
///
/// @dev Note:
/// This implementation does NOT auto-initialize the owner to `msg.sender`.
/// You MUST call the `_initializeOwner` in the constructor / initializer.
///
/// While the ownable portion follows
/// [EIP-173](https://eips.ethereum.org/EIPS/eip-173) for compatibility,
/// the nomenclature for the 2-step ownership handover may be unique to this codebase.
abstract contract Ownable {
    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                       CUSTOM ERRORS                        */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev The caller is not authorized to call the function.
    error Unauthorized();

    /// @dev The `newOwner` cannot be the zero address.
    error NewOwnerIsZeroAddress();

    /// @dev The `pendingOwner` does not have a valid handover request.
    error NoHandoverRequest();

    /// @dev Cannot double-initialize.
    error AlreadyInitialized();

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

    /// @dev The ownership is transferred from `oldOwner` to `newOwner`.
    /// This event is intentionally kept the same as OpenZeppelin's Ownable to be
    /// compatible with indexers and [EIP-173](https://eips.ethereum.org/EIPS/eip-173),
    /// despite it not being as lightweight as a single argument event.
    event OwnershipTransferred(address indexed oldOwner, address indexed newOwner);

    /// @dev An ownership handover to `pendingOwner` has been requested.
    event OwnershipHandoverRequested(address indexed pendingOwner);

    /// @dev The ownership handover to `pendingOwner` has been canceled.
    event OwnershipHandoverCanceled(address indexed pendingOwner);

    /// @dev `keccak256(bytes("OwnershipTransferred(address,address)"))`.
    uint256 private constant _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE =
        0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0;

    /// @dev `keccak256(bytes("OwnershipHandoverRequested(address)"))`.
    uint256 private constant _OWNERSHIP_HANDOVER_REQUESTED_EVENT_SIGNATURE =
        0xdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d;

    /// @dev `keccak256(bytes("OwnershipHandoverCanceled(address)"))`.
    uint256 private constant _OWNERSHIP_HANDOVER_CANCELED_EVENT_SIGNATURE =
        0xfa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c92;

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

    /// @dev The owner slot is given by:
    /// `bytes32(~uint256(uint32(bytes4(keccak256("_OWNER_SLOT_NOT")))))`.
    /// It is intentionally chosen to be a high value
    /// to avoid collision with lower slots.
    /// The choice of manual storage layout is to enable compatibility
    /// with both regular and upgradeable contracts.
    bytes32 internal constant _OWNER_SLOT =
        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffff74873927;

    /// The ownership handover slot of `newOwner` is given by:
    /// ```
    ///     mstore(0x00, or(shl(96, user), _HANDOVER_SLOT_SEED))
    ///     let handoverSlot := keccak256(0x00, 0x20)
    /// ```
    /// It stores the expiry timestamp of the two-step ownership handover.
    uint256 private constant _HANDOVER_SLOT_SEED = 0x389a75e1;

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                     INTERNAL FUNCTIONS                     */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Override to return true to make `_initializeOwner` prevent double-initialization.
    function _guardInitializeOwner() internal pure virtual returns (bool guard) {}

    /// @dev Initializes the owner directly without authorization guard.
    /// This function must be called upon initialization,
    /// regardless of whether the contract is upgradeable or not.
    /// This is to enable generalization to both regular and upgradeable contracts,
    /// and to save gas in case the initial owner is not the caller.
    /// For performance reasons, this function will not check if there
    /// is an existing owner.
    function _initializeOwner(address newOwner) internal virtual {
        if (_guardInitializeOwner()) {
            /// @solidity memory-safe-assembly
            assembly {
                let ownerSlot := _OWNER_SLOT
                if sload(ownerSlot) {
                    mstore(0x00, 0x0dc149f0) // `AlreadyInitialized()`.
                    revert(0x1c, 0x04)
                }
                // Clean the upper 96 bits.
                newOwner := shr(96, shl(96, newOwner))
                // Store the new value.
                sstore(ownerSlot, or(newOwner, shl(255, iszero(newOwner))))
                // Emit the {OwnershipTransferred} event.
                log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, 0, newOwner)
            }
        } else {
            /// @solidity memory-safe-assembly
            assembly {
                // Clean the upper 96 bits.
                newOwner := shr(96, shl(96, newOwner))
                // Store the new value.
                sstore(_OWNER_SLOT, newOwner)
                // Emit the {OwnershipTransferred} event.
                log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, 0, newOwner)
            }
        }
    }

    /// @dev Sets the owner directly without authorization guard.
    function _setOwner(address newOwner) internal virtual {
        if (_guardInitializeOwner()) {
            /// @solidity memory-safe-assembly
            assembly {
                let ownerSlot := _OWNER_SLOT
                // Clean the upper 96 bits.
                newOwner := shr(96, shl(96, newOwner))
                // Emit the {OwnershipTransferred} event.
                log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, sload(ownerSlot), newOwner)
                // Store the new value.
                sstore(ownerSlot, or(newOwner, shl(255, iszero(newOwner))))
            }
        } else {
            /// @solidity memory-safe-assembly
            assembly {
                let ownerSlot := _OWNER_SLOT
                // Clean the upper 96 bits.
                newOwner := shr(96, shl(96, newOwner))
                // Emit the {OwnershipTransferred} event.
                log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, sload(ownerSlot), newOwner)
                // Store the new value.
                sstore(ownerSlot, newOwner)
            }
        }
    }

    /// @dev Throws if the sender is not the owner.
    function _checkOwner() internal view virtual {
        /// @solidity memory-safe-assembly
        assembly {
            // If the caller is not the stored owner, revert.
            if iszero(eq(caller(), sload(_OWNER_SLOT))) {
                mstore(0x00, 0x82b42900) // `Unauthorized()`.
                revert(0x1c, 0x04)
            }
        }
    }

    /// @dev Returns how long a two-step ownership handover is valid for in seconds.
    /// Override to return a different value if needed.
    /// Made internal to conserve bytecode. Wrap it in a public function if needed.
    function _ownershipHandoverValidFor() internal view virtual returns (uint64) {
        return 48 * 3600;
    }

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                  PUBLIC UPDATE FUNCTIONS                   */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Allows the owner to transfer the ownership to `newOwner`.
    function transferOwnership(address newOwner) public payable virtual onlyOwner {
        /// @solidity memory-safe-assembly
        assembly {
            if iszero(shl(96, newOwner)) {
                mstore(0x00, 0x7448fbae) // `NewOwnerIsZeroAddress()`.
                revert(0x1c, 0x04)
            }
        }
        _setOwner(newOwner);
    }

    /// @dev Allows the owner to renounce their ownership.
    function renounceOwnership() public payable virtual onlyOwner {
        _setOwner(address(0));
    }

    /// @dev Request a two-step ownership handover to the caller.
    /// The request will automatically expire in 48 hours (172800 seconds) by default.
    function requestOwnershipHandover() public payable virtual {
        unchecked {
            uint256 expires = block.timestamp + _ownershipHandoverValidFor();
            /// @solidity memory-safe-assembly
            assembly {
                // Compute and set the handover slot to `expires`.
                mstore(0x0c, _HANDOVER_SLOT_SEED)
                mstore(0x00, caller())
                sstore(keccak256(0x0c, 0x20), expires)
                // Emit the {OwnershipHandoverRequested} event.
                log2(0, 0, _OWNERSHIP_HANDOVER_REQUESTED_EVENT_SIGNATURE, caller())
            }
        }
    }

    /// @dev Cancels the two-step ownership handover to the caller, if any.
    function cancelOwnershipHandover() public payable virtual {
        /// @solidity memory-safe-assembly
        assembly {
            // Compute and set the handover slot to 0.
            mstore(0x0c, _HANDOVER_SLOT_SEED)
            mstore(0x00, caller())
            sstore(keccak256(0x0c, 0x20), 0)
            // Emit the {OwnershipHandoverCanceled} event.
            log2(0, 0, _OWNERSHIP_HANDOVER_CANCELED_EVENT_SIGNATURE, caller())
        }
    }

    /// @dev Allows the owner to complete the two-step ownership handover to `pendingOwner`.
    /// Reverts if there is no existing ownership handover requested by `pendingOwner`.
    function completeOwnershipHandover(address pendingOwner) public payable virtual onlyOwner {
        /// @solidity memory-safe-assembly
        assembly {
            // Compute and set the handover slot to 0.
            mstore(0x0c, _HANDOVER_SLOT_SEED)
            mstore(0x00, pendingOwner)
            let handoverSlot := keccak256(0x0c, 0x20)
            // If the handover does not exist, or has expired.
            if gt(timestamp(), sload(handoverSlot)) {
                mstore(0x00, 0x6f5e8818) // `NoHandoverRequest()`.
                revert(0x1c, 0x04)
            }
            // Set the handover slot to 0.
            sstore(handoverSlot, 0)
        }
        _setOwner(pendingOwner);
    }

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                   PUBLIC READ FUNCTIONS                    */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Returns the owner of the contract.
    function owner() public view virtual returns (address result) {
        /// @solidity memory-safe-assembly
        assembly {
            result := sload(_OWNER_SLOT)
        }
    }

    /// @dev Returns the expiry timestamp for the two-step ownership handover to `pendingOwner`.
    function ownershipHandoverExpiresAt(address pendingOwner)
        public
        view
        virtual
        returns (uint256 result)
    {
        /// @solidity memory-safe-assembly
        assembly {
            // Compute the handover slot.
            mstore(0x0c, _HANDOVER_SLOT_SEED)
            mstore(0x00, pendingOwner)
            // Load the handover slot.
            result := sload(keccak256(0x0c, 0x20))
        }
    }

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

    /// @dev Marks a function as only callable by the owner.
    modifier onlyOwner() virtual {
        _checkOwner();
        _;
    }
}

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

/// @notice Simple ERC20 + EIP-2612 implementation.
/// @author Solady (https://github.com/vectorized/solady/blob/main/src/tokens/ERC20.sol)
/// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol)
/// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol)
///
/// @dev Note:
/// - The ERC20 standard allows minting and transferring to and from the zero address,
///   minting and transferring zero tokens, as well as self-approvals.
///   For performance, this implementation WILL NOT revert for such actions.
///   Please add any checks with overrides if desired.
/// - The `permit` function uses the ecrecover precompile (0x1).
///
/// If you are overriding:
/// - NEVER violate the ERC20 invariant:
///   the total sum of all balances must be equal to `totalSupply()`.
/// - Check that the overridden function is actually used in the function you want to
///   change the behavior of. Much of the code has been manually inlined for performance.
abstract contract ERC20 {
    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                       CUSTOM ERRORS                        */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev The total supply has overflowed.
    error TotalSupplyOverflow();

    /// @dev The allowance has overflowed.
    error AllowanceOverflow();

    /// @dev The allowance has underflowed.
    error AllowanceUnderflow();

    /// @dev Insufficient balance.
    error InsufficientBalance();

    /// @dev Insufficient allowance.
    error InsufficientAllowance();

    /// @dev The permit is invalid.
    error InvalidPermit();

    /// @dev The permit has expired.
    error PermitExpired();

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

    /// @dev Emitted when `amount` tokens is transferred from `from` to `to`.
    event Transfer(address indexed from, address indexed to, uint256 amount);

    /// @dev Emitted when `amount` tokens is approved by `owner` to be used by `spender`.
    event Approval(address indexed owner, address indexed spender, uint256 amount);

    /// @dev `keccak256(bytes("Transfer(address,address,uint256)"))`.
    uint256 private constant _TRANSFER_EVENT_SIGNATURE =
        0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef;

    /// @dev `keccak256(bytes("Approval(address,address,uint256)"))`.
    uint256 private constant _APPROVAL_EVENT_SIGNATURE =
        0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925;

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

    /// @dev The storage slot for the total supply.
    uint256 private constant _TOTAL_SUPPLY_SLOT = 0x05345cdf77eb68f44c;

    /// @dev The balance slot of `owner` is given by:
    /// ```
    ///     mstore(0x0c, _BALANCE_SLOT_SEED)
    ///     mstore(0x00, owner)
    ///     let balanceSlot := keccak256(0x0c, 0x20)
    /// ```
    uint256 private constant _BALANCE_SLOT_SEED = 0x87a211a2;

    /// @dev The allowance slot of (`owner`, `spender`) is given by:
    /// ```
    ///     mstore(0x20, spender)
    ///     mstore(0x0c, _ALLOWANCE_SLOT_SEED)
    ///     mstore(0x00, owner)
    ///     let allowanceSlot := keccak256(0x0c, 0x34)
    /// ```
    uint256 private constant _ALLOWANCE_SLOT_SEED = 0x7f5e9f20;

    /// @dev The nonce slot of `owner` is given by:
    /// ```
    ///     mstore(0x0c, _NONCES_SLOT_SEED)
    ///     mstore(0x00, owner)
    ///     let nonceSlot := keccak256(0x0c, 0x20)
    /// ```
    uint256 private constant _NONCES_SLOT_SEED = 0x38377508;

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

    /// @dev `(_NONCES_SLOT_SEED << 16) | 0x1901`.
    uint256 private constant _NONCES_SLOT_SEED_WITH_SIGNATURE_PREFIX = 0x383775081901;

    /// @dev `keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)")`.
    bytes32 private constant _DOMAIN_TYPEHASH =
        0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f;

    /// @dev `keccak256("1")`.
    bytes32 private constant _VERSION_HASH =
        0xc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6;

    /// @dev `keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)")`.
    bytes32 private constant _PERMIT_TYPEHASH =
        0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;

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

    /// @dev Returns the name of the token.
    function name() public view virtual returns (string memory);

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

    /// @dev Returns the decimals places of the token.
    function decimals() public view virtual returns (uint8) {
        return 18;
    }

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

    /// @dev Returns the amount of tokens in existence.
    function totalSupply() public view virtual returns (uint256 result) {
        /// @solidity memory-safe-assembly
        assembly {
            result := sload(_TOTAL_SUPPLY_SLOT)
        }
    }

    /// @dev Returns the amount of tokens owned by `owner`.
    function balanceOf(address owner) public view virtual returns (uint256 result) {
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x0c, _BALANCE_SLOT_SEED)
            mstore(0x00, owner)
            result := sload(keccak256(0x0c, 0x20))
        }
    }

    /// @dev Returns the amount of tokens that `spender` can spend on behalf of `owner`.
    function allowance(address owner, address spender)
        public
        view
        virtual
        returns (uint256 result)
    {
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x20, spender)
            mstore(0x0c, _ALLOWANCE_SLOT_SEED)
            mstore(0x00, owner)
            result := sload(keccak256(0x0c, 0x34))
        }
    }

    /// @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
    ///
    /// Emits a {Approval} event.
    function approve(address spender, uint256 amount) public virtual returns (bool) {
        /// @solidity memory-safe-assembly
        assembly {
            // Compute the allowance slot and store the amount.
            mstore(0x20, spender)
            mstore(0x0c, _ALLOWANCE_SLOT_SEED)
            mstore(0x00, caller())
            sstore(keccak256(0x0c, 0x34), amount)
            // Emit the {Approval} event.
            mstore(0x00, amount)
            log3(0x00, 0x20, _APPROVAL_EVENT_SIGNATURE, caller(), shr(96, mload(0x2c)))
        }
        return true;
    }

    /// @dev Transfer `amount` tokens from the caller to `to`.
    ///
    /// Requirements:
    /// - `from` must at least have `amount`.
    ///
    /// Emits a {Transfer} event.
    function transfer(address to, uint256 amount) public virtual returns (bool) {
        _beforeTokenTransfer(msg.sender, to, amount);
        /// @solidity memory-safe-assembly
        assembly {
            // Compute the balance slot and load its value.
            mstore(0x0c, _BALANCE_SLOT_SEED)
            mstore(0x00, caller())
            let fromBalanceSlot := keccak256(0x0c, 0x20)
            let fromBalance := sload(fromBalanceSlot)
            // Revert if insufficient balance.
            if gt(amount, fromBalance) {
                mstore(0x00, 0xf4d678b8) // `InsufficientBalance()`.
                revert(0x1c, 0x04)
            }
            // Subtract and store the updated balance.
            sstore(fromBalanceSlot, sub(fromBalance, amount))
            // Compute the balance slot of `to`.
            mstore(0x00, to)
            let toBalanceSlot := keccak256(0x0c, 0x20)
            // Add and store the updated balance of `to`.
            // Will not overflow because the sum of all user balances
            // cannot exceed the maximum uint256 value.
            sstore(toBalanceSlot, add(sload(toBalanceSlot), amount))
            // Emit the {Transfer} event.
            mstore(0x20, amount)
            log3(0x20, 0x20, _TRANSFER_EVENT_SIGNATURE, caller(), shr(96, mload(0x0c)))
        }
        _afterTokenTransfer(msg.sender, to, amount);
        return true;
    }

    /// @dev Transfers `amount` tokens from `from` to `to`.
    ///
    /// Note: Does not update the allowance if it is the maximum uint256 value.
    ///
    /// Requirements:
    /// - `from` must at least have `amount`.
    /// - The caller must have at least `amount` of allowance to transfer the tokens of `from`.
    ///
    /// Emits a {Transfer} event.
    function transferFrom(address from, address to, uint256 amount) public virtual returns (bool) {
        _beforeTokenTransfer(from, to, amount);
        /// @solidity memory-safe-assembly
        assembly {
            let from_ := shl(96, from)
            // Compute the allowance slot and load its value.
            mstore(0x20, caller())
            mstore(0x0c, or(from_, _ALLOWANCE_SLOT_SEED))
            let allowanceSlot := keccak256(0x0c, 0x34)
            let allowance_ := sload(allowanceSlot)
            // If the allowance is not the maximum uint256 value.
            if add(allowance_, 1) {
                // Revert if the amount to be transferred exceeds the allowance.
                if gt(amount, allowance_) {
                    mstore(0x00, 0x13be252b) // `InsufficientAllowance()`.
                    revert(0x1c, 0x04)
                }
                // Subtract and store the updated allowance.
                sstore(allowanceSlot, sub(allowance_, amount))
            }
            // Compute the balance slot and load its value.
            mstore(0x0c, or(from_, _BALANCE_SLOT_SEED))
            let fromBalanceSlot := keccak256(0x0c, 0x20)
            let fromBalance := sload(fromBalanceSlot)
            // Revert if insufficient balance.
            if gt(amount, fromBalance) {
                mstore(0x00, 0xf4d678b8) // `InsufficientBalance()`.
                revert(0x1c, 0x04)
            }
            // Subtract and store the updated balance.
            sstore(fromBalanceSlot, sub(fromBalance, amount))
            // Compute the balance slot of `to`.
            mstore(0x00, to)
            let toBalanceSlot := keccak256(0x0c, 0x20)
            // Add and store the updated balance of `to`.
            // Will not overflow because the sum of all user balances
            // cannot exceed the maximum uint256 value.
            sstore(toBalanceSlot, add(sload(toBalanceSlot), amount))
            // Emit the {Transfer} event.
            mstore(0x20, amount)
            log3(0x20, 0x20, _TRANSFER_EVENT_SIGNATURE, shr(96, from_), shr(96, mload(0x0c)))
        }
        _afterTokenTransfer(from, to, amount);
        return true;
    }

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                          EIP-2612                          */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev For more performance, override to return the constant value
    /// of `keccak256(bytes(name()))` if `name()` will never change.
    function _constantNameHash() internal view virtual returns (bytes32 result) {}

    /// @dev Returns the current nonce for `owner`.
    /// This value is used to compute the signature for EIP-2612 permit.
    function nonces(address owner) public view virtual returns (uint256 result) {
        /// @solidity memory-safe-assembly
        assembly {
            // Compute the nonce slot and load its value.
            mstore(0x0c, _NONCES_SLOT_SEED)
            mstore(0x00, owner)
            result := sload(keccak256(0x0c, 0x20))
        }
    }

    /// @dev Sets `value` as the allowance of `spender` over the tokens of `owner`,
    /// authorized by a signed approval by `owner`.
    ///
    /// Emits a {Approval} event.
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) public virtual {
        bytes32 nameHash = _constantNameHash();
        //  We simply calculate it on-the-fly to allow for cases where the `name` may change.
        if (nameHash == bytes32(0)) nameHash = keccak256(bytes(name()));
        /// @solidity memory-safe-assembly
        assembly {
            // Revert if the block timestamp is greater than `deadline`.
            if gt(timestamp(), deadline) {
                mstore(0x00, 0x1a15a3cc) // `PermitExpired()`.
                revert(0x1c, 0x04)
            }
            let m := mload(0x40) // Grab the free memory pointer.
            // Clean the upper 96 bits.
            owner := shr(96, shl(96, owner))
            spender := shr(96, shl(96, spender))
            // Compute the nonce slot and load its value.
            mstore(0x0e, _NONCES_SLOT_SEED_WITH_SIGNATURE_PREFIX)
            mstore(0x00, owner)
            let nonceSlot := keccak256(0x0c, 0x20)
            let nonceValue := sload(nonceSlot)
            // Prepare the domain separator.
            mstore(m, _DOMAIN_TYPEHASH)
            mstore(add(m, 0x20), nameHash)
            mstore(add(m, 0x40), _VERSION_HASH)
            mstore(add(m, 0x60), chainid())
            mstore(add(m, 0x80), address())
            mstore(0x2e, keccak256(m, 0xa0))
            // Prepare the struct hash.
            mstore(m, _PERMIT_TYPEHASH)
            mstore(add(m, 0x20), owner)
            mstore(add(m, 0x40), spender)
            mstore(add(m, 0x60), value)
            mstore(add(m, 0x80), nonceValue)
            mstore(add(m, 0xa0), deadline)
            mstore(0x4e, keccak256(m, 0xc0))
            // Prepare the ecrecover calldata.
            mstore(0x00, keccak256(0x2c, 0x42))
            mstore(0x20, and(0xff, v))
            mstore(0x40, r)
            mstore(0x60, s)
            let t := staticcall(gas(), 1, 0, 0x80, 0x20, 0x20)
            // If the ecrecover fails, the returndatasize will be 0x00,
            // `owner` will be checked if it equals the hash at 0x00,
            // which evaluates to false (i.e. 0), and we will revert.
            // If the ecrecover succeeds, the returndatasize will be 0x20,
            // `owner` will be compared against the returned address at 0x20.
            if iszero(eq(mload(returndatasize()), owner)) {
                mstore(0x00, 0xddafbaef) // `InvalidPermit()`.
                revert(0x1c, 0x04)
            }
            // Increment and store the updated nonce.
            sstore(nonceSlot, add(nonceValue, t)) // `t` is 1 if ecrecover succeeds.
            // Compute the allowance slot and store the value.
            // The `owner` is already at slot 0x20.
            mstore(0x40, or(shl(160, _ALLOWANCE_SLOT_SEED), spender))
            sstore(keccak256(0x2c, 0x34), value)
            // Emit the {Approval} event.
            log3(add(m, 0x60), 0x20, _APPROVAL_EVENT_SIGNATURE, owner, spender)
            mstore(0x40, m) // Restore the free memory pointer.
            mstore(0x60, 0) // Restore the zero pointer.
        }
    }

    /// @dev Returns the EIP-712 domain separator for the EIP-2612 permit.
    function DOMAIN_SEPARATOR() public view virtual returns (bytes32 result) {
        bytes32 nameHash = _constantNameHash();
        //  We simply calculate it on-the-fly to allow for cases where the `name` may change.
        if (nameHash == bytes32(0)) nameHash = keccak256(bytes(name()));
        /// @solidity memory-safe-assembly
        assembly {
            let m := mload(0x40) // Grab the free memory pointer.
            mstore(m, _DOMAIN_TYPEHASH)
            mstore(add(m, 0x20), nameHash)
            mstore(add(m, 0x40), _VERSION_HASH)
            mstore(add(m, 0x60), chainid())
            mstore(add(m, 0x80), address())
            result := keccak256(m, 0xa0)
        }
    }

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                  INTERNAL MINT FUNCTIONS                   */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Mints `amount` tokens to `to`, increasing the total supply.
    ///
    /// Emits a {Transfer} event.
    function _mint(address to, uint256 amount) internal virtual {
        _beforeTokenTransfer(address(0), to, amount);
        /// @solidity memory-safe-assembly
        assembly {
            let totalSupplyBefore := sload(_TOTAL_SUPPLY_SLOT)
            let totalSupplyAfter := add(totalSupplyBefore, amount)
            // Revert if the total supply overflows.
            if lt(totalSupplyAfter, totalSupplyBefore) {
                mstore(0x00, 0xe5cfe957) // `TotalSupplyOverflow()`.
                revert(0x1c, 0x04)
            }
            // Store the updated total supply.
            sstore(_TOTAL_SUPPLY_SLOT, totalSupplyAfter)
            // Compute the balance slot and load its value.
            mstore(0x0c, _BALANCE_SLOT_SEED)
            mstore(0x00, to)
            let toBalanceSlot := keccak256(0x0c, 0x20)
            // Add and store the updated balance.
            sstore(toBalanceSlot, add(sload(toBalanceSlot), amount))
            // Emit the {Transfer} event.
            mstore(0x20, amount)
            log3(0x20, 0x20, _TRANSFER_EVENT_SIGNATURE, 0, shr(96, mload(0x0c)))
        }
        _afterTokenTransfer(address(0), to, amount);
    }

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                  INTERNAL BURN FUNCTIONS                   */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Burns `amount` tokens from `from`, reducing the total supply.
    ///
    /// Emits a {Transfer} event.
    function _burn(address from, uint256 amount) internal virtual {
        _beforeTokenTransfer(from, address(0), amount);
        /// @solidity memory-safe-assembly
        assembly {
            // Compute the balance slot and load its value.
            mstore(0x0c, _BALANCE_SLOT_SEED)
            mstore(0x00, from)
            let fromBalanceSlot := keccak256(0x0c, 0x20)
            let fromBalance := sload(fromBalanceSlot)
            // Revert if insufficient balance.
            if gt(amount, fromBalance) {
                mstore(0x00, 0xf4d678b8) // `InsufficientBalance()`.
                revert(0x1c, 0x04)
            }
            // Subtract and store the updated balance.
            sstore(fromBalanceSlot, sub(fromBalance, amount))
            // Subtract and store the updated total supply.
            sstore(_TOTAL_SUPPLY_SLOT, sub(sload(_TOTAL_SUPPLY_SLOT), amount))
            // Emit the {Transfer} event.
            mstore(0x00, amount)
            log3(0x00, 0x20, _TRANSFER_EVENT_SIGNATURE, shr(96, shl(96, from)), 0)
        }
        _afterTokenTransfer(from, address(0), amount);
    }

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                INTERNAL TRANSFER FUNCTIONS                 */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Moves `amount` of tokens from `from` to `to`.
    function _transfer(address from, address to, uint256 amount) internal virtual {
        _beforeTokenTransfer(from, to, amount);
        /// @solidity memory-safe-assembly
        assembly {
            let from_ := shl(96, from)
            // Compute the balance slot and load its value.
            mstore(0x0c, or(from_, _BALANCE_SLOT_SEED))
            let fromBalanceSlot := keccak256(0x0c, 0x20)
            let fromBalance := sload(fromBalanceSlot)
            // Revert if insufficient balance.
            if gt(amount, fromBalance) {
                mstore(0x00, 0xf4d678b8) // `InsufficientBalance()`.
                revert(0x1c, 0x04)
            }
            // Subtract and store the updated balance.
            sstore(fromBalanceSlot, sub(fromBalance, amount))
            // Compute the balance slot of `to`.
            mstore(0x00, to)
            let toBalanceSlot := keccak256(0x0c, 0x20)
            // Add and store the updated balance of `to`.
            // Will not overflow because the sum of all user balances
            // cannot exceed the maximum uint256 value.
            sstore(toBalanceSlot, add(sload(toBalanceSlot), amount))
            // Emit the {Transfer} event.
            mstore(0x20, amount)
            log3(0x20, 0x20, _TRANSFER_EVENT_SIGNATURE, shr(96, from_), shr(96, mload(0x0c)))
        }
        _afterTokenTransfer(from, to, amount);
    }

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                INTERNAL ALLOWANCE FUNCTIONS                */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Updates the allowance of `owner` for `spender` based on spent `amount`.
    function _spendAllowance(address owner, address spender, uint256 amount) internal virtual {
        /// @solidity memory-safe-assembly
        assembly {
            // Compute the allowance slot and load its value.
            mstore(0x20, spender)
            mstore(0x0c, _ALLOWANCE_SLOT_SEED)
            mstore(0x00, owner)
            let allowanceSlot := keccak256(0x0c, 0x34)
            let allowance_ := sload(allowanceSlot)
            // If the allowance is not the maximum uint256 value.
            if add(allowance_, 1) {
                // Revert if the amount to be transferred exceeds the allowance.
                if gt(amount, allowance_) {
                    mstore(0x00, 0x13be252b) // `InsufficientAllowance()`.
                    revert(0x1c, 0x04)
                }
                // Subtract and store the updated allowance.
                sstore(allowanceSlot, sub(allowance_, amount))
            }
        }
    }

    /// @dev Sets `amount` as the allowance of `spender` over the tokens of `owner`.
    ///
    /// Emits a {Approval} event.
    function _approve(address owner, address spender, uint256 amount) internal virtual {
        /// @solidity memory-safe-assembly
        assembly {
            let owner_ := shl(96, owner)
            // Compute the allowance slot and store the amount.
            mstore(0x20, spender)
            mstore(0x0c, or(owner_, _ALLOWANCE_SLOT_SEED))
            sstore(keccak256(0x0c, 0x34), amount)
            // Emit the {Approval} event.
            mstore(0x00, amount)
            log3(0x00, 0x20, _APPROVAL_EVENT_SIGNATURE, shr(96, owner_), shr(96, mload(0x2c)))
        }
    }

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                     HOOKS TO OVERRIDE                      */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Hook that is called before any transfer of tokens.
    /// This includes minting and burning.
    function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {}

    /// @dev Hook that is called after any transfer of tokens.
    /// This includes minting and burning.
    function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {}
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    /// @dev Returns the cube root of `x`, rounded down.
    /// Credit to bout3fiddy and pcaversaccio under AGPLv3 license:
    /// https://github.com/pcaversaccio/snekmate/blob/main/src/utils/Math.vy
    /// Formally verified by xuwinnie:
    /// https://github.com/vectorized/solady/blob/main/audits/xuwinnie-solady-cbrt-proof.pdf
    function cbrt(uint256 x) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            let r := shl(7, lt(0xffffffffffffffffffffffffffffffff, x))
            r := or(r, shl(6, lt(0xffffffffffffffff, shr(r, x))))
            r := or(r, shl(5, lt(0xffffffff, shr(r, x))))
            r := or(r, shl(4, lt(0xffff, shr(r, x))))
            r := or(r, shl(3, lt(0xff, shr(r, x))))
            // Makeshift lookup table to nudge the approximate log2 result.
            z := div(shl(div(r, 3), shl(lt(0xf, shr(r, x)), 0xf)), xor(7, mod(r, 3)))
            // Newton-Raphson's.
            z := div(add(add(div(x, mul(z, z)), z), z), 3)
            z := div(add(add(div(x, mul(z, z)), z), z), 3)
            z := div(add(add(div(x, mul(z, z)), z), z), 3)
            z := div(add(add(div(x, mul(z, z)), z), z), 3)
            z := div(add(add(div(x, mul(z, z)), z), z), 3)
            z := div(add(add(div(x, mul(z, z)), z), z), 3)
            z := div(add(add(div(x, mul(z, z)), z), z), 3)
            // Round down.
            z := sub(z, lt(div(x, mul(z, z)), z))
        }
    }

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

    /// @dev Returns the cube root of `x`, denominated in `WAD`, rounded down.
    /// Formally verified by xuwinnie:
    /// https://github.com/vectorized/solady/blob/main/audits/xuwinnie-solady-cbrt-proof.pdf
    function cbrtWad(uint256 x) internal pure returns (uint256 z) {
        unchecked {
            if (x <= type(uint256).max / 10 ** 36) return cbrt(x * 10 ** 36);
            z = (1 + cbrt(x)) * 10 ** 12;
            z = (fullMulDivUnchecked(x, 10 ** 36, z * z) + z + z) / 3;
        }
        /// @solidity memory-safe-assembly
        assembly {
            let p := x
            for {} 1 {} {
                if iszero(shr(229, p)) {
                    if iszero(shr(199, p)) {
                        p := mul(p, 100000000000000000) // 10 ** 17.
                        break
                    }
                    p := mul(p, 100000000) // 10 ** 8.
                    break
                }
                if iszero(shr(249, p)) { p := mul(p, 100) }
                break
            }
            let t := mulmod(mul(z, z), z, p)
            z := sub(z, gt(lt(t, shr(1, p)), iszero(t))) // Round down.
        }
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    /// @dev Returns if `x` is an even number. Some people may need this.
    function isEven(uint256 x) internal pure returns (bool) {
        return x & uint256(1) == uint256(0);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

interface IRateProvider {
    function rate(address token) external view returns (uint256);
}

File 8 of 9 : LogExpMath.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/* solhint-disable */

/**
 * @dev Exponentiation and logarithm functions for 18 decimal fixed point numbers (both base and exponent/argument).
 * @dev forked from https://github.com/balancer/balancer-v2-monorepo/blob/599b0cd8f744e1eabef3600d79a2c2b0aea3ddcb/pkg/solidity-utils/contracts/math/LogExpMath.sol
 *
 * Exponentiation and logarithm with arbitrary bases (x^y and log_x(y)) are implemented by conversion to natural
 * exponentiation and logarithm (where the base is Euler's number).
 *
 * @author Fernando Martinelli - @fernandomartinelli
 * @author Sergio Yuhjtman - @sergioyuhjtman
 * @author Daniel Fernandez - @dmf7z
 */
library LogExpMath {
    // All fixed point multiplications and divisions are inlined. This means we need to divide by ONE when multiplying
    // two numbers, and multiply by ONE when dividing them.

    // All arguments and return values are 18 decimal fixed point numbers.
    int256 constant ONE_18 = 1e18;

    // Internally, intermediate values are computed with higher precision as 20 decimal fixed point numbers, and in the
    // case of ln36, 36 decimals.
    int256 constant ONE_20 = 1e20;
    int256 constant ONE_36 = 1e36;

    // The domain of natural exponentiation is bound by the word size and number of decimals used.
    //
    // Because internally the result will be stored using 20 decimals, the largest possible result is
    // (2^255 - 1) / 10^20, which makes the largest exponent ln((2^255 - 1) / 10^20) = 130.700829182905140221.
    // The smallest possible result is 10^(-18), which makes largest negative argument
    // ln(10^(-18)) = -41.446531673892822312.
    // We use 130.0 and -41.0 to have some safety margin.
    int256 constant MAX_NATURAL_EXPONENT = 130e18;
    int256 constant MIN_NATURAL_EXPONENT = -41e18;

    // Bounds for ln_36's argument. Both ln(0.9) and ln(1.1) can be represented with 36 decimal places in a fixed point
    // 256 bit integer.
    int256 constant LN_36_LOWER_BOUND = ONE_18 - 1e17;
    int256 constant LN_36_UPPER_BOUND = ONE_18 + 1e17;

    uint256 constant MILD_EXPONENT_BOUND = 2 ** 254 / uint256(ONE_20);

    // 18 decimal constants
    int256 constant x0 = 128000000000000000000; // 2ˆ7
    int256 constant a0 = 38877084059945950922200000000000000000000000000000000000; // eˆ(x0) (no decimals)
    int256 constant x1 = 64000000000000000000; // 2ˆ6
    int256 constant a1 = 6235149080811616882910000000; // eˆ(x1) (no decimals)

    // 20 decimal constants
    int256 constant x2 = 3200000000000000000000; // 2ˆ5
    int256 constant a2 = 7896296018268069516100000000000000; // eˆ(x2)
    int256 constant x3 = 1600000000000000000000; // 2ˆ4
    int256 constant a3 = 888611052050787263676000000; // eˆ(x3)
    int256 constant x4 = 800000000000000000000; // 2ˆ3
    int256 constant a4 = 298095798704172827474000; // eˆ(x4)
    int256 constant x5 = 400000000000000000000; // 2ˆ2
    int256 constant a5 = 5459815003314423907810; // eˆ(x5)
    int256 constant x6 = 200000000000000000000; // 2ˆ1
    int256 constant a6 = 738905609893065022723; // eˆ(x6)
    int256 constant x7 = 100000000000000000000; // 2ˆ0
    int256 constant a7 = 271828182845904523536; // eˆ(x7)
    int256 constant x8 = 50000000000000000000; // 2ˆ-1
    int256 constant a8 = 164872127070012814685; // eˆ(x8)
    int256 constant x9 = 25000000000000000000; // 2ˆ-2
    int256 constant a9 = 128402541668774148407; // eˆ(x9)
    int256 constant x10 = 12500000000000000000; // 2ˆ-3
    int256 constant a10 = 113314845306682631683; // eˆ(x10)
    int256 constant x11 = 6250000000000000000; // 2ˆ-4
    int256 constant a11 = 106449445891785942956; // eˆ(x11)

    /**
     * @dev Exponentiation (x^y) with unsigned 18 decimal fixed point base and exponent.
     *
     * Reverts if ln(x) * y is smaller than `MIN_NATURAL_EXPONENT`, or larger than `MAX_NATURAL_EXPONENT`.
     */
    function pow(uint256 x, uint256 y) internal pure returns (uint256) {
        if (y == 0) {
            // We solve the 0^0 indetermination by making it equal one.
            return uint256(ONE_18);
        }

        if (x == 0) {
            return 0;
        }

        // Instead of computing x^y directly, we instead rely on the properties of logarithms and exponentiation to
        // arrive at that result. In particular, exp(ln(x)) = x, and ln(x^y) = y * ln(x). This means
        // x^y = exp(y * ln(x)).

        // The ln function takes a signed value, so we need to make sure x fits in the signed 256 bit range.
        require(x >> 255 == 0, "X out of bounds");
        int256 x_int256 = int256(x);

        // We will compute y * ln(x) in a single step. Depending on the value of x, we can either use ln or ln_36. In
        // both cases, we leave the division by ONE_18 (due to fixed point multiplication) to the end.

        // This prevents y * ln(x) from overflowing, and at the same time guarantees y fits in the signed 256 bit range.
        require(y < MILD_EXPONENT_BOUND, "Y out of bounds");
        int256 y_int256 = int256(y);

        int256 logx_times_y;
        if (LN_36_LOWER_BOUND < x_int256 && x_int256 < LN_36_UPPER_BOUND) {
            int256 ln_36_x = _ln_36(x_int256);

            // ln_36_x has 36 decimal places, so multiplying by y_int256 isn't as straightforward, since we can't just
            // bring y_int256 to 36 decimal places, as it might overflow. Instead, we perform two 18 decimal
            // multiplications and add the results: one with the first 18 decimals of ln_36_x, and one with the
            // (downscaled) last 18 decimals.
            logx_times_y = ((ln_36_x / ONE_18) * y_int256 + ((ln_36_x % ONE_18) * y_int256) / ONE_18);
        } else {
            logx_times_y = _ln(x_int256) * y_int256;
        }
        logx_times_y /= ONE_18;

        // Finally, we compute exp(y * ln(x)) to arrive at x^y
        require(MIN_NATURAL_EXPONENT <= logx_times_y && logx_times_y <= MAX_NATURAL_EXPONENT, "Product out of bounds");

        return uint256(exp(logx_times_y));
    }

    /**
     * @dev Natural exponentiation (e^x) with signed 18 decimal fixed point exponent.
     *
     * Reverts if `x` is smaller than MIN_NATURAL_EXPONENT, or larger than `MAX_NATURAL_EXPONENT`.
     */
    function exp(int256 x) internal pure returns (int256) {
        require(x >= MIN_NATURAL_EXPONENT && x <= MAX_NATURAL_EXPONENT, "Invalid Exponent");

        if (x < 0) {
            // We only handle positive exponents: e^(-x) is computed as 1 / e^x. We can safely make x positive since it
            // fits in the signed 256 bit range (as it is larger than MIN_NATURAL_EXPONENT).
            // Fixed point division requires multiplying by ONE_18.
            return ((ONE_18 * ONE_18) / exp(-x));
        }

        // First, we use the fact that e^(x+y) = e^x * e^y to decompose x into a sum of powers of two, which we call x_n,
        // where x_n == 2^(7 - n), and e^x_n = a_n has been precomputed. We choose the first x_n, x0, to equal 2^7
        // because all larger powers are larger than MAX_NATURAL_EXPONENT, and therefore not present in the
        // decomposition.
        // At the end of this process we will have the product of all e^x_n = a_n that apply, and the remainder of this
        // decomposition, which will be lower than the smallest x_n.
        // exp(x) = k_0 * a_0 * k_1 * a_1 * ... + k_n * a_n * exp(remainder), where each k_n equals either 0 or 1.
        // We mutate x by subtracting x_n, making it the remainder of the decomposition.

        // The first two a_n (e^(2^7) and e^(2^6)) are too large if stored as 18 decimal numbers, and could cause
        // intermediate overflows. Instead we store them as plain integers, with 0 decimals.
        // Additionally, x0 + x1 is larger than MAX_NATURAL_EXPONENT, which means they will not both be present in the
        // decomposition.

        // For each x_n, we test if that term is present in the decomposition (if x is larger than it), and if so deduct
        // it and compute the accumulated product.

        int256 firstAN;
        if (x >= x0) {
            x -= x0;
            firstAN = a0;
        } else if (x >= x1) {
            x -= x1;
            firstAN = a1;
        } else {
            firstAN = 1; // One with no decimal places
        }

        // We now transform x into a 20 decimal fixed point number, to have enhanced precision when computing the
        // smaller terms.
        x *= 100;

        // `product` is the accumulated product of all a_n (except a0 and a1), which starts at 20 decimal fixed point
        // one. Recall that fixed point multiplication requires dividing by ONE_20.
        int256 product = ONE_20;

        if (x >= x2) {
            x -= x2;
            product = (product * a2) / ONE_20;
        }
        if (x >= x3) {
            x -= x3;
            product = (product * a3) / ONE_20;
        }
        if (x >= x4) {
            x -= x4;
            product = (product * a4) / ONE_20;
        }
        if (x >= x5) {
            x -= x5;
            product = (product * a5) / ONE_20;
        }
        if (x >= x6) {
            x -= x6;
            product = (product * a6) / ONE_20;
        }
        if (x >= x7) {
            x -= x7;
            product = (product * a7) / ONE_20;
        }
        if (x >= x8) {
            x -= x8;
            product = (product * a8) / ONE_20;
        }
        if (x >= x9) {
            x -= x9;
            product = (product * a9) / ONE_20;
        }

        // x10 and x11 are unnecessary here since we have high enough precision already.

        // Now we need to compute e^x, where x is small (in particular, it is smaller than x9). We use the Taylor series
        // expansion for e^x: 1 + x + (x^2 / 2!) + (x^3 / 3!) + ... + (x^n / n!).

        int256 seriesSum = ONE_20; // The initial one in the sum, with 20 decimal places.
        int256 term; // Each term in the sum, where the nth term is (x^n / n!).

        // The first term is simply x.
        term = x;
        seriesSum += term;

        // Each term (x^n / n!) equals the previous one times x, divided by n. Since x is a fixed point number,
        // multiplying by it requires dividing by ONE_20, but dividing by the non-fixed point n values does not.

        term = ((term * x) / ONE_20) / 2;
        seriesSum += term;

        term = ((term * x) / ONE_20) / 3;
        seriesSum += term;

        term = ((term * x) / ONE_20) / 4;
        seriesSum += term;

        term = ((term * x) / ONE_20) / 5;
        seriesSum += term;

        term = ((term * x) / ONE_20) / 6;
        seriesSum += term;

        term = ((term * x) / ONE_20) / 7;
        seriesSum += term;

        term = ((term * x) / ONE_20) / 8;
        seriesSum += term;

        term = ((term * x) / ONE_20) / 9;
        seriesSum += term;

        term = ((term * x) / ONE_20) / 10;
        seriesSum += term;

        term = ((term * x) / ONE_20) / 11;
        seriesSum += term;

        term = ((term * x) / ONE_20) / 12;
        seriesSum += term;

        // 12 Taylor terms are sufficient for 18 decimal precision.

        // We now have the first a_n (with no decimals), and the product of all other a_n present, and the Taylor
        // approximation of the exponentiation of the remainder (both with 20 decimals). All that remains is to multiply
        // all three (one 20 decimal fixed point multiplication, dividing by ONE_20, and one integer multiplication),
        // and then drop two digits to return an 18 decimal value.

        return (((product * seriesSum) / ONE_20) * firstAN) / 100;
    }

    /**
     * @dev Logarithm (log(arg, base), with signed 18 decimal fixed point base and argument.
     */
    function log(int256 arg, int256 base) internal pure returns (int256) {
        // This performs a simple base change: log(arg, base) = ln(arg) / ln(base).

        // Both logBase and logArg are computed as 36 decimal fixed point numbers, either by using ln_36, or by
        // upscaling.

        int256 logBase;
        if (LN_36_LOWER_BOUND < base && base < LN_36_UPPER_BOUND) {
            logBase = _ln_36(base);
        } else {
            logBase = _ln(base) * ONE_18;
        }

        int256 logArg;
        if (LN_36_LOWER_BOUND < arg && arg < LN_36_UPPER_BOUND) {
            logArg = _ln_36(arg);
        } else {
            logArg = _ln(arg) * ONE_18;
        }

        // When dividing, we multiply by ONE_18 to arrive at a result with 18 decimal places
        return (logArg * ONE_18) / logBase;
    }

    /**
     * @dev Natural logarithm (ln(a)) with signed 18 decimal fixed point argument.
     */
    function ln(int256 a) internal pure returns (int256) {
        // The real natural logarithm is not defined for negative numbers or zero.
        require(a > 0, "Out of bounds");
        if (LN_36_LOWER_BOUND < a && a < LN_36_UPPER_BOUND) {
            return _ln_36(a) / ONE_18;
        } else {
            return _ln(a);
        }
    }

    /**
     * @dev Internal natural logarithm (ln(a)) with signed 18 decimal fixed point argument.
     */
    function _ln(int256 a) private pure returns (int256) {
        if (a < ONE_18) {
            // Since ln(a^k) = k * ln(a), we can compute ln(a) as ln(a) = ln((1/a)^(-1)) = - ln((1/a)). If a is less
            // than one, 1/a will be greater than one, and this if statement will not be entered in the recursive call.
            // Fixed point division requires multiplying by ONE_18.
            return (-_ln((ONE_18 * ONE_18) / a));
        }

        // First, we use the fact that ln^(a * b) = ln(a) + ln(b) to decompose ln(a) into a sum of powers of two, which
        // we call x_n, where x_n == 2^(7 - n), which are the natural logarithm of precomputed quantities a_n (that is,
        // ln(a_n) = x_n). We choose the first x_n, x0, to equal 2^7 because the exponential of all larger powers cannot
        // be represented as 18 fixed point decimal numbers in 256 bits, and are therefore larger than a.
        // At the end of this process we will have the sum of all x_n = ln(a_n) that apply, and the remainder of this
        // decomposition, which will be lower than the smallest a_n.
        // ln(a) = k_0 * x_0 + k_1 * x_1 + ... + k_n * x_n + ln(remainder), where each k_n equals either 0 or 1.
        // We mutate a by subtracting a_n, making it the remainder of the decomposition.

        // For reasons related to how `exp` works, the first two a_n (e^(2^7) and e^(2^6)) are not stored as fixed point
        // numbers with 18 decimals, but instead as plain integers with 0 decimals, so we need to multiply them by
        // ONE_18 to convert them to fixed point.
        // For each a_n, we test if that term is present in the decomposition (if a is larger than it), and if so divide
        // by it and compute the accumulated sum.

        int256 sum = 0;
        if (a >= a0 * ONE_18) {
            a /= a0; // Integer, not fixed point division
            sum += x0;
        }

        if (a >= a1 * ONE_18) {
            a /= a1; // Integer, not fixed point division
            sum += x1;
        }

        // All other a_n and x_n are stored as 20 digit fixed point numbers, so we convert the sum and a to this format.
        sum *= 100;
        a *= 100;

        // Because further a_n are  20 digit fixed point numbers, we multiply by ONE_20 when dividing by them.

        if (a >= a2) {
            a = (a * ONE_20) / a2;
            sum += x2;
        }

        if (a >= a3) {
            a = (a * ONE_20) / a3;
            sum += x3;
        }

        if (a >= a4) {
            a = (a * ONE_20) / a4;
            sum += x4;
        }

        if (a >= a5) {
            a = (a * ONE_20) / a5;
            sum += x5;
        }

        if (a >= a6) {
            a = (a * ONE_20) / a6;
            sum += x6;
        }

        if (a >= a7) {
            a = (a * ONE_20) / a7;
            sum += x7;
        }

        if (a >= a8) {
            a = (a * ONE_20) / a8;
            sum += x8;
        }

        if (a >= a9) {
            a = (a * ONE_20) / a9;
            sum += x9;
        }

        if (a >= a10) {
            a = (a * ONE_20) / a10;
            sum += x10;
        }

        if (a >= a11) {
            a = (a * ONE_20) / a11;
            sum += x11;
        }

        // a is now a small number (smaller than a_11, which roughly equals 1.06). This means we can use a Taylor series
        // that converges rapidly for values of `a` close to one - the same one used in ln_36.
        // Let z = (a - 1) / (a + 1).
        // ln(a) = 2 * (z + z^3 / 3 + z^5 / 5 + z^7 / 7 + ... + z^(2 * n + 1) / (2 * n + 1))

        // Recall that 20 digit fixed point division requires multiplying by ONE_20, and multiplication requires
        // division by ONE_20.
        int256 z = ((a - ONE_20) * ONE_20) / (a + ONE_20);
        int256 z_squared = (z * z) / ONE_20;

        // num is the numerator of the series: the z^(2 * n + 1) term
        int256 num = z;

        // seriesSum holds the accumulated sum of each term in the series, starting with the initial z
        int256 seriesSum = num;

        // In each step, the numerator is multiplied by z^2
        num = (num * z_squared) / ONE_20;
        seriesSum += num / 3;

        num = (num * z_squared) / ONE_20;
        seriesSum += num / 5;

        num = (num * z_squared) / ONE_20;
        seriesSum += num / 7;

        num = (num * z_squared) / ONE_20;
        seriesSum += num / 9;

        num = (num * z_squared) / ONE_20;
        seriesSum += num / 11;

        // 6 Taylor terms are sufficient for 36 decimal precision.

        // Finally, we multiply by 2 (non fixed point) to compute ln(remainder)
        seriesSum *= 2;

        // We now have the sum of all x_n present, and the Taylor approximation of the logarithm of the remainder (both
        // with 20 decimals). All that remains is to sum these two, and then drop two digits to return a 18 decimal
        // value.

        return (sum + seriesSum) / 100;
    }

    /**
     * @dev Intrnal high precision (36 decimal places) natural logarithm (ln(x)) with signed 18 decimal fixed point argument,
     * for x close to one.
     *
     * Should only be used if x is between LN_36_LOWER_BOUND and LN_36_UPPER_BOUND.
     */
    function _ln_36(int256 x) private pure returns (int256) {
        // Since ln(1) = 0, a value of x close to one will yield a very small result, which makes using 36 digits
        // worthwhile.

        // First, we transform x to a 36 digit fixed point value.
        x *= ONE_18;

        // We will use the following Taylor expansion, which converges very rapidly. Let z = (x - 1) / (x + 1).
        // ln(x) = 2 * (z + z^3 / 3 + z^5 / 5 + z^7 / 7 + ... + z^(2 * n + 1) / (2 * n + 1))

        // Recall that 36 digit fixed point division requires multiplying by ONE_36, and multiplication requires
        // division by ONE_36.
        int256 z = ((x - ONE_36) * ONE_36) / (x + ONE_36);
        int256 z_squared = (z * z) / ONE_36;

        // num is the numerator of the series: the z^(2 * n + 1) term
        int256 num = z;

        // seriesSum holds the accumulated sum of each term in the series, starting with the initial z
        int256 seriesSum = num;

        // In each step, the numerator is multiplied by z^2
        num = (num * z_squared) / ONE_36;
        seriesSum += num / 3;

        num = (num * z_squared) / ONE_36;
        seriesSum += num / 5;

        num = (num * z_squared) / ONE_36;
        seriesSum += num / 7;

        num = (num * z_squared) / ONE_36;
        seriesSum += num / 9;

        num = (num * z_squared) / ONE_36;
        seriesSum += num / 11;

        num = (num * z_squared) / ONE_36;
        seriesSum += num / 13;

        num = (num * z_squared) / ONE_36;
        seriesSum += num / 15;

        // 8 Taylor terms are sufficient for 36 decimal precision.

        // All that remains is multiplying by 2 (non fixed point).
        return seriesSum * 2;
    }
}

File 9 of 9 : PoolToken.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {ERC20} from "solady/tokens/ERC20.sol";
import {Ownable} from "solady/auth/Ownable.sol";

contract PoolToken is ERC20, Ownable {
    error Token__CallerIsNotPool();
    error Token__PoolAddressCannotBeZero();

    event PoolAddressSet(address newPoolAddress);

    string internal _name;
    string internal _symbol;
    uint8 internal _decimals;
    address poolAddress;

    function _checkCallerIsPool() internal view {
        if (msg.sender != poolAddress) {
            revert Token__CallerIsNotPool();
        }
    }

    constructor(string memory name_, string memory symbol_, uint8 decimals_, address owner_) {
        _name = name_;
        _symbol = symbol_;
        _decimals = decimals_;
        _setOwner(owner_);
    }

    function name() public view virtual override returns (string memory) {
        return _name;
    }

    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    function decimals() public view virtual override returns (uint8) {
        return _decimals;
    }

    function mint(address to_, uint256 amount_) public {
        _checkCallerIsPool();
        _mint(to_, amount_);
    }

    function burn(address from_, uint256 amount_) public {
        _checkCallerIsPool();
        _burn(from_, amount_);
    }

    function setPool(address poolAddress_) public onlyOwner {
        if (poolAddress_ == address(0)) revert Token__PoolAddressCannotBeZero();
        poolAddress = poolAddress_;
        renounceOwnership();
        emit PoolAddressSet(poolAddress);
    }
}

Settings
{
  "remappings": [
    "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
    "ds-test/=lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/",
    "erc4626-tests/=lib/erc4626-tests/",
    "forge-std/=lib/forge-std/src/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/",
    "solady/=lib/solady/src/",
    "halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 100
  },
  "metadata": {
    "useLiteralContent": false,
    "bytecodeHash": "ipfs",
    "appendCBOR": true
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "cancun",
  "viaIR": true,
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"tokenAddress_","type":"address"},{"internalType":"uint256","name":"amplification_","type":"uint256"},{"internalType":"address[]","name":"tokens_","type":"address[]"},{"internalType":"address[]","name":"rateProviders_","type":"address[]"},{"internalType":"uint256[]","name":"weights_","type":"uint256[]"},{"internalType":"address","name":"owner_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AlreadyInitialized","type":"error"},{"inputs":[],"name":"NewOwnerIsZeroAddress","type":"error"},{"inputs":[],"name":"NoHandoverRequest","type":"error"},{"inputs":[],"name":"Pool__AlreadyPaused","type":"error"},{"inputs":[],"name":"Pool__AmountsMustBeNonZero","type":"error"},{"inputs":[],"name":"Pool__BandsOutOfBounds","type":"error"},{"inputs":[],"name":"Pool__CannotBeZeroAddress","type":"error"},{"inputs":[],"name":"Pool__CannotRescuePoolToken","type":"error"},{"inputs":[],"name":"Pool__IndexOutOfBounds","type":"error"},{"inputs":[],"name":"Pool__InitialDepositAmountMustBeNonZero","type":"error"},{"inputs":[],"name":"Pool__InputOutputTokensSame","type":"error"},{"inputs":[],"name":"Pool__InvalidDecimals","type":"error"},{"inputs":[],"name":"Pool__InvalidParams","type":"error"},{"inputs":[],"name":"Pool__InvalidRateProvided","type":"error"},{"inputs":[],"name":"Pool__Killed","type":"error"},{"inputs":[],"name":"Pool__MaxLimitExceeded","type":"error"},{"inputs":[],"name":"Pool__MustBeInitiatedWithAGreaterThanZero","type":"error"},{"inputs":[],"name":"Pool__MustBeInitiatedWithMoreThanOneToken","type":"error"},{"inputs":[],"name":"Pool__NeedToDepositAtleastOneToken","type":"error"},{"inputs":[],"name":"Pool__NoConvergence","type":"error"},{"inputs":[],"name":"Pool__NoRate","type":"error"},{"inputs":[],"name":"Pool__NoSurplus","type":"error"},{"inputs":[],"name":"Pool__NotPaused","type":"error"},{"inputs":[],"name":"Pool__Paused","type":"error"},{"inputs":[],"name":"Pool__PoolIsEmpty","type":"error"},{"inputs":[],"name":"Pool__PoolIsFull","type":"error"},{"inputs":[],"name":"Pool__RampActive","type":"error"},{"inputs":[],"name":"Pool__RatioAboveUpperBound","type":"error"},{"inputs":[],"name":"Pool__RatioBelowLowerBound","type":"error"},{"inputs":[],"name":"Pool__SlippageLimitExceeded","type":"error"},{"inputs":[],"name":"Pool__SumOfWeightsMustBeOne","type":"error"},{"inputs":[],"name":"Pool__TokenAlreadyPartOfPool","type":"error"},{"inputs":[],"name":"Pool__WeightOutOfBounds","type":"error"},{"inputs":[],"name":"Pool__WeightsDoNotAddUp","type":"error"},{"inputs":[],"name":"Pool__ZeroAmount","type":"error"},{"inputs":[],"name":"Reentrancy","type":"error"},{"inputs":[],"name":"Unauthorized","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"amountsIn","type":"uint256[]"},{"indexed":false,"internalType":"uint256","name":"lpAmount","type":"uint256"}],"name":"AddLiquidity","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"index","type":"uint256"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"address","name":"rateProvider","type":"address"},{"indexed":false,"internalType":"uint256","name":"rate","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"weight","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"AddToken","type":"event"},{"anonymous":false,"inputs":[],"name":"Kill","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"pendingOwner","type":"address"}],"name":"OwnershipHandoverCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"pendingOwner","type":"address"}],"name":"OwnershipHandoverRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"}],"name":"Pause","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"token","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rate","type":"uint256"}],"name":"RateUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"lpAmount","type":"uint256"}],"name":"RemoveLiquidity","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"token","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountOut","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"lpAmount","type":"uint256"}],"name":"RemoveLiquiditySingle","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"address","name":"guardian","type":"address"}],"name":"SetGuardian","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amplification","type":"uint256"},{"indexed":false,"internalType":"uint256[]","name":"weights","type":"uint256[]"},{"indexed":false,"internalType":"uint256","name":"duration","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"start","type":"uint256"}],"name":"SetRamp","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"rampStep","type":"uint256"}],"name":"SetRampStep","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"token","type":"uint256"},{"indexed":false,"internalType":"address","name":"rateProvider","type":"address"}],"name":"SetRateProvider","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"stakingAddress","type":"address"}],"name":"SetStaking","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"rate","type":"uint256"}],"name":"SetSwapFeeRate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"token","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"lower","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"upper","type":"uint256"}],"name":"SetWeightBand","type":"event"},{"anonymous":false,"inputs":[],"name":"StopRamp","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenIn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"tokenOut","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountIn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountOut","type":"uint256"}],"name":"Swap","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"}],"name":"Unpause","type":"event"},{"inputs":[{"internalType":"uint256[]","name":"amounts_","type":"uint256[]"},{"internalType":"uint256","name":"minLpAmount_","type":"uint256"},{"internalType":"address","name":"receiver_","type":"address"}],"name":"addLiquidity","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token_","type":"address"},{"internalType":"address","name":"rateProvider_","type":"address"},{"internalType":"uint256","name":"weight_","type":"uint256"},{"internalType":"uint256","name":"lower_","type":"uint256"},{"internalType":"uint256","name":"upper_","type":"uint256"},{"internalType":"uint256","name":"amount_","type":"uint256"},{"internalType":"uint256","name":"amplification_","type":"uint256"},{"internalType":"uint256","name":"minLpAmount_","type":"uint256"},{"internalType":"address","name":"receiver_","type":"address"}],"name":"addToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"amplification","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"cancelOwnershipHandover","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"pendingOwner","type":"address"}],"name":"completeOwnershipHandover","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"kill","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"killed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"numTokens","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"result","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"pendingOwner","type":"address"}],"name":"ownershipHandoverExpiresAt","outputs":[{"internalType":"uint256","name":"result","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"packedVirtualBalances","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"token_","type":"uint256"}],"name":"packedWeight","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rampLastTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rampStep","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rampStopTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"token_","type":"uint256"}],"name":"rate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"rateProviders","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"lpAmount_","type":"uint256"},{"internalType":"uint256[]","name":"minAmounts_","type":"uint256[]"},{"internalType":"address","name":"receiver_","type":"address"}],"name":"removeLiquidity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"token_","type":"uint256"},{"internalType":"uint256","name":"lpAmount_","type":"uint256"},{"internalType":"uint256","name":"minTokenOutAmount_","type":"uint256"},{"internalType":"address","name":"receiver_","type":"address"}],"name":"removeLiquiditySingle","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"requestOwnershipHandover","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"token_","type":"address"},{"internalType":"address","name":"receiver_","type":"address"}],"name":"rescue","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amplification_","type":"uint256"},{"internalType":"uint256[]","name":"weights_","type":"uint256[]"},{"internalType":"uint256","name":"duration_","type":"uint256"},{"internalType":"uint256","name":"start_","type":"uint256"}],"name":"setRamp","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"rampStep_","type":"uint256"}],"name":"setRampStep","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"token_","type":"uint256"},{"internalType":"address","name":"rateProvider_","type":"address"}],"name":"setRateProvider","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"stakingAddress_","type":"address"}],"name":"setStaking","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"feeRate_","type":"uint256"}],"name":"setSwapFeeRate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokens_","type":"uint256[]"},{"internalType":"uint256[]","name":"lower_","type":"uint256[]"},{"internalType":"uint256[]","name":"upper_","type":"uint256[]"}],"name":"setWeightBands","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"token_","type":"uint256"},{"internalType":"address","name":"receiver_","type":"address"}],"name":"skim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stakingAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"stopRamp","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"supply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenIn_","type":"uint256"},{"internalType":"uint256","name":"tokenOut_","type":"uint256"},{"internalType":"uint256","name":"tokenInAmount_","type":"uint256"},{"internalType":"uint256","name":"minTokenOutAmount_","type":"uint256"},{"internalType":"address","name":"receiver_","type":"address"}],"name":"swap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"swapFeeRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"targetAmplification","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"tokens","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokens_","type":"uint256[]"}],"name":"updateRates","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"updateWeights","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"token_","type":"uint256"}],"name":"virtualBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"virtualBalanceProdSum","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"token_","type":"uint256"}],"name":"weight","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]

608080604052346102fb57614eba803803809161001c82856103fb565b833981019060c0818303126102fb5761003481610432565b91602082015191604081015160018060401b0381116102fb578261005991830161045d565b60608201516001600160401b0381116102fb578361007891840161045d565b60808301519092906001600160401b0381116102fb5781019380601f860112156102fb5784516100a781610446565b956100b560405197886103fb565b81875260208088019260051b8201019283116102fb57602001905b8282106103eb5750505060a06100e69101610432565b946001600160a01b0316801561029a57815194602086116103dc57600286106103cd57858451148015906103c2575b61029a57670de0b6b3a764000081106103b3575f55846001555f955f965b602088101561039c57868814610312576001600160a01b0361015589866104c2565b5116156102a957600460206001600160a01b036101728b886104c2565b51166040519283809263313ce56760e01b82525afa908115610307575f916102c7575b5060ff60129116036102b8576001600160a01b036101b389866104c2565b5160058a0180546001600160a01b0319166001600160a01b039390921683169190911790556101e289876104c2565b5116156102a9576001600160a01b036101fb89876104c2565b5160258a0180546001600160a01b0319166001600160a01b03939092169290921617905561022988876104c2565b511561029a5769f4240f4240000000000061024489886104c2565b5164e8d4a51000806102568c8b6104c2565b510460141b9104171760b01b886045015561027188876104c2565b51810180911161028657600190970196610133565b634e487b7160e01b5f52601160045260245ffd5b6341598eb160e01b5f5260045ffd5b6309867afd60e41b5f5260045ffd5b6305fca6cf60e51b5f5260045ffd5b90506020813d82116102ff575b816102e1602093836103fb565b810103126102fb575160ff811681036102fb5760ff610195565b5f80fd5b3d91506102d4565b6040513d5f823e3d90fd5b93509450945050670de0b6b3a764000091505b0361038d57600160675560018060a01b031680638b78c6d819547f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a3638b78c6d81955600380546001600160a01b0319169190911790556040516149cf90816104eb8239f35b634c93afb760e11b5f5260045ffd5b93509450945050670de0b6b3a76400009150610325565b63b0ac429160e01b5f5260045ffd5b508585511415610115565b63a596ef6d60e01b5f5260045ffd5b6317fb4af160e11b5f5260045ffd5b81518152602091820191016100d0565b601f909101601f19168101906001600160401b0382119082101761041e57604052565b634e487b7160e01b5f52604160045260245ffd5b51906001600160a01b03821682036102fb57565b6001600160401b03811161041e5760051b60200190565b9080601f830112156102fb57815161047481610446565b9261048260405194856103fb565b81845260208085019260051b8201019283116102fb57602001905b8282106104aa5750505090565b602080916104b784610432565b81520191019061049d565b80518210156104d65760209160051b010190565b634e487b7160e01b5f52603260045260245ffdfe610140806040526004361015610013575f80fd5b5f905f3560e01c908163047fc9aa14612aab575080631082ae9514612a655780631f3a0e4114612a4057806325692962146129f7578063267f4cf9146129da5780632797da80146129785780632d3eac441461290657806331e7e4871461272b5780633a04801d1461270e5780633e8847ec1461204c5780633f4ba83a14611fed57806341c0e1b514611f6c578063455611f214611f4f5780634bb77d9d14611e465780634f64b2be14611e0e5780634fdf5d1d14611d1357806354d1f13d14611ccd578063562e19df146117945780635c975abb1461177157806365c303a5146117365780636e18c5b41461127e578063715018a6146112335780638456cb59146111ce5780638aa044e4146111795780638d56c639146110165780638da5cb5b14610fe95780638e499bcf14610fcb5780638ff3909914610f5957806394068a9314610f275780639d76ea5814610efe578063a3820aa514610d25578063abfed9fd14610c2b578063b533789714610c0d578063b6efab3914610bef578063c6e1d3e714610bc1578063cc3344821461072f578063d1154ff0146106c3578063d7b4be241461069a578063dc036c9a146103ff578063e7ee6ad6146103bb578063ef407c3c1461037f578063f04e283e14610331578063f2fde38b146102f2578063f8dc929c146102d4578063f8e27f931461024e5763fee81cf414610219575f80fd5b3461024b57602036600319011261024b57610232612b0b565b9063389a75e1600c5252602080600c2054604051908152f35b80fd5b503461024b57602036600319011261024b57600435906001548210156102c55760208210156102b1576080610289836045015460b01c612f95565b91606854156102aa575b604051938452602084015260408301526060820152f35b5082610293565b634e487b7160e01b81526032600452602490fd5b6367e0bf5f60e01b8152600490fd5b503461024b578060031936011261024b576020606954604051908152f35b50602036600319011261024b57610307612b0b565b61030f612c31565b8060601b1561032457610321906137be565b80f35b637448fbae82526004601cfd5b50602036600319011261024b57610346612b0b565b61034e612c31565b63389a75e1600c528082526020600c208054421161037257908261032192556137be565b636f5e881883526004601cfd5b503461024b57602036600319011261024b5760043560208110156103b757602501546040516001600160a01b03909116815260209150f35b5080fd5b503461024b57602036600319011261024b57600435906001548210156102c55760208210156102b15760206001600160501b03836045015460601c16604051908152f35b503461024b57606036600319011261024b576004356024356001600160401b03811161066157610433903690600401612ac5565b61043b612af5565b903068929eee149b4bd21268541461068d573068929eee149b4bd212685560015493848214801590610683575b61067457856002549161047b8184612c09565b60028190556003546001600160a01b0316803b1561067057836040518092632770a7eb60e21b82528183816104b4893360048401612c16565b03925af190811561066557849161064c575b50509091506040517fd8ae9b9ba89e637bcb66a69ac91e8f688018e81d6f92c57e02226425c8efbdf63391806104fd868a83612c16565b0390a287908180670de0b6b3a76400005b6020831015610626578a831461062657908a949392918260450190815461053490612f76565b90949198620fffff8216928c61054a8d8d612b78565b9061055491612b8b565b9a8b61055f91612c09565b9561056c87948986612ff1565b915055820264e8d4a510000291870264e8d4a5100002049061058d9161360c565b02670de0b6b3a76400009004940194670de0b6b3a7640000810290808204670de0b6b3a7640000149015171561061257906105c791612b8b565b6105d282898c612b44565b358110610603578b95949392916105f76001928b848060a01b038460050154166135ce565b0191949092939461050e565b634647d8b560e01b8c5260048cfd5b634e487b7160e01b8d52601160045260248dfd5b9750505050945050505061063a9250612f39565b606b553868929eee149b4bd212685580f35b8161065691612ba9565b61066157825f6104c6565b8280fd5b6040513d86823e3d90fd5b8380fd5b6341598eb160e01b8652600486fd5b5060208211610468565b63ab143c0685526004601cfd5b503461024b578060031936011261024b576004546040516001600160a01b039091168152602090f35b503461024b57602036600319011261024b576004356106e0612c31565b662386f26fc100008111610720576020817f15a280e3a8fba7bb6a16834e8c4c8cf503351db60f83e74124075ff74b3d611992606655604051908152a180f35b6341598eb160e01b8252600482fd5b503461024b5761012036600319011261024b5761074a612b0b565b610752612b21565b90610104356001600160a01b03811681036106705761076f612c31565b60a43515610bb2576001546020811015610ba35760c43515610b9457606854610b855760025415610b7657604435151580610b63575b15610b4157670de0b6b3a7640000606435118015610b50575b610b415760018101808211610b2d579091908580805b6020831015610b215785831461086557505060058101546001600160a01b03868116911614610856579161084091600161082195946108466108198260450154612f76565b999099612f95565b90819c939c9a92819d670de0b6b3a76400006044358202049003612fce565b91612ff1565b81604501550191939490926107d4565b6364d9dc7160e11b8752600487fd5b949593929150955b60405163313ce56760e01b81526020816004816001600160a01b0389165afa908115610ad5578991610ae0575b5060ff6012911603610a7f576040516305d4ec6560e11b81526001600160a01b038581166004830152919091169690946020866024818b5afa958615610ad5578996610a9d575b508515610a8e57908561091161094993670de0b6b3a76400006109068460a435612b78565b049360443580612fce565b60018590556005890180546001600160a01b03199081166001600160a01b038a161790915560258a0180549091168b17905591612ff1565b856045015561096d61097e61095c6133d2565b809391600254958260c4359161341e565b60c4939193358b5583600255612f39565b606b5561098f60a4353033876132f0565b81811115610a7f57039060e4358210610a705760035487926001600160a01b039091169190823b15610670576109de928492836040518096819582946340c10f1960e01b845260048401612c16565b03925af18015610a6557610a46575b50927f3c078e7a1bc2cbd8c7cd625a6d75d084e96e6701c6a324576b75a688b38a1c53928560c09360405193845260018060a01b0316602084015260408301526060820152604435608082015260a43560a0820152a180f35b81610a549195949395612ba9565b610a61579091845f6109ed565b8480fd5b6040513d84823e3d90fd5b6341598eb160e01b8752600487fd5b6341598eb160e01b8852600488fd5b639cfd11eb60e01b8952600489fd5b9095506020813d602011610acd575b81610ab960209383612ba9565b81010312610ac95751945f6108e1565b5f80fd5b3d9150610aac565b6040513d8b823e3d90fd5b90506020813d602011610b19575b81610afb60209383612ba9565b81010312610b15575160ff81168103610b155760ff61089a565b8880fd5b3d9150610aee565b9495939291509561086d565b634e487b7160e01b86526011600452602486fd5b6341598eb160e01b8552600485fd5b50670de0b6b3a7640000608435116107be565b50662386f26fc1000060443511156107a5565b632468d44760e11b8552600485fd5b632ffc992d60e21b8552600485fd5b630b5556e560e11b8552600485fd5b6331cc28bd60e01b8552600485fd5b630b5556e560e11b8452600484fd5b503461024b57602036600319011261024b5760043560208110156103b7576020915060450154604051908152f35b503461024b578060031936011261024b576020606a54604051908152f35b503461024b578060031936011261024b576020606854604051908152f35b503461024b57604036600319011261024b57600435610c48612b21565b610c50612c31565b600154821015610d16576020821015610d02576025820180546001600160a01b0319166001600160a01b038316179055606b5460018301808411610cee5791610cd4610cce836040957f908a8bb84530a3f5baf8a0432620a6480e8b2af2e2423dae1222231a90caa5a4979560801c9160018060801b031690613024565b90612f39565b606b5582519182526001600160a01b03166020820152a180f35b634e487b7160e01b85526011600452602485fd5b634e487b7160e01b83526032600452602483fd5b6367e0bf5f60e01b8352600483fd5b503461024b57606036600319011261024b576004356001600160401b0381116103b757610d56903690600401612ac5565b6024356001600160401b03811161067057610d75903690600401612ac5565b6044356001600160401b038111610efa57610d94903690600401612ac5565b919092610d9f612c31565b84821480610ef1575b15610a705760015494875b60208110610dbf578880f35b818114610eed57610dd181838a612b44565b3587811015610ede57670de0b6b3a7640000610dee838787612b44565b35111580610ec1575b15610eb2576020811015610e9e57908186610e5083610e38610840898d8c610e498660019c60450199610e42610e2d8c54612f76565b9b919b9a909a612f95565b5050969098612b44565b3594612b44565b3592612fce565b90557f80394b5329e114f22712d6166857cd77c88256d851082e141591f481227fb8b96040610e80848989612b44565b35610e8c858b8d612b44565b3582519182526020820152a201610db3565b634e487b7160e01b8a52603260045260248afd5b63bd18ee1f60e01b8a5260048afd5b50670de0b6b3a7640000610ed683888a612b44565b351115610df7565b6367e0bf5f60e01b8a5260048afd5b8880f35b50848314610da8565b8580fd5b503461024b578060031936011261024b576003546040516001600160a01b039091168152602090f35b503461024b578060031936011261024b57606b54604080516001600160801b038316815260809290921c602083015290f35b503461024b57602036600319011261024b57610f73612b0b565b610f7b612c31565b6001600160a01b0316801561072057600480546001600160a01b031916821790556040519081527f58fd5d9c33114e6edf8ea5d30956f8d1a4ab112b004f99928b4bcf1b87d6666290602090a180f35b503461024b578060031936011261024b576020600154604051908152f35b503461024b578060031936011261024b57638b78c6d819546040516001600160a01b039091168152602090f35b503461024b57604036600319011261024b5760043590611034612b21565b61103c612c31565b60015483101561116a5760208310156111565761105c8360450154612f76565b5090670de0b6b3a7640000810290808204670de0b6b3a76400001490151715611142579061108991612b8b565b926001840180941161112e57600501546040516370a0823160e01b81523060048201526001600160a01b039091169190602081602481865afa9081156106655784916110fc575b50848111156110ed5761032193946110e791612c09565b916135ce565b63996f8ab960e01b8452600484fd5b90506020813d602011611126575b8161111760209383612ba9565b81010312610ac957515f6110d0565b3d915061110a565b634e487b7160e01b83526011600452602483fd5b634e487b7160e01b84526011600452602484fd5b634e487b7160e01b82526032600452602482fd5b6367e0bf5f60e01b8252600482fd5b503461024b57602036600319011261024b57600435611196612c31565b8015610720576020817f03cd63f3fef742f82f64d7e1775b22c4fe9ed6d2bf0ca7cc04146d620e190ab292606755604051908152a180f35b503461024b578060031936011261024b576111e7612c31565b60655460ff81166112245760ff1916600117606555337f5ee71a369c8672edded508e624ffc9257fa1ae6886ef32905c18e60196bca3998280a280f35b639784de2160e01b8252600482fd5b508060031936011261024b57611247612c31565b80638b78c6d819547f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380638b78c6d8195580f35b503461024b57608036600319011261024b576064356001600160a01b03811681036103b7573068929eee149b4bd212685414611729573068929eee149b4bd212685560015480600435101561171a57606b546112ee90608081901c906001600160801b0316600435600101613024565b6002949194549061130160243583612c09565b60028190556003549095906001600160a01b0316803b15610a6157846040518092632770a7eb60e21b825281838161133f6024353360048401612c16565b03925af1801561170f579085916116fa575b5050602060043510156116e65761139f96670de0b6b3a76400009161137b60043560450154612f76565b9a8b9295919461139964e8d4a510008c620fffff87160202886132c3565b90612b78565b049587905b602082106116ba575b5050886113df8888620fffff948c9d8964e8d4a5100061140f9e9f6113d2838f612c09565b998a975495160202613645565b966114156113ed8988612c09565b670de0b6b3a764000061140260665483612b78565b60011c049a8b8092612c09565b99612b37565b97670de0b6b3a7640000810290808204670de0b6b3a764000014901517156116a6578561144191612b8b565b946044358610611697578c611456918a612ff1565b6004356045015580670de0b6b3a7640000810204670de0b6b3a7640000148115171561168357876114ae6114b492670de0b6b3a76400008f8f64e8d4a5100090620fffff6114a793160202856132c3565b9102612b8b565b93612b37565b97895b6020811015611668578b81146115b457600435810361155557670de0b6b3a76400008702878104670de0b6b3a7640000148815171561154157886114fa91612b8b565b89670de0b6b3a7640000810204670de0b6b3a7640000148a151715611541579061153b8e6001936115358e670de0b6b3a76400008f02612b8b565b9061333c565b016114b7565b634e487b7160e01b8c52601160045260248cfd5b6115628160450154612f76565b91809150670de0b6b3a7640000810204670de0b6b3a7640000148115171561061257600192918d6115358e670de0b6b3a7640000858f6115a790836115af9902612b8b565b945002612b8b565b61153b565b50919450919796945060209950849298506115d795505b611655575b5050612f39565b606b5550600560043501546115f890839083906001600160a01b03166135ce565b6040519060018060a01b031681526004358382015281604082015260243560608201527f7a3728879285f3ca5108b5f39698f28002a6b72cac81653343b8a7dfb75037f160803392a23868929eee149b4bd2126855604051908152f35b9161165f92612e16565b9050815f6115d0565b50919450919796945060209950849298506115d795506115cb565b634e487b7160e01b8a52601160045260248afd5b634647d8b560e01b8b5260048bfd5b634e487b7160e01b8b52601160045260248bfd5b90968988146116e0576116d8826116d38d600194612b78565b612b8b565b9701906113a4565b966113ad565b634e487b7160e01b84526032600452602484fd5b8161170491612ba9565b61067057835f611351565b6040513d87823e3d90fd5b6341598eb160e01b8352600483fd5b63ab143c0682526004601cfd5b503461024b57602036600319011261024b57600435906001548210156102c55760208210156102b1576020826045015460b01c604051908152f35b503461024b578060031936011261024b57602060ff606554166040519015158152f35b503461024b5760a036600319011261024b576084356001600160a01b03811681036103b7573068929eee149b4bd212685414611729573068929eee149b4bd21268556001549060243560043514611cbe578160043510801590611cb2575b610d165760443515611ca357611827606b5460018060801b0381169060801c9060016024350160081b60016004350117613024565b909260206004351015611c8f5761184360043560450154612f76565b9193909260206024351015611c7b5761186160243560450154612f76565b9194670de0b6b3a764000061187a606654604435612b78565b0496670de0b6b3a764000061189a826118958b604435612c09565b612b78565b04956118c26118a9888c612b37565b9c61139964e8d4a5100089620fffff8a1602028b6132c3565b8c670de0b6b3a7640000810204670de0b6b3a7640000148d151715611c585790888e81938f8e8b620fffff8a160264e8d4a510000291670de0b6b3a7640000029061190c91612b8b565b906119169161360c565b61191f91612b8b565b9a61192b8c9b85612b37565b9061193591612c09565b998a916002549054908b620fffff8c160264e8d4a51000029461195795613645565b978861196291612b37565b9a80670de0b6b3a7640000810204670de0b6b3a76400001481151715611c4457848f8f8e670de0b6b3a7640000611535926115a788836119a29902612b8b565b670de0b6b3a76400008202828104670de0b6b3a76400001483151715611c4457906119cc91612b8b565b670de0b6b3a76400008802888104670de0b6b3a76400001489151715611c445791611a00878a936115358f611a0597612b8b565b612c09565b670de0b6b3a7640000810290808204670de0b6b3a764000014901517156106125783611a3091612b8b565b9a6064358c10611c6c5788611b8c575b8492611a5d9492611a5092612ff1565b6004356045015585612ff1565b60243560450155670de0b6b3a7640000840293808504670de0b6b3a76400001490151715611b78578593611aab611abd969464e8d4a5100060209c9995620fffff611ab196160202906132c3565b90612b8b565b91611b64575b50612f39565b606b5560056004350154611ae19060443590309033906001600160a01b03166132f0565b5060056024350154611aff90839083906001600160a01b03166135ce565b6040519060018060a01b0316815260043583820152602435604082015260443560608201528160808201527fb3e2773606abfd36b5bd91394b3a54d1398336c65005baf7bf7a05efeffaf75b60a03392a23868929eee149b4bd2126855604051908152f35b611b7091600254612e16565b905081611ab7565b634e487b7160e01b89526011600452602489fd5b96670de0b6b3a7640000611ba0838b612b78565b049080670de0b6b3a7640000810204670de0b6b3a76400001481151715611c5857611bcb828a612b37565b80670de0b6b3a7640000810204670de0b6b3a76400001481151715611c445792611c3783611c31611a5095611c3189968f6114a78f9b8f9d611a5d9f9d93670de0b6b3a764000064e8d4a510008196620fffff611c2c951602029302612b8b565b61360c565b9d612b37565b9b92509294509250611a40565b634e487b7160e01b8f52601160045260248ffd5b634e487b7160e01b8e52601160045260248efd5b634647d8b560e01b8d5260048dfd5b634e487b7160e01b88526032600452602488fd5b634e487b7160e01b85526032600452602485fd5b630b5556e560e11b8352600483fd5b508160243510156117f2565b63a8bf4d5f60e01b8352600483fd5b508060031936011261024b5763389a75e1600c52338152806020600c2055337ffa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c928280a280f35b503461024b57604036600319011261024b57611d2d612b0b565b90611d36612b21565b611d3e612c31565b600154926001600160a01b03811691835b6020811015611dfe57858114611d8a5760058101546001600160a01b03168414611d7b57600101611d4f565b63103d1a8760e31b8552600485fd5b50909160249394506020905b6040516370a0823160e01b815230600482015294859182905afa918215610665578492611dc8575b61032193506135ce565b91506020833d602011611df6575b81611de360209383612ba9565b81010312610ac957610321925191611dbe565b3d9150611dd6565b5090916024939450602090611d96565b503461024b57602036600319011261024b5760043560208110156103b757600501546040516001600160a01b03909116815260209150f35b503461024b57602036600319011261024b576004356001600160401b0381116103b757611e77903690600401612ac5565b600154839284905b60208210611edb575b50505015611eb4575b610cce611eae91606b5460018060801b0381169060801c91613024565b606b5580f35b507f201f1e1d1c1b1a191817161514131211100f0e0d0c0b0a090807060504030201611e91565b90929193828414611f465784611ef2858585612b44565b351015611f3757611f04848484612b44565b3560018101809111611f2357600385901b1b1793919260010190611e7f565b634e487b7160e01b87526011600452602487fd5b6367e0bf5f60e01b8652600486fd5b93829350611e88565b503461024b578060031936011261024b5760209054604051908152f35b503461024b578060031936011261024b57611f85612c31565b60655460ff811615611fde5760ff8160081c16611fcf5761ff001916610100176065557fbe26733c2bf6ff3ea5ba8cfe744422bd49052ff9ed5685c9e81e6f9321dbaddd8180a180f35b631c6a9ca160e11b8252600482fd5b6363856c5960e01b8252600482fd5b503461024b578060031936011261024b57612006612c31565b60655460ff811615611fde5760ff8160081c16611fcf5760ff1916606555337faeb196d352664784d1900b0e7414a8face7d29f4dae8c4b0cf68ed477423bbf48280a280f35b5034610ac9576060366003190112610ac9576004356001600160401b038111610ac95761207d903690600401612ac5565b612088929192612af5565b903068929eee149b4bd212685414612701573068929eee149b4bd212685560015460805260805181036126f257606b545f1960a0526001600160801b038116935f9360809290921c928492909190835b60208110156126e5576080518114612170576120f581858b612b44565b3596871561216157906008600192838301881b1796019787151580612156575b612125575b505b019593956120d8565b612141906116d36121398460450154612f76565b509092612b78565b8060a0511060a0518218021860a0525f61211a565b5060a0511515612115565b9496506001905f60a05261211c565b50939194929590955b156126d65761218792613024565b610100529061010051918095600254919461010051966121a8608051612bde565b946121b66040519687612ba9565b6080518652601f196121c9608051612bde565b013660208801375f60c0525b602060c05110156126c85760805160c051146123f0576121f860c0518486612b44565b3580156123db5760c05160450161220f8154612f76565b9092670de0b6b3a76400006122248587612b78565b0460e05261223f8261223860e05186612b37565b9586612ff1565b905588612276575b505060c05160050154612268929150309033906001600160a01b03166132f0565b600160c0510160c0526121d5565b909b9a8c670de0b6b3a7640000939e93819c959c0204670de0b6b3a7640000148d1517156123c7578c8e61010051670de0b6b3a76400008302906122b991612b8b565b8c60c0516122c691612bf5565b52608051620fffff85160264e8d4a510000291670de0b6b3a764000002906122ed91612b8b565b906122f7916132c3565b61230091612b78565b670de0b6b3a764000090049a60e05161231891612b37565b9b60a0516123269082612b78565b670de0b6b3a7640000900460e0519061233e91612c09565b60665460011c61234d91612b78565b670de0b6b3a764000090049d8e9260805190620fffff160264e8d4a51000029261237691612c09565b61238991670de0b6b3a764000002612b8b565b90612393916132c3565b61239c91612b78565b670de0b6b3a764000090049a60e051906123b591612c09565b6123be91612b37565b965f8080612247565b634e487b7160e01b5f52601160045260245ffd5b50846122685763f6ef3f5d60e01b5f5260045ffd5b9295989096949197985b848061261e575050505061240c6133d2565b8091801561260f578261242992915b8615925f54906080516134ee565b9290956124368588612c09565b9889151580612603575b156125f4576003546001600160a01b0316803b15610ac9575f61247c81928d6040519485809481936340c10f1960e01b83528b60048401612c16565b03925af180156125e9576125ad575b507f67902069e86c21d5ad116d9df073bf02a2bfdbd591414157cda22d3b8476cd53916124d1916040519460018060a01b03168552606060208601526060850191612b54565b918960408201528033930390a284918315612598575050506124fa91869185549060805161341e565b600354600454919492936001600160a01b03928316929091169061251e9085612c09565b91813b156106705791839161254a93836040518096819582946340c10f1960e01b845260048401612c16565b03925af18015610a6557612583575b50509261256c916020945b600255612f39565b606b553868929eee149b4bd2126855604051908152f35b61258e828092612ba9565b61024b5780612559565b6020985061256c965090945092509050612564565b6124d1919950916125df5f7f67902069e86c21d5ad116d9df073bf02a2bfdbd591414157cda22d3b8476cd5394612ba9565b5f9991509161248b565b6040513d5f823e3d90fd5b634647d8b560e01b5f5260045ffd5b506024358a1015612440565b63df7da5cd60e01b5f5260045ffd5b5f9a9895939a9997969492995b60208110156126b35760805181146126b357612648818a8a612b44565b35156126ab57808c61266a6126608360450154612f76565b9591939050612bf5565b519281670de0b6b3a7640000810204670de0b6b3a764000014821517156123c7576001936115358e670de0b6b3a76400006126a59502612b8b565b0161262b565b6001906126a5565b5090809395989a50612429929496979961241b565b9295989096949197986123fa565b631f0ebc5760e21b5f5260045ffd5b5093919492959095612179565b6341598eb160e01b5f5260045ffd5b63ab143c065f526004601cfd5b34610ac9575f366003190112610ac9576020606654604051908152f35b34610ac9576080366003190112610ac9576004356024356001600160401b038111610ac95761275e903690600401612ac5565b604435916064359361276e612c31565b6001549381156126f2578484036126f2574286106126f257606b54608081901c906127a1906001600160801b0316612c6d565b9190916128e5575b50506068546128d657856068556127c08187612b37565b60695581606a555f955f965b60208810156128bf5786881461284a576127e7888787612b44565b3597670de0b6b3a764000089101561283b5761280589600193612b37565b98612832826045019161282961084061281e8554612f76565b949194939093612f95565b93915091612fce565b905501966127cc565b630152ac2f60e31b5f5260045ffd5b9092949550670de0b6b3a7640000919396505b036128b0576128a07fb0fb14f34df2e6ea25fc5285462fa7522278318522be931036565d550e5236a5956040519586958652608060208701526080860191612b54565b91604084015260608301520390a1005b63083aafed60e41b5f5260045ffd5b9092949550670de0b6b3a76400009193965061285d565b632ffc992d60e21b5f5260045ffd5b6128f5816128fc93600254612e16565b9050612f39565b606b5586806127a9565b34610ac9575f366003190112610ac95761291e612c4d565b606b54602090608081901c9061293c906001600160801b0316612c6d565b91828061296f575b612955575b50506040519015158152f35b6128f58161296593600254612e16565b606b558280612949565b50801515612944565b34610ac9576020366003190112610ac9576004356001548110156129cb5760208110156129b7576001600160601b036020916045015416604051908152f35b634e487b7160e01b5f52603260045260245ffd5b6367e0bf5f60e01b5f5260045ffd5b34610ac9575f366003190112610ac9576020606754604051908152f35b5f366003190112610ac95763389a75e1600c52335f526202a30042016020600c2055337fdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d5f80a2005b34610ac9575f366003190112610ac957602060ff60655460081c166040519015158152f35b34610ac9575f366003190112610ac957612a7d612c31565b5f6068555f6069557fc3014e77feddea63dc4c4b247508845d74eb35678da2e55000c3bb655727650e5f80a1005b34610ac9575f366003190112610ac9576020906002548152f35b9181601f84011215610ac9578235916001600160401b038311610ac9576020808501948460051b010111610ac957565b604435906001600160a01b0382168203610ac957565b600435906001600160a01b0382168203610ac957565b602435906001600160a01b0382168203610ac957565b919082018092116123c757565b91908110156129b75760051b0190565b81835290916001600160fb1b038311610ac95760209260051b809284830137010190565b818102929181159184041417156123c757565b8115612b95570490565b634e487b7160e01b5f52601260045260245ffd5b90601f801991011681019081106001600160401b03821117612bca57604052565b634e487b7160e01b5f52604160045260245ffd5b6001600160401b038111612bca5760051b60200190565b80518210156129b75760209160051b010190565b919082039182116123c757565b6001600160a01b039091168152602081019190915260400190565b638b78c6d819543303612c4057565b6382b429005f526004601cfd5b600160ff60655416151514612c5e57565b63b8c449b360e01b5f5260045ffd5b90606854916069549083158015612e0d575b8015612def575b612de7575080839142105f14612dd357612caf91612ca391612c09565b92426068555b42612c09565b915f5490606a548180159386855f14612d98575050505b5f555f5b6020811015612d8e576001548114612d675760019080604501612d1e87612d046108408789612cf98754612f76565b969196959095612f95565b9592809592949195925f14612d265750505050805b612fce565b905501612cca565b84811115612d4a5750612d19926116d3612d44926118958786612c09565b90612c09565b9150612d19926116d3612d61926118958588612c09565b90612b37565b50505090505b5f60025480612d7e575b5090600190565b612d8891506137fb565b5f612d77565b5050509050612d6d565b9091928083115f14612dbe57926116d3612d4492611895612db99686612c09565b612cc6565b926116d3612d619261189585612db997612c09565b5050612caf5f925f6068555f606955612ca9565b92505f919050565b50612dfa8442612c09565b606754118015612c865750428211612c86565b50428411612c7f565b9092915f938215612f305790612e3291600154845f549161341e565b93909180831115612eb7576003546004546001600160a01b0390811692911690612e5c9085612c09565b91813b1561067057918391612e8893836040518096819582946340c10f1960e01b845260048401612c16565b03925af18015610a6557612ea2575b50505b806002559190565b612ead828092612ba9565b61024b5780612e97565b8091508210612ec7575b50612e9a565b6003546004546001600160a01b0391821692911690612ee7908490612c09565b823b15610ac957612f11925f9283604051809681958294632770a7eb60e21b845260048401612c16565b03925af180156125e95715612ec1575f612f2a91612ba9565b5f612ec1565b935050505f9190565b906001600160801b0382111580612f65575b612f5e576341598eb160e01b5f5260045ffd5b60801b1790565b506001600160801b03811115612f4b565b6001600160601b038116916001600160501b038260601c169160b01c90565b9064e8d4a51000620fffff8316029164e8d4a51000620fffff8260141c16029164e8d4a5100080620fffff8460281c160292603c1c0290565b90919264e8d4a510008080809304603c1b950460281b930460141b910417171790565b90916001600160601b0382118015613014575b6126f25760b01b9160601b171790565b506001600160501b038311613004565b9161302d612c4d565b806101205261303b82612c6d565b90936001545f5b6020811061309c575b505050159182613092575b5081613085575b5061307d57613073906101205190600254612e16565b9050906101205190565b906101205190565b905061012051145f61305d565b831491505f613056565b60ff838260031b1c16801580156132ba575b6132b4575f1981019060208210156129b75760018060a01b03602482015416906130db6044820154612f76565b9190602060018060a01b036004860154166024604051809881936305d4ec6560e11b835260048301525afa9485156125e9575f95613281575b5084156132725780851461326457600b8102818104600b14821517156123c757600a900485118061325b575b61324e575b5f9181151580613242575b61319e575b5050927f516c8bdb823996757c901b6b9bd210afa82c6ec8d550f0e57cd3f64896f7319c92604461318d6020948460019a9998612ff1565b910155604051908152a25b01613042565b9296959493909c9150670de0b6b3a76400008d02918d808404670de0b6b3a764000014901517156123c7578480938a620fffff8b160264e8d4a5100002916131e591612b8b565b906131ef916132c3565b6131f891612b78565b670de0b6b3a764000090049c61320e8385612b78565b9061321891612b8b565b9283610120519061322891612b37565b9061323291612c09565b610120529293949591905f613155565b50610120511515613150565b613256612c31565b613145565b50801515613140565b505050505050600190613198565b639531a3a160e01b5f5260045ffd5b9094506020813d82116132ac575b8161329c60209383612ba9565b81010312610ac95751935f613114565b3d915061328f565b5061304b565b508281116130ae565b906132cd91613d40565b80156132eb57670de0b6b3a7640000606482025f1901040160010190565b505f90565b601c5f60649281946020966040519860605260405260601b602c526323b872dd60601b600c525af13d1560015f511417161561332f575f606052604052565b637939f4245f526004601cfd5b9164e8d4a51000620fffff8216029064e8d4a51000620fffff8260281c16028281115f146133cb57505f5b83106133b25764e8d4a5100090603c1c020180670de0b6b3a764000010670de0b6b3a764000082180218811161339b575050565b10156133a357565b63b1a539bd60e01b5f5260045ffd5b505011156133bc57565b637b3a1f9560e01b5f5260045ffd5b8203613367565b6001545f91825b602084101561341557828414613403576001906001600160601b03856045015416019301926133d9565b925090505b613411826137fb565b9190565b92509050613408565b9290939491670de0b6b3a763ffff198101958187116123c75761344091612b78565b9390945f915b610100831061345e5763b138078b60e01b5f5260045ffd5b80156126f25781878202870304905f5b602081106134d2575b506064908083106134c157670de0b6b3a76400008184035b020411156134a257600190920191613446565b929450613411935050670de0b6b3a76400006064830204919050612b37565b670de0b6b3a764000083820361348f565b978689146134e85781836001920204980161346e565b97613477565b939592909491670de0b6b3a763ffff198101968188116123c75761351191612b78565b9490955f915b610100831061352f5763b138078b60e01b5f5260045ffd5b80156126f25781888202880304905f5b602081106135b2575b506064908083106135a157670de0b6b3a76400008184035b0204111561357357600190920191613517565b94505050909250670de0b6b3a76400006064830204905f146135985761341191612b37565b61341191612c09565b670de0b6b3a7640000838203613560565b98878a146135c85781836001920204990161353f565b98613548565b60105f604492602095829560145260345263a9059cbb60601b82525af13d1560015f51141716156135ff575f603452565b6390b8ec185f526004601cfd5b9061361691613d40565b80156132eb57670de0b6b3a7640000606482025f19010460018101821061363f5790035f190190565b50505f90565b92909194670de0b6b3a76400008602868104670de0b6b3a764000014871517156123c75761368961368261369094670de0b6b3a764000093612b8b565b8097612b78565b0494612b37565b908215612b9557826a0c097ce7bc90715b34b9f160241b0490935f945b61010086106136c55763b138078b60e01b5f5260045ffd5b80156126f257606461375684611aab8a611a008961375188670de0b6b3a764000061374b8f613745848f8a611a008a8f61373e8161372461189597612d618a9c8f96613737816137318f8b8f91611aab968f6137249061372a93612b37565b93612b78565b0490612b37565b95612b78565b918d6132c3565b0490612c09565b99612b78565b04612b37565b612b37565b918083106137a657670de0b6b3a76400006137718285612c09565b02041115613784576001909501946136ad565b9450505050506137a39150670de0b6b3a7640000606482020490612b37565b90565b670de0b6b3a76400006137b98483612c09565b613771565b60018060a01b031680638b78c6d819547f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a3638b78c6d81955565b6001545f670de0b6b3a76400005b602082101561387f5782821461387f57620fffff9061382b8360450154612f76565b9050929092169064e8d4a510008202151580613876575b156126f25761386c8260019464e8d4a510008089670de0b6b3a7640000970202928a02020461360c565b0204910190613809565b50821515613842565b9250505090565b9068056bc75e2d630fffff1982019182136001166123c757565b906803782dace9d8ffffff1982019182136001166123c757565b906806f05b59d3b1ffffff1982019182136001166123c757565b9068ad78ebc5ac61ffffff1982019182136001166123c757565b906856bc75e2d630ffffff1982019182136001166123c757565b90682b5e3af16b187fffff1982019182136001166123c757565b906815af1d78b58c3fffff1982019182136001166123c757565b90680ad78ebc5ac61fffff1982019182136001166123c757565b906802b5e3af16b187ffff1982019182136001166123c757565b9068015af1d78b58c3ffff1982019182136001166123c757565b906803782dace9d90000008201915f6803782dace9d9000000841291129080158216911516176123c757565b9068ad78ebc5ac620000008201915f68ad78ebc5ac62000000841291129080158216911516176123c757565b906856bc75e2d6310000008201915f6856bc75e2d631000000841291129080158216911516176123c757565b90682b5e3af16b188000008201915f682b5e3af16b18800000841291129080158216911516176123c757565b906815af1d78b58c4000008201915f6815af1d78b58c400000841291129080158216911516176123c757565b90680ad78ebc5ac62000008201915f680ad78ebc5ac6200000841291129080158216911516176123c757565b9068056bc75e2d631000008201915f68056bc75e2d63100000841291129080158216911516176123c757565b906802b5e3af16b18800008201915f6802b5e3af16b1880000841291129080158216911516176123c757565b9068015af1d78b58c400008201915f68015af1d78b58c40000841291129080158216911516176123c757565b9067ad78ebc5ac6200008201915f67ad78ebc5ac620000841291129080158216911516176123c757565b906756bc75e2d63100008201915f6756bc75e2d6310000841291129080158216911516176123c757565b908168056bc75e2d63100000019182126001166123c757565b9190915f83820193841291129080158216911516176123c757565b908160011b91808305600214901517156123c757565b906064820291808305606414901517156123c757565b9068056bc75e2d6310000082029180830568056bc75e2d6310000014901517156123c757565b906b02df0ab5a80a22c61ab5a7008202918083056b02df0ab5a80a22c61ab5a70014901517156123c757565b90693f1fce3da636ea5cf850820291808305693f1fce3da636ea5cf85014901517156123c757565b90690127fa27722cc06cc5e2820291808305690127fa27722cc06cc5e214901517156123c757565b9068280e60114edb805d0382029180830568280e60114edb805d0314901517156123c757565b90680ebc5fb41746121110820291808305680ebc5fb4174612111014901517156123c757565b906808f00f760a4b2db55d8202918083056808f00f760a4b2db55d14901517156123c757565b906806f5f17757889379378202918083056806f5f177578893793714901517156123c757565b81810292915f8212600160ff1b8214166123c75781840514901517156123c757565b8115612b9557600160ff1b81145f198314166123c7570590565b81156140d157801561363f578060ff1c61409a57770bce5086492111aea88f4bb1ca6bcf584181ea8059f765328210156140635780670c7d713b49da00001280614052575b1561403257670de0b6b3a76400008102908105670de0b6b3a7640000036123c7576ec097ce7bc90715b34b9f0fffffffff198101906001818313166123c7576a0c097ce7bc90715b34b9f160241b8202918083056a0c097ce7bc90715b34b9f160241b14901517156123c7576a0c097ce7bc90715b34b9f160241b8101905f6a0c097ce7bc90715b34b9f160241b831291129080158216911516176123c757613e2d91613d26565b613e378180613d04565b6a0c097ce7bc90715b34b9f160241b90058080808085613e58828098613d04565b6a0c097ce7bc90715b34b9f160241b90059060038205613e7791613b83565b91613e8191613d04565b6a0c097ce7bc90715b34b9f160241b90059060058205613ea091613b83565b91613eaa91613d04565b6a0c097ce7bc90715b34b9f160241b90059060078205613ec991613b83565b91613ed391613d04565b6a0c097ce7bc90715b34b9f160241b90059060098205613ef291613b83565b91613efc91613d04565b6a0c097ce7bc90715b34b9f160241b900590600b8205613f1b91613b83565b91613f2591613d04565b6a0c097ce7bc90715b34b9f160241b900590600d8205613f4491613b83565b91613f4e91613d04565b6a0c097ce7bc90715b34b9f160241b9005600f9005613f6c91613b83565b613f7590613b9e565b90613f8a81670de0b6b3a76400008405613d04565b91670de0b6b3a7640000900790613fa091613d04565b670de0b6b3a76400009005613fb491613b83565b670de0b6b3a7640000905b0580680238fd42c5cf03ffff1913158061401f575b15613fe2576137a390614588565b60405162461bcd60e51b815260206004820152601560248201527450726f64756374206f7574206f6620626f756e647360581b6044820152606490fd5b5068070c1cc73b00c80000811315613fd4565b670de0b6b3a76400009161404861404d926140ef565b613d04565b613fbf565b50670f43fc2c04ee00008112613d85565b60405162461bcd60e51b815260206004820152600f60248201526e59206f7574206f6620626f756e647360881b6044820152606490fd5b60405162461bcd60e51b815260206004820152600f60248201526e58206f7574206f6620626f756e647360881b6044820152606490fd5b5050670de0b6b3a764000090565b600160ff1b81146123c7575f0390565b670de0b6b3a76400008112614520576137a3906142e7905f775803bcc5cb9634ba4cfb2213f784019318ed4dcb6017880f60361b8212156144f7575b73011798004d755d3c8bc8e03204cf44619e00000082121561449d575b6142e26142a06142a06142db6142706142b56142d56142cb61427061425a61417b6141756142a09c613bb4565b9c613bb4565b6e01855144814a7ff805980ff008400081121561446d575b6b02df0ab5a80a22c61ab5a700811215614440575b693f1fce3da636ea5cf850811215614415575b690127fa27722cc06cc5e28112156143ea575b68280e60114edb805d038112156143c0575b680ebc5fb41746121110811215614396575b6808f00f760a4b2db55d81121561436c575b6806f5f1775788937937811215614342575b6806248f33704b286603811215614318575b6805c548670b9510e7ac8112156142ee575b61425461424e61424983613886565b613bca565b91613a92565b90613d26565b6142c56142bb61427061427f6142708580613d04565b68056bc75e2d63100000900590565b8098856142ac614270846142a661429a61427083809d613d04565b94600386055b90613b83565b93613d04565b9e8f6005900590565b9c613d04565b9960078b056142a0565b98613d04565b95600987056142a0565b94613d04565b600b900590565b613b9e565b6064900590565b61430c6142fd61431292613bca565b6805c548670b9510e7ac900590565b9c613b40565b9b61423a565b61433661432761433c92613bca565b6806248f33704b286603900590565b9c613b16565b9b614228565b61436061435161436692613bca565b6806f5f1775788937937900590565b9c613aea565b9b614216565b61438a61437b61439092613bca565b6808f00f760a4b2db55d900590565b9c613abe565b9b614204565b6143b46143a56143ba92613bca565b680ebc5fb41746121110900590565b9c613a92565b9b6141f2565b6143de6143cf6143e492613bca565b68280e60114edb805d03900590565b9c613a66565b9b6141e0565b6144096143f961440f92613bca565b690127fa27722cc06cc5e2900590565b9c613a3a565b9b6141ce565b61443461442461443a92613bca565b693f1fce3da636ea5cf850900590565b9c613a0e565b9b6141bb565b61446161444f61446792613bca565b6b02df0ab5a80a22c61ab5a700900590565b9c6139e2565b9b6141a8565b61449161447c61449792613bca565b6e01855144814a7ff805980ff0084000900590565b9c6139b6565b9b614193565b906142e26142a06142a06142db6142706142b56142d56142cb61427061425a61417b6141756144e46144de6142a09e6b1425982cf597cd205cef7380900590565b9e61398a565b9c50505050505050505050505050614148565b5072195e54c5dd42177f53a27172fa9ec63026282760241b90056806f05b59d3b200000061412b565b61453b614540916a0c097ce7bc90715b34b9f160241b613d26565b6140ef565b6137a3906140df565b1561455057565b60405162461bcd60e51b815260206004820152601060248201526f125b9d985b1a5908115e1c1bdb995b9d60821b6044820152606490fd5b680238fd42c5cf03ffff1981121580614986575b6145a590614549565b5f811261495d576806f05b59d3b20000008112614923576145c5906138ba565b6145e572195e54c5dd42177f53a27172fa9ec63026282760241b91613bb4565b68056bc75e2d631000009068ad78ebc5ac62000000811215614903575b6856bc75e2d6310000008112156148e8575b682b5e3af16b188000008112156148cd575b6815af1d78b58c4000008112156148b2575b680ad78ebc5ac6200000811215614897575b68056bc75e2d6310000081121561487c575b6802b5e3af16b1880000811215614861575b68015af1d78b58c40000811215614846575b80808080808080808061469281613b6a565b61469c8280613d04565b68056bc75e2d6310000090056002900590816146b791613b83565b916146c191613d04565b68056bc75e2d6310000090056003900590816146dc91613b83565b916146e691613d04565b68056bc75e2d63100000900560049005908161470191613b83565b9161470b91613d04565b68056bc75e2d63100000900560059005908161472691613b83565b9161473091613d04565b68056bc75e2d63100000900560069005908161474b91613b83565b9161475591613d04565b68056bc75e2d63100000900560079005908161477091613b83565b9161477a91613d04565b68056bc75e2d63100000900560089005908161479591613b83565b9161479f91613d04565b68056bc75e2d6310000090056009900590816147ba91613b83565b916147c491613d04565b68056bc75e2d631000009005600a900590816147df91613b83565b916147e991613d04565b68056bc75e2d631000009005600b9005908161480491613b83565b9161480e91613d04565b68056bc75e2d631000009005600c900561482791613b83565b61483091613d04565b68056bc75e2d631000009005906142e791613d04565b61427061485561485b92613970565b92613cde565b90614680565b61427061487061487692613956565b92613cb8565b9061466e565b61427061488b61489192613886565b92613c92565b9061465c565b6142706148a66148ac9261393c565b92613c6c565b9061464a565b6142706148c16148c792613922565b92613c44565b90614638565b6142706148dc6148e292613908565b92613c1c565b90614626565b6142706148f76148fd926138ee565b92613bf0565b90614614565b61490d91506138d4565b6e01855144814a7ff805980ff008400090614602565b6803782dace9d900000081126149525761493c906138a0565b6145e56b1425982cf597cd205cef738091613bb4565b6145e5600191613bb4565b61497d6149786a0c097ce7bc90715b34b9f160241b926140df565b614588565b6137a391613d26565b5068070c1cc73b00c8000081131561459c56fea26469706673582212202352e2409f3d576deb9548d1d8d82a1f8020d32c0551bde8f37e591c5e3527d164736f6c634300081a0033000000000000000000000000608c9fd78276f8fae37517129d653803a92ea53a000000000000000000000000000000000000000000000018650127cc3dc8000000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000020000000000000000000000000092ae2d908a647241eeb77a4b4da065803bba46b90000000000000000000000000000000000000000000000000000000000000004000000000000000000000000d9a442856c234a39a81a089c06451ebaa4306a72000000000000000000000000eeda34a377dd0ca676b9511ee1324974fa8d980d00000000000000000000000039f5b252de249790faed0c2f05abead56d2088e1000000000000000000000000ec3b2cc4c6a8fc9a13620a91622483b56e2e6fd90000000000000000000000000000000000000000000000000000000000000004000000000000000000000000c4ef2c4b4ed79cd7639af070d4a6a82eef5edd4f000000000000000000000000c4ef2c4b4ed79cd7639af070d4a6a82eef5edd4f00000000000000000000000060d4bcab4a8b1849ca19f6b4a6eab26a664962670000000000000000000000003c730bc8ff9d7d51395c180c409597ae80a630560000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000016345785d8a00000000000000000000000000000000000000000000000000000429d069189e00000000000000000000000000000000000000000000000000000429d069189e00000000000000000000000000000000000000000000000000000429d069189e0000

Deployed Bytecode

0x610140806040526004361015610013575f80fd5b5f905f3560e01c908163047fc9aa14612aab575080631082ae9514612a655780631f3a0e4114612a4057806325692962146129f7578063267f4cf9146129da5780632797da80146129785780632d3eac441461290657806331e7e4871461272b5780633a04801d1461270e5780633e8847ec1461204c5780633f4ba83a14611fed57806341c0e1b514611f6c578063455611f214611f4f5780634bb77d9d14611e465780634f64b2be14611e0e5780634fdf5d1d14611d1357806354d1f13d14611ccd578063562e19df146117945780635c975abb1461177157806365c303a5146117365780636e18c5b41461127e578063715018a6146112335780638456cb59146111ce5780638aa044e4146111795780638d56c639146110165780638da5cb5b14610fe95780638e499bcf14610fcb5780638ff3909914610f5957806394068a9314610f275780639d76ea5814610efe578063a3820aa514610d25578063abfed9fd14610c2b578063b533789714610c0d578063b6efab3914610bef578063c6e1d3e714610bc1578063cc3344821461072f578063d1154ff0146106c3578063d7b4be241461069a578063dc036c9a146103ff578063e7ee6ad6146103bb578063ef407c3c1461037f578063f04e283e14610331578063f2fde38b146102f2578063f8dc929c146102d4578063f8e27f931461024e5763fee81cf414610219575f80fd5b3461024b57602036600319011261024b57610232612b0b565b9063389a75e1600c5252602080600c2054604051908152f35b80fd5b503461024b57602036600319011261024b57600435906001548210156102c55760208210156102b1576080610289836045015460b01c612f95565b91606854156102aa575b604051938452602084015260408301526060820152f35b5082610293565b634e487b7160e01b81526032600452602490fd5b6367e0bf5f60e01b8152600490fd5b503461024b578060031936011261024b576020606954604051908152f35b50602036600319011261024b57610307612b0b565b61030f612c31565b8060601b1561032457610321906137be565b80f35b637448fbae82526004601cfd5b50602036600319011261024b57610346612b0b565b61034e612c31565b63389a75e1600c528082526020600c208054421161037257908261032192556137be565b636f5e881883526004601cfd5b503461024b57602036600319011261024b5760043560208110156103b757602501546040516001600160a01b03909116815260209150f35b5080fd5b503461024b57602036600319011261024b57600435906001548210156102c55760208210156102b15760206001600160501b03836045015460601c16604051908152f35b503461024b57606036600319011261024b576004356024356001600160401b03811161066157610433903690600401612ac5565b61043b612af5565b903068929eee149b4bd21268541461068d573068929eee149b4bd212685560015493848214801590610683575b61067457856002549161047b8184612c09565b60028190556003546001600160a01b0316803b1561067057836040518092632770a7eb60e21b82528183816104b4893360048401612c16565b03925af190811561066557849161064c575b50509091506040517fd8ae9b9ba89e637bcb66a69ac91e8f688018e81d6f92c57e02226425c8efbdf63391806104fd868a83612c16565b0390a287908180670de0b6b3a76400005b6020831015610626578a831461062657908a949392918260450190815461053490612f76565b90949198620fffff8216928c61054a8d8d612b78565b9061055491612b8b565b9a8b61055f91612c09565b9561056c87948986612ff1565b915055820264e8d4a510000291870264e8d4a5100002049061058d9161360c565b02670de0b6b3a76400009004940194670de0b6b3a7640000810290808204670de0b6b3a7640000149015171561061257906105c791612b8b565b6105d282898c612b44565b358110610603578b95949392916105f76001928b848060a01b038460050154166135ce565b0191949092939461050e565b634647d8b560e01b8c5260048cfd5b634e487b7160e01b8d52601160045260248dfd5b9750505050945050505061063a9250612f39565b606b553868929eee149b4bd212685580f35b8161065691612ba9565b61066157825f6104c6565b8280fd5b6040513d86823e3d90fd5b8380fd5b6341598eb160e01b8652600486fd5b5060208211610468565b63ab143c0685526004601cfd5b503461024b578060031936011261024b576004546040516001600160a01b039091168152602090f35b503461024b57602036600319011261024b576004356106e0612c31565b662386f26fc100008111610720576020817f15a280e3a8fba7bb6a16834e8c4c8cf503351db60f83e74124075ff74b3d611992606655604051908152a180f35b6341598eb160e01b8252600482fd5b503461024b5761012036600319011261024b5761074a612b0b565b610752612b21565b90610104356001600160a01b03811681036106705761076f612c31565b60a43515610bb2576001546020811015610ba35760c43515610b9457606854610b855760025415610b7657604435151580610b63575b15610b4157670de0b6b3a7640000606435118015610b50575b610b415760018101808211610b2d579091908580805b6020831015610b215785831461086557505060058101546001600160a01b03868116911614610856579161084091600161082195946108466108198260450154612f76565b999099612f95565b90819c939c9a92819d670de0b6b3a76400006044358202049003612fce565b91612ff1565b81604501550191939490926107d4565b6364d9dc7160e11b8752600487fd5b949593929150955b60405163313ce56760e01b81526020816004816001600160a01b0389165afa908115610ad5578991610ae0575b5060ff6012911603610a7f576040516305d4ec6560e11b81526001600160a01b038581166004830152919091169690946020866024818b5afa958615610ad5578996610a9d575b508515610a8e57908561091161094993670de0b6b3a76400006109068460a435612b78565b049360443580612fce565b60018590556005890180546001600160a01b03199081166001600160a01b038a161790915560258a0180549091168b17905591612ff1565b856045015561096d61097e61095c6133d2565b809391600254958260c4359161341e565b60c4939193358b5583600255612f39565b606b5561098f60a4353033876132f0565b81811115610a7f57039060e4358210610a705760035487926001600160a01b039091169190823b15610670576109de928492836040518096819582946340c10f1960e01b845260048401612c16565b03925af18015610a6557610a46575b50927f3c078e7a1bc2cbd8c7cd625a6d75d084e96e6701c6a324576b75a688b38a1c53928560c09360405193845260018060a01b0316602084015260408301526060820152604435608082015260a43560a0820152a180f35b81610a549195949395612ba9565b610a61579091845f6109ed565b8480fd5b6040513d84823e3d90fd5b6341598eb160e01b8752600487fd5b6341598eb160e01b8852600488fd5b639cfd11eb60e01b8952600489fd5b9095506020813d602011610acd575b81610ab960209383612ba9565b81010312610ac95751945f6108e1565b5f80fd5b3d9150610aac565b6040513d8b823e3d90fd5b90506020813d602011610b19575b81610afb60209383612ba9565b81010312610b15575160ff81168103610b155760ff61089a565b8880fd5b3d9150610aee565b9495939291509561086d565b634e487b7160e01b86526011600452602486fd5b6341598eb160e01b8552600485fd5b50670de0b6b3a7640000608435116107be565b50662386f26fc1000060443511156107a5565b632468d44760e11b8552600485fd5b632ffc992d60e21b8552600485fd5b630b5556e560e11b8552600485fd5b6331cc28bd60e01b8552600485fd5b630b5556e560e11b8452600484fd5b503461024b57602036600319011261024b5760043560208110156103b7576020915060450154604051908152f35b503461024b578060031936011261024b576020606a54604051908152f35b503461024b578060031936011261024b576020606854604051908152f35b503461024b57604036600319011261024b57600435610c48612b21565b610c50612c31565b600154821015610d16576020821015610d02576025820180546001600160a01b0319166001600160a01b038316179055606b5460018301808411610cee5791610cd4610cce836040957f908a8bb84530a3f5baf8a0432620a6480e8b2af2e2423dae1222231a90caa5a4979560801c9160018060801b031690613024565b90612f39565b606b5582519182526001600160a01b03166020820152a180f35b634e487b7160e01b85526011600452602485fd5b634e487b7160e01b83526032600452602483fd5b6367e0bf5f60e01b8352600483fd5b503461024b57606036600319011261024b576004356001600160401b0381116103b757610d56903690600401612ac5565b6024356001600160401b03811161067057610d75903690600401612ac5565b6044356001600160401b038111610efa57610d94903690600401612ac5565b919092610d9f612c31565b84821480610ef1575b15610a705760015494875b60208110610dbf578880f35b818114610eed57610dd181838a612b44565b3587811015610ede57670de0b6b3a7640000610dee838787612b44565b35111580610ec1575b15610eb2576020811015610e9e57908186610e5083610e38610840898d8c610e498660019c60450199610e42610e2d8c54612f76565b9b919b9a909a612f95565b5050969098612b44565b3594612b44565b3592612fce565b90557f80394b5329e114f22712d6166857cd77c88256d851082e141591f481227fb8b96040610e80848989612b44565b35610e8c858b8d612b44565b3582519182526020820152a201610db3565b634e487b7160e01b8a52603260045260248afd5b63bd18ee1f60e01b8a5260048afd5b50670de0b6b3a7640000610ed683888a612b44565b351115610df7565b6367e0bf5f60e01b8a5260048afd5b8880f35b50848314610da8565b8580fd5b503461024b578060031936011261024b576003546040516001600160a01b039091168152602090f35b503461024b578060031936011261024b57606b54604080516001600160801b038316815260809290921c602083015290f35b503461024b57602036600319011261024b57610f73612b0b565b610f7b612c31565b6001600160a01b0316801561072057600480546001600160a01b031916821790556040519081527f58fd5d9c33114e6edf8ea5d30956f8d1a4ab112b004f99928b4bcf1b87d6666290602090a180f35b503461024b578060031936011261024b576020600154604051908152f35b503461024b578060031936011261024b57638b78c6d819546040516001600160a01b039091168152602090f35b503461024b57604036600319011261024b5760043590611034612b21565b61103c612c31565b60015483101561116a5760208310156111565761105c8360450154612f76565b5090670de0b6b3a7640000810290808204670de0b6b3a76400001490151715611142579061108991612b8b565b926001840180941161112e57600501546040516370a0823160e01b81523060048201526001600160a01b039091169190602081602481865afa9081156106655784916110fc575b50848111156110ed5761032193946110e791612c09565b916135ce565b63996f8ab960e01b8452600484fd5b90506020813d602011611126575b8161111760209383612ba9565b81010312610ac957515f6110d0565b3d915061110a565b634e487b7160e01b83526011600452602483fd5b634e487b7160e01b84526011600452602484fd5b634e487b7160e01b82526032600452602482fd5b6367e0bf5f60e01b8252600482fd5b503461024b57602036600319011261024b57600435611196612c31565b8015610720576020817f03cd63f3fef742f82f64d7e1775b22c4fe9ed6d2bf0ca7cc04146d620e190ab292606755604051908152a180f35b503461024b578060031936011261024b576111e7612c31565b60655460ff81166112245760ff1916600117606555337f5ee71a369c8672edded508e624ffc9257fa1ae6886ef32905c18e60196bca3998280a280f35b639784de2160e01b8252600482fd5b508060031936011261024b57611247612c31565b80638b78c6d819547f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380638b78c6d8195580f35b503461024b57608036600319011261024b576064356001600160a01b03811681036103b7573068929eee149b4bd212685414611729573068929eee149b4bd212685560015480600435101561171a57606b546112ee90608081901c906001600160801b0316600435600101613024565b6002949194549061130160243583612c09565b60028190556003549095906001600160a01b0316803b15610a6157846040518092632770a7eb60e21b825281838161133f6024353360048401612c16565b03925af1801561170f579085916116fa575b5050602060043510156116e65761139f96670de0b6b3a76400009161137b60043560450154612f76565b9a8b9295919461139964e8d4a510008c620fffff87160202886132c3565b90612b78565b049587905b602082106116ba575b5050886113df8888620fffff948c9d8964e8d4a5100061140f9e9f6113d2838f612c09565b998a975495160202613645565b966114156113ed8988612c09565b670de0b6b3a764000061140260665483612b78565b60011c049a8b8092612c09565b99612b37565b97670de0b6b3a7640000810290808204670de0b6b3a764000014901517156116a6578561144191612b8b565b946044358610611697578c611456918a612ff1565b6004356045015580670de0b6b3a7640000810204670de0b6b3a7640000148115171561168357876114ae6114b492670de0b6b3a76400008f8f64e8d4a5100090620fffff6114a793160202856132c3565b9102612b8b565b93612b37565b97895b6020811015611668578b81146115b457600435810361155557670de0b6b3a76400008702878104670de0b6b3a7640000148815171561154157886114fa91612b8b565b89670de0b6b3a7640000810204670de0b6b3a7640000148a151715611541579061153b8e6001936115358e670de0b6b3a76400008f02612b8b565b9061333c565b016114b7565b634e487b7160e01b8c52601160045260248cfd5b6115628160450154612f76565b91809150670de0b6b3a7640000810204670de0b6b3a7640000148115171561061257600192918d6115358e670de0b6b3a7640000858f6115a790836115af9902612b8b565b945002612b8b565b61153b565b50919450919796945060209950849298506115d795505b611655575b5050612f39565b606b5550600560043501546115f890839083906001600160a01b03166135ce565b6040519060018060a01b031681526004358382015281604082015260243560608201527f7a3728879285f3ca5108b5f39698f28002a6b72cac81653343b8a7dfb75037f160803392a23868929eee149b4bd2126855604051908152f35b9161165f92612e16565b9050815f6115d0565b50919450919796945060209950849298506115d795506115cb565b634e487b7160e01b8a52601160045260248afd5b634647d8b560e01b8b5260048bfd5b634e487b7160e01b8b52601160045260248bfd5b90968988146116e0576116d8826116d38d600194612b78565b612b8b565b9701906113a4565b966113ad565b634e487b7160e01b84526032600452602484fd5b8161170491612ba9565b61067057835f611351565b6040513d87823e3d90fd5b6341598eb160e01b8352600483fd5b63ab143c0682526004601cfd5b503461024b57602036600319011261024b57600435906001548210156102c55760208210156102b1576020826045015460b01c604051908152f35b503461024b578060031936011261024b57602060ff606554166040519015158152f35b503461024b5760a036600319011261024b576084356001600160a01b03811681036103b7573068929eee149b4bd212685414611729573068929eee149b4bd21268556001549060243560043514611cbe578160043510801590611cb2575b610d165760443515611ca357611827606b5460018060801b0381169060801c9060016024350160081b60016004350117613024565b909260206004351015611c8f5761184360043560450154612f76565b9193909260206024351015611c7b5761186160243560450154612f76565b9194670de0b6b3a764000061187a606654604435612b78565b0496670de0b6b3a764000061189a826118958b604435612c09565b612b78565b04956118c26118a9888c612b37565b9c61139964e8d4a5100089620fffff8a1602028b6132c3565b8c670de0b6b3a7640000810204670de0b6b3a7640000148d151715611c585790888e81938f8e8b620fffff8a160264e8d4a510000291670de0b6b3a7640000029061190c91612b8b565b906119169161360c565b61191f91612b8b565b9a61192b8c9b85612b37565b9061193591612c09565b998a916002549054908b620fffff8c160264e8d4a51000029461195795613645565b978861196291612b37565b9a80670de0b6b3a7640000810204670de0b6b3a76400001481151715611c4457848f8f8e670de0b6b3a7640000611535926115a788836119a29902612b8b565b670de0b6b3a76400008202828104670de0b6b3a76400001483151715611c4457906119cc91612b8b565b670de0b6b3a76400008802888104670de0b6b3a76400001489151715611c445791611a00878a936115358f611a0597612b8b565b612c09565b670de0b6b3a7640000810290808204670de0b6b3a764000014901517156106125783611a3091612b8b565b9a6064358c10611c6c5788611b8c575b8492611a5d9492611a5092612ff1565b6004356045015585612ff1565b60243560450155670de0b6b3a7640000840293808504670de0b6b3a76400001490151715611b78578593611aab611abd969464e8d4a5100060209c9995620fffff611ab196160202906132c3565b90612b8b565b91611b64575b50612f39565b606b5560056004350154611ae19060443590309033906001600160a01b03166132f0565b5060056024350154611aff90839083906001600160a01b03166135ce565b6040519060018060a01b0316815260043583820152602435604082015260443560608201528160808201527fb3e2773606abfd36b5bd91394b3a54d1398336c65005baf7bf7a05efeffaf75b60a03392a23868929eee149b4bd2126855604051908152f35b611b7091600254612e16565b905081611ab7565b634e487b7160e01b89526011600452602489fd5b96670de0b6b3a7640000611ba0838b612b78565b049080670de0b6b3a7640000810204670de0b6b3a76400001481151715611c5857611bcb828a612b37565b80670de0b6b3a7640000810204670de0b6b3a76400001481151715611c445792611c3783611c31611a5095611c3189968f6114a78f9b8f9d611a5d9f9d93670de0b6b3a764000064e8d4a510008196620fffff611c2c951602029302612b8b565b61360c565b9d612b37565b9b92509294509250611a40565b634e487b7160e01b8f52601160045260248ffd5b634e487b7160e01b8e52601160045260248efd5b634647d8b560e01b8d5260048dfd5b634e487b7160e01b88526032600452602488fd5b634e487b7160e01b85526032600452602485fd5b630b5556e560e11b8352600483fd5b508160243510156117f2565b63a8bf4d5f60e01b8352600483fd5b508060031936011261024b5763389a75e1600c52338152806020600c2055337ffa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c928280a280f35b503461024b57604036600319011261024b57611d2d612b0b565b90611d36612b21565b611d3e612c31565b600154926001600160a01b03811691835b6020811015611dfe57858114611d8a5760058101546001600160a01b03168414611d7b57600101611d4f565b63103d1a8760e31b8552600485fd5b50909160249394506020905b6040516370a0823160e01b815230600482015294859182905afa918215610665578492611dc8575b61032193506135ce565b91506020833d602011611df6575b81611de360209383612ba9565b81010312610ac957610321925191611dbe565b3d9150611dd6565b5090916024939450602090611d96565b503461024b57602036600319011261024b5760043560208110156103b757600501546040516001600160a01b03909116815260209150f35b503461024b57602036600319011261024b576004356001600160401b0381116103b757611e77903690600401612ac5565b600154839284905b60208210611edb575b50505015611eb4575b610cce611eae91606b5460018060801b0381169060801c91613024565b606b5580f35b507f201f1e1d1c1b1a191817161514131211100f0e0d0c0b0a090807060504030201611e91565b90929193828414611f465784611ef2858585612b44565b351015611f3757611f04848484612b44565b3560018101809111611f2357600385901b1b1793919260010190611e7f565b634e487b7160e01b87526011600452602487fd5b6367e0bf5f60e01b8652600486fd5b93829350611e88565b503461024b578060031936011261024b5760209054604051908152f35b503461024b578060031936011261024b57611f85612c31565b60655460ff811615611fde5760ff8160081c16611fcf5761ff001916610100176065557fbe26733c2bf6ff3ea5ba8cfe744422bd49052ff9ed5685c9e81e6f9321dbaddd8180a180f35b631c6a9ca160e11b8252600482fd5b6363856c5960e01b8252600482fd5b503461024b578060031936011261024b57612006612c31565b60655460ff811615611fde5760ff8160081c16611fcf5760ff1916606555337faeb196d352664784d1900b0e7414a8face7d29f4dae8c4b0cf68ed477423bbf48280a280f35b5034610ac9576060366003190112610ac9576004356001600160401b038111610ac95761207d903690600401612ac5565b612088929192612af5565b903068929eee149b4bd212685414612701573068929eee149b4bd212685560015460805260805181036126f257606b545f1960a0526001600160801b038116935f9360809290921c928492909190835b60208110156126e5576080518114612170576120f581858b612b44565b3596871561216157906008600192838301881b1796019787151580612156575b612125575b505b019593956120d8565b612141906116d36121398460450154612f76565b509092612b78565b8060a0511060a0518218021860a0525f61211a565b5060a0511515612115565b9496506001905f60a05261211c565b50939194929590955b156126d65761218792613024565b610100529061010051918095600254919461010051966121a8608051612bde565b946121b66040519687612ba9565b6080518652601f196121c9608051612bde565b013660208801375f60c0525b602060c05110156126c85760805160c051146123f0576121f860c0518486612b44565b3580156123db5760c05160450161220f8154612f76565b9092670de0b6b3a76400006122248587612b78565b0460e05261223f8261223860e05186612b37565b9586612ff1565b905588612276575b505060c05160050154612268929150309033906001600160a01b03166132f0565b600160c0510160c0526121d5565b909b9a8c670de0b6b3a7640000939e93819c959c0204670de0b6b3a7640000148d1517156123c7578c8e61010051670de0b6b3a76400008302906122b991612b8b565b8c60c0516122c691612bf5565b52608051620fffff85160264e8d4a510000291670de0b6b3a764000002906122ed91612b8b565b906122f7916132c3565b61230091612b78565b670de0b6b3a764000090049a60e05161231891612b37565b9b60a0516123269082612b78565b670de0b6b3a7640000900460e0519061233e91612c09565b60665460011c61234d91612b78565b670de0b6b3a764000090049d8e9260805190620fffff160264e8d4a51000029261237691612c09565b61238991670de0b6b3a764000002612b8b565b90612393916132c3565b61239c91612b78565b670de0b6b3a764000090049a60e051906123b591612c09565b6123be91612b37565b965f8080612247565b634e487b7160e01b5f52601160045260245ffd5b50846122685763f6ef3f5d60e01b5f5260045ffd5b9295989096949197985b848061261e575050505061240c6133d2565b8091801561260f578261242992915b8615925f54906080516134ee565b9290956124368588612c09565b9889151580612603575b156125f4576003546001600160a01b0316803b15610ac9575f61247c81928d6040519485809481936340c10f1960e01b83528b60048401612c16565b03925af180156125e9576125ad575b507f67902069e86c21d5ad116d9df073bf02a2bfdbd591414157cda22d3b8476cd53916124d1916040519460018060a01b03168552606060208601526060850191612b54565b918960408201528033930390a284918315612598575050506124fa91869185549060805161341e565b600354600454919492936001600160a01b03928316929091169061251e9085612c09565b91813b156106705791839161254a93836040518096819582946340c10f1960e01b845260048401612c16565b03925af18015610a6557612583575b50509261256c916020945b600255612f39565b606b553868929eee149b4bd2126855604051908152f35b61258e828092612ba9565b61024b5780612559565b6020985061256c965090945092509050612564565b6124d1919950916125df5f7f67902069e86c21d5ad116d9df073bf02a2bfdbd591414157cda22d3b8476cd5394612ba9565b5f9991509161248b565b6040513d5f823e3d90fd5b634647d8b560e01b5f5260045ffd5b506024358a1015612440565b63df7da5cd60e01b5f5260045ffd5b5f9a9895939a9997969492995b60208110156126b35760805181146126b357612648818a8a612b44565b35156126ab57808c61266a6126608360450154612f76565b9591939050612bf5565b519281670de0b6b3a7640000810204670de0b6b3a764000014821517156123c7576001936115358e670de0b6b3a76400006126a59502612b8b565b0161262b565b6001906126a5565b5090809395989a50612429929496979961241b565b9295989096949197986123fa565b631f0ebc5760e21b5f5260045ffd5b5093919492959095612179565b6341598eb160e01b5f5260045ffd5b63ab143c065f526004601cfd5b34610ac9575f366003190112610ac9576020606654604051908152f35b34610ac9576080366003190112610ac9576004356024356001600160401b038111610ac95761275e903690600401612ac5565b604435916064359361276e612c31565b6001549381156126f2578484036126f2574286106126f257606b54608081901c906127a1906001600160801b0316612c6d565b9190916128e5575b50506068546128d657856068556127c08187612b37565b60695581606a555f955f965b60208810156128bf5786881461284a576127e7888787612b44565b3597670de0b6b3a764000089101561283b5761280589600193612b37565b98612832826045019161282961084061281e8554612f76565b949194939093612f95565b93915091612fce565b905501966127cc565b630152ac2f60e31b5f5260045ffd5b9092949550670de0b6b3a7640000919396505b036128b0576128a07fb0fb14f34df2e6ea25fc5285462fa7522278318522be931036565d550e5236a5956040519586958652608060208701526080860191612b54565b91604084015260608301520390a1005b63083aafed60e41b5f5260045ffd5b9092949550670de0b6b3a76400009193965061285d565b632ffc992d60e21b5f5260045ffd5b6128f5816128fc93600254612e16565b9050612f39565b606b5586806127a9565b34610ac9575f366003190112610ac95761291e612c4d565b606b54602090608081901c9061293c906001600160801b0316612c6d565b91828061296f575b612955575b50506040519015158152f35b6128f58161296593600254612e16565b606b558280612949565b50801515612944565b34610ac9576020366003190112610ac9576004356001548110156129cb5760208110156129b7576001600160601b036020916045015416604051908152f35b634e487b7160e01b5f52603260045260245ffd5b6367e0bf5f60e01b5f5260045ffd5b34610ac9575f366003190112610ac9576020606754604051908152f35b5f366003190112610ac95763389a75e1600c52335f526202a30042016020600c2055337fdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d5f80a2005b34610ac9575f366003190112610ac957602060ff60655460081c166040519015158152f35b34610ac9575f366003190112610ac957612a7d612c31565b5f6068555f6069557fc3014e77feddea63dc4c4b247508845d74eb35678da2e55000c3bb655727650e5f80a1005b34610ac9575f366003190112610ac9576020906002548152f35b9181601f84011215610ac9578235916001600160401b038311610ac9576020808501948460051b010111610ac957565b604435906001600160a01b0382168203610ac957565b600435906001600160a01b0382168203610ac957565b602435906001600160a01b0382168203610ac957565b919082018092116123c757565b91908110156129b75760051b0190565b81835290916001600160fb1b038311610ac95760209260051b809284830137010190565b818102929181159184041417156123c757565b8115612b95570490565b634e487b7160e01b5f52601260045260245ffd5b90601f801991011681019081106001600160401b03821117612bca57604052565b634e487b7160e01b5f52604160045260245ffd5b6001600160401b038111612bca5760051b60200190565b80518210156129b75760209160051b010190565b919082039182116123c757565b6001600160a01b039091168152602081019190915260400190565b638b78c6d819543303612c4057565b6382b429005f526004601cfd5b600160ff60655416151514612c5e57565b63b8c449b360e01b5f5260045ffd5b90606854916069549083158015612e0d575b8015612def575b612de7575080839142105f14612dd357612caf91612ca391612c09565b92426068555b42612c09565b915f5490606a548180159386855f14612d98575050505b5f555f5b6020811015612d8e576001548114612d675760019080604501612d1e87612d046108408789612cf98754612f76565b969196959095612f95565b9592809592949195925f14612d265750505050805b612fce565b905501612cca565b84811115612d4a5750612d19926116d3612d44926118958786612c09565b90612c09565b9150612d19926116d3612d61926118958588612c09565b90612b37565b50505090505b5f60025480612d7e575b5090600190565b612d8891506137fb565b5f612d77565b5050509050612d6d565b9091928083115f14612dbe57926116d3612d4492611895612db99686612c09565b612cc6565b926116d3612d619261189585612db997612c09565b5050612caf5f925f6068555f606955612ca9565b92505f919050565b50612dfa8442612c09565b606754118015612c865750428211612c86565b50428411612c7f565b9092915f938215612f305790612e3291600154845f549161341e565b93909180831115612eb7576003546004546001600160a01b0390811692911690612e5c9085612c09565b91813b1561067057918391612e8893836040518096819582946340c10f1960e01b845260048401612c16565b03925af18015610a6557612ea2575b50505b806002559190565b612ead828092612ba9565b61024b5780612e97565b8091508210612ec7575b50612e9a565b6003546004546001600160a01b0391821692911690612ee7908490612c09565b823b15610ac957612f11925f9283604051809681958294632770a7eb60e21b845260048401612c16565b03925af180156125e95715612ec1575f612f2a91612ba9565b5f612ec1565b935050505f9190565b906001600160801b0382111580612f65575b612f5e576341598eb160e01b5f5260045ffd5b60801b1790565b506001600160801b03811115612f4b565b6001600160601b038116916001600160501b038260601c169160b01c90565b9064e8d4a51000620fffff8316029164e8d4a51000620fffff8260141c16029164e8d4a5100080620fffff8460281c160292603c1c0290565b90919264e8d4a510008080809304603c1b950460281b930460141b910417171790565b90916001600160601b0382118015613014575b6126f25760b01b9160601b171790565b506001600160501b038311613004565b9161302d612c4d565b806101205261303b82612c6d565b90936001545f5b6020811061309c575b505050159182613092575b5081613085575b5061307d57613073906101205190600254612e16565b9050906101205190565b906101205190565b905061012051145f61305d565b831491505f613056565b60ff838260031b1c16801580156132ba575b6132b4575f1981019060208210156129b75760018060a01b03602482015416906130db6044820154612f76565b9190602060018060a01b036004860154166024604051809881936305d4ec6560e11b835260048301525afa9485156125e9575f95613281575b5084156132725780851461326457600b8102818104600b14821517156123c757600a900485118061325b575b61324e575b5f9181151580613242575b61319e575b5050927f516c8bdb823996757c901b6b9bd210afa82c6ec8d550f0e57cd3f64896f7319c92604461318d6020948460019a9998612ff1565b910155604051908152a25b01613042565b9296959493909c9150670de0b6b3a76400008d02918d808404670de0b6b3a764000014901517156123c7578480938a620fffff8b160264e8d4a5100002916131e591612b8b565b906131ef916132c3565b6131f891612b78565b670de0b6b3a764000090049c61320e8385612b78565b9061321891612b8b565b9283610120519061322891612b37565b9061323291612c09565b610120529293949591905f613155565b50610120511515613150565b613256612c31565b613145565b50801515613140565b505050505050600190613198565b639531a3a160e01b5f5260045ffd5b9094506020813d82116132ac575b8161329c60209383612ba9565b81010312610ac95751935f613114565b3d915061328f565b5061304b565b508281116130ae565b906132cd91613d40565b80156132eb57670de0b6b3a7640000606482025f1901040160010190565b505f90565b601c5f60649281946020966040519860605260405260601b602c526323b872dd60601b600c525af13d1560015f511417161561332f575f606052604052565b637939f4245f526004601cfd5b9164e8d4a51000620fffff8216029064e8d4a51000620fffff8260281c16028281115f146133cb57505f5b83106133b25764e8d4a5100090603c1c020180670de0b6b3a764000010670de0b6b3a764000082180218811161339b575050565b10156133a357565b63b1a539bd60e01b5f5260045ffd5b505011156133bc57565b637b3a1f9560e01b5f5260045ffd5b8203613367565b6001545f91825b602084101561341557828414613403576001906001600160601b03856045015416019301926133d9565b925090505b613411826137fb565b9190565b92509050613408565b9290939491670de0b6b3a763ffff198101958187116123c75761344091612b78565b9390945f915b610100831061345e5763b138078b60e01b5f5260045ffd5b80156126f25781878202870304905f5b602081106134d2575b506064908083106134c157670de0b6b3a76400008184035b020411156134a257600190920191613446565b929450613411935050670de0b6b3a76400006064830204919050612b37565b670de0b6b3a764000083820361348f565b978689146134e85781836001920204980161346e565b97613477565b939592909491670de0b6b3a763ffff198101968188116123c75761351191612b78565b9490955f915b610100831061352f5763b138078b60e01b5f5260045ffd5b80156126f25781888202880304905f5b602081106135b2575b506064908083106135a157670de0b6b3a76400008184035b0204111561357357600190920191613517565b94505050909250670de0b6b3a76400006064830204905f146135985761341191612b37565b61341191612c09565b670de0b6b3a7640000838203613560565b98878a146135c85781836001920204990161353f565b98613548565b60105f604492602095829560145260345263a9059cbb60601b82525af13d1560015f51141716156135ff575f603452565b6390b8ec185f526004601cfd5b9061361691613d40565b80156132eb57670de0b6b3a7640000606482025f19010460018101821061363f5790035f190190565b50505f90565b92909194670de0b6b3a76400008602868104670de0b6b3a764000014871517156123c75761368961368261369094670de0b6b3a764000093612b8b565b8097612b78565b0494612b37565b908215612b9557826a0c097ce7bc90715b34b9f160241b0490935f945b61010086106136c55763b138078b60e01b5f5260045ffd5b80156126f257606461375684611aab8a611a008961375188670de0b6b3a764000061374b8f613745848f8a611a008a8f61373e8161372461189597612d618a9c8f96613737816137318f8b8f91611aab968f6137249061372a93612b37565b93612b78565b0490612b37565b95612b78565b918d6132c3565b0490612c09565b99612b78565b04612b37565b612b37565b918083106137a657670de0b6b3a76400006137718285612c09565b02041115613784576001909501946136ad565b9450505050506137a39150670de0b6b3a7640000606482020490612b37565b90565b670de0b6b3a76400006137b98483612c09565b613771565b60018060a01b031680638b78c6d819547f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a3638b78c6d81955565b6001545f670de0b6b3a76400005b602082101561387f5782821461387f57620fffff9061382b8360450154612f76565b9050929092169064e8d4a510008202151580613876575b156126f25761386c8260019464e8d4a510008089670de0b6b3a7640000970202928a02020461360c565b0204910190613809565b50821515613842565b9250505090565b9068056bc75e2d630fffff1982019182136001166123c757565b906803782dace9d8ffffff1982019182136001166123c757565b906806f05b59d3b1ffffff1982019182136001166123c757565b9068ad78ebc5ac61ffffff1982019182136001166123c757565b906856bc75e2d630ffffff1982019182136001166123c757565b90682b5e3af16b187fffff1982019182136001166123c757565b906815af1d78b58c3fffff1982019182136001166123c757565b90680ad78ebc5ac61fffff1982019182136001166123c757565b906802b5e3af16b187ffff1982019182136001166123c757565b9068015af1d78b58c3ffff1982019182136001166123c757565b906803782dace9d90000008201915f6803782dace9d9000000841291129080158216911516176123c757565b9068ad78ebc5ac620000008201915f68ad78ebc5ac62000000841291129080158216911516176123c757565b906856bc75e2d6310000008201915f6856bc75e2d631000000841291129080158216911516176123c757565b90682b5e3af16b188000008201915f682b5e3af16b18800000841291129080158216911516176123c757565b906815af1d78b58c4000008201915f6815af1d78b58c400000841291129080158216911516176123c757565b90680ad78ebc5ac62000008201915f680ad78ebc5ac6200000841291129080158216911516176123c757565b9068056bc75e2d631000008201915f68056bc75e2d63100000841291129080158216911516176123c757565b906802b5e3af16b18800008201915f6802b5e3af16b1880000841291129080158216911516176123c757565b9068015af1d78b58c400008201915f68015af1d78b58c40000841291129080158216911516176123c757565b9067ad78ebc5ac6200008201915f67ad78ebc5ac620000841291129080158216911516176123c757565b906756bc75e2d63100008201915f6756bc75e2d6310000841291129080158216911516176123c757565b908168056bc75e2d63100000019182126001166123c757565b9190915f83820193841291129080158216911516176123c757565b908160011b91808305600214901517156123c757565b906064820291808305606414901517156123c757565b9068056bc75e2d6310000082029180830568056bc75e2d6310000014901517156123c757565b906b02df0ab5a80a22c61ab5a7008202918083056b02df0ab5a80a22c61ab5a70014901517156123c757565b90693f1fce3da636ea5cf850820291808305693f1fce3da636ea5cf85014901517156123c757565b90690127fa27722cc06cc5e2820291808305690127fa27722cc06cc5e214901517156123c757565b9068280e60114edb805d0382029180830568280e60114edb805d0314901517156123c757565b90680ebc5fb41746121110820291808305680ebc5fb4174612111014901517156123c757565b906808f00f760a4b2db55d8202918083056808f00f760a4b2db55d14901517156123c757565b906806f5f17757889379378202918083056806f5f177578893793714901517156123c757565b81810292915f8212600160ff1b8214166123c75781840514901517156123c757565b8115612b9557600160ff1b81145f198314166123c7570590565b81156140d157801561363f578060ff1c61409a57770bce5086492111aea88f4bb1ca6bcf584181ea8059f765328210156140635780670c7d713b49da00001280614052575b1561403257670de0b6b3a76400008102908105670de0b6b3a7640000036123c7576ec097ce7bc90715b34b9f0fffffffff198101906001818313166123c7576a0c097ce7bc90715b34b9f160241b8202918083056a0c097ce7bc90715b34b9f160241b14901517156123c7576a0c097ce7bc90715b34b9f160241b8101905f6a0c097ce7bc90715b34b9f160241b831291129080158216911516176123c757613e2d91613d26565b613e378180613d04565b6a0c097ce7bc90715b34b9f160241b90058080808085613e58828098613d04565b6a0c097ce7bc90715b34b9f160241b90059060038205613e7791613b83565b91613e8191613d04565b6a0c097ce7bc90715b34b9f160241b90059060058205613ea091613b83565b91613eaa91613d04565b6a0c097ce7bc90715b34b9f160241b90059060078205613ec991613b83565b91613ed391613d04565b6a0c097ce7bc90715b34b9f160241b90059060098205613ef291613b83565b91613efc91613d04565b6a0c097ce7bc90715b34b9f160241b900590600b8205613f1b91613b83565b91613f2591613d04565b6a0c097ce7bc90715b34b9f160241b900590600d8205613f4491613b83565b91613f4e91613d04565b6a0c097ce7bc90715b34b9f160241b9005600f9005613f6c91613b83565b613f7590613b9e565b90613f8a81670de0b6b3a76400008405613d04565b91670de0b6b3a7640000900790613fa091613d04565b670de0b6b3a76400009005613fb491613b83565b670de0b6b3a7640000905b0580680238fd42c5cf03ffff1913158061401f575b15613fe2576137a390614588565b60405162461bcd60e51b815260206004820152601560248201527450726f64756374206f7574206f6620626f756e647360581b6044820152606490fd5b5068070c1cc73b00c80000811315613fd4565b670de0b6b3a76400009161404861404d926140ef565b613d04565b613fbf565b50670f43fc2c04ee00008112613d85565b60405162461bcd60e51b815260206004820152600f60248201526e59206f7574206f6620626f756e647360881b6044820152606490fd5b60405162461bcd60e51b815260206004820152600f60248201526e58206f7574206f6620626f756e647360881b6044820152606490fd5b5050670de0b6b3a764000090565b600160ff1b81146123c7575f0390565b670de0b6b3a76400008112614520576137a3906142e7905f775803bcc5cb9634ba4cfb2213f784019318ed4dcb6017880f60361b8212156144f7575b73011798004d755d3c8bc8e03204cf44619e00000082121561449d575b6142e26142a06142a06142db6142706142b56142d56142cb61427061425a61417b6141756142a09c613bb4565b9c613bb4565b6e01855144814a7ff805980ff008400081121561446d575b6b02df0ab5a80a22c61ab5a700811215614440575b693f1fce3da636ea5cf850811215614415575b690127fa27722cc06cc5e28112156143ea575b68280e60114edb805d038112156143c0575b680ebc5fb41746121110811215614396575b6808f00f760a4b2db55d81121561436c575b6806f5f1775788937937811215614342575b6806248f33704b286603811215614318575b6805c548670b9510e7ac8112156142ee575b61425461424e61424983613886565b613bca565b91613a92565b90613d26565b6142c56142bb61427061427f6142708580613d04565b68056bc75e2d63100000900590565b8098856142ac614270846142a661429a61427083809d613d04565b94600386055b90613b83565b93613d04565b9e8f6005900590565b9c613d04565b9960078b056142a0565b98613d04565b95600987056142a0565b94613d04565b600b900590565b613b9e565b6064900590565b61430c6142fd61431292613bca565b6805c548670b9510e7ac900590565b9c613b40565b9b61423a565b61433661432761433c92613bca565b6806248f33704b286603900590565b9c613b16565b9b614228565b61436061435161436692613bca565b6806f5f1775788937937900590565b9c613aea565b9b614216565b61438a61437b61439092613bca565b6808f00f760a4b2db55d900590565b9c613abe565b9b614204565b6143b46143a56143ba92613bca565b680ebc5fb41746121110900590565b9c613a92565b9b6141f2565b6143de6143cf6143e492613bca565b68280e60114edb805d03900590565b9c613a66565b9b6141e0565b6144096143f961440f92613bca565b690127fa27722cc06cc5e2900590565b9c613a3a565b9b6141ce565b61443461442461443a92613bca565b693f1fce3da636ea5cf850900590565b9c613a0e565b9b6141bb565b61446161444f61446792613bca565b6b02df0ab5a80a22c61ab5a700900590565b9c6139e2565b9b6141a8565b61449161447c61449792613bca565b6e01855144814a7ff805980ff0084000900590565b9c6139b6565b9b614193565b906142e26142a06142a06142db6142706142b56142d56142cb61427061425a61417b6141756144e46144de6142a09e6b1425982cf597cd205cef7380900590565b9e61398a565b9c50505050505050505050505050614148565b5072195e54c5dd42177f53a27172fa9ec63026282760241b90056806f05b59d3b200000061412b565b61453b614540916a0c097ce7bc90715b34b9f160241b613d26565b6140ef565b6137a3906140df565b1561455057565b60405162461bcd60e51b815260206004820152601060248201526f125b9d985b1a5908115e1c1bdb995b9d60821b6044820152606490fd5b680238fd42c5cf03ffff1981121580614986575b6145a590614549565b5f811261495d576806f05b59d3b20000008112614923576145c5906138ba565b6145e572195e54c5dd42177f53a27172fa9ec63026282760241b91613bb4565b68056bc75e2d631000009068ad78ebc5ac62000000811215614903575b6856bc75e2d6310000008112156148e8575b682b5e3af16b188000008112156148cd575b6815af1d78b58c4000008112156148b2575b680ad78ebc5ac6200000811215614897575b68056bc75e2d6310000081121561487c575b6802b5e3af16b1880000811215614861575b68015af1d78b58c40000811215614846575b80808080808080808061469281613b6a565b61469c8280613d04565b68056bc75e2d6310000090056002900590816146b791613b83565b916146c191613d04565b68056bc75e2d6310000090056003900590816146dc91613b83565b916146e691613d04565b68056bc75e2d63100000900560049005908161470191613b83565b9161470b91613d04565b68056bc75e2d63100000900560059005908161472691613b83565b9161473091613d04565b68056bc75e2d63100000900560069005908161474b91613b83565b9161475591613d04565b68056bc75e2d63100000900560079005908161477091613b83565b9161477a91613d04565b68056bc75e2d63100000900560089005908161479591613b83565b9161479f91613d04565b68056bc75e2d6310000090056009900590816147ba91613b83565b916147c491613d04565b68056bc75e2d631000009005600a900590816147df91613b83565b916147e991613d04565b68056bc75e2d631000009005600b9005908161480491613b83565b9161480e91613d04565b68056bc75e2d631000009005600c900561482791613b83565b61483091613d04565b68056bc75e2d631000009005906142e791613d04565b61427061485561485b92613970565b92613cde565b90614680565b61427061487061487692613956565b92613cb8565b9061466e565b61427061488b61489192613886565b92613c92565b9061465c565b6142706148a66148ac9261393c565b92613c6c565b9061464a565b6142706148c16148c792613922565b92613c44565b90614638565b6142706148dc6148e292613908565b92613c1c565b90614626565b6142706148f76148fd926138ee565b92613bf0565b90614614565b61490d91506138d4565b6e01855144814a7ff805980ff008400090614602565b6803782dace9d900000081126149525761493c906138a0565b6145e56b1425982cf597cd205cef738091613bb4565b6145e5600191613bb4565b61497d6149786a0c097ce7bc90715b34b9f160241b926140df565b614588565b6137a391613d26565b5068070c1cc73b00c8000081131561459c56fea26469706673582212202352e2409f3d576deb9548d1d8d82a1f8020d32c0551bde8f37e591c5e3527d164736f6c634300081a0033

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

000000000000000000000000608c9fd78276f8fae37517129d653803a92ea53a000000000000000000000000000000000000000000000018650127cc3dc8000000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000020000000000000000000000000092ae2d908a647241eeb77a4b4da065803bba46b90000000000000000000000000000000000000000000000000000000000000004000000000000000000000000d9a442856c234a39a81a089c06451ebaa4306a72000000000000000000000000eeda34a377dd0ca676b9511ee1324974fa8d980d00000000000000000000000039f5b252de249790faed0c2f05abead56d2088e1000000000000000000000000ec3b2cc4c6a8fc9a13620a91622483b56e2e6fd90000000000000000000000000000000000000000000000000000000000000004000000000000000000000000c4ef2c4b4ed79cd7639af070d4a6a82eef5edd4f000000000000000000000000c4ef2c4b4ed79cd7639af070d4a6a82eef5edd4f00000000000000000000000060d4bcab4a8b1849ca19f6b4a6eab26a664962670000000000000000000000003c730bc8ff9d7d51395c180c409597ae80a630560000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000016345785d8a00000000000000000000000000000000000000000000000000000429d069189e00000000000000000000000000000000000000000000000000000429d069189e00000000000000000000000000000000000000000000000000000429d069189e0000

-----Decoded View---------------
Arg [0] : tokenAddress_ (address): 0x608C9fD78276F8Fae37517129D653803A92ea53A
Arg [1] : amplification_ (uint256): 450000000000000000000
Arg [2] : tokens_ (address[]): 0xD9A442856C234a39a81a089C06451EBAa4306a72,0xEEda34A377dD0ca676b9511EE1324974fA8d980D,0x39F5b252dE249790fAEd0C2F05aBead56D2088e1,0xeC3B2CC4C6a8fC9a13620A91622483b56E2E6fD9
Arg [3] : rateProviders_ (address[]): 0xC4EF2c4B4eD79CD7639AF070d4a6A82eEF5edd4f,0xC4EF2c4B4eD79CD7639AF070d4a6A82eEF5edd4f,0x60d4BCab4A8b1849Ca19F6B4a6EaB26A66496267,0x3C730BC8Ff9d7D51395c180c409597ae80A63056
Arg [4] : weights_ (uint256[]): 100000000000000000,300000000000000000,300000000000000000,300000000000000000
Arg [5] : owner_ (address): 0x92Ae2d908a647241eEb77A4b4DA065803bbA46b9

-----Encoded View---------------
21 Constructor Arguments found :
Arg [0] : 000000000000000000000000608c9fd78276f8fae37517129d653803a92ea53a
Arg [1] : 000000000000000000000000000000000000000000000018650127cc3dc80000
Arg [2] : 00000000000000000000000000000000000000000000000000000000000000c0
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000160
Arg [4] : 0000000000000000000000000000000000000000000000000000000000000200
Arg [5] : 00000000000000000000000092ae2d908a647241eeb77a4b4da065803bba46b9
Arg [6] : 0000000000000000000000000000000000000000000000000000000000000004
Arg [7] : 000000000000000000000000d9a442856c234a39a81a089c06451ebaa4306a72
Arg [8] : 000000000000000000000000eeda34a377dd0ca676b9511ee1324974fa8d980d
Arg [9] : 00000000000000000000000039f5b252de249790faed0c2f05abead56d2088e1
Arg [10] : 000000000000000000000000ec3b2cc4c6a8fc9a13620a91622483b56e2e6fd9
Arg [11] : 0000000000000000000000000000000000000000000000000000000000000004
Arg [12] : 000000000000000000000000c4ef2c4b4ed79cd7639af070d4a6a82eef5edd4f
Arg [13] : 000000000000000000000000c4ef2c4b4ed79cd7639af070d4a6a82eef5edd4f
Arg [14] : 00000000000000000000000060d4bcab4a8b1849ca19f6b4a6eab26a66496267
Arg [15] : 0000000000000000000000003c730bc8ff9d7d51395c180c409597ae80a63056
Arg [16] : 0000000000000000000000000000000000000000000000000000000000000004
Arg [17] : 000000000000000000000000000000000000000000000000016345785d8a0000
Arg [18] : 0000000000000000000000000000000000000000000000000429d069189e0000
Arg [19] : 0000000000000000000000000000000000000000000000000429d069189e0000
Arg [20] : 0000000000000000000000000000000000000000000000000429d069189e0000


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]

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.