ETH Price: $1,980.08 (-2.68%)
 
Transaction Hash
Method
Block
From
To
Burn220761242025-03-18 20:23:592 days ago1742329439IN
0x594f4983...1986ED6f1
0 ETH0.000153940.88855434
Execute Arbitrag...220564132025-03-16 2:19:114 days ago1742091551IN
0x594f4983...1986ED6f1
0 ETH0.00014350.46261363
Execute Arbitrag...219800852025-03-05 10:27:5915 days ago1741170479IN
0x594f4983...1986ED6f1
0 ETH0.000230590.74339126
Execute Arbitrag...219765692025-03-04 22:40:1115 days ago1741128011IN
0x594f4983...1986ED6f1
0 ETH0.000208690.67279894
Execute Arbitrag...219713362025-03-04 5:08:2316 days ago1741064903IN
0x594f4983...1986ED6f1
0 ETH0.000233510.75281973
Execute Arbitrag...219709612025-03-04 3:52:5916 days ago1741060379IN
0x594f4983...1986ED6f1
0 ETH0.000295740.95342332
Execute Arbitrag...219709192025-03-04 3:44:3516 days ago1741059875IN
0x594f4983...1986ED6f1
0 ETH0.000352840.92119047
Execute Arbitrag...219701712025-03-04 1:14:1116 days ago1741050851IN
0x594f4983...1986ED6f1
0 ETH0.000336130.87757583
Execute Arbitrag...219699752025-03-04 0:34:5916 days ago1741048499IN
0x594f4983...1986ED6f1
0 ETH0.000367380.95919336
Execute Arbitrag...219694682025-03-03 22:53:1116 days ago1741042391IN
0x594f4983...1986ED6f1
0 ETH0.000375131.20938635
Execute Arbitrag...219690302025-03-03 21:25:2316 days ago1741037123IN
0x594f4983...1986ED6f1
0 ETH0.000728981.90321289
Execute Arbitrag...219674722025-03-03 16:12:3517 days ago1741018355IN
0x594f4983...1986ED6f1
0 ETH0.000462331.46378263
Execute Arbitrag...219674662025-03-03 16:11:2317 days ago1741018283IN
0x594f4983...1986ED6f1
0 ETH0.000559751.46143919
Execute Arbitrag...219670972025-03-03 14:57:1117 days ago1741013831IN
0x594f4983...1986ED6f1
0 ETH0.00104463.30728172
Execute Arbitrag...219670842025-03-03 14:54:3517 days ago1741013675IN
0x594f4983...1986ED6f1
0 ETH0.001054652.75355747
Execute Arbitrag...219670302025-03-03 14:43:4717 days ago1741013027IN
0x594f4983...1986ED6f1
0 ETH0.000615371.8815704
Execute Arbitrag...219670122025-03-03 14:40:1117 days ago1741012811IN
0x594f4983...1986ED6f1
0 ETH0.000562241.46795869
Execute Arbitrag...219658842025-03-03 10:53:1117 days ago1740999191IN
0x594f4983...1986ED6f1
0 ETH0.000176090.69142442
Execute Arbitrag...219657072025-03-03 10:17:1117 days ago1740997031IN
0x594f4983...1986ED6f1
0 ETH0.000277060.7297544
Execute Arbitrag...219654302025-03-03 9:21:2317 days ago1740993683IN
0x594f4983...1986ED6f1
0 ETH0.000169130.7240599
Execute Arbitrag...219654302025-03-03 9:21:2317 days ago1740993683IN
0x594f4983...1986ED6f1
0 ETH0.000228690.7240599
Execute Arbitrag...219654292025-03-03 9:21:1117 days ago1740993671IN
0x594f4983...1986ED6f1
0 ETH0.000271270.70824306
Execute Arbitrag...219651582025-03-03 8:26:4717 days ago1740990407IN
0x594f4983...1986ED6f1
0 ETH0.000234880.71818037
Execute Arbitrag...219651572025-03-03 8:26:3517 days ago1740990395IN
0x594f4983...1986ED6f1
0 ETH0.000278320.72666757
Execute Arbitrag...219650282025-03-03 8:00:4717 days ago1740988847IN
0x594f4983...1986ED6f1
0 ETH0.000265520.69932524
View all transactions

Latest 14 internal transactions

Advanced mode:
Parent Transaction Hash Method Block
From
To
Deposit218882892025-02-20 14:53:4728 days ago1740063227
0x594f4983...1986ED6f1
0.4 ETH
Deposit217210102025-01-28 5:43:3551 days ago1738043015
0x594f4983...1986ED6f1
0.035 ETH
Deposit216847602025-01-23 4:19:4756 days ago1737605987
0x594f4983...1986ED6f1
0.05 ETH
Deposit216257452025-01-14 22:35:4764 days ago1736894147
0x594f4983...1986ED6f1
0.99 ETH
Deposit216245772025-01-14 18:39:5965 days ago1736879999
0x594f4983...1986ED6f1
3.11 ETH
Deposit214786952024-12-25 9:48:4785 days ago1735120127
0x594f4983...1986ED6f1
0.001 ETH
Mint214786952024-12-25 9:48:4785 days ago1735120127
0x594f4983...1986ED6f1
0.001 ETH
Deposit214607422024-12-22 21:32:5987 days ago1734903179
0x594f4983...1986ED6f1
0.001 ETH
Deposit214147742024-12-16 11:27:1194 days ago1734348431
0x594f4983...1986ED6f1
0.06007805 ETH
Deposit214099142024-12-15 19:10:3595 days ago1734289835
0x594f4983...1986ED6f1
0.001 ETH
Deposit214088912024-12-15 15:44:1195 days ago1734277451
0x594f4983...1986ED6f1
0.003 ETH
Mint214088912024-12-15 15:44:1195 days ago1734277451
0x594f4983...1986ED6f1
0.003 ETH
Deposit214088552024-12-15 15:36:5995 days ago1734277019
0x594f4983...1986ED6f1
0.00366662 ETH
Deposit213951842024-12-13 17:48:3597 days ago1734112115
0x594f4983...1986ED6f1
0.01 ETH
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ArbitrageV5

Compiler Version
v0.8.28+commit.7893614a

Optimization Enabled:
Yes with 200 runs

Other Settings:
cancun EvmVersion
File 1 of 23 : ArbitrageV5.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/math/Math.sol";
import "@chainlink/contracts/src/v0.8/shared/interfaces/AggregatorV3Interface.sol";
import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol";
import "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol";
import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol";
import "src/interfaces/IWETH.sol";
import "src/interfaces/IPriceFeedAggregator.sol";
import "src/interfaces/IReserveHolderV2.sol";
import "src/interfaces/IArbitrageERC20.sol";
import "src/library/ExternalContractAddresses.sol";
import "src/library/uniswap/UniswapV2Library.sol";
import "src/interfaces/IArbitrageV5.sol";

/// @title Contract for performing arbitrage
/// @notice This contract is responsible for buying USC tokens and for keeping price of USC token pegged to target price
/// @dev This contract represent second version of arbitrage contract, arbitrage is now private and all profit from arbitrage is kept in this contract
contract ArbitrageV5 is IArbitrageV5, ReentrancyGuard, Ownable {
    using SafeERC20 for IERC20;
    using SafeERC20 for IArbitrageERC20;

    uint256 public constant BASE_PRICE = 1e8;
    uint256 public constant USC_TARGET_PRICE = 1e8;
    uint256 public constant POOL_FEE = 30;
    uint256 public constant MAX_FEE = 100_00;

    // F = (1 - pool_fee) on 18 decimals
    uint256 public constant F = ((MAX_FEE - POOL_FEE) * 1e18) / MAX_FEE;
    uint16 public constant MAX_PRICE_TOLERANCE = 100_00;
    address public constant WETH = ExternalContractAddresses.WETH;
    address public constant STETH = ExternalContractAddresses.stETH;
    IUniswapV2Router02 public constant swapRouter = IUniswapV2Router02(ExternalContractAddresses.UNI_V2_SWAP_ROUTER);
    IUniswapV2Factory public constant poolFactory = IUniswapV2Factory(ExternalContractAddresses.UNI_V2_POOL_FACTORY);

    IArbitrageERC20 public immutable USC;
    IArbitrageERC20 public immutable CHI;
    IPriceFeedAggregator public immutable priceFeedAggregator;
    IReserveHolderV2 public reserveHolder;

    uint256 public pegPriceToleranceAbs;
    uint256 public mintBurnFee;
    uint256 public maxMintBurnPriceDiff;
    uint16 public maxMintBurnReserveTolerance;
    uint16 public chiPriceTolerance;
    uint16 public priceTolerance;

    bool public mintPaused;
    bool public burnPaused;

    uint256 public totalMintedUsc; // total amount of minted USC tokens during arbitrage when stablecoin is pegged

    mapping(address => bool) public isArbitrager;
    mapping(address => bool) public isPrivileged;
    mapping(address => uint256) public reserveMintTxLimit;
    mapping(address => uint256) public reserveBurnTxLimit;

    modifier onlyArbitrager() {
        if (!isArbitrager[msg.sender]) {
            revert NotArbitrager(msg.sender);
        }

        _;
    }

    modifier whenMintNotPaused() {
        if (mintPaused) {
            revert ContractIsPaused();
        }

        _;
    }

    modifier whenBurnNotPaused() {
        if (burnPaused) {
            revert ContractIsPaused();
        }

        _;
    }

    modifier onlyWhenMintableOrBurnable() {
        uint256 ethPrice = priceFeedAggregator.peek(WETH);

        uint256 uscSpotPrice = _calculateUscSpotPrice(ethPrice);
        if (!_almostEqualAbs(uscSpotPrice, USC_TARGET_PRICE, maxMintBurnPriceDiff)) {
            revert PriceIsNotPegged();
        }

        (, uint256 reserveDiff, uint256 reserveValue) = _getReservesData();
        if (reserveDiff > Math.mulDiv(reserveValue, maxMintBurnReserveTolerance, MAX_PRICE_TOLERANCE)) {
            revert ReserveDiffTooBig();
        }

        _;
    }

    modifier onlyBellowMintLimit(address reserveAsset, uint256 amount) {
        if (reserveMintTxLimit[reserveAsset] < amount) {
            revert ReserveTxLimitExceeded();
        }

        _;
    }

    modifier onlyBellowBurnLimit(address reserveAsset, uint256 amount) {
        if (reserveBurnTxLimit[reserveAsset] < amount) {
            revert ReserveTxLimitExceeded();
        }

        _;
    }

    constructor(
        IArbitrageERC20 _USC,
        IArbitrageERC20 _CHI,
        IPriceFeedAggregator _priceFeedAggregator,
        IReserveHolderV2 _reserveHolder
    ) Ownable() {
        USC = _USC;
        CHI = _CHI;
        priceFeedAggregator = _priceFeedAggregator;
        reserveHolder = _reserveHolder;
        mintPaused = false;
        burnPaused = false;

        IERC20(STETH).approve(address(reserveHolder), type(uint256).max);
    }

    /// @inheritdoc IArbitrageV5
    function setReserveHolder(address _reserveHolder) external onlyOwner {
        reserveHolder = IReserveHolderV2(_reserveHolder);
    }

    /// @inheritdoc IArbitrageV5
    function setPegPriceToleranceAbs(uint256 _priceTolerance) external override onlyOwner {
        pegPriceToleranceAbs = _priceTolerance;
    }

    /// @inheritdoc IArbitrageV5
    function setMintPause(bool isPaused) external onlyOwner {
        mintPaused = isPaused;
    }

    /// @inheritdoc IArbitrageV5
    function setBurnPause(bool isPaused) external onlyOwner {
        burnPaused = isPaused;
    }

    /// @inheritdoc IArbitrageV5
    function setPriceTolerance(uint16 _priceTolerance) external onlyOwner {
        if (_priceTolerance > MAX_PRICE_TOLERANCE) {
            revert ToleranceTooBig(_priceTolerance);
        }
        priceTolerance = _priceTolerance;
        emit SetPriceTolerance(_priceTolerance);
    }

    /// @inheritdoc IArbitrageV5
    function setChiPriceTolerance(uint16 _chiPriceTolerance) external onlyOwner {
        if (_chiPriceTolerance > MAX_PRICE_TOLERANCE) {
            revert ToleranceTooBig(_chiPriceTolerance);
        }
        chiPriceTolerance = _chiPriceTolerance;
        emit SetChiPriceTolerance(_chiPriceTolerance);
    }

    /// @inheritdoc IArbitrageV5
    function setMaxMintBurnPriceDiff(uint256 _maxMintBurnPriceDiff) external onlyOwner {
        maxMintBurnPriceDiff = _maxMintBurnPriceDiff;
        emit SetMaxMintBurnPriceDiff(_maxMintBurnPriceDiff);
    }

    /// @inheritdoc IArbitrageV5
    function setMaxMintBurnReserveTolerance(uint16 _maxMintBurnReserveTolerance) external onlyOwner {
        if (_maxMintBurnReserveTolerance > MAX_PRICE_TOLERANCE) {
            revert ToleranceTooBig(_maxMintBurnReserveTolerance);
        }
        maxMintBurnReserveTolerance = _maxMintBurnReserveTolerance;
        emit SetMaxMintBurnReserveTolerance(_maxMintBurnReserveTolerance);
    }

    /// @inheritdoc IArbitrageV5
    function setMintBurnFee(uint16 _mintBurnFee) external onlyOwner {
        if (_mintBurnFee > MAX_FEE) {
            revert FeeTooBig(_mintBurnFee);
        }

        mintBurnFee = _mintBurnFee;
        emit SetMintBurnFee(_mintBurnFee);
    }

    /// @inheritdoc IArbitrageV5
    function setReserveMintTxLimit(address reserveAsset, uint256 limit) external onlyOwner {
        reserveMintTxLimit[reserveAsset] = limit;
        emit SetReserveMintTxLimit(reserveAsset, limit);
    }

    /// @inheritdoc IArbitrageV5
    function setReserveBurnTxLimit(address reserveAsset, uint256 limit) external onlyOwner {
        reserveBurnTxLimit[reserveAsset] = limit;
        emit SetReserveBurnTxLimit(reserveAsset, limit);
    }

    /// @inheritdoc IArbitrageV5
    function updateArbitrager(address arbitrager, bool status) external onlyOwner {
        isArbitrager[arbitrager] = status;
        emit UpdateArbitrager(arbitrager, status);
    }

    /// @inheritdoc IArbitrageV5
    function updatePrivileged(address account, bool status) external onlyOwner {
        isPrivileged[account] = status;
        emit UpdatePrivileged(account, status);
    }

    /// @inheritdoc IArbitrageV5
    function claimRewards(IERC20[] memory tokens, uint256[] memory amounts) external onlyOwner {
        for (uint256 i = 0; i < tokens.length; i++) {
            IERC20 token = tokens[i];
            uint256 amount = amounts[i];

            token.safeTransfer(msg.sender, amount);

            if (address(token) == address(USC)) {
                if (amount < totalMintedUsc) {
                    totalMintedUsc -= amount;
                } else {
                    totalMintedUsc = 0;
                }
            }
        }
    }

    function rewardUSC(uint256 amount) external onlyOwner {
        USC.safeTransferFrom(msg.sender, address(this), amount);
        totalMintedUsc += amount;

        emit RewardUSC(amount);
    }

    /// @inheritdoc IArbitrageV5
    function mint(address token, uint256 amount, address receiver)
        external
        whenMintNotPaused
        nonReentrant
        onlyWhenMintableOrBurnable
        onlyBellowMintLimit(token, amount)
        returns (uint256)
    {
        uint256 fee = Math.mulDiv(amount, mintBurnFee, MAX_FEE);
        uint256 amountAfterFee = amount - fee;

        IERC20(token).safeTransferFrom(msg.sender, address(this), amount);
        IERC20(token).approve(address(reserveHolder), amountAfterFee);
        reserveHolder.deposit(token, amountAfterFee);

        return _mint(amountAfterFee, token, receiver);
    }

    /// @inheritdoc IArbitrageV5
    function mint(address receiver)
        external
        payable
        whenMintNotPaused
        nonReentrant
        onlyWhenMintableOrBurnable
        onlyBellowMintLimit(address(WETH), msg.value)
        returns (uint256)
    {
        uint256 ethAmount = msg.value;
        uint256 fee = Math.mulDiv(ethAmount, mintBurnFee, MAX_FEE);
        uint256 ethAmountAfterFee = ethAmount - fee;

        IWETH(WETH).deposit{value: ethAmount}();
        IERC20(WETH).safeTransfer(address(reserveHolder), ethAmountAfterFee);
        return _mint(ethAmountAfterFee, WETH, receiver);
    }

    /// @inheritdoc IArbitrageV5
    function burn(uint256 amount, address reserveToReceive)
        external
        whenBurnNotPaused
        nonReentrant
        onlyWhenMintableOrBurnable
        onlyBellowBurnLimit(reserveToReceive, amount)
        returns (uint256)
    {
        uint256 reservePrice = priceFeedAggregator.peek(reserveToReceive);

        USC.safeTransferFrom(msg.sender, address(this), amount);
        amount -= (amount * mintBurnFee) / MAX_FEE;
        USC.burn(amount);

        uint256 reserveAmountToRedeem = Math.mulDiv(amount, USC_TARGET_PRICE, reservePrice);

        reserveHolder.redeem(reserveAmountToRedeem, reserveToReceive);
        IERC20(reserveToReceive).safeTransfer(msg.sender, reserveAmountToRedeem);

        emit Burn(msg.sender, amount, reserveAmountToRedeem, reserveToReceive);
        return reserveAmountToRedeem;
    }

    /// @inheritdoc IArbitrageV5
    function executeArbitrageWithReserveSell(uint256 maxChiSpotPrice, SwapParams[] calldata swapParams)
        external
        returns (uint256)
    {
        for (uint256 i = 0; i < swapParams.length; i++) {
            reserveHolder.swapReserveForEth(
                swapParams[i].reserveAsset, swapParams[i].amountIn, swapParams[i].minAmountOut
            );
        }

        return executeArbitrage(maxChiSpotPrice);
    }

    /// @inheritdoc IArbitrageV5
    function executeArbitrage(uint256 maxChiSpotPrice) public override nonReentrant onlyArbitrager returns (uint256) {
        _validateArbitrage(maxChiSpotPrice);
        return _executeArbitrage();
    }

    /// @inheritdoc IArbitrageV5
    function getArbitrageData()
        public
        view
        returns (bool isPriceAtPeg, bool isPriceAboveTarget, bool isExcessOfReserves, uint256 reserveDiff)
    {
        uint256 ethPrice = priceFeedAggregator.peek(WETH);
        uint256 uscPrice = _getAndValidateUscPrice(ethPrice);

        uint256 reserveValue;
        (isExcessOfReserves, reserveDiff, reserveValue) = _getReservesData();
        isPriceAboveTarget = uscPrice >= USC_TARGET_PRICE;

        return (
            _almostEqualAbs(uscPrice, USC_TARGET_PRICE, pegPriceToleranceAbs),
            isPriceAboveTarget,
            isExcessOfReserves,
            reserveDiff
        );
    }

    function _executeArbitrage() internal returns (uint256) {
        (bool isPriceAtPeg, bool isPriceAboveTarget, bool isExcessOfReserves, uint256 reserveDiff) = getArbitrageData();

        uint256 ethPrice = priceFeedAggregator.peek(WETH);

        if (isPriceAtPeg) {
            if (isExcessOfReserves) {
                return _arbitrageAtPegExcessOfReserves(reserveDiff, ethPrice);
            } else {
                return _arbitrageAtPegDeficitOfReserves(reserveDiff, ethPrice);
            }
        } else if (isPriceAboveTarget) {
            if (isExcessOfReserves) {
                return _arbitrageAbovePegExcessOfReserves(reserveDiff, ethPrice);
            } else {
                return _arbitrageAbovePegDeficitOfReserves(reserveDiff, ethPrice);
            }
        } else {
            if (isExcessOfReserves) {
                return _arbitrageBellowPegExcessOfReserves(reserveDiff, ethPrice);
            } else {
                return _arbitrageBellowPegDeficitOfReserves(reserveDiff, ethPrice);
            }
        }
    }

    function _mint(uint256 amount, address token, address receiver) private returns (uint256) {
        uint256 usdValue;
        if (token == WETH) {
            uint256 ethPrice = priceFeedAggregator.peek(WETH);
            usdValue = _convertTokenAmountToUsdValue(amount, ethPrice);
        } else {
            uint256 tokenPrice = priceFeedAggregator.peek(token);
            usdValue = _convertTokenAmountToUsdValue(amount, tokenPrice);
        }

        uint256 uscAmountToMint = _convertUsdValueToTokenAmount(usdValue, USC_TARGET_PRICE);
        USC.mint(receiver, uscAmountToMint);
        emit Mint(msg.sender, token, amount, uscAmountToMint);
        return uscAmountToMint;
    }

    function _arbitrageAbovePegExcessOfReserves(uint256 reserveDiff, uint256 ethPrice) private returns (uint256) {
        uint256 deltaUSC = _calculateDeltaUSC(ethPrice);

        USC.mint(address(this), deltaUSC);
        uint256 ethAmountReceived = _swap(address(USC), WETH, deltaUSC);

        uint256 deltaUsd = _convertTokenAmountToUsdValue(deltaUSC, USC_TARGET_PRICE);
        uint256 deltaInETH = _convertUsdValueToTokenAmount(deltaUsd, ethPrice);

        if (deltaInETH > ethAmountReceived) {
            revert DeltaBiggerThanAmountReceivedETH(deltaInETH, ethAmountReceived);
        }

        uint256 ethAmountToSwap;
        uint256 ethAmountForReserves;

        if (deltaUsd > reserveDiff) {
            ethAmountToSwap = _convertUsdValueToTokenAmount(reserveDiff, ethPrice);
            ethAmountForReserves = _convertUsdValueToTokenAmount(deltaUsd, ethPrice) - ethAmountToSwap;
            IERC20(WETH).safeTransfer(address(reserveHolder), ethAmountForReserves);
        } else {
            ethAmountToSwap = _convertUsdValueToTokenAmount(deltaUsd, ethPrice);
        }

        uint256 chiAmountReceived = _swap(WETH, address(CHI), ethAmountToSwap);
        CHI.burn(chiAmountReceived);

        uint256 rewardAmount = ethAmountReceived - ethAmountToSwap - ethAmountForReserves;

        uint256 rewardValue = _convertTokenAmountToUsdValue(rewardAmount, ethPrice);
        emit ExecuteArbitrage(msg.sender, 1, deltaUsd, reserveDiff, ethPrice, rewardValue);
        return rewardValue;
    }

    function _arbitrageAbovePegDeficitOfReserves(uint256 reserveDiff, uint256 ethPrice) private returns (uint256) {
        uint256 deltaUSC = _calculateDeltaUSC(ethPrice);

        USC.mint(address(this), deltaUSC);
        uint256 ethAmountReceived = _swap(address(USC), WETH, deltaUSC);

        uint256 deltaUsd = _convertTokenAmountToUsdValue(deltaUSC, USC_TARGET_PRICE);
        uint256 deltaInETH = _convertUsdValueToTokenAmount(deltaUsd, ethPrice);

        if (deltaInETH > ethAmountReceived) {
            revert DeltaBiggerThanAmountReceivedETH(deltaInETH, ethAmountReceived);
        }

        IERC20(WETH).safeTransfer(address(reserveHolder), deltaInETH);

        uint256 rewardAmount = ethAmountReceived - deltaInETH;

        uint256 rewardValue = _convertTokenAmountToUsdValue(rewardAmount, ethPrice);
        emit ExecuteArbitrage(msg.sender, 2, deltaUsd, reserveDiff, ethPrice, rewardValue);
        return rewardValue;
    }

    function _arbitrageBellowPegExcessOfReserves(uint256 reserveDiff, uint256 ethPrice) private returns (uint256) {
        uint256 uscAmountToFreeze;
        uint256 uscAmountToBurn;

        uint256 deltaETH = _calculateDeltaETH(ethPrice);
        uint256 deltaUsd = _convertTokenAmountToUsdValue(deltaETH, ethPrice);

        if (deltaUsd > reserveDiff) {
            uscAmountToFreeze = _convertUsdValueToTokenAmount(reserveDiff, USC_TARGET_PRICE);
            uscAmountToBurn = _convertUsdValueToTokenAmount(deltaUsd - reserveDiff, USC_TARGET_PRICE);
        } else {
            uscAmountToFreeze = _convertUsdValueToTokenAmount(deltaUsd, USC_TARGET_PRICE);
        }

        reserveHolder.redeem(deltaETH, address(WETH));
        uint256 uscAmountReceived = _swap(WETH, address(USC), deltaETH);

        if (uscAmountReceived < uscAmountToFreeze) {
            uscAmountToFreeze = uscAmountReceived;
        }

        if (uscAmountToBurn > 0) {
            USC.burn(uscAmountToBurn);
        }

        uint256 rewardAmount = uscAmountReceived - uscAmountToFreeze - uscAmountToBurn;
        uint256 rewardValue = _convertTokenAmountToUsdValue(rewardAmount, USC_TARGET_PRICE);
        emit ExecuteArbitrage(msg.sender, 3, deltaUsd, reserveDiff, ethPrice, rewardValue);
        return rewardValue;
    }

    function _arbitrageBellowPegDeficitOfReserves(uint256 reserveDiff, uint256 ethPrice) private returns (uint256) {
        uint256 ethAmountToRedeem;
        uint256 ethAmountFromChi;

        uint256 deltaETH = _calculateDeltaETH(ethPrice);
        uint256 deltaUsd = _convertTokenAmountToUsdValue(deltaETH, ethPrice);

        if (deltaUsd > reserveDiff) {
            ethAmountFromChi = _convertUsdValueToTokenAmount(reserveDiff, ethPrice);
            ethAmountToRedeem = deltaETH - ethAmountFromChi;
            reserveHolder.redeem(ethAmountToRedeem, address(WETH));
        } else {
            ethAmountFromChi = deltaETH;
        }

        uint256 uscAmountToBurn = _convertUsdValueToTokenAmount(deltaUsd, USC_TARGET_PRICE);

        uint256 uscAmountReceived;
        {
            if (ethAmountFromChi > 0) {
                uint256 chiAmountToMint = _getAmountInForAmountOut(address(CHI), WETH, ethAmountFromChi);
                CHI.mint(address(this), chiAmountToMint);
                _swap(address(CHI), WETH, chiAmountToMint);
            }

            uscAmountReceived = _swap(WETH, address(USC), ethAmountFromChi + ethAmountToRedeem);
        }

        if (uscAmountToBurn > 0) {
            USC.burn(uscAmountToBurn);
        }

        {
            uint256 rewardAmount = uscAmountReceived - uscAmountToBurn;
            uint256 rewardValue = _convertTokenAmountToUsdValue(rewardAmount, USC_TARGET_PRICE);
            emit ExecuteArbitrage(msg.sender, 4, deltaUsd, reserveDiff, ethPrice, rewardValue);
            return rewardValue;
        }
    }

    function _arbitrageAtPegExcessOfReserves(uint256 reserveDiff, uint256 ethPrice) private returns (uint256) {
        uint256 uscAmountToMint = _convertUsdValueToTokenAmount(reserveDiff, USC_TARGET_PRICE);

        USC.mint(address(this), uscAmountToMint);
        totalMintedUsc += uscAmountToMint;

        emit ExecuteArbitrage(msg.sender, 5, 0, reserveDiff, ethPrice, 0);
        return 0;
    }

    function _arbitrageAtPegDeficitOfReserves(uint256 reserveDiff, uint256 ethPrice) private returns (uint256) {
        uint256 reserveDiffInUsc = _convertUsdValueToTokenAmount(reserveDiff, USC_TARGET_PRICE);

        uint256 uscAmountToBurn;
        uint256 ethToGet;
        if (reserveDiffInUsc > totalMintedUsc) {
            uscAmountToBurn = totalMintedUsc;

            uint256 ethToGetInUsd = _convertTokenAmountToUsdValue(reserveDiffInUsc - totalMintedUsc, USC_TARGET_PRICE);
            ethToGet = _convertUsdValueToTokenAmount(ethToGetInUsd, ethPrice);
        } else {
            uscAmountToBurn = reserveDiffInUsc;
            ethToGet = 0;
        }

        uint256 chiToCoverEth;
        if (ethToGet > 0) {
            chiToCoverEth = _getAmountInForAmountOut(address(CHI), WETH, ethToGet);
        }

        CHI.mint(address(this), chiToCoverEth);

        if (ethToGet > 0) {
            uint256 ethReceived = _swap(address(CHI), WETH, chiToCoverEth);
            IERC20(WETH).safeTransfer(address(reserveHolder), ethReceived);
        }

        if (uscAmountToBurn > 0) {
            USC.burn(uscAmountToBurn);
            totalMintedUsc -= uscAmountToBurn;
        }

        emit ExecuteArbitrage(msg.sender, 6, 0, reserveDiff, ethPrice, 0);
        return 0;
    }

    function _getReservesData()
        public
        view
        returns (bool isExcessOfReserves, uint256 reserveDiff, uint256 reserveValue)
    {
        reserveValue = reserveHolder.getReserveValue();
        uint256 uscTotalSupplyValue = _convertTokenAmountToUsdValue(USC.totalSupply(), USC_TARGET_PRICE);

        if (reserveValue > uscTotalSupplyValue) {
            isExcessOfReserves = true;
            reserveDiff = (reserveValue - uscTotalSupplyValue);
        } else {
            isExcessOfReserves = false;
            reserveDiff = (uscTotalSupplyValue - reserveValue);
        }
    }

    function _getAndValidateUscPrice(uint256 ethPrice) private view returns (uint256) {
        uint256 uscPrice = priceFeedAggregator.peek(address(USC));
        uint256 uscSpotPrice = _calculateUscSpotPrice(ethPrice);
        uint256 priceDiff = _absDiff(uscSpotPrice, uscPrice);
        uint256 maxPriceDiff = Math.mulDiv(uscPrice, priceTolerance, MAX_PRICE_TOLERANCE);

        if (priceDiff > maxPriceDiff) {
            revert PriceSlippageTooBig();
        }

        return uscSpotPrice;
    }

    function _validateArbitrage(uint256 maxChiSpotPrice) private view {
        if (!isPrivileged[msg.sender]) {
            uint256 ethPrice = priceFeedAggregator.peek(WETH);
            uint256 chiSpotPrice = _calculateChiSpotPrice(ethPrice);

            if (maxChiSpotPrice != 0 && chiSpotPrice > maxChiSpotPrice) {
                revert ChiSpotPriceTooBig();
            }

            // If max chi spot price is not specified we need to check for twap difference
            if (maxChiSpotPrice == 0) {
                uint256 chiOraclePrice = priceFeedAggregator.peek(address(CHI));

                if (!_almostEqualRel(chiSpotPrice, chiOraclePrice, chiPriceTolerance)) {
                    revert ChiPriceNotPegged(chiSpotPrice, chiOraclePrice);
                }
            }
        }
    }

    // input ethPrice has 8 decimals
    // returns result with 8 decimals
    function _calculateUscSpotPrice(uint256 ethPrice) private view returns (uint256) {
        (uint256 reserveUSC, uint256 reserveWETH) =
            UniswapV2Library.getReserves(address(poolFactory), address(USC), address(WETH));
        uint256 uscFor1ETH = UniswapV2Library.quote(1 ether, reserveWETH, reserveUSC);
        return Math.mulDiv(ethPrice, 1 ether, uscFor1ETH);
    }

    // input ethPrice has 8 decimals
    // returns result with 8 decimals
    function _calculateChiSpotPrice(uint256 ethPrice) private view returns (uint256) {
        (uint256 reserveCHI, uint256 reserveWETH) =
            UniswapV2Library.getReserves(address(poolFactory), address(CHI), address(WETH));
        uint256 chiFor1ETH = UniswapV2Library.quote(1 ether, reserveWETH, reserveCHI);
        return Math.mulDiv(ethPrice, 1 ether, chiFor1ETH);
    }

    // what amount of In tokens to put in pool to make price:   1 tokenOut = (priceOut / priceIn) tokenIn
    // assuming reserves are on 18 decimals, prices are on 8 decimals
    function _calculateDelta(uint256 reserveIn, uint256 priceIn, uint256 reserveOut, uint256 priceOut)
        public
        pure
        returns (uint256)
    {
        // F = (1 - pool_fee) = 0.997 on 18 decimals,   in square root formula  a = F

        // parameter `b` in square root formula,  b = rIn * (1+f) ,  on 18 decimals
        uint256 b = Math.mulDiv(reserveIn, 1e18 + F, 1e18);
        uint256 b_sqr = Math.mulDiv(b, b, 1e18);

        // parameter `c` in square root formula,  c = rIn^2 - (rIn * rOut * priceOut) / priceIn
        uint256 c_1 = Math.mulDiv(reserveIn, reserveIn, 1e18);
        uint256 c_2 = Math.mulDiv(Math.mulDiv(reserveIn, reserveOut, 1e18), priceOut, priceIn);

        uint256 c;
        uint256 root;
        if (c_1 > c_2) {
            c = c_1 - c_2;
            // d = 4ac
            uint256 d = Math.mulDiv(4 * F, c, 1e18);

            // root = sqrt(b^2 - 4ac)
            // multiplying by 10^9 to get back to 18 decimals
            root = Math.sqrt(b_sqr - d) * 1e9;
        } else {
            c = c_2 - c_1;
            // d = 4ac
            uint256 d = Math.mulDiv(4 * F, c, 1e18);

            // root = sqrt(b^2 - 4ac)    -> in this case `c` is negative, so we add `d` to `b^2`
            // multiplying by 10^9 to get back to 18 decimals
            root = Math.sqrt(b_sqr + d) * 1e9;
        }
        // delta = (-b + root) / 2*f
        uint256 delta = Math.mulDiv(1e18, root - b, 2 * F);

        return delta;
    }

    // given ethPrice is on 8 decimals
    // how many USC to put in pool to make price:   1 ETH = ethPrice * USC
    function _calculateDeltaUSC(uint256 ethPrice) public view returns (uint256) {
        (uint256 reserveUSC, uint256 reserveWETH) =
            UniswapV2Library.getReserves(address(poolFactory), address(USC), address(WETH));
        return _calculateDelta(reserveUSC, USC_TARGET_PRICE, reserveWETH, ethPrice);
    }

    // how many ETH to put in pool to make price:   1 ETH = ethPrice * USC
    function _calculateDeltaETH(uint256 ethPrice) public view returns (uint256) {
        (uint256 reserveUSC, uint256 reserveWETH) =
            UniswapV2Library.getReserves(address(poolFactory), address(USC), address(WETH));
        return _calculateDelta(reserveWETH, ethPrice, reserveUSC, USC_TARGET_PRICE);
    }

    function _makePath(address t1, address t2) internal pure returns (address[] memory path) {
        path = new address[](2);
        path[0] = t1;
        path[1] = t2;
    }

    function _makePath(address t1, address t2, address t3) internal pure returns (address[] memory path) {
        path = new address[](3);
        path[0] = t1;
        path[1] = t2;
        path[2] = t3;
    }

    function _swap(address tokenIn, address tokenOut, uint256 amount) private returns (uint256) {
        address[] memory path;

        if (tokenIn != WETH && tokenOut != WETH) {
            path = _makePath(tokenIn, WETH, tokenOut);
        } else {
            path = _makePath(tokenIn, tokenOut);
        }

        IERC20(tokenIn).approve(address(swapRouter), amount);
        uint256[] memory amounts = swapRouter.swapExactTokensForTokens(amount, 0, path, address(this), block.timestamp);

        uint256 amountReceived = amounts[path.length - 1];

        return amountReceived;
    }

    function _getAmountInForAmountOut(address tIn, address tOut, uint256 amountOut) internal view returns (uint256) {
        (uint256 rIn, uint256 rOut) = UniswapV2Library.getReserves(address(poolFactory), tIn, tOut);
        return UniswapV2Library.getAmountIn(amountOut, rIn, rOut);
    }

    function _convertUsdValueToTokenAmount(uint256 usdValue, uint256 price) internal pure returns (uint256) {
        return Math.mulDiv(usdValue, 1e18, price);
    }

    function _convertTokenAmountToUsdValue(uint256 amount, uint256 price) internal pure returns (uint256) {
        return Math.mulDiv(amount, price, 1e18);
    }

    function _absDiff(uint256 a, uint256 b) internal pure returns (uint256) {
        return (a > b) ? a - b : b - a;
    }

    function _almostEqualAbs(uint256 price1, uint256 price2, uint256 delta) internal pure returns (bool) {
        return _absDiff(price1, price2) <= delta;
    }

    function _almostEqualRel(uint256 price1, uint256 price2, uint256 delta) internal pure returns (bool) {
        (uint256 highPrice, uint256 lowPrice) = price1 > price2 ? (price1, price2) : (price2, price1);
        uint256 priceDiff = highPrice - lowPrice;
        uint256 maxPriceDiff = Math.mulDiv(highPrice, delta, MAX_PRICE_TOLERANCE);

        return priceDiff <= maxPriceDiff;
    }

    receive() external payable {}
}

File 2 of 23 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../extensions/IERC20Permit.sol";
import "../../../utils/Address.sol";

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

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

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

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(IERC20 token, address spender, uint256 value) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);

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

    /**
     * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
     * Revert on invalid signature.
     */
    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

        (bool success, bytes memory returndata) = address(token).call(data);
        return
            success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
    }
}

File 3 of 23 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

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

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

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be _NOT_ENTERED
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

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

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

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

File 4 of 23 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/Context.sol";

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

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

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

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

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

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

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

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

File 5 of 23 : Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    enum Rounding {
        Down, // Toward negative infinity
        Up, // Toward infinity
        Zero // Toward zero
    }

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

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

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

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

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

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

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1, "Math: mulDiv overflow");

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

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

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

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

            // Does not overflow because the denominator cannot be zero at this stage in the function.
            uint256 twos = denominator & (~denominator + 1);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

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

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

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

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

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

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

    /**
     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
        uint256 result = mulDiv(x, y, denominator);
        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
     *
     * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        //
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
        //
        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
        //
        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1 << (log2(a) >> 1);

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

    /**
     * @notice Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = sqrt(a);
            return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
        }
    }

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

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

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

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

    /**
     * @dev Return the log in base 256, rounded down, of a positive value.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 16;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 8;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 4;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 2;
            }
            if (value >> 8 > 0) {
                result += 1;
            }
        }
        return result;
    }

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

File 6 of 23 : AggregatorV3Interface.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

// solhint-disable-next-line interface-starts-with-i
interface AggregatorV3Interface {
  function decimals() external view returns (uint8);

  function description() external view returns (string memory);

  function version() external view returns (uint256);

  function getRoundData(
    uint80 _roundId
  ) external view returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound);

  function latestRoundData()
    external
    view
    returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound);
}

File 7 of 23 : IUniswapV2Factory.sol
pragma solidity >=0.5.0;

interface IUniswapV2Factory {
    event PairCreated(address indexed token0, address indexed token1, address pair, uint);

    function feeTo() external view returns (address);
    function feeToSetter() external view returns (address);

    function getPair(address tokenA, address tokenB) external view returns (address pair);
    function allPairs(uint) external view returns (address pair);
    function allPairsLength() external view returns (uint);

    function createPair(address tokenA, address tokenB) external returns (address pair);

    function setFeeTo(address) external;
    function setFeeToSetter(address) external;
}

File 8 of 23 : IUniswapV2Router02.sol
pragma solidity >=0.6.2;

import './IUniswapV2Router01.sol';

interface IUniswapV2Router02 is IUniswapV2Router01 {
    function removeLiquidityETHSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external returns (uint amountETH);
    function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountETH);

    function swapExactTokensForTokensSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external;
    function swapExactETHForTokensSupportingFeeOnTransferTokens(
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external payable;
    function swapExactTokensForETHSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external;
}

File 9 of 23 : IUniswapV2Pair.sol
pragma solidity >=0.5.0;

interface IUniswapV2Pair {
    event Approval(address indexed owner, address indexed spender, uint value);
    event Transfer(address indexed from, address indexed to, uint value);

    function name() external pure returns (string memory);
    function symbol() external pure returns (string memory);
    function decimals() external pure returns (uint8);
    function totalSupply() external view returns (uint);
    function balanceOf(address owner) external view returns (uint);
    function allowance(address owner, address spender) external view returns (uint);

    function approve(address spender, uint value) external returns (bool);
    function transfer(address to, uint value) external returns (bool);
    function transferFrom(address from, address to, uint value) external returns (bool);

    function DOMAIN_SEPARATOR() external view returns (bytes32);
    function PERMIT_TYPEHASH() external pure returns (bytes32);
    function nonces(address owner) external view returns (uint);

    function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;

    event Mint(address indexed sender, uint amount0, uint amount1);
    event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
    event Swap(
        address indexed sender,
        uint amount0In,
        uint amount1In,
        uint amount0Out,
        uint amount1Out,
        address indexed to
    );
    event Sync(uint112 reserve0, uint112 reserve1);

    function MINIMUM_LIQUIDITY() external pure returns (uint);
    function factory() external view returns (address);
    function token0() external view returns (address);
    function token1() external view returns (address);
    function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
    function price0CumulativeLast() external view returns (uint);
    function price1CumulativeLast() external view returns (uint);
    function kLast() external view returns (uint);

    function mint(address to) external returns (uint liquidity);
    function burn(address to) external returns (uint amount0, uint amount1);
    function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
    function skim(address to) external;
    function sync() external;

    function initialize(address, address) external;
}

File 10 of 23 : IWETH.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

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

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

    function withdraw(uint256 amount) external;
}

File 11 of 23 : IPriceFeedAggregator.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "src/interfaces/IOracle.sol";

interface IPriceFeedAggregator {
    event SetPriceFeed(address indexed base, address indexed feed);

    error ZeroAddress();

    /// @notice Sets price feed adapter for given token
    /// @param base Token address
    /// @param feed Price feed adapter address
    function setPriceFeed(address base, address feed) external;

    /// @notice Gets price feed adapter for given token
    /// @param base Token address
    /// @return feed Price feed adapter address
    function priceFeeds(address base) external view returns (IOracle feed);

    /// @notice Gets price for given token
    /// @param base Token address
    /// @return price Price for given token
    function peek(address base) external view returns (uint256 price);
}

File 12 of 23 : IReserveHolderV2.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IReserveHolderV2 {
    struct ReserveAssetInfo {
        /// @dev Amount of underlying ETH for this LST
        /// @dev For rebasing tokens it will be equal to amount of LST but for non-rebasing tokens it will depends on exchange rate
        uint256 totalDeposited;
        /// @dev Amount of LST claimed for this LST
        uint256 totalClaimed;
        /// @dev Address of underlying asset, if LST is rebasing then underlying asset is that LST but if LST is non-rebasing then underlying asset is WETH
        address underlyingAsset;
        /// @dev Address of swap adapter for this LST
        address swapAdapter;
        /// @dev Percentage of total reserve tokens that should be kept in this underlying asset
        uint256 percentage;
    }

    event SetArbitrager(address indexed arbitrager, bool enabled);
    event SetClaimer(address indexed claimer);
    event SetRebalancer(address indexed rebalancer, bool enabled);
    event SetSwapTolerance(uint256 swapTolerance);
    event AddReserveAsset(address indexed reserveAsset);
    event SetReserveAssetAdapter(address indexed reserveAsset, address adapter);
    event SetReserveAssetPercentage(address indexed reserveAsset, uint256 percentage);
    event Deposit(address indexed account, address indexed reserveAsset, uint256 amount);
    event Rebalance();
    event Redeem(address indexed account, address indexed reserve, uint256 amount);
    event ClaimRewards(address indexed account);
    event Claimed(address indexed account, address indexed reserveAsset, uint256 amount);

    error NotArbitrager();
    error NotClaimer();
    error NotRebalancer();
    error PercentageTooHigh();
    error AssetAlreadyAdded();
    error SlippageTooBig();

    /// @notice Gets reserve assets
    /// @return reserveAssets Reserve assets
    function getReserveAssets() external view returns (address[] memory reserveAssets);

    /// @notice Updates arbitrager status
    /// @param arbitrager Arbitrager address
    /// @param status Arbitrager status
    function setArbitrager(address arbitrager, bool status) external;

    /// @notice Sets claimer address
    /// @param claimer Claimer address
    /// @custom:usage Claimer should be rewardController contract
    function setClaimer(address claimer) external;

    /// @notice Sets rebalancer address
    /// @param rebalancer Rebalancer address
    /// @param status Rebalancer status
    function setRebalancer(address rebalancer, bool status) external;

    /// @notice Sets swap tolerance
    /// @param swapTolerance Swap tolerance
    /// @dev Only owner can call this function
    function setSwapTolerance(uint256 swapTolerance) external;

    /// @notice Adds reserve asset to reserves
    /// @param reserveAsset Reserve asset address
    /// @param reserveAdapter Adapter address
    /// @param reservePercentage Percentage of reserve asset in reserves
    /// @dev Only owner can call this function
    function addReserveAsset(address reserveAsset, address reserveAdapter, uint256 reservePercentage) external;

    /// @notice Sets adapter for new reserve asset
    /// @param reserveAsset Reserve asset address
    /// @param adapter Adapter address
    /// @dev Only owner can call this function
    function setReserveAssetAdapter(address reserveAsset, address adapter) external;

    /// @notice Sets percentage of reserve asset in reserves
    /// @param reserveAsset Reserve asset address
    /// @param percentage Percentage of reserve asset in reserves
    function setReserveAssetPercentage(address reserveAsset, uint256 percentage) external;

    /// @notice Gets reserve value in USD
    /// @return reserveValue Reserve value in USD
    function getReserveValue() external view returns (uint256 reserveValue);

    /// @notice Deposits reserve asset to reserves
    /// @param reserveAsset Reserve asset address
    /// @param amount Amount of reserve asset to deposit
    function deposit(address reserveAsset, uint256 amount) external;

    /// @notice Rebalance reserve in order to achieve balace
    /// @param spotPrices Spot prices of reserve assets. This is used for slippage protection
    /// @custom:usage This function should be called by external keeper
    function rebalance(uint256[] memory spotPrices) external;

    /// @notice Redeems stETH from reserves
    /// @param amount Amount of stETH to redeem
    /// @param reserve Reserve to redeem
    /// @return wethAmount Amount of WETH received
    /// @custom:usage This function should be called by arbitrage contract
    function redeem(uint256 amount, address reserve) external returns (uint256 wethAmount);

    /// @notice Claims stETH rewards in given amount for given account
    /// @notice Contract does not perform any check and is relying on rewardController contract to perform them
    /// @param account Account to claim stETH rewards for
    /// @custom:usage This function should be called by rewardController contract
    function claimRewards(address account) external;

    /// @notice Swap reserve asset for ETH
    /// @param reserve Reserve asset address
    /// @param amountIn Amount of reserve asset to swap
    /// @param minAmountOut Minimum amount of ETH to receive
    /// @custom:usage This function should be called by arbitrage contract in order to swap reserve asset for ETH and execute arbitrage with ETH
    function swapReserveForEth(address reserve, uint256 amountIn, uint256 minAmountOut) external;
}

File 13 of 23 : IArbitrageERC20.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

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

interface IArbitrageERC20 is IERC20 {
    function mint(address to, uint256 amount) external;

    function burn(uint256 amount) external;
}

File 14 of 23 : ExternalContractAddresses.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/// @notice external contract addresses on Ethereum Mainnet
library ExternalContractAddresses {
    address public constant WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
    address public constant stETH = 0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84;
    address public constant eETH = 0x35fA164735182de50811E8e2E824cFb9B6118ac2;
    address public constant weETH = 0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee;
    address public constant eETH_POOL = 0x308861A430be4cce5502d0A12724771Fc6DaF216;
    address public constant UNI_V2_SWAP_ROUTER = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
    address public constant UNI_V3_SWAP_ROUTER = 0xE592427A0AEce92De3Edee1F18E0157C05861564;
    address public constant UNI_V2_POOL_FACTORY = 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f;
    address public constant ETH_USD_CHAINLINK_FEED = 0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419;
    address public constant STETH_USD_CHAINLINK_FEED = 0xCfE54B5cD566aB89272946F602D76Ea879CAb4a8;
    address public constant WEETH_ETH_CHAINLINK_FEED = 0x5c9C449BbC9a6075A2c061dF312a35fd1E05fF22;
    address public constant CURVE_ETH_STETH_POOL = 0xDC24316b9AE028F1497c275EB9192a3Ea0f67022;
    address public constant ONE_INCH_ROUTER = 0x111111125421cA6dc452d289314280a0f8842A65;
}

File 15 of 23 : UniswapV2Library.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

// library copied from uniswap/v2-core/contracts/libraries/UniswapV2Library.sol
// the only change is in pragma solidity version.

import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol";

import "./SafeMath.sol";

library UniswapV2Library {
    using SafeMath for uint256;

    // returns sorted token addresses, used to handle return values from pairs sorted in this order
    function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {
        require(tokenA != tokenB, "UniswapV2Library: IDENTICAL_ADDRESSES");
        (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
        require(token0 != address(0), "UniswapV2Library: ZERO_ADDRESS");
    }

    // calculates the CREATE2 address for a pair without making any external calls
    function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
        (address token0, address token1) = sortTokens(tokenA, tokenB);
        pair = address(
            uint160(
                uint256(
                    keccak256(
                        abi.encodePacked(
                            hex"ff",
                            factory,
                            keccak256(abi.encodePacked(token0, token1)),
                            hex"96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f" // init code hash
                        )
                    )
                )
            )
        );
    }

    // fetches and sorts the reserves for a pair
    function getReserves(address factory, address tokenA, address tokenB)
        internal
        view
        returns (uint256 reserveA, uint256 reserveB)
    {
        (address token0,) = sortTokens(tokenA, tokenB);
        (uint256 reserve0, uint256 reserve1,) = IUniswapV2Pair(pairFor(factory, tokenA, tokenB)).getReserves();
        (reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
    }

    // given some amount of an asset and pair reserves, returns an equivalent amount of the other asset
    function quote(uint256 amountA, uint256 reserveA, uint256 reserveB) internal pure returns (uint256 amountB) {
        require(amountA > 0, "UniswapV2Library: INSUFFICIENT_AMOUNT");
        require(reserveA > 0 && reserveB > 0, "UniswapV2Library: INSUFFICIENT_LIQUIDITY");
        amountB = amountA.mul(reserveB) / reserveA;
    }

    // given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset
    function getAmountOut(uint256 amountIn, uint256 reserveIn, uint256 reserveOut)
        internal
        pure
        returns (uint256 amountOut)
    {
        require(amountIn > 0, "UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT");
        require(reserveIn > 0 && reserveOut > 0, "UniswapV2Library: INSUFFICIENT_LIQUIDITY");
        uint256 amountInWithFee = amountIn.mul(997);
        uint256 numerator = amountInWithFee.mul(reserveOut);
        uint256 denominator = reserveIn.mul(1000).add(amountInWithFee);
        amountOut = numerator / denominator;
    }

    // given an output amount of an asset and pair reserves, returns a required input amount of the other asset
    function getAmountIn(uint256 amountOut, uint256 reserveIn, uint256 reserveOut)
        internal
        pure
        returns (uint256 amountIn)
    {
        require(amountOut > 0, "UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT");
        require(reserveIn > 0 && reserveOut > 0, "UniswapV2Library: INSUFFICIENT_LIQUIDITY");
        uint256 numerator = reserveIn.mul(amountOut).mul(1000);
        uint256 denominator = reserveOut.sub(amountOut).mul(997);
        amountIn = (numerator / denominator).add(1);
    }

    // performs chained getAmountOut calculations on any number of pairs
    function getAmountsOut(address factory, uint256 amountIn, address[] memory path)
        internal
        view
        returns (uint256[] memory amounts)
    {
        require(path.length >= 2, "UniswapV2Library: INVALID_PATH");
        amounts = new uint256[](path.length);
        amounts[0] = amountIn;
        for (uint256 i; i < path.length - 1; i++) {
            (uint256 reserveIn, uint256 reserveOut) = getReserves(factory, path[i], path[i + 1]);
            amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut);
        }
    }

    // performs chained getAmountIn calculations on any number of pairs
    function getAmountsIn(address factory, uint256 amountOut, address[] memory path)
        internal
        view
        returns (uint256[] memory amounts)
    {
        require(path.length >= 2, "UniswapV2Library: INVALID_PATH");
        amounts = new uint256[](path.length);
        amounts[amounts.length - 1] = amountOut;
        for (uint256 i = path.length - 1; i > 0; i--) {
            (uint256 reserveIn, uint256 reserveOut) = getReserves(factory, path[i - 1], path[i]);
            amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut);
        }
    }
}

File 16 of 23 : IArbitrageV5.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

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

interface IArbitrageV5 {
    struct SwapParams {
        address reserveAsset;
        uint256 amountIn;
        uint256 minAmountOut;
    }

    error DeltaBiggerThanAmountReceivedETH(uint256 deltaETH, uint256 receivedETH);
    error ToleranceTooBig(uint16 _tolerance);
    error PriceSlippageTooBig();
    error NotArbitrager(address account);
    error PriceIsNotPegged();
    error ReserveDiffTooBig();
    error ChiPriceNotPegged(uint256 spotPrice, uint256 twapPrice);
    error FeeTooBig(uint256 fee);
    error ChiSpotPriceTooBig();
    error ContractIsPaused();
    error ReserveTxLimitExceeded();

    event SetPriceTolerance(uint16 priceTolerance);
    event Mint(address indexed account, address token, uint256 amount, uint256 uscAmount);
    event ExecuteArbitrage(
        address indexed account,
        uint256 indexed arbNum,
        uint256 deltaUsd,
        uint256 reserveDiff,
        uint256 ethPrice,
        uint256 rewardValue
    );
    event UpdateArbitrager(address indexed account, bool status);
    event SetMaxMintBurnPriceDiff(uint256 maxMintBurnPriceDiff);
    event SetChiPriceTolerance(uint16 chiPriceTolerance);
    event SetMaxMintBurnReserveTolerance(uint16 maxBurnReserveTolerance);
    event SetMintBurnFee(uint256 mintFee);
    event UpdatePrivileged(address indexed privileged, bool isPrivileged);
    event Burn(address account, uint256 amount, uint256 reserveReceived, address reserve);
    event RewardUSC(uint256 amount);
    event SetReserveMintTxLimit(address reserveAsset, uint256 limit);
    event SetReserveBurnTxLimit(address reserveAsset, uint256 limit);

    /// @notice Sets reserve holder
    /// @param _reserveHolder Address of reserve holder
    /// @custom:usage This function should be called from owner in purpose of setting reserve holder
    function setReserveHolder(address _reserveHolder) external;

    /// @notice Sets absolute peg price tolerance
    /// @param _priceTolerance Absolute value of price tolerance
    /// @custom:usage This function should be called from owner in purpose of setting price tolerance
    function setPegPriceToleranceAbs(uint256 _priceTolerance) external;

    /// @notice Sets spot price tolerance from TWAP price
    /// @dev 100% = 10000
    /// @param _priceTolerance Price tolerance in percents
    /// @custom:usage This function should be called from owner in purpose of setting price tolerance
    function setPriceTolerance(uint16 _priceTolerance) external;

    /// @notice Sets reserve tx limit for minting
    /// @param reserveAsset Address of reserve asset
    /// @param limit Limit of reserve tx
    function setReserveMintTxLimit(address reserveAsset, uint256 limit) external;

    /// @notice Sets reserve tx limit for burn
    /// @param reserveAsset Address of reserve asset
    /// @param limit Limit of reserve tx
    function setReserveBurnTxLimit(address reserveAsset, uint256 limit) external;

    /// @notice Mint USC tokens for ETH
    /// @dev If USC price is different from target price for less then max mint price diff, then minting is allowed without performing arbitrage
    /// @param receiver Receiver of USC tokens
    /// @return uscAmount Amount of USC tokens minted
    function mint(address receiver) external payable returns (uint256 uscAmount);

    /// @notice Mint USC tokens for WETH
    /// @param token Address of a token that will be used to mint USC
    /// @param amount Amount of token to use for minting
    /// @param receiver Receiver of USC tokens
    /// @return uscAmount Amount of USC tokens minted
    function mint(address token, uint256 amount, address receiver) external returns (uint256 uscAmount);

    /// @notice Executes arbitrage with reserve rebalance
    /// @param chiSpotPrice CHI spot price
    /// @param swapParams Array of swap params for reserve holder in order to perform safe reserve sell and get ETH
    /// @return amountOut Amount out
    /// @dev This function should execute arbitrage with reserve rebalance when there is not enough ETH in reserve holder so some reserves need to be sold
    function executeArbitrageWithReserveSell(uint256 chiSpotPrice, SwapParams[] memory swapParams)
        external
        returns (uint256);

    /// @notice Executes arbitrage, profit sent to caller
    /// @notice Returns reward value in USD
    /// @param maxChiSpotPrice maximum spot price of CHI, if 0 TWAP check will be done
    /// @return rewardValue Reward value in USD
    /// @custom:usage This function should be called from external keeper in purpose of pegging USC price and getting reward
    /// @custom:usage This function has no restrictions, anyone can be arbitrager
    function executeArbitrage(uint256 maxChiSpotPrice) external returns (uint256 rewardValue);

    /// @notice Gets information for perfoming arbitrage such as price diff, reserve diff, discount
    /// @return isPriceAtPeg True if USC price is above target price
    /// @return isPriceAboveTarget True if USC price is above target price
    /// @return isExcessOfReserves True if there is excess of reserves
    /// @return reserveDiff Reserve diff, excess or deficit of reserves
    function getArbitrageData()
        external
        view
        returns (bool isPriceAtPeg, bool isPriceAboveTarget, bool isExcessOfReserves, uint256 reserveDiff);

    /// @notice Update arbitrager status
    /// @dev This function can be called only by owner of contract
    /// @param account Arbitrager account
    /// @param status Arbitrager status
    function updateArbitrager(address account, bool status) external;

    /// @notice Claim rewards from arbitrages
    /// @dev This function can be called only by owner of contract
    /// @param tokens Tokens to claim rewards for
    /// @param amounts Amounts of tokens to claim rewards for
    function claimRewards(IERC20[] memory tokens, uint256[] memory amounts) external;

    /// @notice Rewards USC
    /// @dev This function can be called only by owner of contract
    /// @param amount Amount of USC to reward
    function rewardUSC(uint256 amount) external;

    /// @notice Sets maximum mint and burn price difference
    /// @dev This function can be called only by owner of contract, value is absolute
    /// @param _maxMintBurnPriceDiff Maximum mint and burn price difference
    function setMaxMintBurnPriceDiff(uint256 _maxMintBurnPriceDiff) external;

    /// @notice Sets CHI price tolerance percentage when checking TWAP
    /// @dev This function can be called only by owner of contract, value is relative
    /// @param _chiPriceTolerance CHI price tolerance percentage
    function setChiPriceTolerance(uint16 _chiPriceTolerance) external;

    /// @notice Sets maximum mint and burn price difference
    /// @dev This function can be called only by owner of contract, value is relative
    /// @param _maxMintBurnReserveTolerance Maximum mint and burn reserve tolerance
    function setMaxMintBurnReserveTolerance(uint16 _maxMintBurnReserveTolerance) external;

    /// @notice Sets mint and burn fee
    /// @dev This function can be called only by owner of contract
    /// @param _mintBurnFee Mint and burn fee
    function setMintBurnFee(uint16 _mintBurnFee) external;

    /// @notice Update privilege status, only privileged accounts can call arbitrage and pass CHI TWAP check
    /// @dev This function can be called only by owner of contract
    /// @param account Arbitrager account
    /// @param status Privilege status
    function updatePrivileged(address account, bool status) external;

    /// @notice Burns USC tokens from msg.sender and sends him WETH from reserves
    /// @param amount Amount of USC tokens to burn
    /// @param reserveToReceive Address of reserve to receive
    /// @return ethAmount Amount of WETH received
    function burn(uint256 amount, address reserveToReceive) external returns (uint256 ethAmount);

    /// @notice Sets mint pause
    /// @param isPaused true of false
    function setMintPause(bool isPaused) external;

    /// @notice Sets burn pause
    /// @param isPaused true of false
    function setBurnPause(bool isPaused) external;
}

File 17 of 23 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

File 18 of 23 : IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 *
 * ==== Security Considerations
 *
 * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
 * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
 * considered as an intention to spend the allowance in any specific way. The second is that because permits have
 * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
 * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
 * generally recommended is:
 *
 * ```solidity
 * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
 *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
 *     doThing(..., value);
 * }
 *
 * function doThing(..., uint256 value) public {
 *     token.safeTransferFrom(msg.sender, address(this), value);
 *     ...
 * }
 * ```
 *
 * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
 * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
 * {SafeERC20-safeTransferFrom}).
 *
 * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
 * contracts should have entry points that don't rely on permit.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     *
     * CAUTION: See Security Considerations above.
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}

File 19 of 23 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     *
     * Furthermore, `isContract` will also return true if the target contract within
     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
     * which only has an effect at the end of a transaction.
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

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

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

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

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

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

File 20 of 23 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)

pragma solidity ^0.8.0;

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

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

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

File 21 of 23 : IUniswapV2Router01.sol
pragma solidity >=0.6.2;

interface IUniswapV2Router01 {
    function factory() external pure returns (address);
    function WETH() external pure returns (address);

    function addLiquidity(
        address tokenA,
        address tokenB,
        uint amountADesired,
        uint amountBDesired,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB, uint liquidity);
    function addLiquidityETH(
        address token,
        uint amountTokenDesired,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external payable returns (uint amountToken, uint amountETH, uint liquidity);
    function removeLiquidity(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB);
    function removeLiquidityETH(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external returns (uint amountToken, uint amountETH);
    function removeLiquidityWithPermit(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountA, uint amountB);
    function removeLiquidityETHWithPermit(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountToken, uint amountETH);
    function swapExactTokensForTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapTokensForExactTokens(
        uint amountOut,
        uint amountInMax,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
        external
        payable
        returns (uint[] memory amounts);
    function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
        external
        returns (uint[] memory amounts);
    function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
        external
        returns (uint[] memory amounts);
    function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
        external
        payable
        returns (uint[] memory amounts);

    function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
    function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
    function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
    function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
    function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
}

File 22 of 23 : IOracle.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IOracle {
    /// @notice Gets name of price adapter
    /// @return name Name of price adapter
    function name() external view returns (string memory name);

    /// @notice Gets decimals of price adapter
    /// @return decimals Decimals of price adapter
    function decimals() external view returns (uint8 decimals);

    /// @notice Gets price base token from Chainlink price feed
    /// @return price price in USD for the 1 baseToken
    function peek() external view returns (uint256 price);
}

File 23 of 23 : SafeMath.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

// library copied from uniswap/v2-core/contracts/libraries/SafeMath.sol
// the only change is in pragma solidity version.
// this contract was the reason of incompatible solidity version error

// a library for performing overflow-safe math, courtesy of DappHub (https://github.com/dapphub/ds-math)

library SafeMath {
    function add(uint256 x, uint256 y) internal pure returns (uint256 z) {
        require((z = x + y) >= x, "ds-math-add-overflow");
    }

    function sub(uint256 x, uint256 y) internal pure returns (uint256 z) {
        require((z = x - y) <= x, "ds-math-sub-underflow");
    }

    function mul(uint256 x, uint256 y) internal pure returns (uint256 z) {
        require(y == 0 || (z = x * y) / y == x, "ds-math-mul-overflow");
    }
}

Settings
{
  "remappings": [
    "@chainlink/=lib/chainlink/",
    "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
    "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
    "@uniswap/v2-core/=lib/v2-core/",
    "@uniswap/v2-periphery/=lib/v2-periphery/",
    "@uniswap/v3-core/=lib/v3-core/",
    "@uniswap/v3-periphery/=lib/v3-periphery/",
    "ds-test/=lib/openzeppelin-contracts-upgradeable/lib/forge-std/lib/ds-test/src/",
    "erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/",
    "forge-std/=lib/forge-std/src/",
    "openzeppelin-foundry-upgrades-0.3.6/=dependencies/openzeppelin-foundry-upgrades-0.3.6/",
    "openzeppelin/=lib/openzeppelin-contracts-upgradeable/contracts/",
    "openzeppelin-foundry-upgrades/=dependencies/openzeppelin-foundry-upgrades-0.3.6/src/",
    "solidity-stringutils/=dependencies/openzeppelin-foundry-upgrades-0.3.6/lib/solidity-stringutils/",
    "chainlink/=lib/chainlink/",
    "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/",
    "v2-core/=lib/v2-core/contracts/",
    "v2-periphery/=lib/v2-periphery/contracts/",
    "v3-core/=lib/v3-core/",
    "v3-periphery/=lib/v3-periphery/contracts/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "metadata": {
    "useLiteralContent": false,
    "bytecodeHash": "ipfs",
    "appendCBOR": true
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "cancun",
  "viaIR": false,
  "libraries": {}
}

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"contract IArbitrageERC20","name":"_USC","type":"address"},{"internalType":"contract IArbitrageERC20","name":"_CHI","type":"address"},{"internalType":"contract IPriceFeedAggregator","name":"_priceFeedAggregator","type":"address"},{"internalType":"contract IReserveHolderV2","name":"_reserveHolder","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"uint256","name":"spotPrice","type":"uint256"},{"internalType":"uint256","name":"twapPrice","type":"uint256"}],"name":"ChiPriceNotPegged","type":"error"},{"inputs":[],"name":"ChiSpotPriceTooBig","type":"error"},{"inputs":[],"name":"ContractIsPaused","type":"error"},{"inputs":[{"internalType":"uint256","name":"deltaETH","type":"uint256"},{"internalType":"uint256","name":"receivedETH","type":"uint256"}],"name":"DeltaBiggerThanAmountReceivedETH","type":"error"},{"inputs":[{"internalType":"uint256","name":"fee","type":"uint256"}],"name":"FeeTooBig","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"NotArbitrager","type":"error"},{"inputs":[],"name":"PriceIsNotPegged","type":"error"},{"inputs":[],"name":"PriceSlippageTooBig","type":"error"},{"inputs":[],"name":"ReserveDiffTooBig","type":"error"},{"inputs":[],"name":"ReserveTxLimitExceeded","type":"error"},{"inputs":[{"internalType":"uint16","name":"_tolerance","type":"uint16"}],"name":"ToleranceTooBig","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"reserveReceived","type":"uint256"},{"indexed":false,"internalType":"address","name":"reserve","type":"address"}],"name":"Burn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"uint256","name":"arbNum","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"deltaUsd","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"reserveDiff","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"ethPrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rewardValue","type":"uint256"}],"name":"ExecuteArbitrage","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"uscAmount","type":"uint256"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RewardUSC","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"chiPriceTolerance","type":"uint16"}],"name":"SetChiPriceTolerance","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"maxMintBurnPriceDiff","type":"uint256"}],"name":"SetMaxMintBurnPriceDiff","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"maxBurnReserveTolerance","type":"uint16"}],"name":"SetMaxMintBurnReserveTolerance","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"mintFee","type":"uint256"}],"name":"SetMintBurnFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"priceTolerance","type":"uint16"}],"name":"SetPriceTolerance","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"reserveAsset","type":"address"},{"indexed":false,"internalType":"uint256","name":"limit","type":"uint256"}],"name":"SetReserveBurnTxLimit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"reserveAsset","type":"address"},{"indexed":false,"internalType":"uint256","name":"limit","type":"uint256"}],"name":"SetReserveMintTxLimit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"bool","name":"status","type":"bool"}],"name":"UpdateArbitrager","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"privileged","type":"address"},{"indexed":false,"internalType":"bool","name":"isPrivileged","type":"bool"}],"name":"UpdatePrivileged","type":"event"},{"inputs":[],"name":"BASE_PRICE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"CHI","outputs":[{"internalType":"contract IArbitrageERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"F","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_FEE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_PRICE_TOLERANCE","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"POOL_FEE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"STETH","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"USC","outputs":[{"internalType":"contract IArbitrageERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"USC_TARGET_PRICE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WETH","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"reserveIn","type":"uint256"},{"internalType":"uint256","name":"priceIn","type":"uint256"},{"internalType":"uint256","name":"reserveOut","type":"uint256"},{"internalType":"uint256","name":"priceOut","type":"uint256"}],"name":"_calculateDelta","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"ethPrice","type":"uint256"}],"name":"_calculateDeltaETH","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"ethPrice","type":"uint256"}],"name":"_calculateDeltaUSC","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_getReservesData","outputs":[{"internalType":"bool","name":"isExcessOfReserves","type":"bool"},{"internalType":"uint256","name":"reserveDiff","type":"uint256"},{"internalType":"uint256","name":"reserveValue","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"reserveToReceive","type":"address"}],"name":"burn","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"burnPaused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"chiPriceTolerance","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20[]","name":"tokens","type":"address[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"name":"claimRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"maxChiSpotPrice","type":"uint256"}],"name":"executeArbitrage","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"maxChiSpotPrice","type":"uint256"},{"components":[{"internalType":"address","name":"reserveAsset","type":"address"},{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"minAmountOut","type":"uint256"}],"internalType":"struct IArbitrageV5.SwapParams[]","name":"swapParams","type":"tuple[]"}],"name":"executeArbitrageWithReserveSell","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getArbitrageData","outputs":[{"internalType":"bool","name":"isPriceAtPeg","type":"bool"},{"internalType":"bool","name":"isPriceAboveTarget","type":"bool"},{"internalType":"bool","name":"isExcessOfReserves","type":"bool"},{"internalType":"uint256","name":"reserveDiff","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isArbitrager","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isPrivileged","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxMintBurnPriceDiff","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxMintBurnReserveTolerance","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"}],"name":"mint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"mint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"mintBurnFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"mintPaused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pegPriceToleranceAbs","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"poolFactory","outputs":[{"internalType":"contract IUniswapV2Factory","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"priceFeedAggregator","outputs":[{"internalType":"contract IPriceFeedAggregator","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"priceTolerance","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"reserveBurnTxLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"reserveHolder","outputs":[{"internalType":"contract IReserveHolderV2","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"reserveMintTxLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"rewardUSC","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"isPaused","type":"bool"}],"name":"setBurnPause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_chiPriceTolerance","type":"uint16"}],"name":"setChiPriceTolerance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxMintBurnPriceDiff","type":"uint256"}],"name":"setMaxMintBurnPriceDiff","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_maxMintBurnReserveTolerance","type":"uint16"}],"name":"setMaxMintBurnReserveTolerance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_mintBurnFee","type":"uint16"}],"name":"setMintBurnFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"isPaused","type":"bool"}],"name":"setMintPause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_priceTolerance","type":"uint256"}],"name":"setPegPriceToleranceAbs","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_priceTolerance","type":"uint16"}],"name":"setPriceTolerance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"reserveAsset","type":"address"},{"internalType":"uint256","name":"limit","type":"uint256"}],"name":"setReserveBurnTxLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_reserveHolder","type":"address"}],"name":"setReserveHolder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"reserveAsset","type":"address"},{"internalType":"uint256","name":"limit","type":"uint256"}],"name":"setReserveMintTxLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"swapRouter","outputs":[{"internalType":"contract IUniswapV2Router02","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalMintedUsc","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"arbitrager","type":"address"},{"internalType":"bool","name":"status","type":"bool"}],"name":"updateArbitrager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bool","name":"status","type":"bool"}],"name":"updatePrivileged","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

60e060405234801561000f575f5ffd5b50604051614ca7380380614ca783398101604081905261002e91610166565b60015f5561003b336100fe565b6001600160a01b0384811660805283811660a05282811660c052600280546001600160a01b03191691831691821790556006805461ffff60301b1916905560405163095ea7b360e01b815260048101919091525f19602482015273ae7ab96520de3a18e5e111b5eaab095312d7fe849063095ea7b3906044016020604051808303815f875af11580156100d0573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906100f491906101c2565b50505050506101e8565b600180546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a35050565b6001600160a01b0381168114610163575f5ffd5b50565b5f5f5f5f60808587031215610179575f5ffd5b84516101848161014f565b60208601519094506101958161014f565b60408601519093506101a68161014f565b60608601519092506101b78161014f565b939692955090935050565b5f602082840312156101d2575f5ffd5b815180151581146101e1575f5ffd5b9392505050565b60805160a05160c0516149766103315f395f81816107df01528181610af4015281816113340152818161167e01528181611c4d01528181611d9c015281816122cb015281816123710152818161273e015281816128490152818161293c0152612a2e01525f81816106710152818161291201528181612f34015281816130e501528181613132015281816131a40152818161345d0152818161349b015281816139f701528181613a440152613aad01525f81816104e201528181610dce015281816116040152818161177c0152818161198801528181611ab401528181611e1601528181611e7c015281816120ac015281816124150152818161271201528181612fd30152818161321d015281816132fc0152818161336601528181613590015281816135fa015281816137f50152818161384401528181613af60152613b4201526149765ff3fe608060405260043610610344575f3560e01c806371f9f1e1116101bd578063c1019b87116100f2578063e00bfe5011610092578063f7bbb2c41161006d578063f7bbb2c414610a14578063f7c7724f14610a33578063f86325ed1461051c578063fcd3533c14610a52575f5ffd5b8063e00bfe50146109a3578063e089bfb0146109ca578063f2fde38b146109f5575f5ffd5b8063cf07ebb9116100cd578063cf07ebb914610922578063d684534e14610941578063dae19cdf14610961578063dd1b9c4a1461098f575f5ffd5b8063c1019b87146108c7578063c31c9c07146108e6578063c3f5640c1461090d575f5ffd5b8063a3658b781161015d578063ada925a611610138578063ada925a61461085f578063bbd48ee51461087e578063bc063e1a14610893578063bc7bf6c2146108a8575f5ffd5b8063a3658b7814610801578063ab59196914610820578063ad5c46481461083f575f5ffd5b80638da5cb5b116101985780638da5cb5b14610773578063971aa174146107905780639a4fc494146107af578063a20b8b4e146107ce575f5ffd5b806371f9f1e1146106f85780637e4831d3146107175780638507fdc314610737575f5ffd5b80633cc0e41f11610293578063668c2e47116102335780636a6278421161020e5780636a627842146106935780636dea228e146106a65780636ec7cbfd146106c5578063715018a6146106e4575f5ffd5b8063668c2e4714610622578063676cfe3f146106415780636a5b266d14610660575f5ffd5b80634403bea31161026e5780634403bea3146105a357806359011cd1146105c25780635b95c482146105e4578063621200a714610603575f5ffd5b80633cc0e41f146105525780633de541b4146105675780634219dc401461057c575f5ffd5b80632618d0ea116102fe57806332bb2fc2116102d957806332bb2fc2146104b157806335b43754146104d15780633848a49e1461051c5780633935e0cb14610533575f5ffd5b80632618d0ea1461044057806328811f591461045f5780632e2326d514610473575f5ffd5b806306c152641461034f57806307d74d10146103705780630d4d1513146103985780630e38012a146103b757806311d978e3146103e857806314ba6c2f14610415575f5ffd5b3661034b57005b5f5ffd5b34801561035a575f5ffd5b5061036e6103693660046142be565b610a71565b005b34801561037b575f5ffd5b5061038560075481565b6040519081526020015b60405180910390f35b3480156103a3575f5ffd5b506103856103b23660046142d9565b610a9b565b3480156103c2575f5ffd5b506103cb610d4f565b60408051931515845260208401929092529082015260600161038f565b3480156103f3575f5ffd5b506006546104029061ffff1681565b60405161ffff909116815260200161038f565b348015610420575f5ffd5b5061038561042f3660046142be565b600a6020525f908152604090205481565b34801561044b575f5ffd5b5061036e61045a366004614318565b610e8b565b34801561046a575f5ffd5b50610385610eeb565b34801561047e575f5ffd5b506104a161048d3660046142be565b60096020525f908152604090205460ff1681565b604051901515815260200161038f565b3480156104bc575f5ffd5b506006546104029062010000900461ffff1681565b3480156104dc575f5ffd5b506105047f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b03909116815260200161038f565b348015610527575f5ffd5b506103856305f5e10081565b34801561053e575f5ffd5b5061036e61054d36600461434f565b610f18565b34801561055d575f5ffd5b5061038560045481565b348015610572575f5ffd5b5061038560055481565b348015610587575f5ffd5b50610504735c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f81565b3480156105ae575f5ffd5b5061036e6105bd36600461436a565b610f42565b3480156105cd575f5ffd5b5060065461040290640100000000900461ffff1681565b3480156105ef575f5ffd5b5061036e6105fe366004614318565b610fd1565b34801561060e575f5ffd5b5061036e61061d36600461436a565b611025565b34801561062d575f5ffd5b5061036e61063c36600461438b565b6110ac565b34801561064c575f5ffd5b5061038561065b3660046143c2565b611113565b34801561066b575f5ffd5b506105047f000000000000000000000000000000000000000000000000000000000000000081565b6103856106a13660046142be565b6112db565b3480156106b1575f5ffd5b5061036e6106c036600461436a565b611558565b3480156106d0575f5ffd5b5061036e6106df3660046143f1565b6115c7565b3480156106ef575f5ffd5b5061036e6115d4565b348015610703575f5ffd5b506103856107123660046143f1565b6115e7565b348015610722575f5ffd5b506006546104a190600160301b900460ff1681565b348015610742575f5ffd5b5061074b61164a565b604080519415158552921515602085015290151591830191909152606082015260800161038f565b34801561077e575f5ffd5b506001546001600160a01b0316610504565b34801561079b575f5ffd5b5061036e6107aa3660046143f1565b61172a565b3480156107ba575f5ffd5b5061036e6107c93660046143f1565b611767565b3480156107d9575f5ffd5b506105047f000000000000000000000000000000000000000000000000000000000000000081565b34801561080c575f5ffd5b5061036e61081b36600461434f565b6117ea565b34801561082b575f5ffd5b5061036e61083a36600461438b565b611813565b34801561084a575f5ffd5b506105045f5160206149015f395f51905f5281565b34801561086a575f5ffd5b50610385610879366004614408565b611872565b348015610889575f5ffd5b5061038560035481565b34801561089e575f5ffd5b5061038561271081565b3480156108b3575f5ffd5b506103856108c23660046143f1565b61196b565b3480156108d2575f5ffd5b5061036e6108e136600461436a565b6119ce565b3480156108f1575f5ffd5b50610504737a250d5630b4cf539739df2c5dacb4c659f2488d81565b348015610918575f5ffd5b5061040261271081565b34801561092d575f5ffd5b5061036e61093c366004614554565b611a47565b34801561094c575f5ffd5b506006546104a190600160381b900460ff1681565b34801561096c575f5ffd5b506104a161097b3660046142be565b60086020525f908152604090205460ff1681565b34801561099a575f5ffd5b50610385601e81565b3480156109ae575f5ffd5b5061050473ae7ab96520de3a18e5e111b5eaab095312d7fe8481565b3480156109d5575f5ffd5b506103856109e43660046142be565b600b6020525f908152604090205481565b348015610a00575f5ffd5b5061036e610a0f3660046142be565b611b25565b348015610a1f575f5ffd5b50600254610504906001600160a01b031681565b348015610a3e575f5ffd5b50610385610a4d3660046143f1565b611b9e565b348015610a5d575f5ffd5b50610385610a6c366004614619565b611bf4565b610a79611fde565b600280546001600160a01b0319166001600160a01b0392909216919091179055565b6006545f90600160301b900460ff1615610ac8576040516306d39fcd60e41b815260040160405180910390fd5b610ad0612038565b604051635677d7d760e11b81525f5160206149015f395f51905f5260048201525f907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063acefafae90602401602060405180830381865afa158015610b41573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610b65919061463c565b90505f610b718261208f565b9050610b84816305f5e100600554612114565b610ba157604051635a3316bd60e01b815260040160405180910390fd5b5f5f610bab610d4f565b6006549194509250610bc69150829061ffff1661271061212a565b821115610be657604051632df452f560e21b815260040160405180910390fd5b6001600160a01b0388165f908152600a602052604090205488908890811115610c2257604051638c6efd1b60e01b815260040160405180910390fd5b5f610c328a60045461271061212a565b90505f610c3f828c614667565b9050610c566001600160a01b038d1633308e61220f565b60025460405163095ea7b360e01b81526001600160a01b038e81169263095ea7b392610c8a9290911690859060040161467a565b6020604051808303815f875af1158015610ca6573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610cca9190614693565b506002546040516311f9fbc960e21b81526001600160a01b03909116906347e7ef2490610cfd908f90859060040161467a565b5f604051808303815f87803b158015610d14575f5ffd5b505af1158015610d26573d5f5f3e3d5ffd5b50505050610d35818d8c612280565b98505050505050505050610d4860015f55565b9392505050565b5f5f5f60025f9054906101000a90046001600160a01b03166001600160a01b031663cfe1f8206040518163ffffffff1660e01b8152600401602060405180830381865afa158015610da2573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610dc6919061463c565b90505f610e567f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e28573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610e4c919061463c565b6305f5e1006124ce565b905080821115610e755760019350610e6e8183614667565b9250610e85565b5f9350610e828282614667565b92505b50909192565b610e93611fde565b6001600160a01b0382165f908152600a602052604090819020829055517f504d7c9ec54de0c057e967947bff6357927d8d6687b88219effdeab3c2da57d590610edf908490849061467a565b60405180910390a15050565b612710610ef9601e82614667565b610f0b90670de0b6b3a76400006146ae565b610f1591906146d9565b81565b610f20611fde565b60068054911515600160381b0267ff0000000000000019909216919091179055565b610f4a611fde565b61271061ffff82161115610f7c5760405163dffed50560e01b815261ffff821660048201526024015b60405180910390fd5b6006805463ffff000019166201000061ffff8416908102919091179091556040519081527f72f06322cd9850d5e3f38df3d71f49bb139bf4560fa5b8331adcd95b7517c028906020015b60405180910390a150565b610fd9611fde565b6001600160a01b0382165f908152600b602052604090819020829055517fe2c87c38ba0c8e7ad3c1ad12624fca8b9a5009cdc8bffd65e17f657374ea9f7290610edf908490849061467a565b61102d611fde565b61271061ffff8216111561105a5760405163dffed50560e01b815261ffff82166004820152602401610f73565b6006805465ffff00000000191664010000000061ffff8416908102919091179091556040519081527fc1220d63647ec1ecc3c185b7d3108ced8d6980e3acea2da15245778cc1b6101490602001610fc6565b6110b4611fde565b6001600160a01b0382165f81815260096020908152604091829020805460ff191685151590811790915591519182527f522c6e1b1db49e41bc2cb162869c03f0e85d2b6812e4369b27c8f61898fc6eb491015b60405180910390a25050565b5f8061116386612710611127601e82614667565b61113990670de0b6b3a76400006146ae565b61114391906146d9565b61115590670de0b6b3a76400006146f8565b670de0b6b3a764000061212a565b90505f6111798283670de0b6b3a764000061212a565b90505f61118f8889670de0b6b3a764000061212a565b90505f6111af6111a88a89670de0b6b3a764000061212a565b878a61212a565b90505f5f82841115611239576111c58385614667565b91505f61120f6127106111d9601e82614667565b6111eb90670de0b6b3a76400006146ae565b6111f591906146d9565b6112009060046146ae565b84670de0b6b3a764000061212a565b905061122361121e8288614667565b6124e2565b61123190633b9aca006146ae565b915050611278565b6112438484614667565b91505f6112576127106111d9601e82614667565b905061126661121e82886146f8565b61127490633b9aca006146ae565b9150505b5f6112c9670de0b6b3a764000061128f8985614667565b61271061129d601e82614667565b6112af90670de0b6b3a76400006146ae565b6112b991906146d9565b6112c49060026146ae565b61212a565b9750505050505050505b949350505050565b6006545f90600160301b900460ff1615611308576040516306d39fcd60e41b815260040160405180910390fd5b611310612038565b604051635677d7d760e11b81525f5160206149015f395f51905f5260048201525f907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063acefafae90602401602060405180830381865afa158015611381573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906113a5919061463c565b90505f6113b18261208f565b90506113c4816305f5e100600554612114565b6113e157604051635a3316bd60e01b815260040160405180910390fd5b5f5f6113eb610d4f565b60065491945092506114069150829061ffff1661271061212a565b82111561142657604051632df452f560e21b815260040160405180910390fd5b5f5160206149015f395f51905f525f819052600a6020527fd0bcf4df132c65dad73803c5e5e1c826f151a3342680034a8a4c8e5f8eb0c13c54349081111561148157604051638c6efd1b60e01b815260040160405180910390fd5b5f3490505f6114958260045461271061212a565b90505f6114a28284614667565b90505f5160206149015f395f51905f526001600160a01b031663d0e30db0846040518263ffffffff1660e01b81526004015f604051808303818588803b1580156114ea575f5ffd5b505af11580156114fc573d5f5f3e3d5ffd5b505060025461152793505f5160206149015f395f51905f5292506001600160a01b03169050836125c6565b61153f815f5160206149015f395f51905f528d612280565b995050505050505050505061155360015f55565b919050565b611560611fde565b6127108161ffff16111561158d57604051631e57e2d960e21b815261ffff82166004820152602401610f73565b61ffff811660048190556040519081527fd446502274520c2290d33d7ee138d6d8e74167ab863258c6e296c5b529e2c66d90602001610fc6565b6115cf611fde565b600355565b6115dc611fde565b6115e55f6125e5565b565b5f5f5f611636735c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f7f00000000000000000000000000000000000000000000000000000000000000005f5160206149015f395f51905f52612636565b915091506112d3826305f5e1008387611113565b604051635677d7d760e11b81525f5160206149015f395f51905f5260048201525f9081908190819081906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063acefafae90602401602060405180830381865afa1580156116c3573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906116e7919061463c565b90505f6116f3826126fb565b90505f6116fe610d4f565b6003546305f5e100808710159a50939850919650925061171f918491612114565b965050505090919293565b611732611fde565b60058190556040518181527fffb4f4d29733d0f5d83cf9ff992fbdd36cd9f17a57e4871ff763ac812ffaffc590602001610fc6565b61176f611fde565b6117a46001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001633308461220f565b8060075f8282546117b591906146f8565b90915550506040518181527febb72640566415c6a28dfdb80b483e6c75bad975887046ebab0f517d9457154c90602001610fc6565b6117f2611fde565b60068054911515600160301b0266ff00000000000019909216919091179055565b61181b611fde565b6001600160a01b0382165f81815260086020908152604091829020805460ff191685151590811790915591519182527f720533d44efb0342f5ab7b8fd10f7613c72680e643a7094b63d5016367b85fcf9101611107565b5f805b82811015611961576002546001600160a01b031663b964730c8585848181106118a0576118a061470b565b6118b692602060609092020190810191506142be565b8686858181106118c8576118c861470b565b905060600201602001358787868181106118e4576118e461470b565b905060600201604001356040518463ffffffff1660e01b8152600401611928939291906001600160a01b039390931683526020830191909152604082015260600190565b5f604051808303815f87803b15801561193f575f5ffd5b505af1158015611951573d5f5f3e3d5ffd5b5050600190920191506118759050565b506112d384611b9e565b5f5f5f6119ba735c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f7f00000000000000000000000000000000000000000000000000000000000000005f5160206149015f395f51905f52612636565b915091506112d38185846305f5e100611113565b6119d6611fde565b61271061ffff82161115611a035760405163dffed50560e01b815261ffff82166004820152602401610f73565b6006805461ffff191661ffff83169081179091556040519081527fb92548ef8e4a660d447901ae49a0f4d61d9d192dc471290dd0a524a4e9993a1e90602001610fc6565b611a4f611fde565b5f5b8251811015611b20575f838281518110611a6d57611a6d61470b565b602002602001015190505f838381518110611a8a57611a8a61470b565b60200260200101519050611ab23382846001600160a01b03166125c69092919063ffffffff16565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b031603611b1657600754811015611b11578060075f828254611b069190614667565b90915550611b169050565b5f6007555b5050600101611a51565b505050565b611b2d611fde565b6001600160a01b038116611b925760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610f73565b611b9b816125e5565b50565b5f611ba7612038565b335f9081526008602052604090205460ff16611bd857604051639ce9e4d160e01b8152336004820152602401610f73565b611be18261280f565b611be96129eb565b905061155360015f55565b6006545f90600160381b900460ff1615611c21576040516306d39fcd60e41b815260040160405180910390fd5b611c29612038565b604051635677d7d760e11b81525f5160206149015f395f51905f5260048201525f907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063acefafae90602401602060405180830381865afa158015611c9a573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611cbe919061463c565b90505f611cca8261208f565b9050611cdd816305f5e100600554612114565b611cfa57604051635a3316bd60e01b815260040160405180910390fd5b5f5f611d04610d4f565b6006549194509250611d1f9150829061ffff1661271061212a565b821115611d3f57604051632df452f560e21b815260040160405180910390fd5b6001600160a01b0386165f908152600b602052604090205486908890811115611d7b57604051638c6efd1b60e01b815260040160405180910390fd5b604051635677d7d760e11b81526001600160a01b0389811660048301525f917f00000000000000000000000000000000000000000000000000000000000000009091169063acefafae90602401602060405180830381865afa158015611de3573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611e07919061463c565b9050611e3e6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001633308d61220f565b6127106004548b611e4f91906146ae565b611e5991906146d9565b611e63908b614667565b604051630852cd8d60e31b815260048101829052909a507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906342966c68906024015f604051808303815f87803b158015611ec5575f5ffd5b505af1158015611ed7573d5f5f3e3d5ffd5b505050505f611eeb8b6305f5e1008461212a565b600254604051633def417960e11b8152600481018390526001600160a01b038d81166024830152929350911690637bde82f2906044016020604051808303815f875af1158015611f3d573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611f61919061463c565b50611f766001600160a01b038b1633836125c6565b60408051338152602081018d90529081018290526001600160a01b038b1660608201527fdccd412f0b1252819cb1fd330b93224ca42612892bb3f4f789976e6d819364969060800160405180910390a1975050505050505050611fd860015f55565b92915050565b6001546001600160a01b031633146115e55760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610f73565b60025f54036120895760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610f73565b60025f55565b5f5f5f6120de735c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f7f00000000000000000000000000000000000000000000000000000000000000005f5160206149015f395f51905f52612636565b915091505f6120f6670de0b6b3a76400008385612afd565b905061210b85670de0b6b3a76400008361212a565b95945050505050565b5f816121208585612b9a565b1115949350505050565b5f80805f19858709858702925082811083820303915050805f0361216157838281612157576121576146c5565b0492505050610d48565b8084116121a85760405162461bcd60e51b81526020600482015260156024820152744d6174683a206d756c446976206f766572666c6f7760581b6044820152606401610f73565b5f8486880960026001871981018816978890046003810283188082028403028082028403028082028403028082028403028082028403029081029092039091025f889003889004909101858311909403939093029303949094049190911702949350505050565b6040516001600160a01b038085166024830152831660448201526064810182905261227a9085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612bbb565b50505050565b5f8073c02aaa39b223fe8d0a0e5c4f27ead9083c756cc1196001600160a01b0385160161235057604051635677d7d760e11b81525f5160206149015f395f51905f5260048201525f907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063acefafae90602401602060405180830381865afa158015612318573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061233c919061463c565b905061234886826124ce565b9150506123ec565b604051635677d7d760e11b81526001600160a01b0385811660048301525f917f00000000000000000000000000000000000000000000000000000000000000009091169063acefafae90602401602060405180830381865afa1580156123b8573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906123dc919061463c565b90506123e886826124ce565b9150505b5f6123fb826305f5e100612c8e565b6040516340c10f1960e01b81529091506001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906340c10f199061244c908790859060040161467a565b5f604051808303815f87803b158015612463575f5ffd5b505af1158015612475573d5f5f3e3d5ffd5b5050604080516001600160a01b0389168152602081018a90529081018490523392507f2f00e3cdd69a77be7ed215ec7b2a36784dd158f921fca79ac29deffa353fe6ee915060600160405180910390a295945050505050565b5f610d488383670de0b6b3a764000061212a565b5f815f036124f157505f919050565b5f60016124fd84612ca2565b901c6001901b90506001818481612516576125166146c5565b048201901c9050600181848161252e5761252e6146c5565b048201901c90506001818481612546576125466146c5565b048201901c9050600181848161255e5761255e6146c5565b048201901c90506001818481612576576125766146c5565b048201901c9050600181848161258e5761258e6146c5565b048201901c905060018184816125a6576125a66146c5565b048201901c9050610d48818285816125c0576125c06146c5565b04612d35565b611b208363a9059cbb60e01b848460405160240161224392919061467a565b600180546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a35050565b5f5f5f6126438585612d4a565b5090505f5f612653888888612e40565b6001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa15801561268e573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906126b29190614735565b506001600160701b031691506001600160701b03169150826001600160a01b0316876001600160a01b0316146126e95780826126ec565b81815b90999098509650505050505050565b604051635677d7d760e11b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811660048301525f9182917f0000000000000000000000000000000000000000000000000000000000000000169063acefafae90602401602060405180830381865afa158015612783573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906127a7919061463c565b90505f6127b38461208f565b90505f6127c08284612b9a565b6006549091505f906127e2908590640100000000900461ffff1661271061212a565b90508082111561280557604051636d0bc11760e01b815260040160405180910390fd5b5090949350505050565b335f9081526009602052604090205460ff16611b9b57604051635677d7d760e11b81525f5160206149015f395f51905f5260048201525f907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063acefafae90602401602060405180830381865afa158015612896573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906128ba919061463c565b90505f6128c682612f17565b905082158015906128d657508281115b156128f45760405163202bf84160e11b815260040160405180910390fd5b825f03611b2057604051635677d7d760e11b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811660048301525f917f00000000000000000000000000000000000000000000000000000000000000009091169063acefafae90602401602060405180830381865afa158015612983573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906129a7919061463c565b6006549091506129c4908390839062010000900461ffff16612f66565b61227a57604051637d898ce960e11b81526004810183905260248101829052604401610f73565b5f5f5f5f5f6129f861164a565b604051635677d7d760e11b81525f5160206149015f395f51905f526004820152939750919550935091505f906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063acefafae90602401602060405180830381865afa158015612a73573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612a97919061463c565b90508415612ac3578215612ab957612aaf8282612fa9565b9550505050505090565b612aaf828261308e565b8315612ae3578215612ad957612aaf82826132d7565b612aaf828261356b565b8215612af357612aaf82826136fe565b612aaf8282613915565b5f5f8411612b5b5760405162461bcd60e51b815260206004820152602560248201527f556e697377617056324c6962726172793a20494e53554646494349454e545f416044820152641353d5539560da1b6064820152608401610f73565b5f83118015612b6957505f82115b612b855760405162461bcd60e51b8152600401610f7390614776565b82612b908584613c09565b6112d391906146d9565b5f818311612bb157612bac8383614667565b610d48565b610d488284614667565b5f612c0f826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613c6f9092919063ffffffff16565b905080515f1480612c2f575080806020019051810190612c2f9190614693565b611b205760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610f73565b5f610d4883670de0b6b3a76400008461212a565b5f80608083901c15612cb657608092831c92015b604083901c15612cc857604092831c92015b602083901c15612cda57602092831c92015b601083901c15612cec57601092831c92015b600883901c15612cfe57600892831c92015b600483901c15612d1057600492831c92015b600283901c15612d2257600292831c92015b600183901c15611fd85760010192915050565b5f818310612d435781610d48565b5090919050565b5f5f826001600160a01b0316846001600160a01b031603612dbb5760405162461bcd60e51b815260206004820152602560248201527f556e697377617056324c6962726172793a204944454e544943414c5f41444452604482015264455353455360d81b6064820152608401610f73565b826001600160a01b0316846001600160a01b031610612ddb578284612dde565b83835b90925090506001600160a01b038216612e395760405162461bcd60e51b815260206004820152601e60248201527f556e697377617056324c6962726172793a205a45524f5f4144445245535300006044820152606401610f73565b9250929050565b5f5f5f612e4d8585612d4a565b6040516bffffffffffffffffffffffff19606084811b8216602084015283901b1660348201529193509150869060480160405160208183030381529060405280519060200120604051602001612ef59291906001600160f81b0319815260609290921b6bffffffffffffffffffffffff1916600183015260158201527f96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f603582015260550190565b60408051601f1981840301815291905280516020909101209695505050505050565b5f5f5f6120de735c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f7f00000000000000000000000000000000000000000000000000000000000000005f5160206149015f395f51905f52612636565b5f5f5f848611612f77578486612f7a565b85855b90925090505f612f8a8284614667565b90505f612f9a848761271061212a565b90911115979650505050505050565b5f5f612fb9846305f5e100612c8e565b6040516340c10f1960e01b81529091506001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906340c10f199061300a903090859060040161467a565b5f604051808303815f87803b158015613021575f5ffd5b505af1158015613033573d5f5f3e3d5ffd5b505050508060075f82825461304891906146f8565b9091555050604080515f808252602082018790528183018690526060820152905160059133915f5160206149215f395f51905f529181900360800190a3505f9392505050565b5f5f61309e846305f5e100612c8e565b90505f5f6007548311156130d35760075491505f6130bf610e4c8486614667565b90506130cb8187612c8e565b9150506130d9565b508190505f5b5f811561311b576131187f00000000000000000000000000000000000000000000000000000000000000005f5160206149015f395f51905f5284613c7d565b90505b6040516340c10f1960e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906340c10f1990613169903090859060040161467a565b5f604051808303815f87803b158015613180575f5ffd5b505af1158015613192573d5f5f3e3d5ffd5b505050505f821115613201575f6131d77f00000000000000000000000000000000000000000000000000000000000000005f5160206149015f395f51905f5284613cb8565b6002549091506131ff905f5160206149015f395f51905f52906001600160a01b0316836125c6565b505b821561329357604051630852cd8d60e31b8152600481018490527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906342966c68906024015f604051808303815f87803b158015613266575f5ffd5b505af1158015613278573d5f5f3e3d5ffd5b505050508260075f82825461328d9190614667565b90915550505b604080515f808252602082018a90528183018990526060820152905160069133915f5160206149215f395f51905f529181900360800190a3505f9695505050505050565b5f5f6132e2836115e7565b6040516340c10f1960e01b81529091506001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906340c10f1990613333903090859060040161467a565b5f604051808303815f87803b15801561334a575f5ffd5b505af115801561335c573d5f5f3e3d5ffd5b505050505f6133997f00000000000000000000000000000000000000000000000000000000000000005f5160206149015f395f51905f5284613cb8565b90505f6133aa836305f5e1006124ce565b90505f6133b78287612c8e565b9050828111156133e45760405163318bf40560e11b81526004810182905260248101849052604401610f73565b5f5f8884111561343c576133f88989612c8e565b915081613405858a612c8e565b61340f9190614667565b600254909150613437905f5160206149015f395f51905f52906001600160a01b0316836125c6565b613449565b6134468489612c8e565b91505b5f6134825f5160206149015f395f51905f527f000000000000000000000000000000000000000000000000000000000000000085613cb8565b604051630852cd8d60e31b8152600481018290529091507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906342966c68906024015f604051808303815f87803b1580156134e4575f5ffd5b505af11580156134f6573d5f5f3e3d5ffd5b505050505f8284886135089190614667565b6135129190614667565b90505f61351f828c6124ce565b60408051898152602081018f90529081018d90526060810182905290915060019033905f5160206149215f395f51905f529060800160405180910390a39b9a5050505050505050505050565b5f5f613576836115e7565b6040516340c10f1960e01b81529091506001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906340c10f19906135c7903090859060040161467a565b5f604051808303815f87803b1580156135de575f5ffd5b505af11580156135f0573d5f5f3e3d5ffd5b505050505f61362d7f00000000000000000000000000000000000000000000000000000000000000005f5160206149015f395f51905f5284613cb8565b90505f61363e836305f5e1006124ce565b90505f61364b8287612c8e565b9050828111156136785760405163318bf40560e11b81526004810182905260248101849052604401610f73565b60025461369d905f5160206149015f395f51905f52906001600160a01b0316836125c6565b5f6136a88285614667565b90505f6136b582896124ce565b60408051868152602081018c90529081018a90526060810182905290915060029033905f5160206149215f395f51905f529060800160405180910390a398975050505050505050565b5f5f5f5f61370b8561196b565b90505f61371882876124ce565b90508681111561375057613730876305f5e100612c8e565b935061374961373f8883614667565b6305f5e100612c8e565b9250613761565b61375e816305f5e100612c8e565b93505b600254604051633def417960e11b8152600481018490525f5160206149015f395f51905f5260248201526001600160a01b0390911690637bde82f2906044016020604051808303815f875af11580156137bc573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906137e0919061463c565b505f61381a5f5160206149015f395f51905f527f000000000000000000000000000000000000000000000000000000000000000085613cb8565b905084811015613828578094505b83156138a457604051630852cd8d60e31b8152600481018590527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906342966c68906024015f604051808303815f87803b15801561388d575f5ffd5b505af115801561389f573d5f5f3e3d5ffd5b505050505b5f846138b08784614667565b6138ba9190614667565b90505f6138cb826305f5e1006124ce565b60408051868152602081018d90529081018b90526060810182905290915060039033905f5160206149215f395f51905f529060800160405180910390a39998505050505050505050565b5f5f5f5f6139228561196b565b90505f61392f82876124ce565b9050868111156139d5576139438787612c8e565b925061394f8383614667565b600254604051633def417960e11b8152600481018390525f5160206149015f395f51905f5260248201529195506001600160a01b031690637bde82f2906044016020604051808303815f875af11580156139ab573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906139cf919061463c565b506139d9565b8192505b5f6139e8826305f5e100612c8e565b90505f8415613ae3575f613a2a7f00000000000000000000000000000000000000000000000000000000000000005f5160206149015f395f51905f5288613c7d565b6040516340c10f1960e01b81529091506001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906340c10f1990613a7b903090859060040161467a565b5f604051808303815f87803b158015613a92575f5ffd5b505af1158015613aa4573d5f5f3e3d5ffd5b50505050613ae07f00000000000000000000000000000000000000000000000000000000000000005f5160206149015f395f51905f5283613cb8565b50505b613b245f5160206149015f395f51905f527f0000000000000000000000000000000000000000000000000000000000000000613b1f89896146f8565b613cb8565b90508115613ba257604051630852cd8d60e31b8152600481018390527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906342966c68906024015f604051808303815f87803b158015613b8b575f5ffd5b505af1158015613b9d573d5f5f3e3d5ffd5b505050505b5f613bad8383614667565b90505f613bbe826305f5e1006124ce565b60408051878152602081018e90529081018c90526060810182905290915060049033905f5160206149215f395f51905f529060800160405180910390a39a9950505050505050505050565b5f811580613c2c57508282613c1e81836146ae565b9250613c2a90836146d9565b145b611fd85760405162461bcd60e51b815260206004820152601460248201527364732d6d6174682d6d756c2d6f766572666c6f7760601b6044820152606401610f73565b60606112d384845f85613e67565b5f5f5f613c9f735c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f8787612636565b91509150613cae848383613f3e565b9695505050505050565b5f60606001600160a01b0385165f5160206149015f395f51905f5214801590613cf757506001600160a01b0384165f5160206149015f395f51905f5214155b15613d1b57613d14855f5160206149015f395f51905f528661400e565b9050613d28565b613d2585856140d2565b90505b60405163095ea7b360e01b81526001600160a01b0386169063095ea7b390613d6a90737a250d5630b4cf539739df2c5dacb4c659f2488d90879060040161467a565b6020604051808303815f875af1158015613d86573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190613daa9190614693565b506040516338ed173960e01b81525f90737a250d5630b4cf539739df2c5dacb4c659f2488d906338ed173990613dec90879085908790309042906004016147be565b5f604051808303815f875af1158015613e07573d5f5f3e3d5ffd5b505050506040513d5f823e601f3d908101601f19168201604052613e2e919081019061482e565b90505f8160018451613e409190614667565b81518110613e5057613e5061470b565b602002602001015190508093505050509392505050565b606082471015613ec85760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610f73565b5f5f866001600160a01b03168587604051613ee391906148b5565b5f6040518083038185875af1925050503d805f8114613f1d576040519150601f19603f3d011682016040523d82523d5f602084013e613f22565b606091505b5091509150613f338783838761415f565b979650505050505050565b5f5f8411613fa35760405162461bcd60e51b815260206004820152602c60248201527f556e697377617056324c6962726172793a20494e53554646494349454e545f4f60448201526b155514155517d05353d5539560a21b6064820152608401610f73565b5f83118015613fb157505f82115b613fcd5760405162461bcd60e51b8152600401610f7390614776565b5f613fe46103e8613fde8688613c09565b90613c09565b90505f613ff76103e5613fde86896141d7565b9050613cae600161400883856146d9565b9061422c565b6040805160038082526080820190925260609160208201838036833701905050905083815f815181106140435761404361470b565b60200260200101906001600160a01b031690816001600160a01b03168152505082816001815181106140775761407761470b565b60200260200101906001600160a01b031690816001600160a01b03168152505081816002815181106140ab576140ab61470b565b60200260200101906001600160a01b031690816001600160a01b0316815250509392505050565b604080516002808252606080830184529260208301908036833701905050905082815f815181106141055761410561470b565b60200260200101906001600160a01b031690816001600160a01b03168152505081816001815181106141395761413961470b565b60200260200101906001600160a01b031690816001600160a01b03168152505092915050565b606083156141cd5782515f036141c6576001600160a01b0385163b6141c65760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610f73565b50816112d3565b6112d38383614280565b5f826141e38382614667565b9150811115611fd85760405162461bcd60e51b815260206004820152601560248201527464732d6d6174682d7375622d756e646572666c6f7760581b6044820152606401610f73565b5f8261423883826146f8565b9150811015611fd85760405162461bcd60e51b815260206004820152601460248201527364732d6d6174682d6164642d6f766572666c6f7760601b6044820152606401610f73565b8151156142905781518083602001fd5b8060405162461bcd60e51b8152600401610f7391906148cb565b6001600160a01b0381168114611b9b575f5ffd5b5f602082840312156142ce575f5ffd5b8135610d48816142aa565b5f5f5f606084860312156142eb575f5ffd5b83356142f6816142aa565b925060208401359150604084013561430d816142aa565b809150509250925092565b5f5f60408385031215614329575f5ffd5b8235614334816142aa565b946020939093013593505050565b8015158114611b9b575f5ffd5b5f6020828403121561435f575f5ffd5b8135610d4881614342565b5f6020828403121561437a575f5ffd5b813561ffff81168114610d48575f5ffd5b5f5f6040838503121561439c575f5ffd5b82356143a7816142aa565b915060208301356143b781614342565b809150509250929050565b5f5f5f5f608085870312156143d5575f5ffd5b5050823594602084013594506040840135936060013592509050565b5f60208284031215614401575f5ffd5b5035919050565b5f5f5f6040848603121561441a575f5ffd5b83359250602084013567ffffffffffffffff811115614437575f5ffd5b8401601f81018613614447575f5ffd5b803567ffffffffffffffff81111561445d575f5ffd5b866020606083028401011115614471575f5ffd5b939660209190910195509293505050565b634e487b7160e01b5f52604160045260245ffd5b604051601f8201601f1916810167ffffffffffffffff811182821017156144bf576144bf614482565b604052919050565b5f67ffffffffffffffff8211156144e0576144e0614482565b5060051b60200190565b5f82601f8301126144f9575f5ffd5b813561450c614507826144c7565b614496565b8082825260208201915060208360051b86010192508583111561452d575f5ffd5b602085015b8381101561454a578035835260209283019201614532565b5095945050505050565b5f5f60408385031215614565575f5ffd5b823567ffffffffffffffff81111561457b575f5ffd5b8301601f8101851361458b575f5ffd5b8035614599614507826144c7565b8082825260208201915060208360051b8501019250878311156145ba575f5ffd5b6020840193505b828410156145e55783356145d4816142aa565b8252602093840193909101906145c1565b9450505050602083013567ffffffffffffffff811115614603575f5ffd5b61460f858286016144ea565b9150509250929050565b5f5f6040838503121561462a575f5ffd5b8235915060208301356143b7816142aa565b5f6020828403121561464c575f5ffd5b5051919050565b634e487b7160e01b5f52601160045260245ffd5b81810381811115611fd857611fd8614653565b6001600160a01b03929092168252602082015260400190565b5f602082840312156146a3575f5ffd5b8151610d4881614342565b8082028115828204841417611fd857611fd8614653565b634e487b7160e01b5f52601260045260245ffd5b5f826146f357634e487b7160e01b5f52601260045260245ffd5b500490565b80820180821115611fd857611fd8614653565b634e487b7160e01b5f52603260045260245ffd5b80516001600160701b0381168114611553575f5ffd5b5f5f5f60608486031215614747575f5ffd5b6147508461471f565b925061475e6020850161471f565b9150604084015163ffffffff8116811461430d575f5ffd5b60208082526028908201527f556e697377617056324c6962726172793a20494e53554646494349454e545f4c604082015267495155494449545960c01b606082015260800190565b5f60a0820187835286602084015260a0604084015280865180835260c0850191506020880192505f5b8181101561480e5783516001600160a01b03168352602093840193909201916001016147e7565b50506001600160a01b039590951660608401525050608001529392505050565b5f6020828403121561483e575f5ffd5b815167ffffffffffffffff811115614854575f5ffd5b8201601f81018413614864575f5ffd5b8051614872614507826144c7565b8082825260208201915060208360051b850101925086831115614893575f5ffd5b6020840193505b82841015613cae57835182526020938401939091019061489a565b5f82518060208501845e5f920191825250919050565b602081525f82518060208401528060208501604085015e5f604082850101526040601f19601f8301168401019150509291505056fe000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc29bfff6dfb60cbb64c69905e709aa9b3fa7ceeeff847205dd3caa324ab30f962ea26469706673582212209babe95732df3796851a07812e6f59c9fed6e66c59e8402ba94e27e6286fc99d64736f6c634300081c003300000000000000000000000038547d918b9645f2d94336b6b61aeb08053e142c0000000000000000000000003b21418081528845a6df4e970bd2185545b712ba000000000000000000000000b3a36232ecc1da6c8d0d3f417e00406566933bd0000000000000000000000000037528457cf5b0b9dab641fd7f0ce8fc9690318d

Deployed Bytecode

0x608060405260043610610344575f3560e01c806371f9f1e1116101bd578063c1019b87116100f2578063e00bfe5011610092578063f7bbb2c41161006d578063f7bbb2c414610a14578063f7c7724f14610a33578063f86325ed1461051c578063fcd3533c14610a52575f5ffd5b8063e00bfe50146109a3578063e089bfb0146109ca578063f2fde38b146109f5575f5ffd5b8063cf07ebb9116100cd578063cf07ebb914610922578063d684534e14610941578063dae19cdf14610961578063dd1b9c4a1461098f575f5ffd5b8063c1019b87146108c7578063c31c9c07146108e6578063c3f5640c1461090d575f5ffd5b8063a3658b781161015d578063ada925a611610138578063ada925a61461085f578063bbd48ee51461087e578063bc063e1a14610893578063bc7bf6c2146108a8575f5ffd5b8063a3658b7814610801578063ab59196914610820578063ad5c46481461083f575f5ffd5b80638da5cb5b116101985780638da5cb5b14610773578063971aa174146107905780639a4fc494146107af578063a20b8b4e146107ce575f5ffd5b806371f9f1e1146106f85780637e4831d3146107175780638507fdc314610737575f5ffd5b80633cc0e41f11610293578063668c2e47116102335780636a6278421161020e5780636a627842146106935780636dea228e146106a65780636ec7cbfd146106c5578063715018a6146106e4575f5ffd5b8063668c2e4714610622578063676cfe3f146106415780636a5b266d14610660575f5ffd5b80634403bea31161026e5780634403bea3146105a357806359011cd1146105c25780635b95c482146105e4578063621200a714610603575f5ffd5b80633cc0e41f146105525780633de541b4146105675780634219dc401461057c575f5ffd5b80632618d0ea116102fe57806332bb2fc2116102d957806332bb2fc2146104b157806335b43754146104d15780633848a49e1461051c5780633935e0cb14610533575f5ffd5b80632618d0ea1461044057806328811f591461045f5780632e2326d514610473575f5ffd5b806306c152641461034f57806307d74d10146103705780630d4d1513146103985780630e38012a146103b757806311d978e3146103e857806314ba6c2f14610415575f5ffd5b3661034b57005b5f5ffd5b34801561035a575f5ffd5b5061036e6103693660046142be565b610a71565b005b34801561037b575f5ffd5b5061038560075481565b6040519081526020015b60405180910390f35b3480156103a3575f5ffd5b506103856103b23660046142d9565b610a9b565b3480156103c2575f5ffd5b506103cb610d4f565b60408051931515845260208401929092529082015260600161038f565b3480156103f3575f5ffd5b506006546104029061ffff1681565b60405161ffff909116815260200161038f565b348015610420575f5ffd5b5061038561042f3660046142be565b600a6020525f908152604090205481565b34801561044b575f5ffd5b5061036e61045a366004614318565b610e8b565b34801561046a575f5ffd5b50610385610eeb565b34801561047e575f5ffd5b506104a161048d3660046142be565b60096020525f908152604090205460ff1681565b604051901515815260200161038f565b3480156104bc575f5ffd5b506006546104029062010000900461ffff1681565b3480156104dc575f5ffd5b506105047f00000000000000000000000038547d918b9645f2d94336b6b61aeb08053e142c81565b6040516001600160a01b03909116815260200161038f565b348015610527575f5ffd5b506103856305f5e10081565b34801561053e575f5ffd5b5061036e61054d36600461434f565b610f18565b34801561055d575f5ffd5b5061038560045481565b348015610572575f5ffd5b5061038560055481565b348015610587575f5ffd5b50610504735c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f81565b3480156105ae575f5ffd5b5061036e6105bd36600461436a565b610f42565b3480156105cd575f5ffd5b5060065461040290640100000000900461ffff1681565b3480156105ef575f5ffd5b5061036e6105fe366004614318565b610fd1565b34801561060e575f5ffd5b5061036e61061d36600461436a565b611025565b34801561062d575f5ffd5b5061036e61063c36600461438b565b6110ac565b34801561064c575f5ffd5b5061038561065b3660046143c2565b611113565b34801561066b575f5ffd5b506105047f0000000000000000000000003b21418081528845a6df4e970bd2185545b712ba81565b6103856106a13660046142be565b6112db565b3480156106b1575f5ffd5b5061036e6106c036600461436a565b611558565b3480156106d0575f5ffd5b5061036e6106df3660046143f1565b6115c7565b3480156106ef575f5ffd5b5061036e6115d4565b348015610703575f5ffd5b506103856107123660046143f1565b6115e7565b348015610722575f5ffd5b506006546104a190600160301b900460ff1681565b348015610742575f5ffd5b5061074b61164a565b604080519415158552921515602085015290151591830191909152606082015260800161038f565b34801561077e575f5ffd5b506001546001600160a01b0316610504565b34801561079b575f5ffd5b5061036e6107aa3660046143f1565b61172a565b3480156107ba575f5ffd5b5061036e6107c93660046143f1565b611767565b3480156107d9575f5ffd5b506105047f000000000000000000000000b3a36232ecc1da6c8d0d3f417e00406566933bd081565b34801561080c575f5ffd5b5061036e61081b36600461434f565b6117ea565b34801561082b575f5ffd5b5061036e61083a36600461438b565b611813565b34801561084a575f5ffd5b506105045f5160206149015f395f51905f5281565b34801561086a575f5ffd5b50610385610879366004614408565b611872565b348015610889575f5ffd5b5061038560035481565b34801561089e575f5ffd5b5061038561271081565b3480156108b3575f5ffd5b506103856108c23660046143f1565b61196b565b3480156108d2575f5ffd5b5061036e6108e136600461436a565b6119ce565b3480156108f1575f5ffd5b50610504737a250d5630b4cf539739df2c5dacb4c659f2488d81565b348015610918575f5ffd5b5061040261271081565b34801561092d575f5ffd5b5061036e61093c366004614554565b611a47565b34801561094c575f5ffd5b506006546104a190600160381b900460ff1681565b34801561096c575f5ffd5b506104a161097b3660046142be565b60086020525f908152604090205460ff1681565b34801561099a575f5ffd5b50610385601e81565b3480156109ae575f5ffd5b5061050473ae7ab96520de3a18e5e111b5eaab095312d7fe8481565b3480156109d5575f5ffd5b506103856109e43660046142be565b600b6020525f908152604090205481565b348015610a00575f5ffd5b5061036e610a0f3660046142be565b611b25565b348015610a1f575f5ffd5b50600254610504906001600160a01b031681565b348015610a3e575f5ffd5b50610385610a4d3660046143f1565b611b9e565b348015610a5d575f5ffd5b50610385610a6c366004614619565b611bf4565b610a79611fde565b600280546001600160a01b0319166001600160a01b0392909216919091179055565b6006545f90600160301b900460ff1615610ac8576040516306d39fcd60e41b815260040160405180910390fd5b610ad0612038565b604051635677d7d760e11b81525f5160206149015f395f51905f5260048201525f907f000000000000000000000000b3a36232ecc1da6c8d0d3f417e00406566933bd06001600160a01b03169063acefafae90602401602060405180830381865afa158015610b41573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610b65919061463c565b90505f610b718261208f565b9050610b84816305f5e100600554612114565b610ba157604051635a3316bd60e01b815260040160405180910390fd5b5f5f610bab610d4f565b6006549194509250610bc69150829061ffff1661271061212a565b821115610be657604051632df452f560e21b815260040160405180910390fd5b6001600160a01b0388165f908152600a602052604090205488908890811115610c2257604051638c6efd1b60e01b815260040160405180910390fd5b5f610c328a60045461271061212a565b90505f610c3f828c614667565b9050610c566001600160a01b038d1633308e61220f565b60025460405163095ea7b360e01b81526001600160a01b038e81169263095ea7b392610c8a9290911690859060040161467a565b6020604051808303815f875af1158015610ca6573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610cca9190614693565b506002546040516311f9fbc960e21b81526001600160a01b03909116906347e7ef2490610cfd908f90859060040161467a565b5f604051808303815f87803b158015610d14575f5ffd5b505af1158015610d26573d5f5f3e3d5ffd5b50505050610d35818d8c612280565b98505050505050505050610d4860015f55565b9392505050565b5f5f5f60025f9054906101000a90046001600160a01b03166001600160a01b031663cfe1f8206040518163ffffffff1660e01b8152600401602060405180830381865afa158015610da2573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610dc6919061463c565b90505f610e567f00000000000000000000000038547d918b9645f2d94336b6b61aeb08053e142c6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e28573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610e4c919061463c565b6305f5e1006124ce565b905080821115610e755760019350610e6e8183614667565b9250610e85565b5f9350610e828282614667565b92505b50909192565b610e93611fde565b6001600160a01b0382165f908152600a602052604090819020829055517f504d7c9ec54de0c057e967947bff6357927d8d6687b88219effdeab3c2da57d590610edf908490849061467a565b60405180910390a15050565b612710610ef9601e82614667565b610f0b90670de0b6b3a76400006146ae565b610f1591906146d9565b81565b610f20611fde565b60068054911515600160381b0267ff0000000000000019909216919091179055565b610f4a611fde565b61271061ffff82161115610f7c5760405163dffed50560e01b815261ffff821660048201526024015b60405180910390fd5b6006805463ffff000019166201000061ffff8416908102919091179091556040519081527f72f06322cd9850d5e3f38df3d71f49bb139bf4560fa5b8331adcd95b7517c028906020015b60405180910390a150565b610fd9611fde565b6001600160a01b0382165f908152600b602052604090819020829055517fe2c87c38ba0c8e7ad3c1ad12624fca8b9a5009cdc8bffd65e17f657374ea9f7290610edf908490849061467a565b61102d611fde565b61271061ffff8216111561105a5760405163dffed50560e01b815261ffff82166004820152602401610f73565b6006805465ffff00000000191664010000000061ffff8416908102919091179091556040519081527fc1220d63647ec1ecc3c185b7d3108ced8d6980e3acea2da15245778cc1b6101490602001610fc6565b6110b4611fde565b6001600160a01b0382165f81815260096020908152604091829020805460ff191685151590811790915591519182527f522c6e1b1db49e41bc2cb162869c03f0e85d2b6812e4369b27c8f61898fc6eb491015b60405180910390a25050565b5f8061116386612710611127601e82614667565b61113990670de0b6b3a76400006146ae565b61114391906146d9565b61115590670de0b6b3a76400006146f8565b670de0b6b3a764000061212a565b90505f6111798283670de0b6b3a764000061212a565b90505f61118f8889670de0b6b3a764000061212a565b90505f6111af6111a88a89670de0b6b3a764000061212a565b878a61212a565b90505f5f82841115611239576111c58385614667565b91505f61120f6127106111d9601e82614667565b6111eb90670de0b6b3a76400006146ae565b6111f591906146d9565b6112009060046146ae565b84670de0b6b3a764000061212a565b905061122361121e8288614667565b6124e2565b61123190633b9aca006146ae565b915050611278565b6112438484614667565b91505f6112576127106111d9601e82614667565b905061126661121e82886146f8565b61127490633b9aca006146ae565b9150505b5f6112c9670de0b6b3a764000061128f8985614667565b61271061129d601e82614667565b6112af90670de0b6b3a76400006146ae565b6112b991906146d9565b6112c49060026146ae565b61212a565b9750505050505050505b949350505050565b6006545f90600160301b900460ff1615611308576040516306d39fcd60e41b815260040160405180910390fd5b611310612038565b604051635677d7d760e11b81525f5160206149015f395f51905f5260048201525f907f000000000000000000000000b3a36232ecc1da6c8d0d3f417e00406566933bd06001600160a01b03169063acefafae90602401602060405180830381865afa158015611381573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906113a5919061463c565b90505f6113b18261208f565b90506113c4816305f5e100600554612114565b6113e157604051635a3316bd60e01b815260040160405180910390fd5b5f5f6113eb610d4f565b60065491945092506114069150829061ffff1661271061212a565b82111561142657604051632df452f560e21b815260040160405180910390fd5b5f5160206149015f395f51905f525f819052600a6020527fd0bcf4df132c65dad73803c5e5e1c826f151a3342680034a8a4c8e5f8eb0c13c54349081111561148157604051638c6efd1b60e01b815260040160405180910390fd5b5f3490505f6114958260045461271061212a565b90505f6114a28284614667565b90505f5160206149015f395f51905f526001600160a01b031663d0e30db0846040518263ffffffff1660e01b81526004015f604051808303818588803b1580156114ea575f5ffd5b505af11580156114fc573d5f5f3e3d5ffd5b505060025461152793505f5160206149015f395f51905f5292506001600160a01b03169050836125c6565b61153f815f5160206149015f395f51905f528d612280565b995050505050505050505061155360015f55565b919050565b611560611fde565b6127108161ffff16111561158d57604051631e57e2d960e21b815261ffff82166004820152602401610f73565b61ffff811660048190556040519081527fd446502274520c2290d33d7ee138d6d8e74167ab863258c6e296c5b529e2c66d90602001610fc6565b6115cf611fde565b600355565b6115dc611fde565b6115e55f6125e5565b565b5f5f5f611636735c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f7f00000000000000000000000038547d918b9645f2d94336b6b61aeb08053e142c5f5160206149015f395f51905f52612636565b915091506112d3826305f5e1008387611113565b604051635677d7d760e11b81525f5160206149015f395f51905f5260048201525f9081908190819081906001600160a01b037f000000000000000000000000b3a36232ecc1da6c8d0d3f417e00406566933bd0169063acefafae90602401602060405180830381865afa1580156116c3573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906116e7919061463c565b90505f6116f3826126fb565b90505f6116fe610d4f565b6003546305f5e100808710159a50939850919650925061171f918491612114565b965050505090919293565b611732611fde565b60058190556040518181527fffb4f4d29733d0f5d83cf9ff992fbdd36cd9f17a57e4871ff763ac812ffaffc590602001610fc6565b61176f611fde565b6117a46001600160a01b037f00000000000000000000000038547d918b9645f2d94336b6b61aeb08053e142c1633308461220f565b8060075f8282546117b591906146f8565b90915550506040518181527febb72640566415c6a28dfdb80b483e6c75bad975887046ebab0f517d9457154c90602001610fc6565b6117f2611fde565b60068054911515600160301b0266ff00000000000019909216919091179055565b61181b611fde565b6001600160a01b0382165f81815260086020908152604091829020805460ff191685151590811790915591519182527f720533d44efb0342f5ab7b8fd10f7613c72680e643a7094b63d5016367b85fcf9101611107565b5f805b82811015611961576002546001600160a01b031663b964730c8585848181106118a0576118a061470b565b6118b692602060609092020190810191506142be565b8686858181106118c8576118c861470b565b905060600201602001358787868181106118e4576118e461470b565b905060600201604001356040518463ffffffff1660e01b8152600401611928939291906001600160a01b039390931683526020830191909152604082015260600190565b5f604051808303815f87803b15801561193f575f5ffd5b505af1158015611951573d5f5f3e3d5ffd5b5050600190920191506118759050565b506112d384611b9e565b5f5f5f6119ba735c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f7f00000000000000000000000038547d918b9645f2d94336b6b61aeb08053e142c5f5160206149015f395f51905f52612636565b915091506112d38185846305f5e100611113565b6119d6611fde565b61271061ffff82161115611a035760405163dffed50560e01b815261ffff82166004820152602401610f73565b6006805461ffff191661ffff83169081179091556040519081527fb92548ef8e4a660d447901ae49a0f4d61d9d192dc471290dd0a524a4e9993a1e90602001610fc6565b611a4f611fde565b5f5b8251811015611b20575f838281518110611a6d57611a6d61470b565b602002602001015190505f838381518110611a8a57611a8a61470b565b60200260200101519050611ab23382846001600160a01b03166125c69092919063ffffffff16565b7f00000000000000000000000038547d918b9645f2d94336b6b61aeb08053e142c6001600160a01b0316826001600160a01b031603611b1657600754811015611b11578060075f828254611b069190614667565b90915550611b169050565b5f6007555b5050600101611a51565b505050565b611b2d611fde565b6001600160a01b038116611b925760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610f73565b611b9b816125e5565b50565b5f611ba7612038565b335f9081526008602052604090205460ff16611bd857604051639ce9e4d160e01b8152336004820152602401610f73565b611be18261280f565b611be96129eb565b905061155360015f55565b6006545f90600160381b900460ff1615611c21576040516306d39fcd60e41b815260040160405180910390fd5b611c29612038565b604051635677d7d760e11b81525f5160206149015f395f51905f5260048201525f907f000000000000000000000000b3a36232ecc1da6c8d0d3f417e00406566933bd06001600160a01b03169063acefafae90602401602060405180830381865afa158015611c9a573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611cbe919061463c565b90505f611cca8261208f565b9050611cdd816305f5e100600554612114565b611cfa57604051635a3316bd60e01b815260040160405180910390fd5b5f5f611d04610d4f565b6006549194509250611d1f9150829061ffff1661271061212a565b821115611d3f57604051632df452f560e21b815260040160405180910390fd5b6001600160a01b0386165f908152600b602052604090205486908890811115611d7b57604051638c6efd1b60e01b815260040160405180910390fd5b604051635677d7d760e11b81526001600160a01b0389811660048301525f917f000000000000000000000000b3a36232ecc1da6c8d0d3f417e00406566933bd09091169063acefafae90602401602060405180830381865afa158015611de3573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611e07919061463c565b9050611e3e6001600160a01b037f00000000000000000000000038547d918b9645f2d94336b6b61aeb08053e142c1633308d61220f565b6127106004548b611e4f91906146ae565b611e5991906146d9565b611e63908b614667565b604051630852cd8d60e31b815260048101829052909a507f00000000000000000000000038547d918b9645f2d94336b6b61aeb08053e142c6001600160a01b0316906342966c68906024015f604051808303815f87803b158015611ec5575f5ffd5b505af1158015611ed7573d5f5f3e3d5ffd5b505050505f611eeb8b6305f5e1008461212a565b600254604051633def417960e11b8152600481018390526001600160a01b038d81166024830152929350911690637bde82f2906044016020604051808303815f875af1158015611f3d573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611f61919061463c565b50611f766001600160a01b038b1633836125c6565b60408051338152602081018d90529081018290526001600160a01b038b1660608201527fdccd412f0b1252819cb1fd330b93224ca42612892bb3f4f789976e6d819364969060800160405180910390a1975050505050505050611fd860015f55565b92915050565b6001546001600160a01b031633146115e55760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610f73565b60025f54036120895760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610f73565b60025f55565b5f5f5f6120de735c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f7f00000000000000000000000038547d918b9645f2d94336b6b61aeb08053e142c5f5160206149015f395f51905f52612636565b915091505f6120f6670de0b6b3a76400008385612afd565b905061210b85670de0b6b3a76400008361212a565b95945050505050565b5f816121208585612b9a565b1115949350505050565b5f80805f19858709858702925082811083820303915050805f0361216157838281612157576121576146c5565b0492505050610d48565b8084116121a85760405162461bcd60e51b81526020600482015260156024820152744d6174683a206d756c446976206f766572666c6f7760581b6044820152606401610f73565b5f8486880960026001871981018816978890046003810283188082028403028082028403028082028403028082028403028082028403029081029092039091025f889003889004909101858311909403939093029303949094049190911702949350505050565b6040516001600160a01b038085166024830152831660448201526064810182905261227a9085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612bbb565b50505050565b5f8073c02aaa39b223fe8d0a0e5c4f27ead9083c756cc1196001600160a01b0385160161235057604051635677d7d760e11b81525f5160206149015f395f51905f5260048201525f907f000000000000000000000000b3a36232ecc1da6c8d0d3f417e00406566933bd06001600160a01b03169063acefafae90602401602060405180830381865afa158015612318573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061233c919061463c565b905061234886826124ce565b9150506123ec565b604051635677d7d760e11b81526001600160a01b0385811660048301525f917f000000000000000000000000b3a36232ecc1da6c8d0d3f417e00406566933bd09091169063acefafae90602401602060405180830381865afa1580156123b8573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906123dc919061463c565b90506123e886826124ce565b9150505b5f6123fb826305f5e100612c8e565b6040516340c10f1960e01b81529091506001600160a01b037f00000000000000000000000038547d918b9645f2d94336b6b61aeb08053e142c16906340c10f199061244c908790859060040161467a565b5f604051808303815f87803b158015612463575f5ffd5b505af1158015612475573d5f5f3e3d5ffd5b5050604080516001600160a01b0389168152602081018a90529081018490523392507f2f00e3cdd69a77be7ed215ec7b2a36784dd158f921fca79ac29deffa353fe6ee915060600160405180910390a295945050505050565b5f610d488383670de0b6b3a764000061212a565b5f815f036124f157505f919050565b5f60016124fd84612ca2565b901c6001901b90506001818481612516576125166146c5565b048201901c9050600181848161252e5761252e6146c5565b048201901c90506001818481612546576125466146c5565b048201901c9050600181848161255e5761255e6146c5565b048201901c90506001818481612576576125766146c5565b048201901c9050600181848161258e5761258e6146c5565b048201901c905060018184816125a6576125a66146c5565b048201901c9050610d48818285816125c0576125c06146c5565b04612d35565b611b208363a9059cbb60e01b848460405160240161224392919061467a565b600180546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a35050565b5f5f5f6126438585612d4a565b5090505f5f612653888888612e40565b6001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa15801561268e573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906126b29190614735565b506001600160701b031691506001600160701b03169150826001600160a01b0316876001600160a01b0316146126e95780826126ec565b81815b90999098509650505050505050565b604051635677d7d760e11b81526001600160a01b037f00000000000000000000000038547d918b9645f2d94336b6b61aeb08053e142c811660048301525f9182917f000000000000000000000000b3a36232ecc1da6c8d0d3f417e00406566933bd0169063acefafae90602401602060405180830381865afa158015612783573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906127a7919061463c565b90505f6127b38461208f565b90505f6127c08284612b9a565b6006549091505f906127e2908590640100000000900461ffff1661271061212a565b90508082111561280557604051636d0bc11760e01b815260040160405180910390fd5b5090949350505050565b335f9081526009602052604090205460ff16611b9b57604051635677d7d760e11b81525f5160206149015f395f51905f5260048201525f907f000000000000000000000000b3a36232ecc1da6c8d0d3f417e00406566933bd06001600160a01b03169063acefafae90602401602060405180830381865afa158015612896573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906128ba919061463c565b90505f6128c682612f17565b905082158015906128d657508281115b156128f45760405163202bf84160e11b815260040160405180910390fd5b825f03611b2057604051635677d7d760e11b81526001600160a01b037f0000000000000000000000003b21418081528845a6df4e970bd2185545b712ba811660048301525f917f000000000000000000000000b3a36232ecc1da6c8d0d3f417e00406566933bd09091169063acefafae90602401602060405180830381865afa158015612983573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906129a7919061463c565b6006549091506129c4908390839062010000900461ffff16612f66565b61227a57604051637d898ce960e11b81526004810183905260248101829052604401610f73565b5f5f5f5f5f6129f861164a565b604051635677d7d760e11b81525f5160206149015f395f51905f526004820152939750919550935091505f906001600160a01b037f000000000000000000000000b3a36232ecc1da6c8d0d3f417e00406566933bd0169063acefafae90602401602060405180830381865afa158015612a73573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612a97919061463c565b90508415612ac3578215612ab957612aaf8282612fa9565b9550505050505090565b612aaf828261308e565b8315612ae3578215612ad957612aaf82826132d7565b612aaf828261356b565b8215612af357612aaf82826136fe565b612aaf8282613915565b5f5f8411612b5b5760405162461bcd60e51b815260206004820152602560248201527f556e697377617056324c6962726172793a20494e53554646494349454e545f416044820152641353d5539560da1b6064820152608401610f73565b5f83118015612b6957505f82115b612b855760405162461bcd60e51b8152600401610f7390614776565b82612b908584613c09565b6112d391906146d9565b5f818311612bb157612bac8383614667565b610d48565b610d488284614667565b5f612c0f826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613c6f9092919063ffffffff16565b905080515f1480612c2f575080806020019051810190612c2f9190614693565b611b205760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610f73565b5f610d4883670de0b6b3a76400008461212a565b5f80608083901c15612cb657608092831c92015b604083901c15612cc857604092831c92015b602083901c15612cda57602092831c92015b601083901c15612cec57601092831c92015b600883901c15612cfe57600892831c92015b600483901c15612d1057600492831c92015b600283901c15612d2257600292831c92015b600183901c15611fd85760010192915050565b5f818310612d435781610d48565b5090919050565b5f5f826001600160a01b0316846001600160a01b031603612dbb5760405162461bcd60e51b815260206004820152602560248201527f556e697377617056324c6962726172793a204944454e544943414c5f41444452604482015264455353455360d81b6064820152608401610f73565b826001600160a01b0316846001600160a01b031610612ddb578284612dde565b83835b90925090506001600160a01b038216612e395760405162461bcd60e51b815260206004820152601e60248201527f556e697377617056324c6962726172793a205a45524f5f4144445245535300006044820152606401610f73565b9250929050565b5f5f5f612e4d8585612d4a565b6040516bffffffffffffffffffffffff19606084811b8216602084015283901b1660348201529193509150869060480160405160208183030381529060405280519060200120604051602001612ef59291906001600160f81b0319815260609290921b6bffffffffffffffffffffffff1916600183015260158201527f96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f603582015260550190565b60408051601f1981840301815291905280516020909101209695505050505050565b5f5f5f6120de735c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f7f0000000000000000000000003b21418081528845a6df4e970bd2185545b712ba5f5160206149015f395f51905f52612636565b5f5f5f848611612f77578486612f7a565b85855b90925090505f612f8a8284614667565b90505f612f9a848761271061212a565b90911115979650505050505050565b5f5f612fb9846305f5e100612c8e565b6040516340c10f1960e01b81529091506001600160a01b037f00000000000000000000000038547d918b9645f2d94336b6b61aeb08053e142c16906340c10f199061300a903090859060040161467a565b5f604051808303815f87803b158015613021575f5ffd5b505af1158015613033573d5f5f3e3d5ffd5b505050508060075f82825461304891906146f8565b9091555050604080515f808252602082018790528183018690526060820152905160059133915f5160206149215f395f51905f529181900360800190a3505f9392505050565b5f5f61309e846305f5e100612c8e565b90505f5f6007548311156130d35760075491505f6130bf610e4c8486614667565b90506130cb8187612c8e565b9150506130d9565b508190505f5b5f811561311b576131187f0000000000000000000000003b21418081528845a6df4e970bd2185545b712ba5f5160206149015f395f51905f5284613c7d565b90505b6040516340c10f1960e01b81526001600160a01b037f0000000000000000000000003b21418081528845a6df4e970bd2185545b712ba16906340c10f1990613169903090859060040161467a565b5f604051808303815f87803b158015613180575f5ffd5b505af1158015613192573d5f5f3e3d5ffd5b505050505f821115613201575f6131d77f0000000000000000000000003b21418081528845a6df4e970bd2185545b712ba5f5160206149015f395f51905f5284613cb8565b6002549091506131ff905f5160206149015f395f51905f52906001600160a01b0316836125c6565b505b821561329357604051630852cd8d60e31b8152600481018490527f00000000000000000000000038547d918b9645f2d94336b6b61aeb08053e142c6001600160a01b0316906342966c68906024015f604051808303815f87803b158015613266575f5ffd5b505af1158015613278573d5f5f3e3d5ffd5b505050508260075f82825461328d9190614667565b90915550505b604080515f808252602082018a90528183018990526060820152905160069133915f5160206149215f395f51905f529181900360800190a3505f9695505050505050565b5f5f6132e2836115e7565b6040516340c10f1960e01b81529091506001600160a01b037f00000000000000000000000038547d918b9645f2d94336b6b61aeb08053e142c16906340c10f1990613333903090859060040161467a565b5f604051808303815f87803b15801561334a575f5ffd5b505af115801561335c573d5f5f3e3d5ffd5b505050505f6133997f00000000000000000000000038547d918b9645f2d94336b6b61aeb08053e142c5f5160206149015f395f51905f5284613cb8565b90505f6133aa836305f5e1006124ce565b90505f6133b78287612c8e565b9050828111156133e45760405163318bf40560e11b81526004810182905260248101849052604401610f73565b5f5f8884111561343c576133f88989612c8e565b915081613405858a612c8e565b61340f9190614667565b600254909150613437905f5160206149015f395f51905f52906001600160a01b0316836125c6565b613449565b6134468489612c8e565b91505b5f6134825f5160206149015f395f51905f527f0000000000000000000000003b21418081528845a6df4e970bd2185545b712ba85613cb8565b604051630852cd8d60e31b8152600481018290529091507f0000000000000000000000003b21418081528845a6df4e970bd2185545b712ba6001600160a01b0316906342966c68906024015f604051808303815f87803b1580156134e4575f5ffd5b505af11580156134f6573d5f5f3e3d5ffd5b505050505f8284886135089190614667565b6135129190614667565b90505f61351f828c6124ce565b60408051898152602081018f90529081018d90526060810182905290915060019033905f5160206149215f395f51905f529060800160405180910390a39b9a5050505050505050505050565b5f5f613576836115e7565b6040516340c10f1960e01b81529091506001600160a01b037f00000000000000000000000038547d918b9645f2d94336b6b61aeb08053e142c16906340c10f19906135c7903090859060040161467a565b5f604051808303815f87803b1580156135de575f5ffd5b505af11580156135f0573d5f5f3e3d5ffd5b505050505f61362d7f00000000000000000000000038547d918b9645f2d94336b6b61aeb08053e142c5f5160206149015f395f51905f5284613cb8565b90505f61363e836305f5e1006124ce565b90505f61364b8287612c8e565b9050828111156136785760405163318bf40560e11b81526004810182905260248101849052604401610f73565b60025461369d905f5160206149015f395f51905f52906001600160a01b0316836125c6565b5f6136a88285614667565b90505f6136b582896124ce565b60408051868152602081018c90529081018a90526060810182905290915060029033905f5160206149215f395f51905f529060800160405180910390a398975050505050505050565b5f5f5f5f61370b8561196b565b90505f61371882876124ce565b90508681111561375057613730876305f5e100612c8e565b935061374961373f8883614667565b6305f5e100612c8e565b9250613761565b61375e816305f5e100612c8e565b93505b600254604051633def417960e11b8152600481018490525f5160206149015f395f51905f5260248201526001600160a01b0390911690637bde82f2906044016020604051808303815f875af11580156137bc573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906137e0919061463c565b505f61381a5f5160206149015f395f51905f527f00000000000000000000000038547d918b9645f2d94336b6b61aeb08053e142c85613cb8565b905084811015613828578094505b83156138a457604051630852cd8d60e31b8152600481018590527f00000000000000000000000038547d918b9645f2d94336b6b61aeb08053e142c6001600160a01b0316906342966c68906024015f604051808303815f87803b15801561388d575f5ffd5b505af115801561389f573d5f5f3e3d5ffd5b505050505b5f846138b08784614667565b6138ba9190614667565b90505f6138cb826305f5e1006124ce565b60408051868152602081018d90529081018b90526060810182905290915060039033905f5160206149215f395f51905f529060800160405180910390a39998505050505050505050565b5f5f5f5f6139228561196b565b90505f61392f82876124ce565b9050868111156139d5576139438787612c8e565b925061394f8383614667565b600254604051633def417960e11b8152600481018390525f5160206149015f395f51905f5260248201529195506001600160a01b031690637bde82f2906044016020604051808303815f875af11580156139ab573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906139cf919061463c565b506139d9565b8192505b5f6139e8826305f5e100612c8e565b90505f8415613ae3575f613a2a7f0000000000000000000000003b21418081528845a6df4e970bd2185545b712ba5f5160206149015f395f51905f5288613c7d565b6040516340c10f1960e01b81529091506001600160a01b037f0000000000000000000000003b21418081528845a6df4e970bd2185545b712ba16906340c10f1990613a7b903090859060040161467a565b5f604051808303815f87803b158015613a92575f5ffd5b505af1158015613aa4573d5f5f3e3d5ffd5b50505050613ae07f0000000000000000000000003b21418081528845a6df4e970bd2185545b712ba5f5160206149015f395f51905f5283613cb8565b50505b613b245f5160206149015f395f51905f527f00000000000000000000000038547d918b9645f2d94336b6b61aeb08053e142c613b1f89896146f8565b613cb8565b90508115613ba257604051630852cd8d60e31b8152600481018390527f00000000000000000000000038547d918b9645f2d94336b6b61aeb08053e142c6001600160a01b0316906342966c68906024015f604051808303815f87803b158015613b8b575f5ffd5b505af1158015613b9d573d5f5f3e3d5ffd5b505050505b5f613bad8383614667565b90505f613bbe826305f5e1006124ce565b60408051878152602081018e90529081018c90526060810182905290915060049033905f5160206149215f395f51905f529060800160405180910390a39a9950505050505050505050565b5f811580613c2c57508282613c1e81836146ae565b9250613c2a90836146d9565b145b611fd85760405162461bcd60e51b815260206004820152601460248201527364732d6d6174682d6d756c2d6f766572666c6f7760601b6044820152606401610f73565b60606112d384845f85613e67565b5f5f5f613c9f735c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f8787612636565b91509150613cae848383613f3e565b9695505050505050565b5f60606001600160a01b0385165f5160206149015f395f51905f5214801590613cf757506001600160a01b0384165f5160206149015f395f51905f5214155b15613d1b57613d14855f5160206149015f395f51905f528661400e565b9050613d28565b613d2585856140d2565b90505b60405163095ea7b360e01b81526001600160a01b0386169063095ea7b390613d6a90737a250d5630b4cf539739df2c5dacb4c659f2488d90879060040161467a565b6020604051808303815f875af1158015613d86573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190613daa9190614693565b506040516338ed173960e01b81525f90737a250d5630b4cf539739df2c5dacb4c659f2488d906338ed173990613dec90879085908790309042906004016147be565b5f604051808303815f875af1158015613e07573d5f5f3e3d5ffd5b505050506040513d5f823e601f3d908101601f19168201604052613e2e919081019061482e565b90505f8160018451613e409190614667565b81518110613e5057613e5061470b565b602002602001015190508093505050509392505050565b606082471015613ec85760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610f73565b5f5f866001600160a01b03168587604051613ee391906148b5565b5f6040518083038185875af1925050503d805f8114613f1d576040519150601f19603f3d011682016040523d82523d5f602084013e613f22565b606091505b5091509150613f338783838761415f565b979650505050505050565b5f5f8411613fa35760405162461bcd60e51b815260206004820152602c60248201527f556e697377617056324c6962726172793a20494e53554646494349454e545f4f60448201526b155514155517d05353d5539560a21b6064820152608401610f73565b5f83118015613fb157505f82115b613fcd5760405162461bcd60e51b8152600401610f7390614776565b5f613fe46103e8613fde8688613c09565b90613c09565b90505f613ff76103e5613fde86896141d7565b9050613cae600161400883856146d9565b9061422c565b6040805160038082526080820190925260609160208201838036833701905050905083815f815181106140435761404361470b565b60200260200101906001600160a01b031690816001600160a01b03168152505082816001815181106140775761407761470b565b60200260200101906001600160a01b031690816001600160a01b03168152505081816002815181106140ab576140ab61470b565b60200260200101906001600160a01b031690816001600160a01b0316815250509392505050565b604080516002808252606080830184529260208301908036833701905050905082815f815181106141055761410561470b565b60200260200101906001600160a01b031690816001600160a01b03168152505081816001815181106141395761413961470b565b60200260200101906001600160a01b031690816001600160a01b03168152505092915050565b606083156141cd5782515f036141c6576001600160a01b0385163b6141c65760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610f73565b50816112d3565b6112d38383614280565b5f826141e38382614667565b9150811115611fd85760405162461bcd60e51b815260206004820152601560248201527464732d6d6174682d7375622d756e646572666c6f7760581b6044820152606401610f73565b5f8261423883826146f8565b9150811015611fd85760405162461bcd60e51b815260206004820152601460248201527364732d6d6174682d6164642d6f766572666c6f7760601b6044820152606401610f73565b8151156142905781518083602001fd5b8060405162461bcd60e51b8152600401610f7391906148cb565b6001600160a01b0381168114611b9b575f5ffd5b5f602082840312156142ce575f5ffd5b8135610d48816142aa565b5f5f5f606084860312156142eb575f5ffd5b83356142f6816142aa565b925060208401359150604084013561430d816142aa565b809150509250925092565b5f5f60408385031215614329575f5ffd5b8235614334816142aa565b946020939093013593505050565b8015158114611b9b575f5ffd5b5f6020828403121561435f575f5ffd5b8135610d4881614342565b5f6020828403121561437a575f5ffd5b813561ffff81168114610d48575f5ffd5b5f5f6040838503121561439c575f5ffd5b82356143a7816142aa565b915060208301356143b781614342565b809150509250929050565b5f5f5f5f608085870312156143d5575f5ffd5b5050823594602084013594506040840135936060013592509050565b5f60208284031215614401575f5ffd5b5035919050565b5f5f5f6040848603121561441a575f5ffd5b83359250602084013567ffffffffffffffff811115614437575f5ffd5b8401601f81018613614447575f5ffd5b803567ffffffffffffffff81111561445d575f5ffd5b866020606083028401011115614471575f5ffd5b939660209190910195509293505050565b634e487b7160e01b5f52604160045260245ffd5b604051601f8201601f1916810167ffffffffffffffff811182821017156144bf576144bf614482565b604052919050565b5f67ffffffffffffffff8211156144e0576144e0614482565b5060051b60200190565b5f82601f8301126144f9575f5ffd5b813561450c614507826144c7565b614496565b8082825260208201915060208360051b86010192508583111561452d575f5ffd5b602085015b8381101561454a578035835260209283019201614532565b5095945050505050565b5f5f60408385031215614565575f5ffd5b823567ffffffffffffffff81111561457b575f5ffd5b8301601f8101851361458b575f5ffd5b8035614599614507826144c7565b8082825260208201915060208360051b8501019250878311156145ba575f5ffd5b6020840193505b828410156145e55783356145d4816142aa565b8252602093840193909101906145c1565b9450505050602083013567ffffffffffffffff811115614603575f5ffd5b61460f858286016144ea565b9150509250929050565b5f5f6040838503121561462a575f5ffd5b8235915060208301356143b7816142aa565b5f6020828403121561464c575f5ffd5b5051919050565b634e487b7160e01b5f52601160045260245ffd5b81810381811115611fd857611fd8614653565b6001600160a01b03929092168252602082015260400190565b5f602082840312156146a3575f5ffd5b8151610d4881614342565b8082028115828204841417611fd857611fd8614653565b634e487b7160e01b5f52601260045260245ffd5b5f826146f357634e487b7160e01b5f52601260045260245ffd5b500490565b80820180821115611fd857611fd8614653565b634e487b7160e01b5f52603260045260245ffd5b80516001600160701b0381168114611553575f5ffd5b5f5f5f60608486031215614747575f5ffd5b6147508461471f565b925061475e6020850161471f565b9150604084015163ffffffff8116811461430d575f5ffd5b60208082526028908201527f556e697377617056324c6962726172793a20494e53554646494349454e545f4c604082015267495155494449545960c01b606082015260800190565b5f60a0820187835286602084015260a0604084015280865180835260c0850191506020880192505f5b8181101561480e5783516001600160a01b03168352602093840193909201916001016147e7565b50506001600160a01b039590951660608401525050608001529392505050565b5f6020828403121561483e575f5ffd5b815167ffffffffffffffff811115614854575f5ffd5b8201601f81018413614864575f5ffd5b8051614872614507826144c7565b8082825260208201915060208360051b850101925086831115614893575f5ffd5b6020840193505b82841015613cae57835182526020938401939091019061489a565b5f82518060208501845e5f920191825250919050565b602081525f82518060208401528060208501604085015e5f604082850101526040601f19601f8301168401019150509291505056fe000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc29bfff6dfb60cbb64c69905e709aa9b3fa7ceeeff847205dd3caa324ab30f962ea26469706673582212209babe95732df3796851a07812e6f59c9fed6e66c59e8402ba94e27e6286fc99d64736f6c634300081c0033

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

00000000000000000000000038547d918b9645f2d94336b6b61aeb08053e142c0000000000000000000000003b21418081528845a6df4e970bd2185545b712ba000000000000000000000000b3a36232ecc1da6c8d0d3f417e00406566933bd0000000000000000000000000037528457cf5b0b9dab641fd7f0ce8fc9690318d

-----Decoded View---------------
Arg [0] : _USC (address): 0x38547D918b9645F2D94336B6b61AEB08053E142c
Arg [1] : _CHI (address): 0x3b21418081528845a6DF4e970bD2185545b712ba
Arg [2] : _priceFeedAggregator (address): 0xb3a36232ECc1da6C8D0d3f417E00406566933bD0
Arg [3] : _reserveHolder (address): 0x037528457Cf5b0b9DAb641Fd7F0Ce8Fc9690318d

-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 00000000000000000000000038547d918b9645f2d94336b6b61aeb08053e142c
Arg [1] : 0000000000000000000000003b21418081528845a6df4e970bd2185545b712ba
Arg [2] : 000000000000000000000000b3a36232ecc1da6c8d0d3f417e00406566933bd0
Arg [3] : 000000000000000000000000037528457cf5b0b9dab641fd7f0ce8fc9690318d


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
Loading...
Loading
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

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