ETH Price: $2,871.46 (-2.38%)

Contract

0x2Fcb398bcB5Bd2aEc807941F9d7953e1135056B8

Overview

ETH Balance

Linea Mainnet LogoLinea Mainnet LogoLinea Mainnet Logo0.002486 ETH

ETH Value

$7.14 (@ $2,871.46/ETH)

Token Holdings

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Block
From
To
Add Liquidity ET...98317512024-09-23 8:56:01489 days ago1727081761IN
0x2Fcb398b...1135056B8
0.1 ETH0.000128610.2535
Add Liquidity98308122024-09-23 8:24:43489 days ago1727079883IN
0x2Fcb398b...1135056B8
1 wei0.000122610.2258727
Set Price And Up...98300752024-09-23 8:00:09489 days ago1727078409IN
0x2Fcb398b...1135056B8
1 wei0.000113410.279136
Set Price And Up...98300742024-09-23 8:00:07489 days ago1727078407IN
0x2Fcb398b...1135056B8
1 wei0.000113290.279136
Set Price And Up...98300732024-09-23 8:00:05489 days ago1727078405IN
0x2Fcb398b...1135056B8
1 wei0.000117220.279136
Remove Liquidity98288792024-09-23 7:20:17489 days ago1727076017IN
0x2Fcb398b...1135056B8
1 wei0.000112870.22827117
Create Tp Sl98283582024-09-23 7:02:55489 days ago1727074975IN
0x2Fcb398b...1135056B8
0.0001 ETH0.000088340.17701716
Cancel Order98283352024-09-23 7:02:09489 days ago1727074929IN
0x2Fcb398b...1135056B8
0 ETH0.000022190.17701716
Set Price And Up...98282752024-09-23 7:00:09489 days ago1727074809IN
0x2Fcb398b...1135056B8
1 wei0.000110190.27118703
Set Price And Up...98282742024-09-23 7:00:07489 days ago1727074807IN
0x2Fcb398b...1135056B8
1 wei0.000110070.27118703
Set Price And Up...98282742024-09-23 7:00:07489 days ago1727074807IN
0x2Fcb398b...1135056B8
1 wei0.000113890.27118703
Create Decrease ...98269582024-09-23 6:16:15489 days ago1727072175IN
0x2Fcb398b...1135056B8
0.0001 ETH0.000070070.13611778
Set Price And Up...98264752024-09-23 6:00:09489 days ago1727071209IN
0x2Fcb398b...1135056B8
1 wei0.000057220.1408
Set Price And Up...98264742024-09-23 6:00:07489 days ago1727071207IN
0x2Fcb398b...1135056B8
1 wei0.000057150.1408
Set Price And Up...98264742024-09-23 6:00:07489 days ago1727071207IN
0x2Fcb398b...1135056B8
1 wei0.000059120.1408
Create Increase ...98263812024-09-23 5:57:01489 days ago1727071021IN
0x2Fcb398b...1135056B8
0.0001 ETH0.000051270.08890216
Create Increase ...98263252024-09-23 5:55:09489 days ago1727070909IN
0x2Fcb398b...1135056B8
0.0001 ETH0.00004950.08890216
Create Increase ...98257062024-09-23 5:34:31489 days ago1727069671IN
0x2Fcb398b...1135056B8
0.0001 ETH0.000048240.08663293
Create Decrease ...98256942024-09-23 5:34:07489 days ago1727069647IN
0x2Fcb398b...1135056B8
0.0001 ETH0.000045820.09651262
Create Decrease ...98256942024-09-23 5:34:07489 days ago1727069647IN
0x2Fcb398b...1135056B8
0.0001 ETH0.000041980.09651262
Create Increase ...98256492024-09-23 5:32:37489 days ago1727069557IN
0x2Fcb398b...1135056B8
0.0001 ETH0.000053670.09639171
Create Increase ...98256492024-09-23 5:32:37489 days ago1727069557IN
0x2Fcb398b...1135056B8
0.0001 ETH0.000051750.09639171
Create Decrease ...98256412024-09-23 5:32:21489 days ago1727069541IN
0x2Fcb398b...1135056B8
0.0001 ETH0.000045750.0963582
Create Decrease ...98256412024-09-23 5:32:21489 days ago1727069541IN
0x2Fcb398b...1135056B8
0.0001 ETH0.000041910.0963582
Create Decrease ...98256142024-09-23 5:31:27489 days ago1727069487IN
0x2Fcb398b...1135056B8
0.0001 ETH0.000041910.09634206
View all transactions

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To
98317512024-09-23 8:56:01489 days ago1727081761
0x2Fcb398b...1135056B8
0 ETH
98317512024-09-23 8:56:01489 days ago1727081761
0x2Fcb398b...1135056B8
0 ETH
98317512024-09-23 8:56:01489 days ago1727081761
0x2Fcb398b...1135056B8
0 ETH
98317512024-09-23 8:56:01489 days ago1727081761
0x2Fcb398b...1135056B8
0 ETH
98317512024-09-23 8:56:01489 days ago1727081761
0x2Fcb398b...1135056B8
0 ETH
98317512024-09-23 8:56:01489 days ago1727081761
0x2Fcb398b...1135056B8
0 ETH
98317512024-09-23 8:56:01489 days ago1727081761
0x2Fcb398b...1135056B8
0.1 ETH
98317512024-09-23 8:56:01489 days ago1727081761
0x2Fcb398b...1135056B8
0 ETH
98317512024-09-23 8:56:01489 days ago1727081761
0x2Fcb398b...1135056B8
0x2Fcb398b...1135056B8
0.1 ETH
98317512024-09-23 8:56:01489 days ago1727081761
0x2Fcb398b...1135056B8
1 wei
98317512024-09-23 8:56:01489 days ago1727081761
0x2Fcb398b...1135056B8
0 ETH
98317512024-09-23 8:56:01489 days ago1727081761
0x2Fcb398b...1135056B8
0 ETH
98308122024-09-23 8:24:43489 days ago1727079883
0x2Fcb398b...1135056B8
0 ETH
98308122024-09-23 8:24:43489 days ago1727079883
0x2Fcb398b...1135056B8
0 ETH
98308122024-09-23 8:24:43489 days ago1727079883
0x2Fcb398b...1135056B8
0 ETH
98308122024-09-23 8:24:43489 days ago1727079883
0x2Fcb398b...1135056B8
0 ETH
98308122024-09-23 8:24:43489 days ago1727079883
0x2Fcb398b...1135056B8
0 ETH
98308122024-09-23 8:24:43489 days ago1727079883
0x2Fcb398b...1135056B8
0 ETH
98308122024-09-23 8:24:43489 days ago1727079883
0x2Fcb398b...1135056B8
1 wei
98308122024-09-23 8:24:43489 days ago1727079883
0x2Fcb398b...1135056B8
0 ETH
98308122024-09-23 8:24:43489 days ago1727079883
0x2Fcb398b...1135056B8
0 ETH
98300752024-09-23 8:00:09489 days ago1727078409
0x2Fcb398b...1135056B8
0 ETH
98300752024-09-23 8:00:09489 days ago1727078409
0x2Fcb398b...1135056B8
1 wei
98300752024-09-23 8:00:09489 days ago1727078409
0x2Fcb398b...1135056B8
0 ETH
98300742024-09-23 8:00:07489 days ago1727078407
0x2Fcb398b...1135056B8
0 ETH
View All Internal Transactions
Cross-Chain Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
Router

Compiler Version
v0.8.19+commit.7dd6d404

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.19;

import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";

import "../libraries/PositionKey.sol";
import "../libraries/Upgradeable.sol";
import "../libraries/Multicall.sol";
import "../interfaces/IRouter.sol";
import "../interfaces/IAddressesProvider.sol";
import "../interfaces/IRoleManager.sol";
import "../interfaces/IOrderManager.sol";
import "../interfaces/IPositionManager.sol";
import "../interfaces/ILiquidityCallback.sol";
import "../interfaces/ISwapCallback.sol";
import "../interfaces/IPool.sol";
import "../interfaces/IWETH.sol";
import "../interfaces/IOrderCallback.sol";
import "../interfaces/IPythOraclePriceFeed.sol";
import "../libraries/TradingTypes.sol";

contract Router is
    Multicall,
    IRouter,
    ILiquidityCallback,
    IOrderCallback,
    ReentrancyGuard,
    Pausable
{
    using SafeERC20 for IERC20;
    using SafeERC20 for IWETH;
    using Int256Utils for uint256;

    IAddressesProvider public immutable ADDRESS_PROVIDER;
    IOrderManager public immutable orderManager;
    IPositionManager public immutable positionManager;
    IPool public immutable pool;

    mapping(uint256 => OperationStatus) public operationStatus;

    constructor(
        IAddressesProvider addressProvider,
        IOrderManager _orderManager,
        IPositionManager _positionManager,
        IPool _pool
    ){
        ADDRESS_PROVIDER = addressProvider;
        orderManager = _orderManager;
        positionManager = _positionManager;
        pool = _pool;
    }

    modifier onlyPoolAdmin() {
        require(
            IRoleManager(ADDRESS_PROVIDER.roleManager()).isPoolAdmin(msg.sender),
            "onlyPoolAdmin"
        );
        _;
    }

    modifier onlyOrderManager() {
        require(msg.sender == address(orderManager), "onlyOrderManager");
        _;
    }

    modifier onlyPool() {
        require(msg.sender == address(pool), "onlyPool");
        _;
    }

    function salvageToken(address token, uint amount) external onlyPoolAdmin {
        IERC20(token).safeTransfer(msg.sender, amount);
    }

    function setPaused() external onlyPoolAdmin {
        _pause();
    }

    function setUnPaused() external onlyPoolAdmin {
        _unpause();
    }

    function updateIncreasePositionStatus(uint256 pairIndex, bool enabled) external onlyPoolAdmin {
        operationStatus[pairIndex].increasePositionDisabled = !enabled;
        emit UpdateIncreasePositionStatus(msg.sender, pairIndex, enabled);
    }

    function updateDecreasePositionStatus(uint256 pairIndex, bool enabled) external onlyPoolAdmin {
        operationStatus[pairIndex].decreasePositionDisabled = !enabled;
        emit UpdateDecreasePositionStatus(msg.sender, pairIndex, enabled);
    }

    function updateOrderStatus(uint256 pairIndex, bool enabled) external onlyPoolAdmin {
        operationStatus[pairIndex].orderDisabled = !enabled;
        emit UpdateOrderStatus(msg.sender, pairIndex, enabled);
    }

    function updateAddLiquidityStatus(uint256 pairIndex, bool enabled) external onlyPoolAdmin {
        operationStatus[pairIndex].addLiquidityDisabled = !enabled;
        emit UpdateAddLiquidityStatus(msg.sender, pairIndex, enabled);
    }

    function updateRemoveLiquidityStatus(uint256 pairIndex, bool enabled) external onlyPoolAdmin {
        operationStatus[pairIndex].removeLiquidityDisabled = !enabled;
        emit UpdateRemoveLiquidityStatus(msg.sender, pairIndex, enabled);
    }

    function wrapWETH(address recipient) external payable {
        IWETH(ADDRESS_PROVIDER.WETH()).deposit{value: msg.value}();
        IWETH(ADDRESS_PROVIDER.WETH()).transfer(recipient, msg.value);
    }

    function getOperationStatus(uint256 pairIndex) external view returns (OperationStatus memory) {
        return operationStatus[pairIndex];
    }

    function setPriceAndAdjustCollateral(
        uint256 pairIndex,
        bool isLong,
        int256 collateral,
        address[] calldata tokens,
        bytes[] calldata updateData,
        uint64[] calldata publishTimes
    ) external payable whenNotPaused nonReentrant {
        require(!operationStatus[pairIndex].orderDisabled, "disabled");

        IPythOraclePriceFeed(ADDRESS_PROVIDER.priceOracle()).updatePrice{value: msg.value}(tokens, updateData, publishTimes);

        positionManager.adjustCollateral(pairIndex, msg.sender, isLong, collateral);
    }

    function setPriceAndUpdateFundingRate(
        uint256 pairIndex,
        address[] calldata tokens,
        bytes[] calldata updateData,
        uint64[] calldata publishTimes
    ) external payable whenNotPaused nonReentrant {
        IPythOraclePriceFeed(ADDRESS_PROVIDER.priceOracle()).updatePrice{value: msg.value}(tokens, updateData, publishTimes);

        positionManager.updateFundingRate(pairIndex);
    }

    function createIncreaseOrderWithTpSl(
        TradingTypes.IncreasePositionWithTpSlRequest memory request
    ) external payable whenNotPaused nonReentrant returns (uint256 orderId) {
        require(!operationStatus[request.pairIndex].increasePositionDisabled, "disabled");
        require(
            request.tradeType != TradingTypes.TradeType.TP &&
            request.tradeType != TradingTypes.TradeType.SL,
            "not support"
        );
        require(
            request.paymentType == TradingTypes.NetworkFeePaymentType.COLLATERAL ||
            (request.paymentType == TradingTypes.NetworkFeePaymentType.ETH
                && msg.value == request.networkFeeAmount + request.tpNetworkFeeAmount + request.slNetworkFeeAmount),
            "incorrect value"
        );
        request.account = msg.sender;

        orderId = orderManager.createOrder{value: request.networkFeeAmount}(
            TradingTypes.CreateOrderRequest({
                account: request.account,
                pairIndex: request.pairIndex,
                tradeType: request.tradeType,
                collateral: request.collateral,
                openPrice: request.openPrice,
                isLong: request.isLong,
                sizeAmount: uint256(request.sizeAmount).safeConvertToInt256(),
                maxSlippage: request.maxSlippage,
                paymentType: TradingTypes.convertPaymentType(request.paymentType),
                networkFeeAmount: request.networkFeeAmount,
                data: abi.encode(request.account)
            })
        );

        // tp、sl
        _createTpSl(
            request.account,
            request.pairIndex,
            request.isLong,
            request.tpPrice,
            request.tp,
            request.slPrice,
            request.sl,
            request.paymentType,
            request.tpNetworkFeeAmount,
            request.slNetworkFeeAmount
        );
        return orderId;
    }

    function _createTpSl(
        address account,
        uint256 pairIndex,
        bool isLong,
        uint256 tpPrice,
        uint128 tp,
        uint256 slPrice,
        uint128 sl,
        TradingTypes.NetworkFeePaymentType paymentType,
        uint256 tpNetworkFeeAmount,
        uint256 slNetworkFeeAmount
    ) internal returns (uint256 tpOrderId, uint256 slOrderId) {
        if (tp > 0) {
            tpOrderId = orderManager.createOrder{value: tpNetworkFeeAmount}(
                TradingTypes.CreateOrderRequest({
                    account: account,
                    pairIndex: pairIndex,
                    tradeType: TradingTypes.TradeType.TP,
                    collateral: 0,
                    openPrice: tpPrice,
                    isLong: isLong,
                    sizeAmount: -(uint256(tp).safeConvertToInt256()),
                    maxSlippage: 0,
                    paymentType: TradingTypes.convertPaymentType(paymentType),
                    networkFeeAmount: tpNetworkFeeAmount,
                    data: abi.encode(account)
                })
            );
        }
        if (sl > 0) {
            slOrderId = orderManager.createOrder{value: slNetworkFeeAmount}(
                TradingTypes.CreateOrderRequest({
                    account: account,
                    pairIndex: pairIndex,
                    tradeType: TradingTypes.TradeType.SL,
                    collateral: 0,
                    openPrice: slPrice,
                    isLong: isLong,
                    sizeAmount: -(uint256(sl).safeConvertToInt256()),
                    maxSlippage: 0,
                    paymentType: TradingTypes.convertPaymentType(paymentType),
                    networkFeeAmount: slNetworkFeeAmount,
                    data: abi.encode(account)
                })
            );
        }
        return (tpOrderId, slOrderId);
    }

    function createIncreaseOrder(
        TradingTypes.IncreasePositionRequest memory request
    ) external payable whenNotPaused nonReentrant returns (uint256 orderId) {
        require(!operationStatus[request.pairIndex].increasePositionDisabled, "disabled");
        require(
            request.tradeType != TradingTypes.TradeType.TP &&
            request.tradeType != TradingTypes.TradeType.SL,
            "not support"
        );
        require(
            request.paymentType == TradingTypes.NetworkFeePaymentType.COLLATERAL ||
            (request.paymentType == TradingTypes.NetworkFeePaymentType.ETH && msg.value == request.networkFeeAmount),
            "incorrect value"
        );

        request.account = msg.sender;

        return
            orderManager.createOrder{value: msg.value}(
                TradingTypes.CreateOrderRequest({
                    account: request.account,
                    pairIndex: request.pairIndex,
                    tradeType: request.tradeType,
                    collateral: request.collateral,
                    openPrice: request.openPrice,
                    isLong: request.isLong,
                    sizeAmount: request.sizeAmount.safeConvertToInt256(),
                    maxSlippage: request.maxSlippage,
                    paymentType: TradingTypes.convertPaymentType(request.paymentType),
                    networkFeeAmount: request.networkFeeAmount,
                    data: abi.encode(request.account)
                })
            );
    }

    function createDecreaseOrder(
        TradingTypes.DecreasePositionRequest memory request
    ) external payable whenNotPaused nonReentrant returns (uint256) {
        require(!operationStatus[request.pairIndex].decreasePositionDisabled, "disabled");
        require(
            request.paymentType == TradingTypes.NetworkFeePaymentType.COLLATERAL ||
            (request.paymentType == TradingTypes.NetworkFeePaymentType.ETH && msg.value == request.networkFeeAmount),
            "incorrect value"
        );

        request.account = msg.sender;

        return
            orderManager.createOrder{value: msg.value}(
                TradingTypes.CreateOrderRequest({
                    account: request.account,
                    pairIndex: request.pairIndex,
                    tradeType: request.tradeType,
                    collateral: request.collateral,
                    openPrice: request.triggerPrice,
                    isLong: request.isLong,
                    sizeAmount: -(request.sizeAmount.safeConvertToInt256()),
                    maxSlippage: request.maxSlippage,
                    paymentType: TradingTypes.convertPaymentType(request.paymentType),
                    networkFeeAmount: request.networkFeeAmount,
                    data: abi.encode(request.account)
                })
            );
    }

    function createDecreaseOrders(
        TradingTypes.DecreasePositionRequest[] memory requests
    ) external payable whenNotPaused nonReentrant returns (uint256[] memory orderIds) {
        orderIds = new uint256[](requests.length);

        uint256 surplus = msg.value;
        for (uint256 i = 0; i < requests.length; i++) {
            TradingTypes.DecreasePositionRequest memory request = requests[i];

            require(!operationStatus[request.pairIndex].decreasePositionDisabled, "disabled");
            require(surplus >= request.networkFeeAmount, "insufficient network fee");
            surplus -= request.networkFeeAmount;

            orderIds[i] = orderManager.createOrder{value: request.networkFeeAmount}(
                TradingTypes.CreateOrderRequest({
                    account: msg.sender,
                    pairIndex: request.pairIndex,
                    tradeType: request.tradeType,
                    collateral: request.collateral,
                    openPrice: request.triggerPrice,
                    isLong: request.isLong,
                    sizeAmount: -(request.sizeAmount.safeConvertToInt256()),
                    maxSlippage: request.maxSlippage,
                    paymentType: TradingTypes.convertPaymentType(request.paymentType),
                    networkFeeAmount: request.networkFeeAmount,
                    data: abi.encode(msg.sender)
                })
            );
        }
        if (surplus > 0) {
            payable(msg.sender).transfer(surplus);
        }
        return orderIds;
    }

    function _checkOrderAccount(
        uint256 orderId,
        TradingTypes.TradeType tradeType,
        bool isIncrease
    ) private view {
        if (isIncrease) {
            (TradingTypes.IncreasePositionOrder memory order,) = orderManager.getIncreaseOrder(
                orderId,
                tradeType
            );
            require(order.account == msg.sender, "onlyAccount");
        } else {
            (TradingTypes.DecreasePositionOrder memory order,) = orderManager.getDecreaseOrder(
                orderId,
                tradeType
            );
            require(order.account == msg.sender, "onlyAccount");
        }
    }

    function cancelOrder(CancelOrderRequest memory request) external whenNotPaused nonReentrant {
        _checkOrderAccount(request.orderId, request.tradeType, request.isIncrease);
        orderManager.cancelOrder(
            request.orderId,
            request.tradeType,
            request.isIncrease,
            "cancelOrder"
        );
    }

    function cancelOrders(
        CancelOrderRequest[] memory requests
    ) external whenNotPaused nonReentrant {
        for (uint256 i = 0; i < requests.length; i++) {
            CancelOrderRequest memory request = requests[i];
            _checkOrderAccount(request.orderId, request.tradeType, request.isIncrease);
            orderManager.cancelOrder(
                request.orderId,
                request.tradeType,
                request.isIncrease,
                "cancelOrders"
            );
        }
    }

    function cancelPositionOrders(
        uint256 pairIndex,
        bool isLong,
        bool isIncrease
    ) external whenNotPaused nonReentrant {
        bytes32 key = PositionKey.getPositionKey(msg.sender, pairIndex, isLong);
        IOrderManager.PositionOrder[] memory orders = orderManager.getPositionOrders(key);

        for (uint256 i = 0; i < orders.length; i++) {
            IOrderManager.PositionOrder memory positionOrder = orders[i];
            require(positionOrder.account == msg.sender, "onlyAccount");
            if (isIncrease && positionOrder.isIncrease) {
                orderManager.cancelOrder(
                    positionOrder.orderId,
                    positionOrder.tradeType,
                    true,
                    "cancelOrders"
                );
            } else if (!isIncrease && !positionOrder.isIncrease) {
                orderManager.cancelOrder(
                    positionOrder.orderId,
                    positionOrder.tradeType,
                    false,
                    "cancelOrders"
                );
            }
        }
    }

    function addOrderTpSl(
        AddOrderTpSlRequest memory request
    ) external payable whenNotPaused nonReentrant returns (uint256 tpOrderId, uint256 slOrderId) {
        uint256 pairIndex;
        bool isLong;
        if (request.isIncrease) {
            (TradingTypes.IncreasePositionOrder memory order,) = orderManager.getIncreaseOrder(
                request.orderId,
                request.tradeType
            );
            require(order.account == msg.sender, "no access");
            pairIndex = order.pairIndex;
            isLong = order.isLong;
        } else {
            (TradingTypes.DecreasePositionOrder memory order,) = orderManager.getDecreaseOrder(
                request.orderId,
                request.tradeType
            );
            require(order.account == msg.sender, "no access");
            pairIndex = order.pairIndex;
            isLong = order.isLong;
        }
        require(!operationStatus[pairIndex].orderDisabled, "disabled");

        require(
            request.paymentType == TradingTypes.NetworkFeePaymentType.COLLATERAL ||
            (request.paymentType == TradingTypes.NetworkFeePaymentType.ETH
                && msg.value == request.tpNetworkFeeAmount + request.slNetworkFeeAmount),
            "incorrect value"
        );

        if (request.tp > 0 || request.sl > 0) {
            _createTpSl(
                msg.sender,
                pairIndex,
                isLong,
                request.tpPrice,
                request.tp,
                request.slPrice,
                request.sl,
                request.paymentType,
                request.tpNetworkFeeAmount,
                request.slNetworkFeeAmount
            );
        }
        return (tpOrderId, slOrderId);
    }

    function createTpSl(
        TradingTypes.CreateTpSlRequest memory request
    ) external payable whenNotPaused nonReentrant returns (uint256 tpOrderId, uint256 slOrderId) {
        require(!operationStatus[request.pairIndex].orderDisabled, "disabled");

        require(
            request.paymentType == TradingTypes.NetworkFeePaymentType.COLLATERAL ||
            (request.paymentType == TradingTypes.NetworkFeePaymentType.ETH
                && msg.value == request.tpNetworkFeeAmount + request.slNetworkFeeAmount),
            "incorrect value"
        );

        (tpOrderId, slOrderId) = _createTpSl(
            msg.sender,
            request.pairIndex,
            request.isLong,
            request.tpPrice,
            request.tp,
            request.slPrice,
            request.sl,
            request.paymentType,
            request.tpNetworkFeeAmount,
            request.slNetworkFeeAmount
        );
        return (tpOrderId, slOrderId);
    }

    function addLiquidityETH(
        address indexToken,
        address stableToken,
        uint256 indexAmount,
        uint256 stableAmount,
        address[] calldata tokens,
        bytes[] calldata updateData,
        uint64[] calldata publishTimes,
        uint256 updateFee
    ) external payable whenNotPaused nonReentrant returns (uint256 mintAmount, address slipToken, uint256 slipAmount){
        uint256 pairIndex = IPool(pool).getPairIndex(indexToken, stableToken);
        require(pairIndex > 0, "!exists");
        require(!operationStatus[pairIndex].addLiquidityDisabled, "disabled");
        require(msg.value >= indexAmount + updateFee, "ne");

        IPythOraclePriceFeed(ADDRESS_PROVIDER.priceOracle()).updatePrice{value: updateFee}(tokens, updateData, publishTimes);

        uint256 wrapAmount = msg.value - updateFee;
        this.wrapWETH{value: wrapAmount}(address(this));

        (mintAmount, slipToken, slipAmount) = IPool(pool).addLiquidity(
            msg.sender,
            pairIndex,
            indexAmount,
            stableAmount,
            abi.encode(msg.sender)
        );

        if (wrapAmount - indexAmount > 0 && indexToken == ADDRESS_PROVIDER.WETH()) {
            IWETH(ADDRESS_PROVIDER.WETH()).safeTransfer(msg.sender, wrapAmount - indexAmount);
        }
    }

    function addLiquidity(
        address indexToken,
        address stableToken,
        uint256 indexAmount,
        uint256 stableAmount,
        address[] calldata tokens,
        bytes[] calldata updateData,
        uint64[] calldata publishTimes
    )
        external
        payable
        whenNotPaused
        nonReentrant
        returns (uint256 mintAmount, address slipToken, uint256 slipAmount)
    {
        uint256 pairIndex = IPool(pool).getPairIndex(indexToken, stableToken);
        require(pairIndex > 0, "!exists");
        require(!operationStatus[pairIndex].addLiquidityDisabled, "disabled");

        IPythOraclePriceFeed(ADDRESS_PROVIDER.priceOracle()).updatePrice{value: msg.value}(tokens, updateData, publishTimes);

        if (indexToken == ADDRESS_PROVIDER.WETH()) {
            IWETH(ADDRESS_PROVIDER.WETH()).safeTransferFrom(msg.sender, address(this), indexAmount);
        }

        return
            IPool(pool).addLiquidity(
                msg.sender,
                pairIndex,
                indexAmount,
                stableAmount,
                abi.encode(msg.sender)
            );
    }

    function addLiquidityForAccount(
        address indexToken,
        address stableToken,
        address receiver,
        uint256 indexAmount,
        uint256 stableAmount,
        address[] calldata tokens,
        bytes[] calldata updateData,
        uint64[] calldata publishTimes
    )
        external
        payable
        whenNotPaused
        nonReentrant
        returns (uint256 mintAmount, address slipToken, uint256 slipAmount)
    {
        uint256 pairIndex = IPool(pool).getPairIndex(indexToken, stableToken);
        require(pairIndex > 0, "!exists");
        require(!operationStatus[pairIndex].addLiquidityDisabled, "disabled");

        IPythOraclePriceFeed(ADDRESS_PROVIDER.priceOracle()).updatePrice{value: msg.value}(tokens, updateData, publishTimes);

        if (indexToken == ADDRESS_PROVIDER.WETH()) {
            IWETH(ADDRESS_PROVIDER.WETH()).safeTransferFrom(msg.sender, address(this), indexAmount);
        }
        return
            IPool(pool).addLiquidity(
                receiver,
                pairIndex,
                indexAmount,
                stableAmount,
                abi.encode(msg.sender)
            );
    }

    function removeLiquidity(
        address indexToken,
        address stableToken,
        uint256 amount,
        bool useETH,
        address[] calldata tokens,
        bytes[] calldata updateData,
        uint64[] calldata publishTimes
    )
        external
        payable
        whenNotPaused
        nonReentrant
        returns (uint256 receivedIndexAmount, uint256 receivedStableAmount, uint256 feeAmount)
    {
        uint256 pairIndex = IPool(pool).getPairIndex(indexToken, stableToken);
        require(pairIndex > 0, "!exists");
        require(!operationStatus[pairIndex].removeLiquidityDisabled, "disabled");

        IPythOraclePriceFeed(ADDRESS_PROVIDER.priceOracle()).updatePrice{value: msg.value}(tokens, updateData, publishTimes);

        return
            IPool(pool).removeLiquidity(
                payable(msg.sender),
                pairIndex,
                amount,
                useETH,
                abi.encode(msg.sender)
            );
    }

    function removeLiquidityForAccount(
        address indexToken,
        address stableToken,
        address receiver,
        uint256 amount,
        bool useETH,
        address[] calldata tokens,
        bytes[] calldata updateData,
        uint64[] calldata publishTimes
    )
        external
        payable
        whenNotPaused
        nonReentrant
        returns (uint256 receivedIndexAmount, uint256 receivedStableAmount, uint256 feeAmount)
    {
        uint256 pairIndex = IPool(pool).getPairIndex(indexToken, stableToken);
        require(pairIndex > 0, "!exists");
        require(!operationStatus[pairIndex].removeLiquidityDisabled, "disabled");

        IPythOraclePriceFeed(ADDRESS_PROVIDER.priceOracle()).updatePrice{value: msg.value}(tokens, updateData, publishTimes);

        return
            IPool(pool).removeLiquidity(
                payable(receiver),
                pairIndex,
                amount,
                useETH,
                abi.encode(msg.sender)
            );
    }

    function removeLiquidityCallback(
        address pairToken,
        uint256 amount,
        bytes calldata data
    ) external override onlyPool {
        address sender = abi.decode(data, (address));
        IERC20(pairToken).safeTransferFrom(sender, msg.sender, amount);
    }

    function createOrderCallback(
        address collateral,
        uint256 amount,
        address to,
        bytes calldata data
    ) external override onlyOrderManager {
        address sender = abi.decode(data, (address));

        if (amount > 0) {
            IERC20(collateral).safeTransferFrom(sender, to, uint256(amount));
        }
    }

    function addLiquidityCallback(
        address indexToken,
        address stableToken,
        uint256 amountIndex,
        uint256 amountStable,
        bytes calldata data
    ) external override onlyPool {
        address sender = abi.decode(data, (address));

        if (amountIndex > 0) {
            if (indexToken == ADDRESS_PROVIDER.WETH()) {
                IERC20(indexToken).safeTransfer(msg.sender, uint256(amountIndex));
            } else {
                IERC20(indexToken).safeTransferFrom(sender, msg.sender, uint256(amountIndex));
            }
        }
        if (amountStable > 0) {
            IERC20(stableToken).safeTransferFrom(sender, msg.sender, uint256(amountStable));
        }
    }
}

File 2 of 44 : draft-IERC1822Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)

pragma solidity ^0.8.0;

/**
 * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
 * proxy whose upgrades are fully controlled by the current implementation.
 */
interface IERC1822ProxiableUpgradeable {
    /**
     * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
     * address.
     *
     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
     * function revert if invoked through a proxy.
     */
    function proxiableUUID() external view returns (bytes32);
}

File 3 of 44 : IERC1967Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC1967.sol)

pragma solidity ^0.8.0;

/**
 * @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.
 *
 * _Available since v4.8.3._
 */
interface IERC1967Upgradeable {
    /**
     * @dev Emitted when the implementation is upgraded.
     */
    event Upgraded(address indexed implementation);

    /**
     * @dev Emitted when the admin account has changed.
     */
    event AdminChanged(address previousAdmin, address newAdmin);

    /**
     * @dev Emitted when the beacon is changed.
     */
    event BeaconUpgraded(address indexed beacon);
}

File 4 of 44 : IBeaconUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)

pragma solidity ^0.8.0;

/**
 * @dev This is the interface that {BeaconProxy} expects of its beacon.
 */
interface IBeaconUpgradeable {
    /**
     * @dev Must return an address that can be used as a delegate call target.
     *
     * {BeaconProxy} will check that this address is a contract.
     */
    function implementation() external view returns (address);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/ERC1967/ERC1967Upgrade.sol)

pragma solidity ^0.8.2;

import "../beacon/IBeaconUpgradeable.sol";
import "../../interfaces/IERC1967Upgradeable.sol";
import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../../utils/AddressUpgradeable.sol";
import "../../utils/StorageSlotUpgradeable.sol";
import "../utils/Initializable.sol";

/**
 * @dev This abstract contract provides getters and event emitting update functions for
 * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
 *
 * _Available since v4.1._
 */
abstract contract ERC1967UpgradeUpgradeable is Initializable, IERC1967Upgradeable {
    function __ERC1967Upgrade_init() internal onlyInitializing {
    }

    function __ERC1967Upgrade_init_unchained() internal onlyInitializing {
    }
    // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
    bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;

    /**
     * @dev Storage slot with the address of the current implementation.
     * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;

    /**
     * @dev Returns the current implementation address.
     */
    function _getImplementation() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 implementation slot.
     */
    function _setImplementation(address newImplementation) private {
        require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract");
        StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
    }

    /**
     * @dev Perform implementation upgrade
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeTo(address newImplementation) internal {
        _setImplementation(newImplementation);
        emit Upgraded(newImplementation);
    }

    /**
     * @dev Perform implementation upgrade with additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCall(address newImplementation, bytes memory data, bool forceCall) internal {
        _upgradeTo(newImplementation);
        if (data.length > 0 || forceCall) {
            AddressUpgradeable.functionDelegateCall(newImplementation, data);
        }
    }

    /**
     * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCallUUPS(address newImplementation, bytes memory data, bool forceCall) internal {
        // Upgrades from old implementations will perform a rollback test. This test requires the new
        // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing
        // this special case will break upgrade paths from old UUPS implementation to new ones.
        if (StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT).value) {
            _setImplementation(newImplementation);
        } else {
            try IERC1822ProxiableUpgradeable(newImplementation).proxiableUUID() returns (bytes32 slot) {
                require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID");
            } catch {
                revert("ERC1967Upgrade: new implementation is not UUPS");
            }
            _upgradeToAndCall(newImplementation, data, forceCall);
        }
    }

    /**
     * @dev Storage slot with the admin of the contract.
     * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;

    /**
     * @dev Returns the current admin.
     */
    function _getAdmin() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 admin slot.
     */
    function _setAdmin(address newAdmin) private {
        require(newAdmin != address(0), "ERC1967: new admin is the zero address");
        StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
    }

    /**
     * @dev Changes the admin of the proxy.
     *
     * Emits an {AdminChanged} event.
     */
    function _changeAdmin(address newAdmin) internal {
        emit AdminChanged(_getAdmin(), newAdmin);
        _setAdmin(newAdmin);
    }

    /**
     * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
     * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
     */
    bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;

    /**
     * @dev Returns the current beacon.
     */
    function _getBeacon() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value;
    }

    /**
     * @dev Stores a new beacon in the EIP1967 beacon slot.
     */
    function _setBeacon(address newBeacon) private {
        require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract");
        require(
            AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()),
            "ERC1967: beacon implementation is not a contract"
        );
        StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon;
    }

    /**
     * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
     * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
     *
     * Emits a {BeaconUpgraded} event.
     */
    function _upgradeBeaconToAndCall(address newBeacon, bytes memory data, bool forceCall) internal {
        _setBeacon(newBeacon);
        emit BeaconUpgraded(newBeacon);
        if (data.length > 0 || forceCall) {
            AddressUpgradeable.functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data);
        }
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.2;

import "../../utils/AddressUpgradeable.sol";

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
 * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
 * case an upgrade adds a module that needs to be initialized.
 *
 * For example:
 *
 * [.hljs-theme-light.nopadding]
 * ```solidity
 * contract MyToken is ERC20Upgradeable {
 *     function initialize() initializer public {
 *         __ERC20_init("MyToken", "MTK");
 *     }
 * }
 *
 * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
 *     function initializeV2() reinitializer(2) public {
 *         __ERC20Permit_init("MyToken");
 *     }
 * }
 * ```
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
 * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() {
 *     _disableInitializers();
 * }
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     * @custom:oz-retyped-from bool
     */
    uint8 private _initialized;

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

    /**
     * @dev Triggered when the contract has been initialized or reinitialized.
     */
    event Initialized(uint8 version);

    /**
     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
     * `onlyInitializing` functions can be used to initialize parent contracts.
     *
     * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
     * constructor.
     *
     * Emits an {Initialized} event.
     */
    modifier initializer() {
        bool isTopLevelCall = !_initializing;
        require(
            (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
            "Initializable: contract is already initialized"
        );
        _initialized = 1;
        if (isTopLevelCall) {
            _initializing = true;
        }
        _;
        if (isTopLevelCall) {
            _initializing = false;
            emit Initialized(1);
        }
    }

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * A reinitializer may be used after the original initialization step. This is essential to configure modules that
     * are added through upgrades and that require initialization.
     *
     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
     * cannot be nested. If one is invoked in the context of another, execution will revert.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     *
     * WARNING: setting the version to 255 will prevent any future reinitialization.
     *
     * Emits an {Initialized} event.
     */
    modifier reinitializer(uint8 version) {
        require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
        _initialized = version;
        _initializing = true;
        _;
        _initializing = false;
        emit Initialized(version);
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} and {reinitializer} modifiers, directly or indirectly.
     */
    modifier onlyInitializing() {
        require(_initializing, "Initializable: contract is not initializing");
        _;
    }

    /**
     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
     * through proxies.
     *
     * Emits an {Initialized} event the first time it is successfully executed.
     */
    function _disableInitializers() internal virtual {
        require(!_initializing, "Initializable: contract is initializing");
        if (_initialized != type(uint8).max) {
            _initialized = type(uint8).max;
            emit Initialized(type(uint8).max);
        }
    }

    /**
     * @dev Returns the highest version that has been initialized. See {reinitializer}.
     */
    function _getInitializedVersion() internal view returns (uint8) {
        return _initialized;
    }

    /**
     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
     */
    function _isInitializing() internal view returns (bool) {
        return _initializing;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/UUPSUpgradeable.sol)

pragma solidity ^0.8.0;

import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../ERC1967/ERC1967UpgradeUpgradeable.sol";
import "./Initializable.sol";

/**
 * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
 * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
 *
 * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
 * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
 * `UUPSUpgradeable` with a custom implementation of upgrades.
 *
 * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
 *
 * _Available since v4.1._
 */
abstract contract UUPSUpgradeable is Initializable, IERC1822ProxiableUpgradeable, ERC1967UpgradeUpgradeable {
    function __UUPSUpgradeable_init() internal onlyInitializing {
    }

    function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
    }
    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment
    address private immutable __self = address(this);

    /**
     * @dev Check that the execution is being performed through a delegatecall call and that the execution context is
     * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case
     * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
     * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
     * fail.
     */
    modifier onlyProxy() {
        require(address(this) != __self, "Function must be called through delegatecall");
        require(_getImplementation() == __self, "Function must be called through active proxy");
        _;
    }

    /**
     * @dev Check that the execution is not being performed through a delegate call. This allows a function to be
     * callable on the implementing contract but not through proxies.
     */
    modifier notDelegated() {
        require(address(this) == __self, "UUPSUpgradeable: must not be called through delegatecall");
        _;
    }

    /**
     * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the
     * implementation. It is used to validate the implementation's compatibility when performing an upgrade.
     *
     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
     * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
     */
    function proxiableUUID() external view virtual override notDelegated returns (bytes32) {
        return _IMPLEMENTATION_SLOT;
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     *
     * @custom:oz-upgrades-unsafe-allow-reachable delegatecall
     */
    function upgradeTo(address newImplementation) public virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallUUPS(newImplementation, new bytes(0), false);
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
     * encoded in `data`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     *
     * @custom:oz-upgrades-unsafe-allow-reachable delegatecall
     */
    function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallUUPS(newImplementation, data, true);
    }

    /**
     * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
     * {upgradeTo} and {upgradeToAndCall}.
     *
     * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
     *
     * ```solidity
     * function _authorizeUpgrade(address) internal override onlyOwner {}
     * ```
     */
    function _authorizeUpgrade(address newImplementation) internal virtual;

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.

pragma solidity ^0.8.0;

/**
 * @dev Library for reading and writing primitive types to specific storage slots.
 *
 * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
 * This library helps with reading and writing to such slots without the need for inline assembly.
 *
 * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
 *
 * Example usage to set ERC1967 implementation slot:
 * ```solidity
 * contract ERC1967 {
 *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
 *
 *     function _getImplementation() internal view returns (address) {
 *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
 *     }
 *
 *     function _setImplementation(address newImplementation) internal {
 *         require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
 *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
 *     }
 * }
 * ```
 *
 * _Available since v4.1 for `address`, `bool`, `bytes32`, `uint256`._
 * _Available since v4.9 for `string`, `bytes`._
 */
library StorageSlotUpgradeable {
    struct AddressSlot {
        address value;
    }

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

    struct StringSlot {
        string value;
    }

    struct BytesSlot {
        bytes value;
    }

    /**
     * @dev Returns an `AddressSlot` with member `value` located at `slot`.
     */
    function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `BooleanSlot` with member `value` located at `slot`.
     */
    function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
     */
    function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Uint256Slot` with member `value` located at `slot`.
     */
    function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `StringSlot` with member `value` located at `slot`.
     */
    function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `StringSlot` representation of the string storage pointer `store`.
     */
    function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := store.slot
        }
    }

    /**
     * @dev Returns an `BytesSlot` with member `value` located at `slot`.
     */
    function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
     */
    function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := store.slot
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract Pausable is Context {
    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    constructor() {
        _paused = false;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        _requireNotPaused();
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        _requirePaused();
        _;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        require(!paused(), "Pausable: paused");
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        require(paused(), "Pausable: not paused");
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }
}

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (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.
 */
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].
     */
    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);
}

// 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);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (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. Compatible with tokens that require the approval to be set to
     * 0 before setting it to a non-zero value.
     */
    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));
    }
}

// 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);
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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;
    }
}

// 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);
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/SafeMath.sol)

pragma solidity ^0.8.0;

// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.

/**
 * @dev Wrappers over Solidity's arithmetic operations.
 *
 * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
 * now has built in overflow checking.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

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

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

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

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

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        return a + b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return a - b;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        return a * b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator.
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        unchecked {
            require(b <= a, errorMessage);
            return a - b;
        }
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a / b;
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a % b;
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard signed math utilities missing in the Solidity language.
 */
library SignedMath {
    /**
     * @dev Returns the largest of two signed numbers.
     */
    function max(int256 a, int256 b) internal pure returns (int256) {
        return a > b ? a : b;
    }

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

    /**
     * @dev Returns the average of two signed numbers without overflow.
     * The result is rounded towards zero.
     */
    function average(int256 a, int256 b) internal pure returns (int256) {
        // Formula from the book "Hacker's Delight"
        int256 x = (a & b) + ((a ^ b) >> 1);
        return x + (int256(uint256(x) >> 255) & (a ^ b));
    }

    /**
     * @dev Returns the absolute unsigned value of a signed value.
     */
    function abs(int256 n) internal pure returns (uint256) {
        unchecked {
            // must be unchecked in order to support `n = type(int256).min`
            return uint256(n >= 0 ? n : -n);
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

import "./math/Math.sol";
import "./math/SignedMath.sol";

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _SYMBOLS = "0123456789abcdef";
    uint8 private constant _ADDRESS_LENGTH = 20;

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        unchecked {
            uint256 length = Math.log10(value) + 1;
            string memory buffer = new string(length);
            uint256 ptr;
            /// @solidity memory-safe-assembly
            assembly {
                ptr := add(buffer, add(32, length))
            }
            while (true) {
                ptr--;
                /// @solidity memory-safe-assembly
                assembly {
                    mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
                }
                value /= 10;
                if (value == 0) break;
            }
            return buffer;
        }
    }

    /**
     * @dev Converts a `int256` to its ASCII `string` decimal representation.
     */
    function toString(int256 value) internal pure returns (string memory) {
        return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value))));
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        unchecked {
            return toHexString(value, Math.log256(value) + 1);
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
    }

    /**
     * @dev Returns true if the two strings are equal.
     */
    function equal(string memory a, string memory b) internal pure returns (bool) {
        return keccak256(bytes(a)) == keccak256(bytes(b));
    }
}

// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "../libraries/PrecisionUtils.sol";
import "../interfaces/IPool.sol";

library TokenHelper {
    using PrecisionUtils for uint256;
    using SafeMath for uint256;

    function convertIndexAmountToStable(
        IPool.Pair memory pair,
        int256 indexTokenAmount
    ) internal view returns (int256 amount) {
        if (indexTokenAmount == 0) return 0;

        uint8 stableTokenDec = IERC20Metadata(pair.stableToken).decimals();
        return convertTokenAmountTo(pair.indexToken, indexTokenAmount, stableTokenDec);
    }

    function convertIndexAmountToStableWithPrice(
        IPool.Pair memory pair,
        int256 indexTokenAmount,
        uint256 price
    ) internal view returns (int256 amount) {
        if (indexTokenAmount == 0) return 0;

        uint8 stableTokenDec = IERC20Metadata(pair.stableToken).decimals();
        return convertTokenAmountWithPrice(pair.indexToken, indexTokenAmount, stableTokenDec, price);
    }

    function convertTokenAmountWithPrice(
        address token,
        int256 tokenAmount,
        uint8 targetDecimals,
        uint256 price
    ) internal view returns (int256 amount) {
        if (tokenAmount == 0) return 0;

        uint256 tokenDec = uint256(IERC20Metadata(token).decimals());

        uint256 tokenWad = 10 ** (PrecisionUtils.maxTokenDecimals() - tokenDec);
        uint256 targetTokenWad = 10 ** (PrecisionUtils.maxTokenDecimals() - targetDecimals);

        amount = (tokenAmount * int256(tokenWad)) * int256(price) / int256(targetTokenWad) / int256(PrecisionUtils.PRICE_PRECISION);
    }

    function convertStableAmountToIndex(
        IPool.Pair memory pair,
        int256 stableTokenAmount
    ) internal view returns (int256 amount) {
        if (stableTokenAmount == 0) return 0;

        uint8 indexTokenDec = IERC20Metadata(pair.indexToken).decimals();
        return convertTokenAmountTo(pair.stableToken, stableTokenAmount, indexTokenDec);
    }

    function convertTokenAmountTo(
        address token,
        int256 tokenAmount,
        uint8 targetDecimals
    ) internal view returns (int256 amount) {
        if (tokenAmount == 0) return 0;

        uint256 tokenDec = uint256(IERC20Metadata(token).decimals());

        uint256 tokenWad = 10 ** (PrecisionUtils.maxTokenDecimals() - tokenDec);
        uint256 targetTokenWad = 10 ** (PrecisionUtils.maxTokenDecimals() - targetDecimals);
        amount = (tokenAmount * int256(tokenWad)) / int256(targetTokenWad);
    }
}

// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.0;

interface IAddressesProvider {
    event AddressSet(bytes32 indexed id, address indexed oldAddress, address indexed newAddress);

    function WETH() external view returns (address);

    function timelock() external view returns (address);

    function priceOracle() external view returns (address);

    function indexPriceOracle() external view returns (address);

    function fundingRate() external view returns (address);

    function executionLogic() external view returns (address);

    function liquidationLogic() external view returns (address);

    function roleManager() external view returns (address);

    function backtracker() external view returns (address);
}

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

import "./IPool.sol";
import "../libraries/TradingTypes.sol";

interface IFeeCollector {

    event UpdatedTradingFeeTier(
        address sender,
        uint8 tier,
        uint256 oldTakerFee,
        uint256 oldMakerFee,
        uint256 newTakerFee,
        uint256 newMakerFee
    );

    event UpdateMaxReferralsRatio(uint256 oldRatio, uint256 newRatio);

    event UpdatedStakingPoolAddress(address sender, address oldAddress, address newAddress);

    event UpdatedPositionManagerAddress(address sender, address oldAddress, address newAddress);

    event UpdateExecutionLogicAddress(address sender, address oldAddress, address newAddress);

    event DistributeTradingFee(
        address account,
        uint256 pairIndex,
        uint256 sizeDelta,
        uint256 tradingFee,
        uint256 vipDiscountAmount,
        uint256 vipFeeRate,
        uint256 referralsAmount,
        uint256 referralUserAmount,
        address referralOwner,
        uint256 lpAmount,
        uint256 keeperAmount,
        uint256 stakingAmount,
        uint256 distributorAmount
    );

    event ClaimedStakingTradingFee(address account, address claimToken, uint256 amount);

    event ClaimedDistributorTradingFee(address account, address claimToken, uint256 amount);

    event ClaimedReferralsTradingFee(address account, address claimToken, uint256 amount);

    event ClaimedUserTradingFee(address account, address claimToken, uint256 amount);

    event ClaimedKeeperNetworkFee(address account, address claimToken, uint256 amount);

    struct TradingFeeTier {
        uint256 makerFee;
        uint256 takerFee;
    }

    function maxReferralsRatio() external view returns (uint256 maxReferenceRatio);

    function stakingTradingFee() external view returns (uint256);

    function treasuryFee() external view returns (uint256);

    function userTradingFee(address _account) external view returns (uint256);

    function referralFee(address _referralOwner) external view returns (uint256);

    function getTradingFeeTier(uint256 pairIndex, uint8 tier) external view returns (TradingFeeTier memory);

    function getRegularTradingFeeTier(uint256 pairIndex) external view returns (TradingFeeTier memory);

    function getKeeperNetworkFee(
        address account,
        TradingTypes.InnerPaymentType paymentType
    ) external view returns (uint256);

    function updateMaxReferralsRatio(uint256 newRatio) external;

    function claimStakingTradingFee() external returns (uint256);

    function claimTreasuryFee() external returns (uint256);

    function claimReferralFee() external returns (uint256);

    function claimUserTradingFee() external returns (uint256);

    function claimKeeperNetworkFee(
        TradingTypes.InnerPaymentType paymentType
    ) external returns (uint256);

    function distributeTradingFee(
        IPool.Pair memory pair,
        address account,
        address keeper,
        uint256 sizeDelta,
        uint256 tradingFee,
        uint256 vipFeeRate,
        uint256 referralsRatio,
        uint256 referralUserRatio,
        address referralOwner
    ) external returns (uint256 lpAmount, uint256 vipDiscountAmount);

    function distributeNetworkFee(
        address keeper,
        TradingTypes.InnerPaymentType paymentType,
        uint256 networkFeeAmount
    ) external;
}

// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.8.0;

interface ILiquidityCallback {
    function addLiquidityCallback(
        address indexToken,
        address stableToken,
        uint256 amountIndex,
        uint256 amountStable,
        bytes calldata data
    ) external;

    function removeLiquidityCallback(address poolToken, uint256 amount, bytes calldata data) external;
}

// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.8.0;
pragma abicoder v2;

interface IMulticall {
    function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);
}

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

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

interface IOraclePriceFeed is IPriceFeed {

    function updateHistoricalPrice(
        address[] calldata tokens,
        bytes[] calldata updateData,
        uint64 backtrackRound
    ) external payable;

    function removeHistoricalPrice(
        uint64 backtrackRound,
        address[] calldata tokens
    ) external;

    function getHistoricalPrice(
        uint64 backtrackRound,
        address token
    ) external view returns (uint256);

}

// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.8.0;

interface IOrderCallback {
    function createOrderCallback(address collateral, uint256 amount, address to, bytes calldata data) external;
}

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

import '../libraries/TradingTypes.sol';

interface IOrderManager {
    event UpdatePositionManager(address oldAddress, address newAddress);
    event CancelOrder(uint256 orderId, TradingTypes.TradeType tradeType, string reason);

    event CreateIncreaseOrder(
        address account,
        uint256 orderId,
        uint256 pairIndex,
        TradingTypes.TradeType tradeType,
        int256 collateral,
        uint256 openPrice,
        bool isLong,
        uint256 sizeAmount,
        TradingTypes.InnerPaymentType paymentType,
        uint256 networkFeeAmount
    );

    event CreateDecreaseOrder(
        address account,
        uint256 orderId,
        TradingTypes.TradeType tradeType,
        int256 collateral,
        uint256 pairIndex,
        uint256 openPrice,
        uint256 sizeAmount,
        bool isLong,
        bool abovePrice,
        TradingTypes.InnerPaymentType paymentType,
        uint256 networkFeeAmount
    );

    event UpdateRouterAddress(address sender, address oldAddress, address newAddress);

    event CancelIncreaseOrder(address account, uint256 orderId, TradingTypes.TradeType tradeType);
    event CancelDecreaseOrder(address account, uint256 orderId, TradingTypes.TradeType tradeType);

    event UpdatedNetworkFee(
        address sender,
        TradingTypes.NetworkFeePaymentType paymentType,
        uint256 pairIndex,
        uint256 basicNetworkFee,
        uint256 discountThreshold,
        uint256 discountedNetworkFee
    );

    struct PositionOrder {
        address account;
        uint256 pairIndex;
        bool isLong;
        bool isIncrease;
        TradingTypes.TradeType tradeType;
        uint256 orderId;
        uint256 sizeAmount;
    }

    struct NetworkFee {
        uint256 basicNetworkFee;
        uint256 discountThreshold;
        uint256 discountedNetworkFee;
    }

    function ordersIndex() external view returns (uint256);

    function getPositionOrders(bytes32 key) external view returns (PositionOrder[] memory);

    function getNetworkFee(TradingTypes.NetworkFeePaymentType paymentType, uint256 pairIndex) external view returns (NetworkFee memory);

    function createOrder(TradingTypes.CreateOrderRequest memory request) external payable returns (uint256 orderId);

    function cancelOrder(
        uint256 orderId,
        TradingTypes.TradeType tradeType,
        bool isIncrease,
        string memory reason
    ) external;

    function cancelAllPositionOrders(address account, uint256 pairIndex, bool isLong) external;

    function getIncreaseOrder(
        uint256 orderId,
        TradingTypes.TradeType tradeType
    ) external view returns (
        TradingTypes.IncreasePositionOrder memory order,
        TradingTypes.OrderNetworkFee memory orderNetworkFee
    );

    function getDecreaseOrder(
        uint256 orderId,
        TradingTypes.TradeType tradeType
    ) external view returns (
        TradingTypes.DecreasePositionOrder memory order,
        TradingTypes.OrderNetworkFee memory orderNetworkFee
    );

    function increaseOrderExecutedSize(
        uint256 orderId,
        TradingTypes.TradeType tradeType,
        bool isIncrease,
        uint256 increaseSize
    ) external;

    function removeOrderFromPosition(PositionOrder memory order) external;

    function removeIncreaseMarketOrders(uint256 orderId) external;

    function removeIncreaseLimitOrders(uint256 orderId) external;

    function removeDecreaseMarketOrders(uint256 orderId) external;

    function removeDecreaseLimitOrders(uint256 orderId) external;

    function setOrderNeedADL(uint256 orderId, TradingTypes.TradeType tradeType, bool needADL) external;

}

// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

interface IPool {
    // Events
    event PairAdded(
        address indexed indexToken,
        address indexed stableToken,
        address lpToken,
        uint256 index
    );

    event UpdateTotalAmount(
        uint256 indexed pairIndex,
        int256 indexAmount,
        int256 stableAmount,
        uint256 indexTotalAmount,
        uint256 stableTotalAmount
    );

    event UpdateReserveAmount(
        uint256 indexed pairIndex,
        int256 indexAmount,
        int256 stableAmount,
        uint256 indexReservedAmount,
        uint256 stableReservedAmount
    );

    event UpdateLPProfit(
        uint256 indexed pairIndex,
        address token,
        int256 profit,
        uint256 totalAmount
    );

    event UpdateAveragePrice(uint256 indexed pairIndex, uint256 averagePrice);

    event UpdateSpotSwap(address sender, address oldAddress, address newAddress);

    event UpdatePoolView(address sender, address oldAddress, address newAddress);

    event UpdateRouter(address sender, address oldAddress, address newAddress);

    event UpdateRiskReserve(address sender, address oldAddress, address newAddress);

    event UpdateFeeCollector(address sender, address oldAddress, address newAddress);

    event UpdatePositionManager(address sender, address oldAddress, address newAddress);

    event UpdateOrderManager(address sender, address oldAddress, address newAddress);

    event AddStableToken(address sender, address token);

    event RemoveStableToken(address sender, address token);

    event AddLiquidity(
        address indexed recipient,
        uint256 indexed pairIndex,
        uint256 indexAmount,
        uint256 stableAmount,
        uint256 lpAmount,
        uint256 indexFeeAmount,
        uint256 stableFeeAmount,
        address slipToken,
        uint256 slipFeeAmount,
        uint256 lpPrice
    );

    event RemoveLiquidity(
        address indexed recipient,
        uint256 indexed pairIndex,
        uint256 indexAmount,
        uint256 stableAmount,
        uint256 lpAmount,
        uint256 feeAmount,
        uint256 lpPrice
    );

    event ClaimedFee(address sender, address token, uint256 amount);

    struct Vault {
        uint256 indexTotalAmount; // total amount of tokens
        uint256 indexReservedAmount; // amount of tokens reserved for open positions
        uint256 stableTotalAmount;
        uint256 stableReservedAmount;
        uint256 averagePrice;
    }

    struct Pair {
        uint256 pairIndex;
        address indexToken;
        address stableToken;
        address pairToken;
        bool enable;
        uint256 kOfSwap; //Initial k value of liquidity
        uint256 expectIndexTokenP; //   for 100%
        uint256 maxUnbalancedP;
        uint256 unbalancedDiscountRate;
        uint256 addLpFeeP; // Add liquidity fee
        uint256 removeLpFeeP; // remove liquidity fee
    }

    struct TradingConfig {
        uint256 minLeverage;
        uint256 maxLeverage;
        uint256 minTradeAmount;
        uint256 maxTradeAmount;
        uint256 maxPositionAmount;
        uint256 maintainMarginRate; // Maintain the margin rate of  for 100%
        uint256 priceSlipP; // Price slip point
        uint256 maxPriceDeviationP; // Maximum offset of index price
    }

    struct TradingFeeConfig {
        uint256 lpFeeDistributeP;
        uint256 stakingFeeDistributeP;
        uint256 keeperFeeDistributeP;
        uint256 treasuryFeeDistributeP;
        uint256 reservedFeeDistributeP;
        uint256 ecoFundFeeDistributeP;
    }

    function pairsIndex() external view returns (uint256);

    function getPairIndex(address indexToken, address stableToken) external view returns (uint256);

    function getPair(uint256) external view returns (Pair memory);

    function getTradingConfig(uint256 _pairIndex) external view returns (TradingConfig memory);

    function getTradingFeeConfig(uint256) external view returns (TradingFeeConfig memory);

    function getVault(uint256 _pairIndex) external view returns (Vault memory vault);

    function transferTokenTo(address token, address to, uint256 amount) external;

    function transferEthTo(address to, uint256 amount) external;

    function transferTokenOrSwap(
        uint256 pairIndex,
        address token,
        address to,
        uint256 amount
    ) external;

    function increaseReserveAmount(
        uint256 _pairToken,
        uint256 _indexAmount,
        uint256 _stableAmount
    ) external;

    function decreaseReserveAmount(
        uint256 _pairToken,
        uint256 _indexAmount,
        uint256 _stableAmount
    ) external;

    function updateAveragePrice(uint256 _pairIndex, uint256 _averagePrice) external;

    function setLPStableProfit(uint256 _pairIndex, int256 _profit) external;

    function addLiquidity(
        address recipient,
        uint256 _pairIndex,
        uint256 _indexAmount,
        uint256 _stableAmount,
        bytes calldata data
    ) external returns (uint256 mintAmount, address slipToken, uint256 slipAmount);

    function removeLiquidity(
        address payable _receiver,
        uint256 _pairIndex,
        uint256 _amount,
        bool useETH,
        bytes calldata data
    )
        external
        returns (uint256 receivedIndexAmount, uint256 receivedStableAmount, uint256 feeAmount);

    function claimFee(address token, uint256 amount) external;
}

// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.19;

import '../libraries/Position.sol';
import "./IFeeCollector.sol";

enum PositionStatus {
    Balance,
    NetLong,
    NetShort
}

interface IPositionManager {
    event UpdateFundingInterval(uint256 oldInterval, uint256 newInterval);

    event UpdatePosition(
        address account,
        bytes32 positionKey,
        uint256 pairIndex,
        uint256 orderId,
        bool isLong,
        uint256 beforCollateral,
        uint256 afterCollateral,
        uint256 price,
        uint256 beforPositionAmount,
        uint256 afterPositionAmount,
        uint256 averagePrice,
        int256 fundFeeTracker,
        int256 pnl
    );

    event UpdatedExecutionLogic(address sender, address oldAddress, address newAddress);

    event UpdatedLiquidationLogic(address sender, address oldAddress, address newAddress);

    event UpdateRouterAddress(address sender, address oldAddress, address newAddress);

    event UpdateFundingRate(uint256 pairIndex, uint price, int256 fundingRate, uint256 lastFundingTime);

    event TakeFundingFeeAddTraderFee(
        address account,
        uint256 pairIndex,
        uint256 orderId,
        uint256 sizeDelta,
        uint256 tradingFee,
        int256 fundingFee,
        uint256 lpTradingFee,
        uint256 vipDiscountAmount
    );

    event AdjustCollateral(
        address account,
        uint256 pairIndex,
        bool isLong,
        bytes32 positionKey,
        uint256 collateralBefore,
        uint256 collateralAfter
    );

    function getExposedPositions(uint256 pairIndex) external view returns (int256);

    function longTracker(uint256 pairIndex) external view returns (uint256);

    function shortTracker(uint256 pairIndex) external view returns (uint256);

    function getTradingFee(
        uint256 _pairIndex,
        bool _isLong,
        uint256 _sizeAmount,
        uint256 price
    ) external view returns (uint256 tradingFee);

    function getFundingFee(
        address _account,
        uint256 _pairIndex,
        bool _isLong
    ) external view returns (int256 fundingFee);

    function getCurrentFundingRate(uint256 _pairIndex) external view returns (int256);

    function getNextFundingRate(uint256 _pairIndex, uint256 price) external view returns (int256);

    function getNextFundingRateUpdateTime(uint256 _pairIndex) external view returns (uint256);

    function needADL(
        uint256 pairIndex,
        bool isLong,
        uint256 executionSize,
        uint256 executionPrice
    ) external view returns (bool needADL, uint256 needADLAmount);

    function needLiquidation(
        bytes32 positionKey,
        uint256 price
    ) external view returns (bool);

    function getPosition(
        address _account,
        uint256 _pairIndex,
        bool _isLong
    ) external view returns (Position.Info memory);

    function getPositionByKey(bytes32 key) external view returns (Position.Info memory);

    function getPositionKey(address _account, uint256 _pairIndex, bool _isLong) external pure returns (bytes32);

    function increasePosition(
        uint256 _pairIndex,
        uint256 orderId,
        address _account,
        address _keeper,
        uint256 _sizeAmount,
        bool _isLong,
        int256 _collateral,
        IFeeCollector.TradingFeeTier memory tradingFeeTier,
        uint256 referralsRatio,
        uint256 referralUserRatio,
        address referralOwner,
        uint256 _price
    ) external returns (uint256 tradingFee, int256 fundingFee);

    function decreasePosition(
        uint256 _pairIndex,
        uint256 orderId,
        address _account,
        address _keeper,
        uint256 _sizeAmount,
        bool _isLong,
        int256 _collateral,
        IFeeCollector.TradingFeeTier memory tradingFeeTier,
        uint256 referralsRatio,
        uint256 referralUserRatio,
        address referralOwner,
        uint256 _price,
        bool useRiskReserve
    ) external returns (uint256 tradingFee, int256 fundingFee, int256 pnl);

    function adjustCollateral(uint256 pairIndex, address account, bool isLong, int256 collateral) external;

    function updateFundingRate(uint256 _pairIndex) external;

    function lpProfit(uint pairIndex, address token, uint256 price) external view returns (int256 profit);
}

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

interface IPriceFeed {

    event PriceAgeUpdated(uint256 oldAge, uint256 newAge);

    function getPrice(address token) external view returns (uint256);

    function getPriceSafely(address token) external view returns (uint256);

    function decimals() external pure returns (uint256);

}

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

import "./IOraclePriceFeed.sol";

interface IPythOraclePriceFeed is IOraclePriceFeed {

    event TokenPriceIdUpdated(
        address token,
        bytes32 priceId
    );

    event PythAddressUpdated(address oldAddress, address newAddress);

    event UpdatedExecutorAddress(address sender, address oldAddress, address newAddress);

    event UnneededPricePublishWarn();

    function updatePrice(
        address[] calldata tokens,
        bytes[] calldata updateData,
        uint64[] calldata publishTimes
    ) external payable;
}

// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.0;

interface IRoleManager {
    function setRoleAdmin(bytes32 role, bytes32 adminRole) external;

    function isAdmin(address) external view returns (bool);

    function isPoolAdmin(address poolAdmin) external view returns (bool);

    function isOperator(address operator) external view returns (bool);

    function isTreasurer(address treasurer) external view returns (bool);

    function isKeeper(address) external view returns (bool);

    function isBlackList(address account) external view returns (bool);
}

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

import "../libraries/TradingTypes.sol";

interface IRouter {
    struct AddOrderTpSlRequest {
        uint256 orderId;
        TradingTypes.TradeType tradeType;
        bool isIncrease;
        uint256 tpPrice; // Stop profit price 1e30
        uint128 tp; // The number of profit stops
        uint256 slPrice; // Stop price 1e30
        uint128 sl; // Stop loss quantity
        TradingTypes.NetworkFeePaymentType paymentType;
        uint256 tpNetworkFeeAmount;
        uint256 slNetworkFeeAmount;
    }

    struct CancelOrderRequest {
        uint256 orderId;
        TradingTypes.TradeType tradeType;
        bool isIncrease;
    }

    struct OperationStatus {
        bool increasePositionDisabled;
        bool decreasePositionDisabled;
        bool orderDisabled;
        bool addLiquidityDisabled;
        bool removeLiquidityDisabled;
    }

    event UpdateTradingRouter(address oldAddress, address newAddress);

    event UpdateIncreasePositionStatus(address sender, uint256 pairIndex, bool enabled);
    event UpdateDecreasePositionStatus(address sender, uint256 pairIndex, bool enabled);
    event UpdateOrderStatus(address sender, uint256 pairIndex, bool enabled);
    event UpdateAddLiquidityStatus(address sender, uint256 pairIndex, bool enabled);
    event UpdateRemoveLiquidityStatus(address sender, uint256 pairIndex, bool enabled);

    function getOperationStatus(uint256 pairIndex) external view returns (OperationStatus memory);
}

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

interface ISwapCallback {
    function swapCallback(
        address indexToken,
        address stableToken,
        uint256 indexAmount,
        uint256 stableAmount,
        bytes calldata data
    ) external;
}

// SPDX-License-Identifier: MIT
pragma solidity =0.8.19;

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

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

    function withdraw(uint256) external;
}

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

import '@openzeppelin/contracts/utils/math/Math.sol';
import '@openzeppelin/contracts/utils/Strings.sol';

library Int256Utils {
    using Strings for uint256;

    function abs(int256 a) internal pure returns (uint256) {
        return a >= 0 ? uint256(a) : uint256(-a);
    }

    function min(int256 a, int256 b) internal pure returns (int256) {
        return a < b ? a : b;
    }

    function max(int256 a, int256 b) internal pure returns (int256) {
        return a > b ? a : b;
    }

    function safeConvertToInt256(uint256 value) internal pure returns (int256) {
        require(value <= uint256(type(int256).max), "Value too large to fit in int256.");
        return int256(value);
    }

    function toString(int256 amount) internal pure returns (string memory) {
        return string.concat(amount >= 0 ? '' : '-', abs(amount).toString());
    }
}

File 39 of 44 : Multicall.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
pragma abicoder v2;

import '../interfaces/IMulticall.sol';

abstract contract Multicall is IMulticall {
    function multicall(bytes[] calldata data) external payable override returns (bytes[] memory results) {
        results = new bytes[](data.length);
        for (uint256 i = 0; i < data.length; i++) {
            (bool success, bytes memory result) = address(this).delegatecall(data[i]);
            if (!success) {
                if (result.length < 68) revert();
                assembly {
                    result := add(result, 0x04)
                }
                revert(abi.decode(result, (string)));
            }

            results[i] = result;
        }
    }
}

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

import '@openzeppelin/contracts/utils/math/Math.sol';
import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import '../libraries/PrecisionUtils.sol';
import '../libraries/Int256Utils.sol';
import '../libraries/TradingTypes.sol';
import '../libraries/PositionKey.sol';
import "../interfaces/IPool.sol";
import "../helpers/TokenHelper.sol";

library Position {
    using Int256Utils for int256;
    using Math for uint256;
    using PrecisionUtils for uint256;

    struct Info {
        address account;
        uint256 pairIndex;
        bool isLong;
        uint256 collateral;
        uint256 positionAmount;
        uint256 averagePrice;
        int256 fundingFeeTracker;
    }

    function get(
        mapping(bytes32 => Info) storage self,
        address _account,
        uint256 _pairIndex,
        bool _isLong
    ) internal view returns (Position.Info storage position) {
        position = self[PositionKey.getPositionKey(_account, _pairIndex, _isLong)];
    }

    function getPositionByKey(
        mapping(bytes32 => Info) storage self,
        bytes32 key
    ) internal view returns (Position.Info storage position) {
        position = self[key];
    }

    function init(Info storage self, uint256 pairIndex, address account, bool isLong, uint256 oraclePrice) internal {
        self.pairIndex = pairIndex;
        self.account = account;
        self.isLong = isLong;
        self.averagePrice = oraclePrice;
    }

    function getUnrealizedPnl(
        Info memory self,
        IPool.Pair memory pair,
        uint256 _sizeAmount,
        uint256 price
    ) internal view returns (int256 pnl) {
        if (price == self.averagePrice || self.averagePrice == 0 || _sizeAmount == 0) {
            return 0;
        }

        if (self.isLong) {
            if (price > self.averagePrice) {
                pnl = TokenHelper.convertIndexAmountToStableWithPrice(
                    pair,
                    int256(_sizeAmount),
                    price - self.averagePrice
                );
            } else {
                pnl = TokenHelper.convertIndexAmountToStableWithPrice(
                    pair,
                    -int256(_sizeAmount),
                    self.averagePrice - price
                );
            }
        } else {
            if (self.averagePrice > price) {
                pnl = TokenHelper.convertIndexAmountToStableWithPrice(
                    pair,
                    int256(_sizeAmount),
                    self.averagePrice - price
                );
            } else {
                pnl = TokenHelper.convertIndexAmountToStableWithPrice(
                    pair,
                    -int256(_sizeAmount),
                    price - self.averagePrice
                );
            }
        }

        return pnl;
    }

    function validLeverage(
        Info memory self,
        IPool.Pair memory pair,
        uint256 price,
        int256 _collateral,
        uint256 _sizeAmount,
        bool _increase,
        uint256 maxLeverage,
        uint256 maxPositionAmount,
        bool simpleVerify,
        int256 fundingFee
    ) internal view returns (uint256, uint256) {
        // only increase collateral
        if (_sizeAmount == 0 && _collateral >= 0) {
            return (self.positionAmount, self.collateral);
        }

        uint256 afterPosition;
        if (_increase) {
            afterPosition = self.positionAmount + _sizeAmount;
        } else {
            afterPosition = self.positionAmount >= _sizeAmount ? self.positionAmount - _sizeAmount : 0;
        }

        if (_increase && afterPosition > maxPositionAmount) {
            revert("exceeds max position");
        }

        int256 availableCollateral = int256(self.collateral) + fundingFee;

        // pnl
        if (!simpleVerify) {
            int256 pnl = getUnrealizedPnl(self, pair, self.positionAmount, price);
            if (!_increase && _sizeAmount > 0 && _sizeAmount < self.positionAmount) {
                if (pnl >= 0) {
                    availableCollateral += getUnrealizedPnl(self, pair, self.positionAmount - _sizeAmount, price);
                } else {
//                    availableCollateral += getUnrealizedPnl(self, pair, _sizeAmount, price);
                    availableCollateral += pnl;
                }
            } else {
                availableCollateral += pnl;
            }
        }

        // adjust collateral
        if (_collateral != 0) {
            availableCollateral += _collateral;
        }
        require(simpleVerify || availableCollateral >= 0, 'collateral not enough');

        if (!simpleVerify && ((_increase && _sizeAmount > 0) || _collateral < 0)) {
            uint256 collateralDec = uint256(IERC20Metadata(pair.stableToken).decimals());
            uint256 tokenDec = uint256(IERC20Metadata(pair.indexToken).decimals());

            uint256 tokenWad = 10 ** (PrecisionUtils.maxTokenDecimals() - tokenDec);
            uint256 collateralWad = 10 ** (PrecisionUtils.maxTokenDecimals() - collateralDec);

            uint256 afterPositionD = afterPosition * tokenWad;
            uint256 availableD = (availableCollateral.abs() * maxLeverage * collateralWad).divPrice(price);
            require(afterPositionD <= availableD, 'exceeds max leverage');
        }

        return (afterPosition, availableCollateral.abs());
    }
}

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

library PositionKey {
    function getPositionKey(address account, uint256 pairIndex, bool isLong) internal pure returns (bytes32) {
        require(pairIndex < 2 ** (96 - 32), "ptl");
        return bytes32(
            uint256(uint160(account)) << 96 | pairIndex << 32 | (isLong ? 1 : 0)
        );
    }
}

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

import '@openzeppelin/contracts/utils/math/Math.sol';

library PrecisionUtils {
    uint256 public constant PERCENTAGE = 1e8;
    uint256 public constant PRICE_PRECISION = 1e30;
    uint256 public constant MAX_TOKEN_DECIMALS = 18;

    function mulPrice(uint256 amount, uint256 price) internal pure returns (uint256) {
        return Math.mulDiv(amount, price, PRICE_PRECISION);
    }

    function divPrice(uint256 delta, uint256 price) internal pure returns (uint256) {
        return Math.mulDiv(delta, PRICE_PRECISION, price);
    }

    function calculatePrice(uint256 delta, uint256 amount) internal pure returns (uint256) {
        return Math.mulDiv(delta, PRICE_PRECISION, amount);
    }

    function mulPercentage(uint256 amount, uint256 _percentage) internal pure returns (uint256) {
        return Math.mulDiv(amount, _percentage, PERCENTAGE);
    }

    function divPercentage(uint256 amount, uint256 _percentage) internal pure returns (uint256) {
        return Math.mulDiv(amount, PERCENTAGE, _percentage);
    }

    function calculatePercentage(uint256 amount0, uint256 amount1) internal pure returns (uint256) {
        return Math.mulDiv(amount0, PERCENTAGE, amount1);
    }

    function percentage() internal pure returns (uint256) {
        return PERCENTAGE;
    }

    function fundingRatePrecision() internal pure returns (uint256) {
        return PERCENTAGE;
    }

    function pricePrecision() internal pure returns (uint256) {
        return PRICE_PRECISION;
    }

    function maxTokenDecimals() internal pure returns (uint256) {
        return MAX_TOKEN_DECIMALS;
    }
}

File 43 of 44 : TradingTypes.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

library TradingTypes {
    enum TradeType {
        MARKET,
        LIMIT,
        TP,
        SL
    }

    enum NetworkFeePaymentType {
        ETH,
        COLLATERAL
    }

    struct CreateOrderRequest {
        address account;
        uint256 pairIndex; // pair index
        TradeType tradeType; // 0: MARKET, 1: LIMIT 2: TP 3: SL
        int256 collateral; // 1e18 collateral amount,negative number is withdrawal
        uint256 openPrice; // 1e30, price
        bool isLong; // long or short
        int256 sizeAmount; // size
        uint256 maxSlippage;
        InnerPaymentType paymentType;
        uint256 networkFeeAmount;
        bytes data;
    }

    struct OrderWithTpSl {
        uint256 tpPrice; // 1e30, tp price
        uint128 tp; // tp size
        uint256 slPrice; // 1e30, sl price
        uint128 sl; // sl size
    }

    struct IncreasePositionRequest {
        address account;
        uint256 pairIndex; // pair index
        TradeType tradeType; // 0: MARKET, 1: LIMIT 2: TP 3: SL
        int256 collateral; // 1e18 collateral amount,negative number is withdrawal
        uint256 openPrice; // 1e30, price
        bool isLong; // long or short
        uint256 sizeAmount; // size
        uint256 maxSlippage;
        NetworkFeePaymentType paymentType;
        uint256 networkFeeAmount;
    }

    struct IncreasePositionWithTpSlRequest {
        address account;
        uint256 pairIndex; // pair index
        TradeType tradeType; // 0: MARKET, 1: LIMIT 2: TP 3: SL
        int256 collateral; // 1e18 collateral amount,negative number is withdrawal
        uint256 openPrice; // 1e30, price
        bool isLong; // long or short
        uint128 sizeAmount; // size
        uint256 tpPrice; // 1e30, tp price
        uint128 tp; // tp size
        uint256 slPrice; // 1e30, sl price
        uint128 sl; // sl size
        uint256 maxSlippage;
        NetworkFeePaymentType paymentType; // 1: eth 2: collateral
        uint256 networkFeeAmount;
        uint256 tpNetworkFeeAmount;
        uint256 slNetworkFeeAmount;
    }

    struct DecreasePositionRequest {
        address account;
        uint256 pairIndex;
        TradeType tradeType;
        int256 collateral; // 1e18 collateral amount,negative number is withdrawal
        uint256 triggerPrice; // 1e30, price
        uint256 sizeAmount; // size
        bool isLong;
        uint256 maxSlippage;
        NetworkFeePaymentType paymentType;
        uint256 networkFeeAmount;
    }

    struct CreateTpSlRequest {
        address account;
        uint256 pairIndex; // pair index
        bool isLong;
        uint256 tpPrice; // Stop profit price 1e30
        uint128 tp; // The number of profit stops
        uint256 slPrice; // Stop price 1e30
        uint128 sl; // Stop loss quantity
        NetworkFeePaymentType paymentType;
        uint256 tpNetworkFeeAmount;
        uint256 slNetworkFeeAmount;
    }

    struct IncreasePositionOrder {
        uint256 orderId;
        address account;
        uint256 pairIndex; // pair index
        TradeType tradeType; // 0: MARKET, 1: LIMIT
        int256 collateral; // 1e18 Margin amount
        uint256 openPrice; // 1e30 Market acceptable price/Limit opening price
        bool isLong; // Long/short
        uint256 sizeAmount; // Number of positions
        uint256 executedSize;
        uint256 maxSlippage;
        uint256 blockTime;
    }

    struct DecreasePositionOrder {
        uint256 orderId;
        address account;
        uint256 pairIndex;
        TradeType tradeType;
        int256 collateral; // 1e18 Margin amount
        uint256 triggerPrice; // Limit trigger price
        uint256 sizeAmount; // Number of customs documents
        uint256 executedSize;
        uint256 maxSlippage;
        bool isLong;
        bool abovePrice; // Above or below the trigger price
        // market:long: true,  short: false
        //  limit:long: false, short: true
        //     tp:long: false, short: true
        //     sl:long: true,  short: false
        uint256 blockTime;
        bool needADL;
    }

    struct OrderNetworkFee {
        InnerPaymentType paymentType;
        uint256 networkFeeAmount;
    }

    enum InnerPaymentType {
        NONE,
        ETH,
        COLLATERAL
    }

    function convertPaymentType(
        NetworkFeePaymentType paymentType
    ) internal pure returns (InnerPaymentType) {
        if (paymentType == NetworkFeePaymentType.ETH) {
            return InnerPaymentType.ETH;
        } else if (paymentType == NetworkFeePaymentType.COLLATERAL) {
            return InnerPaymentType.COLLATERAL;
        } else {
            revert("Invalid payment type");
        }
    }
}

// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";

import "../interfaces/IAddressesProvider.sol";
import "../interfaces/IRoleManager.sol";

contract Upgradeable is Initializable, UUPSUpgradeable {
    IAddressesProvider public ADDRESS_PROVIDER;

    modifier onlyAdmin() {
        require(IRoleManager(ADDRESS_PROVIDER.roleManager()).isAdmin(msg.sender), "onlyAdmin");
        _;
    }

    modifier onlyPoolAdmin() {
        require(
            IRoleManager(ADDRESS_PROVIDER.roleManager()).isPoolAdmin(msg.sender),
            "onlyPoolAdmin"
        );
        _;
    }

    function _authorizeUpgrade(address) internal virtual override {
        require(msg.sender == ADDRESS_PROVIDER.timelock(), "Unauthorized access");
    }
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "viaIR": true,
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "metadata": {
    "useLiteralContent": true
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"contract IAddressesProvider","name":"addressProvider","type":"address"},{"internalType":"contract IOrderManager","name":"_orderManager","type":"address"},{"internalType":"contract IPositionManager","name":"_positionManager","type":"address"},{"internalType":"contract IPool","name":"_pool","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"pairIndex","type":"uint256"},{"indexed":false,"internalType":"bool","name":"enabled","type":"bool"}],"name":"UpdateAddLiquidityStatus","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"pairIndex","type":"uint256"},{"indexed":false,"internalType":"bool","name":"enabled","type":"bool"}],"name":"UpdateDecreasePositionStatus","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"pairIndex","type":"uint256"},{"indexed":false,"internalType":"bool","name":"enabled","type":"bool"}],"name":"UpdateIncreasePositionStatus","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"pairIndex","type":"uint256"},{"indexed":false,"internalType":"bool","name":"enabled","type":"bool"}],"name":"UpdateOrderStatus","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"pairIndex","type":"uint256"},{"indexed":false,"internalType":"bool","name":"enabled","type":"bool"}],"name":"UpdateRemoveLiquidityStatus","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldAddress","type":"address"},{"indexed":false,"internalType":"address","name":"newAddress","type":"address"}],"name":"UpdateTradingRouter","type":"event"},{"inputs":[],"name":"ADDRESS_PROVIDER","outputs":[{"internalType":"contract IAddressesProvider","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"indexToken","type":"address"},{"internalType":"address","name":"stableToken","type":"address"},{"internalType":"uint256","name":"indexAmount","type":"uint256"},{"internalType":"uint256","name":"stableAmount","type":"uint256"},{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"bytes[]","name":"updateData","type":"bytes[]"},{"internalType":"uint64[]","name":"publishTimes","type":"uint64[]"}],"name":"addLiquidity","outputs":[{"internalType":"uint256","name":"mintAmount","type":"uint256"},{"internalType":"address","name":"slipToken","type":"address"},{"internalType":"uint256","name":"slipAmount","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"indexToken","type":"address"},{"internalType":"address","name":"stableToken","type":"address"},{"internalType":"uint256","name":"amountIndex","type":"uint256"},{"internalType":"uint256","name":"amountStable","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"addLiquidityCallback","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"indexToken","type":"address"},{"internalType":"address","name":"stableToken","type":"address"},{"internalType":"uint256","name":"indexAmount","type":"uint256"},{"internalType":"uint256","name":"stableAmount","type":"uint256"},{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"bytes[]","name":"updateData","type":"bytes[]"},{"internalType":"uint64[]","name":"publishTimes","type":"uint64[]"},{"internalType":"uint256","name":"updateFee","type":"uint256"}],"name":"addLiquidityETH","outputs":[{"internalType":"uint256","name":"mintAmount","type":"uint256"},{"internalType":"address","name":"slipToken","type":"address"},{"internalType":"uint256","name":"slipAmount","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"indexToken","type":"address"},{"internalType":"address","name":"stableToken","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"indexAmount","type":"uint256"},{"internalType":"uint256","name":"stableAmount","type":"uint256"},{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"bytes[]","name":"updateData","type":"bytes[]"},{"internalType":"uint64[]","name":"publishTimes","type":"uint64[]"}],"name":"addLiquidityForAccount","outputs":[{"internalType":"uint256","name":"mintAmount","type":"uint256"},{"internalType":"address","name":"slipToken","type":"address"},{"internalType":"uint256","name":"slipAmount","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"orderId","type":"uint256"},{"internalType":"enum TradingTypes.TradeType","name":"tradeType","type":"uint8"},{"internalType":"bool","name":"isIncrease","type":"bool"},{"internalType":"uint256","name":"tpPrice","type":"uint256"},{"internalType":"uint128","name":"tp","type":"uint128"},{"internalType":"uint256","name":"slPrice","type":"uint256"},{"internalType":"uint128","name":"sl","type":"uint128"},{"internalType":"enum TradingTypes.NetworkFeePaymentType","name":"paymentType","type":"uint8"},{"internalType":"uint256","name":"tpNetworkFeeAmount","type":"uint256"},{"internalType":"uint256","name":"slNetworkFeeAmount","type":"uint256"}],"internalType":"struct IRouter.AddOrderTpSlRequest","name":"request","type":"tuple"}],"name":"addOrderTpSl","outputs":[{"internalType":"uint256","name":"tpOrderId","type":"uint256"},{"internalType":"uint256","name":"slOrderId","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"orderId","type":"uint256"},{"internalType":"enum TradingTypes.TradeType","name":"tradeType","type":"uint8"},{"internalType":"bool","name":"isIncrease","type":"bool"}],"internalType":"struct IRouter.CancelOrderRequest","name":"request","type":"tuple"}],"name":"cancelOrder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"orderId","type":"uint256"},{"internalType":"enum TradingTypes.TradeType","name":"tradeType","type":"uint8"},{"internalType":"bool","name":"isIncrease","type":"bool"}],"internalType":"struct IRouter.CancelOrderRequest[]","name":"requests","type":"tuple[]"}],"name":"cancelOrders","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"pairIndex","type":"uint256"},{"internalType":"bool","name":"isLong","type":"bool"},{"internalType":"bool","name":"isIncrease","type":"bool"}],"name":"cancelPositionOrders","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"pairIndex","type":"uint256"},{"internalType":"enum TradingTypes.TradeType","name":"tradeType","type":"uint8"},{"internalType":"int256","name":"collateral","type":"int256"},{"internalType":"uint256","name":"triggerPrice","type":"uint256"},{"internalType":"uint256","name":"sizeAmount","type":"uint256"},{"internalType":"bool","name":"isLong","type":"bool"},{"internalType":"uint256","name":"maxSlippage","type":"uint256"},{"internalType":"enum TradingTypes.NetworkFeePaymentType","name":"paymentType","type":"uint8"},{"internalType":"uint256","name":"networkFeeAmount","type":"uint256"}],"internalType":"struct TradingTypes.DecreasePositionRequest","name":"request","type":"tuple"}],"name":"createDecreaseOrder","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"pairIndex","type":"uint256"},{"internalType":"enum TradingTypes.TradeType","name":"tradeType","type":"uint8"},{"internalType":"int256","name":"collateral","type":"int256"},{"internalType":"uint256","name":"triggerPrice","type":"uint256"},{"internalType":"uint256","name":"sizeAmount","type":"uint256"},{"internalType":"bool","name":"isLong","type":"bool"},{"internalType":"uint256","name":"maxSlippage","type":"uint256"},{"internalType":"enum TradingTypes.NetworkFeePaymentType","name":"paymentType","type":"uint8"},{"internalType":"uint256","name":"networkFeeAmount","type":"uint256"}],"internalType":"struct TradingTypes.DecreasePositionRequest[]","name":"requests","type":"tuple[]"}],"name":"createDecreaseOrders","outputs":[{"internalType":"uint256[]","name":"orderIds","type":"uint256[]"}],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"pairIndex","type":"uint256"},{"internalType":"enum TradingTypes.TradeType","name":"tradeType","type":"uint8"},{"internalType":"int256","name":"collateral","type":"int256"},{"internalType":"uint256","name":"openPrice","type":"uint256"},{"internalType":"bool","name":"isLong","type":"bool"},{"internalType":"uint256","name":"sizeAmount","type":"uint256"},{"internalType":"uint256","name":"maxSlippage","type":"uint256"},{"internalType":"enum TradingTypes.NetworkFeePaymentType","name":"paymentType","type":"uint8"},{"internalType":"uint256","name":"networkFeeAmount","type":"uint256"}],"internalType":"struct TradingTypes.IncreasePositionRequest","name":"request","type":"tuple"}],"name":"createIncreaseOrder","outputs":[{"internalType":"uint256","name":"orderId","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"pairIndex","type":"uint256"},{"internalType":"enum TradingTypes.TradeType","name":"tradeType","type":"uint8"},{"internalType":"int256","name":"collateral","type":"int256"},{"internalType":"uint256","name":"openPrice","type":"uint256"},{"internalType":"bool","name":"isLong","type":"bool"},{"internalType":"uint128","name":"sizeAmount","type":"uint128"},{"internalType":"uint256","name":"tpPrice","type":"uint256"},{"internalType":"uint128","name":"tp","type":"uint128"},{"internalType":"uint256","name":"slPrice","type":"uint256"},{"internalType":"uint128","name":"sl","type":"uint128"},{"internalType":"uint256","name":"maxSlippage","type":"uint256"},{"internalType":"enum TradingTypes.NetworkFeePaymentType","name":"paymentType","type":"uint8"},{"internalType":"uint256","name":"networkFeeAmount","type":"uint256"},{"internalType":"uint256","name":"tpNetworkFeeAmount","type":"uint256"},{"internalType":"uint256","name":"slNetworkFeeAmount","type":"uint256"}],"internalType":"struct TradingTypes.IncreasePositionWithTpSlRequest","name":"request","type":"tuple"}],"name":"createIncreaseOrderWithTpSl","outputs":[{"internalType":"uint256","name":"orderId","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"collateral","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"createOrderCallback","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"pairIndex","type":"uint256"},{"internalType":"bool","name":"isLong","type":"bool"},{"internalType":"uint256","name":"tpPrice","type":"uint256"},{"internalType":"uint128","name":"tp","type":"uint128"},{"internalType":"uint256","name":"slPrice","type":"uint256"},{"internalType":"uint128","name":"sl","type":"uint128"},{"internalType":"enum TradingTypes.NetworkFeePaymentType","name":"paymentType","type":"uint8"},{"internalType":"uint256","name":"tpNetworkFeeAmount","type":"uint256"},{"internalType":"uint256","name":"slNetworkFeeAmount","type":"uint256"}],"internalType":"struct TradingTypes.CreateTpSlRequest","name":"request","type":"tuple"}],"name":"createTpSl","outputs":[{"internalType":"uint256","name":"tpOrderId","type":"uint256"},{"internalType":"uint256","name":"slOrderId","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"pairIndex","type":"uint256"}],"name":"getOperationStatus","outputs":[{"components":[{"internalType":"bool","name":"increasePositionDisabled","type":"bool"},{"internalType":"bool","name":"decreasePositionDisabled","type":"bool"},{"internalType":"bool","name":"orderDisabled","type":"bool"},{"internalType":"bool","name":"addLiquidityDisabled","type":"bool"},{"internalType":"bool","name":"removeLiquidityDisabled","type":"bool"}],"internalType":"struct IRouter.OperationStatus","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"data","type":"bytes[]"}],"name":"multicall","outputs":[{"internalType":"bytes[]","name":"results","type":"bytes[]"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"operationStatus","outputs":[{"internalType":"bool","name":"increasePositionDisabled","type":"bool"},{"internalType":"bool","name":"decreasePositionDisabled","type":"bool"},{"internalType":"bool","name":"orderDisabled","type":"bool"},{"internalType":"bool","name":"addLiquidityDisabled","type":"bool"},{"internalType":"bool","name":"removeLiquidityDisabled","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"orderManager","outputs":[{"internalType":"contract IOrderManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pool","outputs":[{"internalType":"contract IPool","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"positionManager","outputs":[{"internalType":"contract IPositionManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"indexToken","type":"address"},{"internalType":"address","name":"stableToken","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bool","name":"useETH","type":"bool"},{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"bytes[]","name":"updateData","type":"bytes[]"},{"internalType":"uint64[]","name":"publishTimes","type":"uint64[]"}],"name":"removeLiquidity","outputs":[{"internalType":"uint256","name":"receivedIndexAmount","type":"uint256"},{"internalType":"uint256","name":"receivedStableAmount","type":"uint256"},{"internalType":"uint256","name":"feeAmount","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"pairToken","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"removeLiquidityCallback","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"indexToken","type":"address"},{"internalType":"address","name":"stableToken","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bool","name":"useETH","type":"bool"},{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"bytes[]","name":"updateData","type":"bytes[]"},{"internalType":"uint64[]","name":"publishTimes","type":"uint64[]"}],"name":"removeLiquidityForAccount","outputs":[{"internalType":"uint256","name":"receivedIndexAmount","type":"uint256"},{"internalType":"uint256","name":"receivedStableAmount","type":"uint256"},{"internalType":"uint256","name":"feeAmount","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"salvageToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"setPaused","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"pairIndex","type":"uint256"},{"internalType":"bool","name":"isLong","type":"bool"},{"internalType":"int256","name":"collateral","type":"int256"},{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"bytes[]","name":"updateData","type":"bytes[]"},{"internalType":"uint64[]","name":"publishTimes","type":"uint64[]"}],"name":"setPriceAndAdjustCollateral","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"pairIndex","type":"uint256"},{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"bytes[]","name":"updateData","type":"bytes[]"},{"internalType":"uint64[]","name":"publishTimes","type":"uint64[]"}],"name":"setPriceAndUpdateFundingRate","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"setUnPaused","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"pairIndex","type":"uint256"},{"internalType":"bool","name":"enabled","type":"bool"}],"name":"updateAddLiquidityStatus","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"pairIndex","type":"uint256"},{"internalType":"bool","name":"enabled","type":"bool"}],"name":"updateDecreasePositionStatus","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"pairIndex","type":"uint256"},{"internalType":"bool","name":"enabled","type":"bool"}],"name":"updateIncreasePositionStatus","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"pairIndex","type":"uint256"},{"internalType":"bool","name":"enabled","type":"bool"}],"name":"updateOrderStatus","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"pairIndex","type":"uint256"},{"internalType":"bool","name":"enabled","type":"bool"}],"name":"updateRemoveLiquidityStatus","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"}],"name":"wrapWETH","outputs":[],"stateMutability":"payable","type":"function"}]

610100346200020357601f620057ea38819003918201601f19168301916001600160401b038311848410176200020857808492608094604052833981010312620002035780516001600160a01b0391908281168103620002035760208201519083821682036200020357604083015192848416840362000203576060015193841684036200020357600160005560ff196001541660015560805260a05260c05260e0526040516155cb90816200021f82396080518181816104c801528181610b92015281816110370152818161111a015281816112a0015281816114520152818161174d01528181611ac501528181611cd401528181611da701528181611fd301528181612174015281816123ae01528181614572015281816146fe0152818161479901528181614a2401528181614d4701528181614fac0152615207015260a051818181610acc01528181610ca101528181610e1e01528181611c19015281816125c301528181612f6e0152818161338a01528181613490015281816136840152818161381a01528181613cac01528181613d6301528181613de8015281816140d301526142d2015260c05181818161165c0152818161204801526121e9015260e051818181610650015281816112400152818161153a015281816144dc01528181614680015281816149b601528181614cc001528181614f39015261519b0152f35b600080fd5b634e487b7160e01b600052604160045260246000fdfe6080604052600436101561001257600080fd5b60003560e01c80625e69be146102565780630c12595f146102515780630ee78da51461024c57806316f0115b146102475780631770830a146102425780631848effa1461023d57806319afeb20146102385780631d7b7194146102335780632cc460611461022e578063349fdb091461022957806337a66d85146102245780634264d4e61461021f57806354b6f7211461021a5780635566696d146102155780635a80e080146102105780635c975abb1461020b57806367f4d9c614610206578063791b98bc146102015780637aa6ed41146101fc57806387d34c42146101f757806393bce92c146101f2578063a07610ea146101ed578063ac9650d8146101e8578063ae4b19ae146101e3578063b05a718d146101de578063b74af6d8146101d9578063bdc4fe3d146101d4578063c9b6092d146101cf578063ccc5311e146101ca578063ce05a8a4146101c5578063d1e1a0fe146101c0578063d6205b92146101bb578063e09a22d7146101b6578063e0e2ae8b146101b1578063f1a0510e146101ac5763f9b6117f146101a757600080fd5b6125ad565b612512565b612446565b612373565b612292565b6120e2565b611f0c565b611e3f565b611d6c565b611c99565b611bc2565b611b5d565b611a8a565b6119a7565b611879565b6117e6565b611712565b61168b565b611646565b6115b5565b61157b565b6114ea565b611417565b61137e565b6111d8565b6110e9565b611006565b610dc7565b610d3b565b610c44565b610b7c565b610935565b61063a565b610495565b6103e4565b61032b565b6001600160a01b0381160361026c57565b600080fd5b6004359061027e8261025b565b565b6024359061027e8261025b565b6044359061027e8261025b565b359061027e8261025b565b8015150361026c57565b6084359061027e826102a5565b6044359061027e826102a5565b60a4359061027e826102a5565b6064359061027e826102a5565b60c4359061027e826102a5565b359061027e826102a5565b9181601f8401121561026c578235916001600160401b03831161026c576020808501948460051b01011161026c57565b61010036600319011261026c57610340610271565b610348610280565b61035061028d565b6103586102af565b6001600160401b03929060a43584811161026c5761037a9036906004016102fb565b60c49291923586811161026c576103959036906004016102fb565b93909260e43597881161026c576103e0986103b76103c39936906004016102fb565b98909760643592615158565b604080519384526020840192909252908201529081906060820190565b0390f35b60e036600319011261026c576004356103fc8161025b565b610404610280565b6001600160401b039060843582811161026c576104259036906004016102fb565b60a49491943584811161026c576104409036906004016102fb565b9160c43595861161026c576103e0966104606104709736906004016102fb565b969095606435916044359161496f565b604080519384526001600160a01b039092166020840152908201529081906060820190565b60208060031936011261026c576004356104ae8161025b565b6040516315ab88c960e31b8082526001600160a01b0392917f0000000000000000000000000000000000000000000000000000000000000000841691908581600481865afa80156105c5578591600091610612575b501690813b1561026c57600060049260405193848092630d0e30db60e41b825234905af19182156105c55786926105f9575b5060046040518094819382525afa80156105c557849261058c926000926105ca575b5060405163a9059cbb60e01b81526001600160a01b039091166004820152346024820152938492839160009183906044820190565b0393165af180156105c55761059d57005b816105bc92903d106105be575b6105b48183610719565b81019061262c565b005b503d6105aa565b612615565b6105eb919250843d86116105f2575b6105e38183610719565b8101906125fd565b9038610557565b503d6105d9565b8061060661060c92610695565b8061062f565b38610535565b6106299150873d89116105f2576105e38183610719565b38610503565b600091031261026c57565b3461026c57600036600319011261026c576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b634e487b7160e01b600052604160045260246000fd5b6001600160401b0381116106a857604052565b61067f565b606081019081106001600160401b038211176106a857604052565b60a081019081106001600160401b038211176106a857604052565b60e081019081106001600160401b038211176106a857604052565b604081019081106001600160401b038211176106a857604052565b90601f801991011681019081106001600160401b038211176106a857604052565b6040519061014082018281106001600160401b038211176106a857604052565b6040519061016082018281106001600160401b038211176106a857604052565b6040519061020082018281106001600160401b038211176106a857604052565b604051906101a082018281106001600160401b038211176106a857604052565b6004111561026c57565b6024359061027e826107ba565b6044359061027e826107ba565b359061027e826107ba565b60e43590600282101561026c57565b6101043590600282101561026c57565b6101843590600282101561026c57565b3590600282101561026c57565b61014090600319011261026c5761083a61073a565b90610843610271565b825260243560208301526108556107d1565b60408301526064356060830152608435608083015260a43560a083015261087a6102e3565b60c083015260e43560e083015261088f6107f8565b61010083015261012435610120830152565b91908261014091031261026c576108b661073a565b916108c08161029a565b8352602081013560208401526108d8604082016107de565b6040840152606081013560608401526080810135608084015260a081013560a084015261090760c082016102f0565b60c084015260e081013560e0840152610100610924818301610818565b908401526101208091013590830152565b6101408060031936011261026c5761094c36610825565b6109546128e5565b61095c612d61565b602080928183019261099561099061098c61098287516000526002602052604060002090565b5460081c60ff1690565b1590565b612bcb565b610100808201600181516109a88161310d565b6109b18161310d565b148015610b52575b6109c29061313f565b3380845295516040840151909290916109da836130c9565b6060850151608086015160c087015115159060a08801516109fa90615366565b610a0390613264565b9260e08901519451610a148161310d565b610a1d9061552f565b6101208a8101519a516040516001600160a01b039091168e8201908152819003808252909d919a9299929190610a56906020018f610719565b610a5e61075a565b6001600160a01b03909f168f528e0152610a7b9060408e0161317d565b60608c015260808b0152151560a08a015260c089015260e0880152860190610aa291613189565b840152820152816040518080936301d8cec960e51b82526004820190610ac7916131be565b0381347f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165af19081156105c5576103e092600092610b25575b5050610b156001600055565b6040519081529081906020820190565b610b449250803d10610b4b575b610b3c8183610719565b810190613195565b3880610b09565b503d610b32565b508051610b5e8161310d565b610b678161310d565b1580156109b9575061012083015134146109b9565b3461026c57600036600319011261026c576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b606090600319011261026c5760405190610bda826106ad565b816004358152602435610bec816107ba565b6020820152604060443591610c00836102a5565b0152565b919082606091031261026c57604051610c1c816106ad565b6040808294803584526020810135610c33816107ba565b6020850152013591610c00836102a5565b3461026c57606036600319011261026c57610c5e36610bc1565b610c666128e5565b610c6e612d61565b80519060208101908151926004841015610d3657610c9b906040830194610c958651151590565b91613c72565b519051917f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690610cdd90610cd7856130c9565b51151590565b90803b1561026c57610d0a93600080946040519687958694859363ecd1bbcb60e01b855260048501613a17565b03925af180156105c557610d23575b6105bc6001600055565b80610606610d3092610695565b38610d19565b6130b3565b61010036600319011261026c57610d50610271565b610d58610280565b906001600160401b039060843582811161026c57610d7a9036906004016102fb565b9360a43584811161026c57610d939036906004016102fb565b9060c43595861161026c576103e096610db36104709736906004016102fb565b95909460e435976064359160443591614487565b3461026c5760608060031936011261026c5760243590610de6826102a5565b610e6360443591610df6836102a5565b610dfe6128e5565b610e06612d61565b610e146004948535336154bd565b9260018060a01b037f00000000000000000000000000000000000000000000000000000000000000001690604092835195634cc42b5160e01b8752868060009788938b83019190602083019252565b0381865afa9586156105c5578596610fe2575b50845b8651811015610fd457610e8c8188613789565b5190610eb733610eb1610ea5855160018060a01b031690565b6001600160a01b031690565b14613b8c565b8380610fc8575b15610f3457608060a083015192015191610ed7836130c9565b853b15610f305787908a610efc8951958693849363ecd1bbcb60e01b85528401613ef7565b038183895af19182156105c557610f1892610f1d575b50613764565b610e79565b80610606610f2a92610695565b38610f12565b8780fd5b831580610fb3575b610f4b575b610f189150613764565b608060a083015192015191610f5f836130c9565b853b15610f305787908a610f848951958693849363ecd1bbcb60e01b85528401613eb5565b038183895af19182156105c557610f1892610fa0575b50610f41565b80610606610fad92610695565b38610f9a565b50610fc361098c84840151151590565b610f3c565b50818301511515610ebe565b85610fdf6001600055565b80f35b610fff9196503d8087833e610ff78183610719565b810190613f7c565b9438610e76565b3461026c576000806003193601126110e65760405162435da560e01b81526020906001600160a01b039082816004817f000000000000000000000000000000000000000000000000000000000000000086165afa9182156105c557839185936110c7575b50604051637be53ca160e01b81523360048201529283916024918391165afa9081156105c5576110a29284926110aa575b5050612641565b610fdf612929565b6110c09250803d106105be576105b48183610719565b388061109b565b6110df919350823d84116105f2576105e38183610719565b913861106a565b80fd5b3461026c576000806003193601126110e65760405162435da560e01b81526020906001600160a01b039082816004817f000000000000000000000000000000000000000000000000000000000000000086165afa9182156105c5578391859361118c575b50604051637be53ca160e01b81523360048201529283916024918391165afa9081156105c5576111849284926110aa575050612641565b610fdf6128a5565b6111a4919350823d84116105f2576105e38183610719565b913861114d565b9181601f8401121561026c578235916001600160401b03831161026c576020838186019501011161026c57565b3461026c5760a036600319011261026c576004356111f58161025b565b6024356112018161025b565b6044359060643591608435936001600160401b03851161026c5761126f61122f610ea59636906004016111ab565b6001600160a01b03979190611267337f00000000000000000000000000000000000000000000000000000000000000008b161461531a565b810190615351565b918061128b575b50508261127f57005b6105bc93339216614c39565b6040516315ab88c960e31b81526020816004817f00000000000000000000000000000000000000000000000000000000000000008b165afa9283156105c5578791600094611302575b508116921682036112f1576112ea91339061268e565b3880611276565b6112fd91833391614c39565b6112ea565b8291945061131d9060203d81116105f2576105e38183610719565b93906112d4565b608435906001600160801b038216820361026c57565b60c435906001600160801b038216820361026c57565b61010435906001600160801b038216820361026c57565b61014435906001600160801b038216820361026c57565b61014036600319011261026c5761140561139661073a565b60043581526113a36107c4565b60208201526113b06102bc565b604082015260643560608201526113c5611324565b608082015260a43560a08201526113da61133a565b60c08201526113e76107e9565b60e0820152610104356101008201526101243561012082015261406b565b60408051928352602083019190915290f35b3461026c57604036600319011261026c57602435611434816102a5565b60405162435da560e01b81529060206001600160a01b0381846004817f000000000000000000000000000000000000000000000000000000000000000085165afa9384156105c5576000946114c9575b50604051637be53ca160e01b815233600482015293829185916024918391165afa80156105c5576105bc936114c1926000926110aa575050612641565b600435612aed565b829194506114e390823d84116105f2576105e38183610719565b9390611484565b3461026c57606036600319011261026c576004356115078161025b565b604435906001600160401b03821161026c5761152a6105bc9236906004016111ab565b90916001600160a01b03611561337f000000000000000000000000000000000000000000000000000000000000000083161461531a565b80611573602435953395810190615351565b169116614c39565b3461026c57600036600319011261026c57602060ff600154166040519015158152f35b6001600160401b0381116106a85760051b60200190565b3461026c5760208060031936011261026c57600435906001600160401b03821161026c573660238301121561026c578160040135916115f38361159e565b916116016040519384610719565b838352808301602460608096028401019236841161026c57602401905b83821061162e576105bc85613dd5565b82869161163b3685610c04565b81520191019061161e565b3461026c57600036600319011261026c576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b61014036600319011261026c576114056116a361073a565b6116ab610271565b815260243560208201526116bd6102bc565b604082015260643560608201526116d2611324565b608082015260a43560a08201526116e761133a565b60c08201526116f46107e9565b60e08201526101043561010082015261012435610120820152614393565b3461026c57604036600319011261026c5760043561172f8161025b565b60405162435da560e01b81529060206001600160a01b0381846004817f000000000000000000000000000000000000000000000000000000000000000085165afa9384156105c5576000946117c5575b50604051637be53ca160e01b815233600482015293829185916024918391165afa80156105c5576105bc936117bc926000926110aa575050612641565b6024359061267d565b829194506117df90823d84116105f2576105e38183610719565b939061177f565b61010036600319011261026c576117fb610271565b611803610280565b9061180c61028d565b6001600160401b03919060a43583811161026c5761182e9036906004016102fb565b9060c43585811161026c576118479036906004016102fb565b92909160e43596871161026c576103e0976118696104709836906004016102fb565b9790966084359260643592614c7b565b61014036600319011261026c576103e0610b1561189461073a565b61189c610271565b815260243560208201526118ae6107d1565b6040820152606435606082015260843560808201526118cb6102c9565b60a082015260c43560c082015260e43560e08201526118e86107f8565b610100820152610124356101208201526134f0565b60005b8381106119105750506000910152565b8181015183820152602001611900565b90602091611939815180928185528580860191016118fd565b601f01601f1916010190565b602080820190808352835180925260408301928160408460051b8301019501936000915b8483106119795750505050505090565b9091929394958480611997600193603f198682030187528a51611920565b9801930193019194939290611969565b602036600319011261026c57600480356001600160401b03811161026c576119d290369083016102fb565b906119dc826153c6565b9160005b8181106119f557604051806103e08682611945565b600080611a03838587615410565b60409391611a15855180938193615451565b0390305af490611a236127d7565b91829015611a4c57505090611a4791611a3c8287613789565b52610f128186613789565b6119e0565b826044899394511061026c57611a869183611a7192016024809151830101910161545f565b925162461bcd60e51b81529283928301612894565b0390fd5b3461026c57604036600319011261026c57602435611aa7816102a5565b60405162435da560e01b81529060206001600160a01b0381846004817f000000000000000000000000000000000000000000000000000000000000000085165afa9384156105c557600094611b3c575b50604051637be53ca160e01b815233600482015293829185916024918391165afa80156105c5576105bc93611b34926000926110aa575050612641565b600435612a15565b82919450611b5690823d84116105f2576105e38183610719565b9390611af7565b3461026c57602036600319011261026c57600435600052600260205260a060406000205460ff6040519181811615158352818160081c1615156020840152818160101c1615156040840152818160181c161515606084015260201c1615156080820152f35b3461026c57608036600319011261026c57600435611bdf8161025b565b602435604435611bee8161025b565b6064356001600160401b03811161026c57611c0d9036906004016111ab565b6001600160a01b0391907f000000000000000000000000000000000000000000000000000000000000000083163303611c615781611c4e9184930190615351565b169083611c5757005b6105bc9416614c39565b60405162461bcd60e51b815260206004820152601060248201526f37b7363ca7b93232b926b0b730b3b2b960811b6044820152606490fd5b3461026c57604036600319011261026c57602435611cb6816102a5565b60405162435da560e01b81529060206001600160a01b0381846004817f000000000000000000000000000000000000000000000000000000000000000085165afa9384156105c557600094611d4b575b50604051637be53ca160e01b815233600482015293829185916024918391165afa80156105c5576105bc93611d43926000926110aa575050612641565b6004356129a4565b82919450611d6590823d84116105f2576105e38183610719565b9390611d06565b3461026c57604036600319011261026c57602435611d89816102a5565b60405162435da560e01b81529060206001600160a01b0381846004817f000000000000000000000000000000000000000000000000000000000000000085165afa9384156105c557600094611e1e575b50604051637be53ca160e01b815233600482015293829185916024918391165afa80156105c5576105bc93611e16926000926110aa575050612641565b600435612b5c565b82919450611e3890823d84116105f2576105e38183610719565b9390611dd9565b61020036600319011261026c576103e0610b15611e5a61077a565b611e62610271565b81526024356020820152611e746107d1565b604082015260643560608201526084356080820152611e916102c9565b60a0820152611e9e61133a565b60c082015260e43560e0820152611eb3611350565b61010082015261012435610120820152611ecb611367565b61014082015261016435610160820152611ee3610808565b6101808201526101a4356101a08201526101c4356101c08201526101e4356101e0820152612db7565b60c036600319011261026c5760243560048035611f28836102a5565b6001600160401b0360643581811161026c57611f4790369085016102fb565b60849291923582811161026c57611f6190369087016102fb565b91909260a43590811161026c57611f7b90369088016102fb565b929094611f866128e5565b611f8e612d61565b611fb561099061098c611fab8a6000526002602052604060002090565b5460101c60ff1690565b604051632630c12f60e01b81526001600160a01b0396906020818b817f00000000000000000000000000000000000000000000000000000000000000008c165afa80156105c55788916000916120c4575b501692833b1561026c576000958a9261203492604051998a98899788976318c68c5b60e21b89528801612c71565b039134905af180156105c5576120b1575b507f000000000000000000000000000000000000000000000000000000000000000016803b1561026c5760408051632ca92e3360e21b81529384019283523360208401529315159382019390935260443560608201529091600091839190829084908290608001610d0a565b806106066120be92610695565b38612045565b6120dc915060203d81116105f2576105e38183610719565b38612006565b608036600319011261026c576024356001600160401b0380821161026c5761210f600492369084016102fb565b60449291923582811161026c5761212990369086016102fb565b91909260643590811161026c5761214390369087016102fb565b92909461214e6128e5565b612156612d61565b604051632630c12f60e01b81526001600160a01b0396906020818a817f00000000000000000000000000000000000000000000000000000000000000008c165afa80156105c5578891600091612274575b501692833b1561026c5760009589926121d592604051998a98899788976318c68c5b60e21b89528801612c71565b039134905af180156105c557612261575b507f000000000000000000000000000000000000000000000000000000000000000016803b1561026c5760405163894feb9d60e01b81528235818401908152909160009183919082908490829060200103925af180156105c55761224e576105bc6001600055565b8061060661225b92610695565b80610d19565b8061060661226e92610695565b386121e6565b61228c915060203d81116105f2576105e38183610719565b386121a7565b3461026c57602036600319011261026c576103e0604080608081516122b6816106c8565b60009181838093528260208201528285820152826060820152015260043581526002602052209061233060ff8251936122ee856106c8565b5481811615158552818160081c1615156020860152818160101c16151584860152612323828260181c16606087019015159052565b60201c1615156080840152565b519182918291909160808060a083019480511515845260208101511515602085015260408101511515604085015260608101511515606085015201511515910152565b3461026c57604036600319011261026c57602435612390816102a5565b60405162435da560e01b81529060206001600160a01b0381846004817f000000000000000000000000000000000000000000000000000000000000000085165afa9384156105c557600094612425575b50604051637be53ca160e01b815233600482015293829185916024918391165afa80156105c5576105bc9361241d926000926110aa575050612641565b600435612a80565b8291945061243f90823d84116105f2576105e38183610719565b93906123e0565b60e036600319011261026c5760043561245e8161025b565b612466610280565b61246e6102d6565b916001600160401b039160843583811161026c576124909036906004016102fb565b9060a43585811161026c576124a99036906004016102fb565b92909160c43596871161026c576103e0976124cb6103c39836906004016102fb565b97909660443591614ef2565b6020908160408183019282815285518094520193019160005b8281106124fe575050505090565b8351855293810193928101926001016124f0565b60208060031936011261026c576004356001600160401b03811161026c573660238201121561026c5780600401359061254a8261159e565b926125586040519485610719565b82845280840160246101408095028401019236841161026c57602401905b838210612595576103e0612589876137fb565b604051918291826124d7565b8285916125a236856108a1565b815201910190612576565b3461026c57600036600319011261026c576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b519061027e8261025b565b9081602091031261026c57516126128161025b565b90565b6040513d6000823e3d90fd5b519061027e826102a5565b9081602091031261026c5751612612816102a5565b1561264857565b60405162461bcd60e51b815260206004820152600d60248201526c37b7363ca837b7b620b236b4b760991b6044820152606490fd5b61027e919033906001600160a01b03165b60405163a9059cbb60e01b60208201526001600160a01b039092166024830152604482019290925261027e916126d182606481015b03601f198101845283610719565b6126f1565b6001600160401b0381116106a857601f01601f191660200190565b60405161274f916001600160a01b031661270a826106fe565b6000806020958685527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656487860152868151910182855af16127496127d7565b91612807565b8051908282159283156127bf575b505050156127685750565b6084906040519062461bcd60e51b82526004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152fd5b6127cf935082018101910161262c565b38828161275d565b3d15612802573d906127e8826126d6565b916127f66040519384610719565b82523d6000602084013e565b606090565b91929015612869575081511561281b575090565b3b156128245790565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b82519091501561287c5750805190602001fd5b60405162461bcd60e51b8152908190611a8690600483015b906020612612928181520190611920565b6128ad6128e5565b600160ff19815416176001557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a1565b60ff600154166128f157565b60405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606490fd5b60015460ff8116156129685760ff19166001557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a1565b60405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606490fd5b907ffc5b53a10a690d609db15172bc801db46cd4325162b1d451ecf9c2506793de3591806000526002602052604060002060ff1981541660ff841516179055612a10604051928392338491926040919493606084019560018060a01b0316845260208401521515910152565b0390a1565b600081815260026020908152604091829020805461ff0019169415600881901b61ff00169590951790558151338152908101929092529115918101919091527fc19970c31e6a5e852abc18399a2d6111dedb931ea613d86f2e6be00dc433b2fc908060608101612a10565b600081815260026020908152604091829020805462ff000019169415601081901b62ff0000169590951790558151338152908101929092529115918101919091527f6539cab5b8437438117f6321b1de3c48abc0e1edcbb0f35fcaa5dcb80364774c908060608101612a10565b600081815260026020908152604091829020805463ff00000019169415601881901b63ff000000169590951790558151338152908101929092529115918101919091527fc500659b3cffd5679961b0ae179a7e58a43967e3fc5ddd7a467cdd624d61d819908060608101612a10565b600081815260026020908152604091829020805464ff000000001916941580831b64ff00000000169590951790558151338152908101929092529115918101919091527fb1baea30c77fbf28a108876bf97e168dca9b94d86632c9f4cca34a886f0db672908060608101612a10565b15612bd257565b60405162461bcd60e51b8152602060048201526008602482015267191a5cd8589b195960c21b6044820152606490fd5b908060209392818452848401376000828201840152601f01601f1916010190565b9190808252602080920192916000805b838210612c4257505050505090565b909192939485356001600160401b038116809103612c6d578152830194830193929160010190612c33565b8280fd5b96959390949291806060890160608a525260808801959060005b818110612d325750505060208786038189015281865280860195818360051b82010196846000925b858410612cd3575050505050505084604061261295968503910152612c23565b90919293949598601f198282030184528935601e198436030181121561026c5783018681019190356001600160401b03811161026c57803603831361026c57612d2188928392600195612c02565b9b0194019401929594939190612cb3565b90919293966001908435612d458161025b565b60a083901b839003168152602090810198959401929101612c8b565b600260005414612d72576002600055565b60405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606490fd5b612dbf6128e5565b612dc7612d61565b6020808201612df161099061098c612dea84516000526002602052604060002090565b5460ff1690565b604083019260028451612e03816130c9565b612e0c816130c9565b141580613090575b612e1d906130d3565b61018081019360018551612e308161310d565b612e398161310d565b148015613043575b612e4a9061313f565b338083526101a08301805185519351919792939190612e68826130c9565b8760608701519560808801519660a08901978851612e8590151590565b60c08b0151612e9c906001600160801b0316615366565b916101608c0151938a51612eaf8161310d565b612eb89061552f565b9f518d516040516001600160a01b03909116898201908152819003808252909b919a9190612ee9906020018d610719565b612ef161075a565b6001600160a01b03909816885287890152612f0f906040880161317d565b60608601526080850152151560a084015260c083015260e08201526101009a612f3a908c8301613189565b6101209384820152610140948582015260405192838080936301d8cec960e51b82526004820190612f6a916131be565b03917f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165af19788156105c557600098613020575b50508451969761301497612fc7906001600160a01b031697519551151590565b612ff6612fe260e0890151938901516001600160801b031690565b93880151948801516001600160801b031690565b9451956130028761310d565b6101e06101c089015198015198613275565b50506126126001600055565b6130149850908161303c92903d10610b4b57610b3c8183610719565b9638612fa7565b50845161304f8161310d565b6130588161310d565b158015612e415750612e4a61308761307b6101a08501516101c08601519061312d565b6101e08501519061312d565b34149050612e41565b50612e1d600385516130a1816130c9565b6130aa816130c9565b14159050612e14565b634e487b7160e01b600052602160045260246000fd5b60041115610d3657565b156130da57565b60405162461bcd60e51b815260206004820152600b60248201526a1b9bdd081cdd5c1c1bdc9d60aa1b6044820152606490fd5b60021115610d3657565b634e487b7160e01b600052601160045260246000fd5b9190820180921161313a57565b613117565b1561314657565b60405162461bcd60e51b815260206004820152600f60248201526e696e636f72726563742076616c756560881b6044820152606490fd5b6004821015610d365752565b6003821015610d365752565b9081602091031261026c575190565b906004821015610d365752565b906003821015610d365752565b602080825282516001600160a01b0316908201526126129161018090602081015160408401526131f6604082015160608501906131a4565b60608101516080840152608081015160a084015261321d60a082015160c085019015159052565b60c081015160e084015260e0810151610100908185015281015161324761012091828601906131b1565b810151906101409182850152015191610160808201520190611920565b600160ff1b811461313a5760000390565b9597969190939998949299600098600098899c6001600160801b03809416806133ee575b50505016806132af575b50505050505050509190565b61338697989a5091613349602097969594926132de6132d86132d361335e97615366565b613264565b9361552f565b6040516001600160a01b038a168b820190815290979195919061330f9089906020015b03601f1981018a5289610719565b61332961331a61075a565b6001600160a01b03909b168b52565b898b0152600360408a0152606089018c90526080890152151560a0880152565b60c08601528760e08601526101008501613189565b8161012084015261014083015260405180809581946301d8cec960e51b8352600483016131be565b03917f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165af19182156105c557916133d0575b509138808080808080806132a3565b6133e8915060203d8111610b4b57610b3c8183610719565b386133c1565b61348c939c50918861335e8c938e61340a6132d3602098615366565b6134138c61552f565b6040516001600160a01b0389168a820190815281900380825290969194919061343f9060200188610719565b61345961344a61075a565b6001600160a01b03909a168a52565b888a0152600260408901526060880183905260808801528a151560a088015260c087015260e08601526101008501613189565b03917f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165af19081156105c55789916134d2575b5098388080613299565b6134ea915060203d8111610b4b57610b3c8183610719565b386134c8565b6134f86128e5565b613500612d61565b6020908181019061352561099061098c612dea85516000526002602052604060002090565b604081019060028251613537816130c9565b613540816130c9565b14158061370f575b613551906130d3565b610100808201600181516135648161310d565b61356d8161310d565b1480156136e5575b61357e9061313f565b338084529451935191613590836130c9565b606084015191608085015160a08601516135a990151590565b60c08701516135b790615366565b9160e088015193516135c88161310d565b6135d19061552f565b6101208981015199516040516001600160a01b039091168e8201908152819003808252909b9199929892919061360a906020018d610719565b61361261075a565b6001600160a01b03909d168d528c8e01526136309060408d0161317d565b60608b015260808a0152151560a089015260c088015260e087015285019061365791613189565b830152610140820152816040518080936301d8cec960e51b8252600482019061367f916131be565b0381347f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165af19182156105c5576000926136c85750506126126001600055565b6136de9250803d10610b4b57610b3c8183610719565b3880613014565b5080516136f18161310d565b6136fa8161310d565b15801561357557506101208301513414613575565b5061355160038351613720816130c9565b613729816130c9565b14159050613548565b9061373c8261159e565b6137496040519182610719565b828152809261375a601f199161159e565b0190602036910137565b600019811461313a5760010190565b634e487b7160e01b600052603260045260246000fd5b805182101561379d5760209160051b010190565b613773565b156137a957565b60405162461bcd60e51b815260206004820152601860248201527f696e73756666696369656e74206e6574776f726b2066656500000000000000006044820152606490fd5b9190820391821161313a57565b906138046128e5565b61380c612d61565b6138168251613732565b34927f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169060005b81518110156139d85780602061385f61398c9385613789565b5181810161388161099061098c61098284516000526002602052604060002090565b61389f61012083019a6138978c518210156137a2565b8b51906137ee565b9980519151926139656040820151926138b7846130c9565b60608301519260808101516139516138d260c0840151151590565b6138e26132d360a0860151615366565b926138ff61010060e08701519601516138fa8161310d565b61552f565b9551604080513360208083019190915281529a91999161393e91613923908d610719565b604061392d61075a565b3381529e8f9060208201520161317d565b60608c015260808b0152151560a08a0152565b60c088015260e08701526101008601613189565b61012084015261014083015260405180809681946301d8cec960e51b8352600483016131be565b0391885af180156105c5576139b4926000916139b9575b506139ae8287613789565b52613764565b613846565b6139d2915060203d602011610b4b57610b3c8183610719565b386139a3565b5050509091801580156139f15750506126126001600055565b600080809381938290613a0e575b3390f1156105c5573880613014565b506108fc6139ff565b91613a2c9060c09492845260208401906131a4565b1515604082015260806060820152600b60808201526a31b0b731b2b627b93232b960a91b60a08201520190565b519061027e826107ba565b919082604091031261026c57604051604081018181106001600160401b038211176106a85760405280928051600381101561026c578252602090810151910152565b9190828103906101e0821261026c576101a080921261026c5761261291613acb61079a565b85518152613adb602087016125f2565b602082015260408601516040820152613af660608701613a59565b60608201526080860151608082015260a086015160a082015260c086015160c082015260e086015160e08201526101008087015190820152610120613b3c818801612621565b90820152610140613b4e818801612621565b908201526101608087015190820152610180613b6b818801612621565b908201529401613a64565b90815260408101929161027e91602001906131a4565b15613b9357565b60405162461bcd60e51b815260206004820152600b60248201526a1bdb9b1e5058d8dbdd5b9d60aa1b6044820152606490fd5b9190828103906101a0821261026c5761016080921261026c5761261291613beb61075a565b85518152613bfb602087016125f2565b602082015260408601516040820152613c1660608701613a59565b60608201526080860151608082015260a086015160a0820152613c3b60c08701612621565b60c082015260e086015160e08201526101008087015190820152610120808701519082015261014080870151908201529401613a64565b9115613d2f57613c999060405191829163f9d244fd60e01b83526101a09460048401613b76565b6001600160a01b039291849183919003817f000000000000000000000000000000000000000000000000000000000000000086165afa9283156105c55761027e93613cf992602092600092613d01575b505001516001600160a01b031690565b163314613b8c565b613d209250803d10613d28575b613d188183610719565b810190613bc6565b503880613ce9565b503d613d0e565b613d50906040519182916340b4605b60e11b83526101e09460048401613b76565b6001600160a01b039291849183919003817f000000000000000000000000000000000000000000000000000000000000000086165afa9283156105c55761027e93613cf992602092600092613daf57505001516001600160a01b031690565b613d209250803d10613dce575b613dc68183610719565b810190613aa6565b503d613dbc565b90613dde6128e5565b613de6612d61565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169160005b8151811015613ea757613e278183613789565b519081516020830192613e60845191613e3f836130c9565b613e5360409485830194610c958651151590565b51945191610cd7836130c9565b93873b1561026c57613e8760009351958693849363ecd1bbcb60e01b855260048501613f39565b038183895af19182156105c557613ea292610f1d5750613764565b613e14565b5050905061027e6001600055565b9060c092613ec991835260208301906131a4565b6000604082015260806060820152600c60808201526b63616e63656c4f726465727360a01b60a08201520190565b9060c092613f0b91835260208301906131a4565b6001604082015260806060820152600c60808201526b63616e63656c4f726465727360a01b60a08201520190565b91613f4e9060c09492845260208401906131a4565b1515604082015260806060820152600c60808201526b63616e63656c4f726465727360a01b60a08201520190565b602090818184031261026c578051906001600160401b03821161026c570182601f8201121561026c57805191613fb18361159e565b936040613fc081519687610719565b848652828601918360e08097028601019481861161026c578401925b858410613fed575050505050505090565b868483031261026c578487918451614004816106e3565b865161400f8161025b565b8152828701518382015285870151614026816102a5565b868201526060614037818901612621565b908201526080614048818901613a59565b9082015260a0808801519082015260c08088015190820152815201930192613fdc565b6140736128e5565b61407b612d61565b600061408a6040830151151590565b1561428f575080516140c060208301516140a3816130c9565b60405191829163f9d244fd60e01b83526101a09460048401613b76565b6001600160a01b039291849183919003817f000000000000000000000000000000000000000000000000000000000000000086165afa9283156105c557600093614269575b5050602082015161412391906001600160a01b03165b16331461435b565b61413560c06040830151920151151590565b915b61415461099061098c611fab856000526002602052604060002090565b60e0810192600184516141668161310d565b61416f8161310d565b14801561422b575b6141809061313f565b60808201516001600160801b0316938415801590614200575b6141b5575b50505050506141ad6001600055565b600090600090565b6141f89460608401519060a0850151916141d960c08701516001600160801b031690565b9351946141e58661310d565b6101206101008801519701519733613275565b38808061419e565b5061422461421860c08501516001600160801b031690565b6001600160801b031690565b1515614199565b5083516142378161310d565b6142408161310d565b15801561417757506141806142606101008401516101208501519061312d565b34149050614177565b614123929350908161428692903d10613d2857613d188183610719565b50919038614105565b81516142bf60208401516142a2816130c9565b6040519182916340b4605b60e11b83526101e09460048401613b76565b6001600160a01b039391829184919003817f000000000000000000000000000000000000000000000000000000000000000087165afa9384156105c55793614335575b5050602082015161431c91906001600160a01b031661411b565b61432f6101206040830151920151151590565b91614137565b61431c929350908161435292903d10613dce57613dc68183610719565b50919038614302565b1561436257565b60405162461bcd60e51b81526020600482015260096024820152686e6f2061636365737360b81b6044820152606490fd5b6144399061439f6128e5565b6143a7612d61565b60208101906143ca61099061098c611fab85516000526002602052604060002090565b60e0810191600183516143dc8161310d565b6143e58161310d565b148015614449575b6143f69061313f565b51916144056040830151151590565b90606083015161441f60808501516001600160801b031690565b60a0850151916141d960c08701516001600160801b031690565b91906144456001600055565b9190565b5082516144558161310d565b61445e8161310d565b1580156143ed57506143f661447e6101008401516101208501519061312d565b341490506143ed565b9793919695929a9860206144d89b969261449f6128e5565b6144a7612d61565b60405163684ae9e560e01b81526001600160a01b03808d16600483015290911660248201529b8c9081906044820190565b03817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165afa9a8b156105c55760009b614885575b5061454861099061098c61453e8e61452e8115156148b4565b6000526002602052604060002090565b5460181c60ff1690565b61455d614555878a61312d565b3410156148ea565b604051632630c12f60e01b81526020816004817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165afa9081156105c557600091614866575b506001600160a01b031692833b1561026c576145e287926000976040519a8b98899788966318c68c5b60e21b885260048801612c71565b03925af19182156105c5576145fd92614853575b50346137ee565b93303b1561026c57604051630ee78da560e01b8152306004820152906000828060248101038189305af19081156105c5576060928492614840575b506040805133602082015261467a9161465e90829081015b03601f198101835282610719565b604051633cece6db60e21b8152998a948594336004870161493f565b038160007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165af19384156105c55760009283968496614806575b506146c883836137ee565b15159081614781575b506146e8575b50506146e36001600055565b929190565b6040516315ab88c960e31b8152916020836004817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165afa9081156105c5576147579360009261475e575b5061474691926137ee565b9033906001600160a01b031661268e565b38806146d7565b614746925061477b9060203d6020116105f2576105e38183610719565b9161473b565b6040516315ab88c960e31b81529091506020816004817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165afa9081156105c5576000916147e7575b506001600160a01b03918216911614386146d1565b614800915060203d6020116105f2576105e38183610719565b386147d2565b919350945061482d91955060603d8111614839575b6148258183610719565b81019061491b565b959192909594386146bd565b503d61481b565b8061060661484d92610695565b38614638565b8061060661486092610695565b386145f6565b61487f915060203d6020116105f2576105e38183610719565b386145ab565b61453e9b5061099061098c6148ab6145489360203d602011610b4b57610b3c8183610719565b9d505050614515565b156148bb57565b60405162461bcd60e51b81526020600482015260076024820152662165786973747360c81b6044820152606490fd5b156148f157565b60405162461bcd60e51b81526020600482015260026024820152616e6560f01b6044820152606490fd5b9081606091031261026c57805191604060208301516149398161025b565b92015190565b919260a093612612969592600180871b031684526020840152604083015260608201528160808201520190611920565b99989593919690979492996149826128e5565b61498a612d61565b6040805163684ae9e560e01b81526001600160a01b038381166004808401919091529b811660248301527f000000000000000000000000000000000000000000000000000000000000000081169992976020979196929590939288876044818f5afa9a8b156105c5578e9760009c614c0c575b50614a1661099061098c61453e8f61452e8115156148b4565b8a51632630c12f60e01b81527f00000000000000000000000000000000000000000000000000000000000000008a16988b908290818c5afa80156105c5578a91600091614bef575b501692833b1561026c578f9195600096614a8c928e51998a98899788976318c68c5b60e21b89528801612c71565b039134905af180156105c557614bdc575b5084516315ab88c960e31b808252919085818c81875afa9081156105c55785918291600091614bbf575b5016911614614b59575b50508251339281019283526060976000949093614b129350614af79083906020016126c3565b51633cece6db60e21b8152998a97889687953390870161493f565b03925af19081156105c557600080938193614b33575b506146e36001600055565b91935050614b4f915060603d8111614839576148258183610719565b9290929138614b28565b9288938593998296518094819382525afa9182156105c557614af7600095614b988a60609c614b12976126c3978b91614ba2575b503091339116614c39565b9499505093614ad1565b614bb99150853d87116105f2576105e38183610719565b38614b8d565b614bd69150883d8a116105f2576105e38183610719565b38614ac7565b80610606614be992610695565b38614a9d565b614c0691508c8d3d106105f2576105e38183610719565b38614a5e565b61453e9c5061099061098c614c30614a16938e803d10610b4b57610b3c8183610719565b9e5050506149fd565b6040516323b872dd60e01b60208201526001600160a01b03928316602482015292909116604483015260648083019390935291815261027e916126d1826106c8565b9198939a99614cfc959398919697614c916128e5565b614c99612d61565b60405163684ae9e560e01b81526001600160a01b03858116600483015298891660248201527f000000000000000000000000000000000000000000000000000000000000000089169990986020989097919089908b908d90829081906044820190565b03915afa998a156105c55760009a614ed3575b50614d1b8a15156148b4565b614d3861099061098c61453e8d6000526002602052604060002090565b604051632630c12f60e01b81527f0000000000000000000000000000000000000000000000000000000000000000891697908a816004818c5afa80156105c5578a91600091614eb6575b501692833b1561026c57600095614db091604051988997889687966318c68c5b60e21b885260048801612c71565b039134905af180156105c557614ea3575b506040516315ab88c960e31b80825291908581600481875afa9081156105c55785918291600091614e86575b5016911614614e3c575b505060405133928101928352606096600093909250614b129190614e1f908290602001614650565b604051633cece6db60e21b8152998a97889687956004870161493f565b839060046040999499518094819382525afa9081156105c557614e1f600094614e7b8960609b614b1296614650968a91614ba257503091339116614c39565b945050829750614df7565b614e9d9150883d8a116105f2576105e38183610719565b38614ded565b80610606614eb092610695565b38614dc1565b614ecd91508c8d3d106105f2576105e38183610719565b38614d82565b614eeb919a50893d8b11610b4b57610b3c8183610719565b9838614d0f565b9998929693959194979097614f056128e5565b614f0d612d61565b60405163684ae9e560e01b81526001600160a01b039b8c166004820152988b1660248a015297996020987f000000000000000000000000000000000000000000000000000000000000000082169790918a8d6044818c5afa9c8d156105c55760009d6150dc575b50614f9861099061098c8f8061452e614f8e9215156148b4565b5460201c60ff1690565b604051632630c12f60e01b81528b816004817f000000000000000000000000000000000000000000000000000000000000000086165afa9081156105c5576000916150bf575b501692833b1561026c5760009561500c91604051988997889687966318c68c5b60e21b885260048801612c71565b039134905af19687156105c55761503f6060966000936133019a6150ac575b5060405133918101918252998a9160200190565b6150606040519889968795869463bb04869d60e01b86523360048701615126565b03925af19081156105c55760008093819361508057506146e36001600055565b91935050614b4f915060603d81116150a5575b61509d8183610719565b81019061510b565b503d615093565b806106066150b992610695565b3861502b565b6150d691508c8d3d106105f2576105e38183610719565b38614fde565b909c508a3d8c11615104575b6150f28183610719565b81016150fd91613195565b9b38614f74565b503d6150e8565b9081606091031261026c578051916040602083015192015190565b919260a093612612969592600180871b0316845260208401526040830152151560608201528160808201520190611920565b97949690929a9991939861516a6128e5565b615172612d61565b60405163684ae9e560e01b81526001600160a01b03998a166004820152938916602485015292977f0000000000000000000000000000000000000000000000000000000000000000811697909660209491858b6044818d5afa9a8b156105c55760009b6152ed575b506151f361099061098c614f8e8e61452e8115156148b4565b604051632630c12f60e01b815286816004817f00000000000000000000000000000000000000000000000000000000000000008e165afa80156105c5578a916000916152d0575b501692833b1561026c57600095615268916040519a8b97889687966318c68c5b60e21b885260048801612c71565b039134905af19283156105c55760609761529f615060936126c3936000976152bd575b506040513391810191825293849160200190565b60405163bb04869d60e01b81529a8b98899788961660048701615126565b806106066152ca92610695565b3861528b565b6152e79150883d8a116105f2576105e38183610719565b3861523a565b614f8e9b5061099061098c6153116151f3938a3d8c11610b4b57610b3c8183610719565b9d5050506151da565b1561532157565b60405162461bcd60e51b81526020600482015260086024820152671bdb9b1e541bdbdb60c21b6044820152606490fd5b9081602091031261026c57356126128161025b565b6001600160ff1b0381116153775790565b60405162461bcd60e51b815260206004820152602160248201527f56616c756520746f6f206c6172676520746f2066697420696e20696e743235366044820152601760f91b6064820152608490fd5b906153d08261159e565b6153dd6040519182610719565b82815280926153ee601f199161159e565b019060005b8281106153ff57505050565b8060606020809385010152016153f3565b919081101561379d5760051b81013590601e198136030182121561026c5701908135916001600160401b03831161026c57602001823603811361026c579190565b908092918237016000815290565b60208183031261026c578051906001600160401b03821161026c570181601f8201121561026c578051615491816126d6565b9261549f6040519485610719565b8184526020828401011161026c5761261291602080850191016118fd565b90916801000000000000000083101561550457600090156154fc575060ff60015b169160201b906bffffffffffffffffffffffff199060601b16171790565b60ff906154de565b60405162461bcd60e51b81526020600482015260036024820152621c1d1b60ea1b6044820152606490fd5b6002811015610d3657806155435750600190565b8061554f60019261310d565b0361555957600290565b60405162461bcd60e51b8152602060048201526014602482015273496e76616c6964207061796d656e74207479706560601b6044820152606490fdfea26469706673582212204b8b00809a8f25962b3515e12f59578fa515f6b7986dbdfdde75d1a1842a7cb164736f6c6343000813003300000000000000000000000034df93f37f327757684ae502b47c787c3846503700000000000000000000000069c6b6d88fc2f298473737d22bb9156d74b83d590000000000000000000000005efa5e67a91493cf3e9250b80ccc80e0eac7a1e000000000000000000000000003f61a185efeeefdd3ba032afa8a0259337ced64

Deployed Bytecode

0x6080604052600436101561001257600080fd5b60003560e01c80625e69be146102565780630c12595f146102515780630ee78da51461024c57806316f0115b146102475780631770830a146102425780631848effa1461023d57806319afeb20146102385780631d7b7194146102335780632cc460611461022e578063349fdb091461022957806337a66d85146102245780634264d4e61461021f57806354b6f7211461021a5780635566696d146102155780635a80e080146102105780635c975abb1461020b57806367f4d9c614610206578063791b98bc146102015780637aa6ed41146101fc57806387d34c42146101f757806393bce92c146101f2578063a07610ea146101ed578063ac9650d8146101e8578063ae4b19ae146101e3578063b05a718d146101de578063b74af6d8146101d9578063bdc4fe3d146101d4578063c9b6092d146101cf578063ccc5311e146101ca578063ce05a8a4146101c5578063d1e1a0fe146101c0578063d6205b92146101bb578063e09a22d7146101b6578063e0e2ae8b146101b1578063f1a0510e146101ac5763f9b6117f146101a757600080fd5b6125ad565b612512565b612446565b612373565b612292565b6120e2565b611f0c565b611e3f565b611d6c565b611c99565b611bc2565b611b5d565b611a8a565b6119a7565b611879565b6117e6565b611712565b61168b565b611646565b6115b5565b61157b565b6114ea565b611417565b61137e565b6111d8565b6110e9565b611006565b610dc7565b610d3b565b610c44565b610b7c565b610935565b61063a565b610495565b6103e4565b61032b565b6001600160a01b0381160361026c57565b600080fd5b6004359061027e8261025b565b565b6024359061027e8261025b565b6044359061027e8261025b565b359061027e8261025b565b8015150361026c57565b6084359061027e826102a5565b6044359061027e826102a5565b60a4359061027e826102a5565b6064359061027e826102a5565b60c4359061027e826102a5565b359061027e826102a5565b9181601f8401121561026c578235916001600160401b03831161026c576020808501948460051b01011161026c57565b61010036600319011261026c57610340610271565b610348610280565b61035061028d565b6103586102af565b6001600160401b03929060a43584811161026c5761037a9036906004016102fb565b60c49291923586811161026c576103959036906004016102fb565b93909260e43597881161026c576103e0986103b76103c39936906004016102fb565b98909760643592615158565b604080519384526020840192909252908201529081906060820190565b0390f35b60e036600319011261026c576004356103fc8161025b565b610404610280565b6001600160401b039060843582811161026c576104259036906004016102fb565b60a49491943584811161026c576104409036906004016102fb565b9160c43595861161026c576103e0966104606104709736906004016102fb565b969095606435916044359161496f565b604080519384526001600160a01b039092166020840152908201529081906060820190565b60208060031936011261026c576004356104ae8161025b565b6040516315ab88c960e31b8082526001600160a01b0392917f00000000000000000000000034df93f37f327757684ae502b47c787c38465037841691908581600481865afa80156105c5578591600091610612575b501690813b1561026c57600060049260405193848092630d0e30db60e41b825234905af19182156105c55786926105f9575b5060046040518094819382525afa80156105c557849261058c926000926105ca575b5060405163a9059cbb60e01b81526001600160a01b039091166004820152346024820152938492839160009183906044820190565b0393165af180156105c55761059d57005b816105bc92903d106105be575b6105b48183610719565b81019061262c565b005b503d6105aa565b612615565b6105eb919250843d86116105f2575b6105e38183610719565b8101906125fd565b9038610557565b503d6105d9565b8061060661060c92610695565b8061062f565b38610535565b6106299150873d89116105f2576105e38183610719565b38610503565b600091031261026c57565b3461026c57600036600319011261026c576040517f00000000000000000000000003f61a185efeeefdd3ba032afa8a0259337ced646001600160a01b03168152602090f35b634e487b7160e01b600052604160045260246000fd5b6001600160401b0381116106a857604052565b61067f565b606081019081106001600160401b038211176106a857604052565b60a081019081106001600160401b038211176106a857604052565b60e081019081106001600160401b038211176106a857604052565b604081019081106001600160401b038211176106a857604052565b90601f801991011681019081106001600160401b038211176106a857604052565b6040519061014082018281106001600160401b038211176106a857604052565b6040519061016082018281106001600160401b038211176106a857604052565b6040519061020082018281106001600160401b038211176106a857604052565b604051906101a082018281106001600160401b038211176106a857604052565b6004111561026c57565b6024359061027e826107ba565b6044359061027e826107ba565b359061027e826107ba565b60e43590600282101561026c57565b6101043590600282101561026c57565b6101843590600282101561026c57565b3590600282101561026c57565b61014090600319011261026c5761083a61073a565b90610843610271565b825260243560208301526108556107d1565b60408301526064356060830152608435608083015260a43560a083015261087a6102e3565b60c083015260e43560e083015261088f6107f8565b61010083015261012435610120830152565b91908261014091031261026c576108b661073a565b916108c08161029a565b8352602081013560208401526108d8604082016107de565b6040840152606081013560608401526080810135608084015260a081013560a084015261090760c082016102f0565b60c084015260e081013560e0840152610100610924818301610818565b908401526101208091013590830152565b6101408060031936011261026c5761094c36610825565b6109546128e5565b61095c612d61565b602080928183019261099561099061098c61098287516000526002602052604060002090565b5460081c60ff1690565b1590565b612bcb565b610100808201600181516109a88161310d565b6109b18161310d565b148015610b52575b6109c29061313f565b3380845295516040840151909290916109da836130c9565b6060850151608086015160c087015115159060a08801516109fa90615366565b610a0390613264565b9260e08901519451610a148161310d565b610a1d9061552f565b6101208a8101519a516040516001600160a01b039091168e8201908152819003808252909d919a9299929190610a56906020018f610719565b610a5e61075a565b6001600160a01b03909f168f528e0152610a7b9060408e0161317d565b60608c015260808b0152151560a08a015260c089015260e0880152860190610aa291613189565b840152820152816040518080936301d8cec960e51b82526004820190610ac7916131be565b0381347f00000000000000000000000069c6b6d88fc2f298473737d22bb9156d74b83d596001600160a01b03165af19081156105c5576103e092600092610b25575b5050610b156001600055565b6040519081529081906020820190565b610b449250803d10610b4b575b610b3c8183610719565b810190613195565b3880610b09565b503d610b32565b508051610b5e8161310d565b610b678161310d565b1580156109b9575061012083015134146109b9565b3461026c57600036600319011261026c576040517f00000000000000000000000034df93f37f327757684ae502b47c787c384650376001600160a01b03168152602090f35b606090600319011261026c5760405190610bda826106ad565b816004358152602435610bec816107ba565b6020820152604060443591610c00836102a5565b0152565b919082606091031261026c57604051610c1c816106ad565b6040808294803584526020810135610c33816107ba565b6020850152013591610c00836102a5565b3461026c57606036600319011261026c57610c5e36610bc1565b610c666128e5565b610c6e612d61565b80519060208101908151926004841015610d3657610c9b906040830194610c958651151590565b91613c72565b519051917f00000000000000000000000069c6b6d88fc2f298473737d22bb9156d74b83d596001600160a01b031690610cdd90610cd7856130c9565b51151590565b90803b1561026c57610d0a93600080946040519687958694859363ecd1bbcb60e01b855260048501613a17565b03925af180156105c557610d23575b6105bc6001600055565b80610606610d3092610695565b38610d19565b6130b3565b61010036600319011261026c57610d50610271565b610d58610280565b906001600160401b039060843582811161026c57610d7a9036906004016102fb565b9360a43584811161026c57610d939036906004016102fb565b9060c43595861161026c576103e096610db36104709736906004016102fb565b95909460e435976064359160443591614487565b3461026c5760608060031936011261026c5760243590610de6826102a5565b610e6360443591610df6836102a5565b610dfe6128e5565b610e06612d61565b610e146004948535336154bd565b9260018060a01b037f00000000000000000000000069c6b6d88fc2f298473737d22bb9156d74b83d591690604092835195634cc42b5160e01b8752868060009788938b83019190602083019252565b0381865afa9586156105c5578596610fe2575b50845b8651811015610fd457610e8c8188613789565b5190610eb733610eb1610ea5855160018060a01b031690565b6001600160a01b031690565b14613b8c565b8380610fc8575b15610f3457608060a083015192015191610ed7836130c9565b853b15610f305787908a610efc8951958693849363ecd1bbcb60e01b85528401613ef7565b038183895af19182156105c557610f1892610f1d575b50613764565b610e79565b80610606610f2a92610695565b38610f12565b8780fd5b831580610fb3575b610f4b575b610f189150613764565b608060a083015192015191610f5f836130c9565b853b15610f305787908a610f848951958693849363ecd1bbcb60e01b85528401613eb5565b038183895af19182156105c557610f1892610fa0575b50610f41565b80610606610fad92610695565b38610f9a565b50610fc361098c84840151151590565b610f3c565b50818301511515610ebe565b85610fdf6001600055565b80f35b610fff9196503d8087833e610ff78183610719565b810190613f7c565b9438610e76565b3461026c576000806003193601126110e65760405162435da560e01b81526020906001600160a01b039082816004817f00000000000000000000000034df93f37f327757684ae502b47c787c3846503786165afa9182156105c557839185936110c7575b50604051637be53ca160e01b81523360048201529283916024918391165afa9081156105c5576110a29284926110aa575b5050612641565b610fdf612929565b6110c09250803d106105be576105b48183610719565b388061109b565b6110df919350823d84116105f2576105e38183610719565b913861106a565b80fd5b3461026c576000806003193601126110e65760405162435da560e01b81526020906001600160a01b039082816004817f00000000000000000000000034df93f37f327757684ae502b47c787c3846503786165afa9182156105c5578391859361118c575b50604051637be53ca160e01b81523360048201529283916024918391165afa9081156105c5576111849284926110aa575050612641565b610fdf6128a5565b6111a4919350823d84116105f2576105e38183610719565b913861114d565b9181601f8401121561026c578235916001600160401b03831161026c576020838186019501011161026c57565b3461026c5760a036600319011261026c576004356111f58161025b565b6024356112018161025b565b6044359060643591608435936001600160401b03851161026c5761126f61122f610ea59636906004016111ab565b6001600160a01b03979190611267337f00000000000000000000000003f61a185efeeefdd3ba032afa8a0259337ced648b161461531a565b810190615351565b918061128b575b50508261127f57005b6105bc93339216614c39565b6040516315ab88c960e31b81526020816004817f00000000000000000000000034df93f37f327757684ae502b47c787c384650378b165afa9283156105c5578791600094611302575b508116921682036112f1576112ea91339061268e565b3880611276565b6112fd91833391614c39565b6112ea565b8291945061131d9060203d81116105f2576105e38183610719565b93906112d4565b608435906001600160801b038216820361026c57565b60c435906001600160801b038216820361026c57565b61010435906001600160801b038216820361026c57565b61014435906001600160801b038216820361026c57565b61014036600319011261026c5761140561139661073a565b60043581526113a36107c4565b60208201526113b06102bc565b604082015260643560608201526113c5611324565b608082015260a43560a08201526113da61133a565b60c08201526113e76107e9565b60e0820152610104356101008201526101243561012082015261406b565b60408051928352602083019190915290f35b3461026c57604036600319011261026c57602435611434816102a5565b60405162435da560e01b81529060206001600160a01b0381846004817f00000000000000000000000034df93f37f327757684ae502b47c787c3846503785165afa9384156105c5576000946114c9575b50604051637be53ca160e01b815233600482015293829185916024918391165afa80156105c5576105bc936114c1926000926110aa575050612641565b600435612aed565b829194506114e390823d84116105f2576105e38183610719565b9390611484565b3461026c57606036600319011261026c576004356115078161025b565b604435906001600160401b03821161026c5761152a6105bc9236906004016111ab565b90916001600160a01b03611561337f00000000000000000000000003f61a185efeeefdd3ba032afa8a0259337ced6483161461531a565b80611573602435953395810190615351565b169116614c39565b3461026c57600036600319011261026c57602060ff600154166040519015158152f35b6001600160401b0381116106a85760051b60200190565b3461026c5760208060031936011261026c57600435906001600160401b03821161026c573660238301121561026c578160040135916115f38361159e565b916116016040519384610719565b838352808301602460608096028401019236841161026c57602401905b83821061162e576105bc85613dd5565b82869161163b3685610c04565b81520191019061161e565b3461026c57600036600319011261026c576040517f0000000000000000000000005efa5e67a91493cf3e9250b80ccc80e0eac7a1e06001600160a01b03168152602090f35b61014036600319011261026c576114056116a361073a565b6116ab610271565b815260243560208201526116bd6102bc565b604082015260643560608201526116d2611324565b608082015260a43560a08201526116e761133a565b60c08201526116f46107e9565b60e08201526101043561010082015261012435610120820152614393565b3461026c57604036600319011261026c5760043561172f8161025b565b60405162435da560e01b81529060206001600160a01b0381846004817f00000000000000000000000034df93f37f327757684ae502b47c787c3846503785165afa9384156105c5576000946117c5575b50604051637be53ca160e01b815233600482015293829185916024918391165afa80156105c5576105bc936117bc926000926110aa575050612641565b6024359061267d565b829194506117df90823d84116105f2576105e38183610719565b939061177f565b61010036600319011261026c576117fb610271565b611803610280565b9061180c61028d565b6001600160401b03919060a43583811161026c5761182e9036906004016102fb565b9060c43585811161026c576118479036906004016102fb565b92909160e43596871161026c576103e0976118696104709836906004016102fb565b9790966084359260643592614c7b565b61014036600319011261026c576103e0610b1561189461073a565b61189c610271565b815260243560208201526118ae6107d1565b6040820152606435606082015260843560808201526118cb6102c9565b60a082015260c43560c082015260e43560e08201526118e86107f8565b610100820152610124356101208201526134f0565b60005b8381106119105750506000910152565b8181015183820152602001611900565b90602091611939815180928185528580860191016118fd565b601f01601f1916010190565b602080820190808352835180925260408301928160408460051b8301019501936000915b8483106119795750505050505090565b9091929394958480611997600193603f198682030187528a51611920565b9801930193019194939290611969565b602036600319011261026c57600480356001600160401b03811161026c576119d290369083016102fb565b906119dc826153c6565b9160005b8181106119f557604051806103e08682611945565b600080611a03838587615410565b60409391611a15855180938193615451565b0390305af490611a236127d7565b91829015611a4c57505090611a4791611a3c8287613789565b52610f128186613789565b6119e0565b826044899394511061026c57611a869183611a7192016024809151830101910161545f565b925162461bcd60e51b81529283928301612894565b0390fd5b3461026c57604036600319011261026c57602435611aa7816102a5565b60405162435da560e01b81529060206001600160a01b0381846004817f00000000000000000000000034df93f37f327757684ae502b47c787c3846503785165afa9384156105c557600094611b3c575b50604051637be53ca160e01b815233600482015293829185916024918391165afa80156105c5576105bc93611b34926000926110aa575050612641565b600435612a15565b82919450611b5690823d84116105f2576105e38183610719565b9390611af7565b3461026c57602036600319011261026c57600435600052600260205260a060406000205460ff6040519181811615158352818160081c1615156020840152818160101c1615156040840152818160181c161515606084015260201c1615156080820152f35b3461026c57608036600319011261026c57600435611bdf8161025b565b602435604435611bee8161025b565b6064356001600160401b03811161026c57611c0d9036906004016111ab565b6001600160a01b0391907f00000000000000000000000069c6b6d88fc2f298473737d22bb9156d74b83d5983163303611c615781611c4e9184930190615351565b169083611c5757005b6105bc9416614c39565b60405162461bcd60e51b815260206004820152601060248201526f37b7363ca7b93232b926b0b730b3b2b960811b6044820152606490fd5b3461026c57604036600319011261026c57602435611cb6816102a5565b60405162435da560e01b81529060206001600160a01b0381846004817f00000000000000000000000034df93f37f327757684ae502b47c787c3846503785165afa9384156105c557600094611d4b575b50604051637be53ca160e01b815233600482015293829185916024918391165afa80156105c5576105bc93611d43926000926110aa575050612641565b6004356129a4565b82919450611d6590823d84116105f2576105e38183610719565b9390611d06565b3461026c57604036600319011261026c57602435611d89816102a5565b60405162435da560e01b81529060206001600160a01b0381846004817f00000000000000000000000034df93f37f327757684ae502b47c787c3846503785165afa9384156105c557600094611e1e575b50604051637be53ca160e01b815233600482015293829185916024918391165afa80156105c5576105bc93611e16926000926110aa575050612641565b600435612b5c565b82919450611e3890823d84116105f2576105e38183610719565b9390611dd9565b61020036600319011261026c576103e0610b15611e5a61077a565b611e62610271565b81526024356020820152611e746107d1565b604082015260643560608201526084356080820152611e916102c9565b60a0820152611e9e61133a565b60c082015260e43560e0820152611eb3611350565b61010082015261012435610120820152611ecb611367565b61014082015261016435610160820152611ee3610808565b6101808201526101a4356101a08201526101c4356101c08201526101e4356101e0820152612db7565b60c036600319011261026c5760243560048035611f28836102a5565b6001600160401b0360643581811161026c57611f4790369085016102fb565b60849291923582811161026c57611f6190369087016102fb565b91909260a43590811161026c57611f7b90369088016102fb565b929094611f866128e5565b611f8e612d61565b611fb561099061098c611fab8a6000526002602052604060002090565b5460101c60ff1690565b604051632630c12f60e01b81526001600160a01b0396906020818b817f00000000000000000000000034df93f37f327757684ae502b47c787c384650378c165afa80156105c55788916000916120c4575b501692833b1561026c576000958a9261203492604051998a98899788976318c68c5b60e21b89528801612c71565b039134905af180156105c5576120b1575b507f0000000000000000000000005efa5e67a91493cf3e9250b80ccc80e0eac7a1e016803b1561026c5760408051632ca92e3360e21b81529384019283523360208401529315159382019390935260443560608201529091600091839190829084908290608001610d0a565b806106066120be92610695565b38612045565b6120dc915060203d81116105f2576105e38183610719565b38612006565b608036600319011261026c576024356001600160401b0380821161026c5761210f600492369084016102fb565b60449291923582811161026c5761212990369086016102fb565b91909260643590811161026c5761214390369087016102fb565b92909461214e6128e5565b612156612d61565b604051632630c12f60e01b81526001600160a01b0396906020818a817f00000000000000000000000034df93f37f327757684ae502b47c787c384650378c165afa80156105c5578891600091612274575b501692833b1561026c5760009589926121d592604051998a98899788976318c68c5b60e21b89528801612c71565b039134905af180156105c557612261575b507f0000000000000000000000005efa5e67a91493cf3e9250b80ccc80e0eac7a1e016803b1561026c5760405163894feb9d60e01b81528235818401908152909160009183919082908490829060200103925af180156105c55761224e576105bc6001600055565b8061060661225b92610695565b80610d19565b8061060661226e92610695565b386121e6565b61228c915060203d81116105f2576105e38183610719565b386121a7565b3461026c57602036600319011261026c576103e0604080608081516122b6816106c8565b60009181838093528260208201528285820152826060820152015260043581526002602052209061233060ff8251936122ee856106c8565b5481811615158552818160081c1615156020860152818160101c16151584860152612323828260181c16606087019015159052565b60201c1615156080840152565b519182918291909160808060a083019480511515845260208101511515602085015260408101511515604085015260608101511515606085015201511515910152565b3461026c57604036600319011261026c57602435612390816102a5565b60405162435da560e01b81529060206001600160a01b0381846004817f00000000000000000000000034df93f37f327757684ae502b47c787c3846503785165afa9384156105c557600094612425575b50604051637be53ca160e01b815233600482015293829185916024918391165afa80156105c5576105bc9361241d926000926110aa575050612641565b600435612a80565b8291945061243f90823d84116105f2576105e38183610719565b93906123e0565b60e036600319011261026c5760043561245e8161025b565b612466610280565b61246e6102d6565b916001600160401b039160843583811161026c576124909036906004016102fb565b9060a43585811161026c576124a99036906004016102fb565b92909160c43596871161026c576103e0976124cb6103c39836906004016102fb565b97909660443591614ef2565b6020908160408183019282815285518094520193019160005b8281106124fe575050505090565b8351855293810193928101926001016124f0565b60208060031936011261026c576004356001600160401b03811161026c573660238201121561026c5780600401359061254a8261159e565b926125586040519485610719565b82845280840160246101408095028401019236841161026c57602401905b838210612595576103e0612589876137fb565b604051918291826124d7565b8285916125a236856108a1565b815201910190612576565b3461026c57600036600319011261026c576040517f00000000000000000000000069c6b6d88fc2f298473737d22bb9156d74b83d596001600160a01b03168152602090f35b519061027e8261025b565b9081602091031261026c57516126128161025b565b90565b6040513d6000823e3d90fd5b519061027e826102a5565b9081602091031261026c5751612612816102a5565b1561264857565b60405162461bcd60e51b815260206004820152600d60248201526c37b7363ca837b7b620b236b4b760991b6044820152606490fd5b61027e919033906001600160a01b03165b60405163a9059cbb60e01b60208201526001600160a01b039092166024830152604482019290925261027e916126d182606481015b03601f198101845283610719565b6126f1565b6001600160401b0381116106a857601f01601f191660200190565b60405161274f916001600160a01b031661270a826106fe565b6000806020958685527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656487860152868151910182855af16127496127d7565b91612807565b8051908282159283156127bf575b505050156127685750565b6084906040519062461bcd60e51b82526004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152fd5b6127cf935082018101910161262c565b38828161275d565b3d15612802573d906127e8826126d6565b916127f66040519384610719565b82523d6000602084013e565b606090565b91929015612869575081511561281b575090565b3b156128245790565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b82519091501561287c5750805190602001fd5b60405162461bcd60e51b8152908190611a8690600483015b906020612612928181520190611920565b6128ad6128e5565b600160ff19815416176001557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a1565b60ff600154166128f157565b60405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606490fd5b60015460ff8116156129685760ff19166001557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a1565b60405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606490fd5b907ffc5b53a10a690d609db15172bc801db46cd4325162b1d451ecf9c2506793de3591806000526002602052604060002060ff1981541660ff841516179055612a10604051928392338491926040919493606084019560018060a01b0316845260208401521515910152565b0390a1565b600081815260026020908152604091829020805461ff0019169415600881901b61ff00169590951790558151338152908101929092529115918101919091527fc19970c31e6a5e852abc18399a2d6111dedb931ea613d86f2e6be00dc433b2fc908060608101612a10565b600081815260026020908152604091829020805462ff000019169415601081901b62ff0000169590951790558151338152908101929092529115918101919091527f6539cab5b8437438117f6321b1de3c48abc0e1edcbb0f35fcaa5dcb80364774c908060608101612a10565b600081815260026020908152604091829020805463ff00000019169415601881901b63ff000000169590951790558151338152908101929092529115918101919091527fc500659b3cffd5679961b0ae179a7e58a43967e3fc5ddd7a467cdd624d61d819908060608101612a10565b600081815260026020908152604091829020805464ff000000001916941580831b64ff00000000169590951790558151338152908101929092529115918101919091527fb1baea30c77fbf28a108876bf97e168dca9b94d86632c9f4cca34a886f0db672908060608101612a10565b15612bd257565b60405162461bcd60e51b8152602060048201526008602482015267191a5cd8589b195960c21b6044820152606490fd5b908060209392818452848401376000828201840152601f01601f1916010190565b9190808252602080920192916000805b838210612c4257505050505090565b909192939485356001600160401b038116809103612c6d578152830194830193929160010190612c33565b8280fd5b96959390949291806060890160608a525260808801959060005b818110612d325750505060208786038189015281865280860195818360051b82010196846000925b858410612cd3575050505050505084604061261295968503910152612c23565b90919293949598601f198282030184528935601e198436030181121561026c5783018681019190356001600160401b03811161026c57803603831361026c57612d2188928392600195612c02565b9b0194019401929594939190612cb3565b90919293966001908435612d458161025b565b60a083901b839003168152602090810198959401929101612c8b565b600260005414612d72576002600055565b60405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606490fd5b612dbf6128e5565b612dc7612d61565b6020808201612df161099061098c612dea84516000526002602052604060002090565b5460ff1690565b604083019260028451612e03816130c9565b612e0c816130c9565b141580613090575b612e1d906130d3565b61018081019360018551612e308161310d565b612e398161310d565b148015613043575b612e4a9061313f565b338083526101a08301805185519351919792939190612e68826130c9565b8760608701519560808801519660a08901978851612e8590151590565b60c08b0151612e9c906001600160801b0316615366565b916101608c0151938a51612eaf8161310d565b612eb89061552f565b9f518d516040516001600160a01b03909116898201908152819003808252909b919a9190612ee9906020018d610719565b612ef161075a565b6001600160a01b03909816885287890152612f0f906040880161317d565b60608601526080850152151560a084015260c083015260e08201526101009a612f3a908c8301613189565b6101209384820152610140948582015260405192838080936301d8cec960e51b82526004820190612f6a916131be565b03917f00000000000000000000000069c6b6d88fc2f298473737d22bb9156d74b83d596001600160a01b03165af19788156105c557600098613020575b50508451969761301497612fc7906001600160a01b031697519551151590565b612ff6612fe260e0890151938901516001600160801b031690565b93880151948801516001600160801b031690565b9451956130028761310d565b6101e06101c089015198015198613275565b50506126126001600055565b6130149850908161303c92903d10610b4b57610b3c8183610719565b9638612fa7565b50845161304f8161310d565b6130588161310d565b158015612e415750612e4a61308761307b6101a08501516101c08601519061312d565b6101e08501519061312d565b34149050612e41565b50612e1d600385516130a1816130c9565b6130aa816130c9565b14159050612e14565b634e487b7160e01b600052602160045260246000fd5b60041115610d3657565b156130da57565b60405162461bcd60e51b815260206004820152600b60248201526a1b9bdd081cdd5c1c1bdc9d60aa1b6044820152606490fd5b60021115610d3657565b634e487b7160e01b600052601160045260246000fd5b9190820180921161313a57565b613117565b1561314657565b60405162461bcd60e51b815260206004820152600f60248201526e696e636f72726563742076616c756560881b6044820152606490fd5b6004821015610d365752565b6003821015610d365752565b9081602091031261026c575190565b906004821015610d365752565b906003821015610d365752565b602080825282516001600160a01b0316908201526126129161018090602081015160408401526131f6604082015160608501906131a4565b60608101516080840152608081015160a084015261321d60a082015160c085019015159052565b60c081015160e084015260e0810151610100908185015281015161324761012091828601906131b1565b810151906101409182850152015191610160808201520190611920565b600160ff1b811461313a5760000390565b9597969190939998949299600098600098899c6001600160801b03809416806133ee575b50505016806132af575b50505050505050509190565b61338697989a5091613349602097969594926132de6132d86132d361335e97615366565b613264565b9361552f565b6040516001600160a01b038a168b820190815290979195919061330f9089906020015b03601f1981018a5289610719565b61332961331a61075a565b6001600160a01b03909b168b52565b898b0152600360408a0152606089018c90526080890152151560a0880152565b60c08601528760e08601526101008501613189565b8161012084015261014083015260405180809581946301d8cec960e51b8352600483016131be565b03917f00000000000000000000000069c6b6d88fc2f298473737d22bb9156d74b83d596001600160a01b03165af19182156105c557916133d0575b509138808080808080806132a3565b6133e8915060203d8111610b4b57610b3c8183610719565b386133c1565b61348c939c50918861335e8c938e61340a6132d3602098615366565b6134138c61552f565b6040516001600160a01b0389168a820190815281900380825290969194919061343f9060200188610719565b61345961344a61075a565b6001600160a01b03909a168a52565b888a0152600260408901526060880183905260808801528a151560a088015260c087015260e08601526101008501613189565b03917f00000000000000000000000069c6b6d88fc2f298473737d22bb9156d74b83d596001600160a01b03165af19081156105c55789916134d2575b5098388080613299565b6134ea915060203d8111610b4b57610b3c8183610719565b386134c8565b6134f86128e5565b613500612d61565b6020908181019061352561099061098c612dea85516000526002602052604060002090565b604081019060028251613537816130c9565b613540816130c9565b14158061370f575b613551906130d3565b610100808201600181516135648161310d565b61356d8161310d565b1480156136e5575b61357e9061313f565b338084529451935191613590836130c9565b606084015191608085015160a08601516135a990151590565b60c08701516135b790615366565b9160e088015193516135c88161310d565b6135d19061552f565b6101208981015199516040516001600160a01b039091168e8201908152819003808252909b9199929892919061360a906020018d610719565b61361261075a565b6001600160a01b03909d168d528c8e01526136309060408d0161317d565b60608b015260808a0152151560a089015260c088015260e087015285019061365791613189565b830152610140820152816040518080936301d8cec960e51b8252600482019061367f916131be565b0381347f00000000000000000000000069c6b6d88fc2f298473737d22bb9156d74b83d596001600160a01b03165af19182156105c5576000926136c85750506126126001600055565b6136de9250803d10610b4b57610b3c8183610719565b3880613014565b5080516136f18161310d565b6136fa8161310d565b15801561357557506101208301513414613575565b5061355160038351613720816130c9565b613729816130c9565b14159050613548565b9061373c8261159e565b6137496040519182610719565b828152809261375a601f199161159e565b0190602036910137565b600019811461313a5760010190565b634e487b7160e01b600052603260045260246000fd5b805182101561379d5760209160051b010190565b613773565b156137a957565b60405162461bcd60e51b815260206004820152601860248201527f696e73756666696369656e74206e6574776f726b2066656500000000000000006044820152606490fd5b9190820391821161313a57565b906138046128e5565b61380c612d61565b6138168251613732565b34927f00000000000000000000000069c6b6d88fc2f298473737d22bb9156d74b83d596001600160a01b03169060005b81518110156139d85780602061385f61398c9385613789565b5181810161388161099061098c61098284516000526002602052604060002090565b61389f61012083019a6138978c518210156137a2565b8b51906137ee565b9980519151926139656040820151926138b7846130c9565b60608301519260808101516139516138d260c0840151151590565b6138e26132d360a0860151615366565b926138ff61010060e08701519601516138fa8161310d565b61552f565b9551604080513360208083019190915281529a91999161393e91613923908d610719565b604061392d61075a565b3381529e8f9060208201520161317d565b60608c015260808b0152151560a08a0152565b60c088015260e08701526101008601613189565b61012084015261014083015260405180809681946301d8cec960e51b8352600483016131be565b0391885af180156105c5576139b4926000916139b9575b506139ae8287613789565b52613764565b613846565b6139d2915060203d602011610b4b57610b3c8183610719565b386139a3565b5050509091801580156139f15750506126126001600055565b600080809381938290613a0e575b3390f1156105c5573880613014565b506108fc6139ff565b91613a2c9060c09492845260208401906131a4565b1515604082015260806060820152600b60808201526a31b0b731b2b627b93232b960a91b60a08201520190565b519061027e826107ba565b919082604091031261026c57604051604081018181106001600160401b038211176106a85760405280928051600381101561026c578252602090810151910152565b9190828103906101e0821261026c576101a080921261026c5761261291613acb61079a565b85518152613adb602087016125f2565b602082015260408601516040820152613af660608701613a59565b60608201526080860151608082015260a086015160a082015260c086015160c082015260e086015160e08201526101008087015190820152610120613b3c818801612621565b90820152610140613b4e818801612621565b908201526101608087015190820152610180613b6b818801612621565b908201529401613a64565b90815260408101929161027e91602001906131a4565b15613b9357565b60405162461bcd60e51b815260206004820152600b60248201526a1bdb9b1e5058d8dbdd5b9d60aa1b6044820152606490fd5b9190828103906101a0821261026c5761016080921261026c5761261291613beb61075a565b85518152613bfb602087016125f2565b602082015260408601516040820152613c1660608701613a59565b60608201526080860151608082015260a086015160a0820152613c3b60c08701612621565b60c082015260e086015160e08201526101008087015190820152610120808701519082015261014080870151908201529401613a64565b9115613d2f57613c999060405191829163f9d244fd60e01b83526101a09460048401613b76565b6001600160a01b039291849183919003817f00000000000000000000000069c6b6d88fc2f298473737d22bb9156d74b83d5986165afa9283156105c55761027e93613cf992602092600092613d01575b505001516001600160a01b031690565b163314613b8c565b613d209250803d10613d28575b613d188183610719565b810190613bc6565b503880613ce9565b503d613d0e565b613d50906040519182916340b4605b60e11b83526101e09460048401613b76565b6001600160a01b039291849183919003817f00000000000000000000000069c6b6d88fc2f298473737d22bb9156d74b83d5986165afa9283156105c55761027e93613cf992602092600092613daf57505001516001600160a01b031690565b613d209250803d10613dce575b613dc68183610719565b810190613aa6565b503d613dbc565b90613dde6128e5565b613de6612d61565b7f00000000000000000000000069c6b6d88fc2f298473737d22bb9156d74b83d596001600160a01b03169160005b8151811015613ea757613e278183613789565b519081516020830192613e60845191613e3f836130c9565b613e5360409485830194610c958651151590565b51945191610cd7836130c9565b93873b1561026c57613e8760009351958693849363ecd1bbcb60e01b855260048501613f39565b038183895af19182156105c557613ea292610f1d5750613764565b613e14565b5050905061027e6001600055565b9060c092613ec991835260208301906131a4565b6000604082015260806060820152600c60808201526b63616e63656c4f726465727360a01b60a08201520190565b9060c092613f0b91835260208301906131a4565b6001604082015260806060820152600c60808201526b63616e63656c4f726465727360a01b60a08201520190565b91613f4e9060c09492845260208401906131a4565b1515604082015260806060820152600c60808201526b63616e63656c4f726465727360a01b60a08201520190565b602090818184031261026c578051906001600160401b03821161026c570182601f8201121561026c57805191613fb18361159e565b936040613fc081519687610719565b848652828601918360e08097028601019481861161026c578401925b858410613fed575050505050505090565b868483031261026c578487918451614004816106e3565b865161400f8161025b565b8152828701518382015285870151614026816102a5565b868201526060614037818901612621565b908201526080614048818901613a59565b9082015260a0808801519082015260c08088015190820152815201930192613fdc565b6140736128e5565b61407b612d61565b600061408a6040830151151590565b1561428f575080516140c060208301516140a3816130c9565b60405191829163f9d244fd60e01b83526101a09460048401613b76565b6001600160a01b039291849183919003817f00000000000000000000000069c6b6d88fc2f298473737d22bb9156d74b83d5986165afa9283156105c557600093614269575b5050602082015161412391906001600160a01b03165b16331461435b565b61413560c06040830151920151151590565b915b61415461099061098c611fab856000526002602052604060002090565b60e0810192600184516141668161310d565b61416f8161310d565b14801561422b575b6141809061313f565b60808201516001600160801b0316938415801590614200575b6141b5575b50505050506141ad6001600055565b600090600090565b6141f89460608401519060a0850151916141d960c08701516001600160801b031690565b9351946141e58661310d565b6101206101008801519701519733613275565b38808061419e565b5061422461421860c08501516001600160801b031690565b6001600160801b031690565b1515614199565b5083516142378161310d565b6142408161310d565b15801561417757506141806142606101008401516101208501519061312d565b34149050614177565b614123929350908161428692903d10613d2857613d188183610719565b50919038614105565b81516142bf60208401516142a2816130c9565b6040519182916340b4605b60e11b83526101e09460048401613b76565b6001600160a01b039391829184919003817f00000000000000000000000069c6b6d88fc2f298473737d22bb9156d74b83d5987165afa9384156105c55793614335575b5050602082015161431c91906001600160a01b031661411b565b61432f6101206040830151920151151590565b91614137565b61431c929350908161435292903d10613dce57613dc68183610719565b50919038614302565b1561436257565b60405162461bcd60e51b81526020600482015260096024820152686e6f2061636365737360b81b6044820152606490fd5b6144399061439f6128e5565b6143a7612d61565b60208101906143ca61099061098c611fab85516000526002602052604060002090565b60e0810191600183516143dc8161310d565b6143e58161310d565b148015614449575b6143f69061313f565b51916144056040830151151590565b90606083015161441f60808501516001600160801b031690565b60a0850151916141d960c08701516001600160801b031690565b91906144456001600055565b9190565b5082516144558161310d565b61445e8161310d565b1580156143ed57506143f661447e6101008401516101208501519061312d565b341490506143ed565b9793919695929a9860206144d89b969261449f6128e5565b6144a7612d61565b60405163684ae9e560e01b81526001600160a01b03808d16600483015290911660248201529b8c9081906044820190565b03817f00000000000000000000000003f61a185efeeefdd3ba032afa8a0259337ced646001600160a01b03165afa9a8b156105c55760009b614885575b5061454861099061098c61453e8e61452e8115156148b4565b6000526002602052604060002090565b5460181c60ff1690565b61455d614555878a61312d565b3410156148ea565b604051632630c12f60e01b81526020816004817f00000000000000000000000034df93f37f327757684ae502b47c787c384650376001600160a01b03165afa9081156105c557600091614866575b506001600160a01b031692833b1561026c576145e287926000976040519a8b98899788966318c68c5b60e21b885260048801612c71565b03925af19182156105c5576145fd92614853575b50346137ee565b93303b1561026c57604051630ee78da560e01b8152306004820152906000828060248101038189305af19081156105c5576060928492614840575b506040805133602082015261467a9161465e90829081015b03601f198101835282610719565b604051633cece6db60e21b8152998a948594336004870161493f565b038160007f00000000000000000000000003f61a185efeeefdd3ba032afa8a0259337ced646001600160a01b03165af19384156105c55760009283968496614806575b506146c883836137ee565b15159081614781575b506146e8575b50506146e36001600055565b929190565b6040516315ab88c960e31b8152916020836004817f00000000000000000000000034df93f37f327757684ae502b47c787c384650376001600160a01b03165afa9081156105c5576147579360009261475e575b5061474691926137ee565b9033906001600160a01b031661268e565b38806146d7565b614746925061477b9060203d6020116105f2576105e38183610719565b9161473b565b6040516315ab88c960e31b81529091506020816004817f00000000000000000000000034df93f37f327757684ae502b47c787c384650376001600160a01b03165afa9081156105c5576000916147e7575b506001600160a01b03918216911614386146d1565b614800915060203d6020116105f2576105e38183610719565b386147d2565b919350945061482d91955060603d8111614839575b6148258183610719565b81019061491b565b959192909594386146bd565b503d61481b565b8061060661484d92610695565b38614638565b8061060661486092610695565b386145f6565b61487f915060203d6020116105f2576105e38183610719565b386145ab565b61453e9b5061099061098c6148ab6145489360203d602011610b4b57610b3c8183610719565b9d505050614515565b156148bb57565b60405162461bcd60e51b81526020600482015260076024820152662165786973747360c81b6044820152606490fd5b156148f157565b60405162461bcd60e51b81526020600482015260026024820152616e6560f01b6044820152606490fd5b9081606091031261026c57805191604060208301516149398161025b565b92015190565b919260a093612612969592600180871b031684526020840152604083015260608201528160808201520190611920565b99989593919690979492996149826128e5565b61498a612d61565b6040805163684ae9e560e01b81526001600160a01b038381166004808401919091529b811660248301527f00000000000000000000000003f61a185efeeefdd3ba032afa8a0259337ced6481169992976020979196929590939288876044818f5afa9a8b156105c5578e9760009c614c0c575b50614a1661099061098c61453e8f61452e8115156148b4565b8a51632630c12f60e01b81527f00000000000000000000000034df93f37f327757684ae502b47c787c384650378a16988b908290818c5afa80156105c5578a91600091614bef575b501692833b1561026c578f9195600096614a8c928e51998a98899788976318c68c5b60e21b89528801612c71565b039134905af180156105c557614bdc575b5084516315ab88c960e31b808252919085818c81875afa9081156105c55785918291600091614bbf575b5016911614614b59575b50508251339281019283526060976000949093614b129350614af79083906020016126c3565b51633cece6db60e21b8152998a97889687953390870161493f565b03925af19081156105c557600080938193614b33575b506146e36001600055565b91935050614b4f915060603d8111614839576148258183610719565b9290929138614b28565b9288938593998296518094819382525afa9182156105c557614af7600095614b988a60609c614b12976126c3978b91614ba2575b503091339116614c39565b9499505093614ad1565b614bb99150853d87116105f2576105e38183610719565b38614b8d565b614bd69150883d8a116105f2576105e38183610719565b38614ac7565b80610606614be992610695565b38614a9d565b614c0691508c8d3d106105f2576105e38183610719565b38614a5e565b61453e9c5061099061098c614c30614a16938e803d10610b4b57610b3c8183610719565b9e5050506149fd565b6040516323b872dd60e01b60208201526001600160a01b03928316602482015292909116604483015260648083019390935291815261027e916126d1826106c8565b9198939a99614cfc959398919697614c916128e5565b614c99612d61565b60405163684ae9e560e01b81526001600160a01b03858116600483015298891660248201527f00000000000000000000000003f61a185efeeefdd3ba032afa8a0259337ced6489169990986020989097919089908b908d90829081906044820190565b03915afa998a156105c55760009a614ed3575b50614d1b8a15156148b4565b614d3861099061098c61453e8d6000526002602052604060002090565b604051632630c12f60e01b81527f00000000000000000000000034df93f37f327757684ae502b47c787c38465037891697908a816004818c5afa80156105c5578a91600091614eb6575b501692833b1561026c57600095614db091604051988997889687966318c68c5b60e21b885260048801612c71565b039134905af180156105c557614ea3575b506040516315ab88c960e31b80825291908581600481875afa9081156105c55785918291600091614e86575b5016911614614e3c575b505060405133928101928352606096600093909250614b129190614e1f908290602001614650565b604051633cece6db60e21b8152998a97889687956004870161493f565b839060046040999499518094819382525afa9081156105c557614e1f600094614e7b8960609b614b1296614650968a91614ba257503091339116614c39565b945050829750614df7565b614e9d9150883d8a116105f2576105e38183610719565b38614ded565b80610606614eb092610695565b38614dc1565b614ecd91508c8d3d106105f2576105e38183610719565b38614d82565b614eeb919a50893d8b11610b4b57610b3c8183610719565b9838614d0f565b9998929693959194979097614f056128e5565b614f0d612d61565b60405163684ae9e560e01b81526001600160a01b039b8c166004820152988b1660248a015297996020987f00000000000000000000000003f61a185efeeefdd3ba032afa8a0259337ced6482169790918a8d6044818c5afa9c8d156105c55760009d6150dc575b50614f9861099061098c8f8061452e614f8e9215156148b4565b5460201c60ff1690565b604051632630c12f60e01b81528b816004817f00000000000000000000000034df93f37f327757684ae502b47c787c3846503786165afa9081156105c5576000916150bf575b501692833b1561026c5760009561500c91604051988997889687966318c68c5b60e21b885260048801612c71565b039134905af19687156105c55761503f6060966000936133019a6150ac575b5060405133918101918252998a9160200190565b6150606040519889968795869463bb04869d60e01b86523360048701615126565b03925af19081156105c55760008093819361508057506146e36001600055565b91935050614b4f915060603d81116150a5575b61509d8183610719565b81019061510b565b503d615093565b806106066150b992610695565b3861502b565b6150d691508c8d3d106105f2576105e38183610719565b38614fde565b909c508a3d8c11615104575b6150f28183610719565b81016150fd91613195565b9b38614f74565b503d6150e8565b9081606091031261026c578051916040602083015192015190565b919260a093612612969592600180871b0316845260208401526040830152151560608201528160808201520190611920565b97949690929a9991939861516a6128e5565b615172612d61565b60405163684ae9e560e01b81526001600160a01b03998a166004820152938916602485015292977f00000000000000000000000003f61a185efeeefdd3ba032afa8a0259337ced64811697909660209491858b6044818d5afa9a8b156105c55760009b6152ed575b506151f361099061098c614f8e8e61452e8115156148b4565b604051632630c12f60e01b815286816004817f00000000000000000000000034df93f37f327757684ae502b47c787c384650378e165afa80156105c5578a916000916152d0575b501692833b1561026c57600095615268916040519a8b97889687966318c68c5b60e21b885260048801612c71565b039134905af19283156105c55760609761529f615060936126c3936000976152bd575b506040513391810191825293849160200190565b60405163bb04869d60e01b81529a8b98899788961660048701615126565b806106066152ca92610695565b3861528b565b6152e79150883d8a116105f2576105e38183610719565b3861523a565b614f8e9b5061099061098c6153116151f3938a3d8c11610b4b57610b3c8183610719565b9d5050506151da565b1561532157565b60405162461bcd60e51b81526020600482015260086024820152671bdb9b1e541bdbdb60c21b6044820152606490fd5b9081602091031261026c57356126128161025b565b6001600160ff1b0381116153775790565b60405162461bcd60e51b815260206004820152602160248201527f56616c756520746f6f206c6172676520746f2066697420696e20696e743235366044820152601760f91b6064820152608490fd5b906153d08261159e565b6153dd6040519182610719565b82815280926153ee601f199161159e565b019060005b8281106153ff57505050565b8060606020809385010152016153f3565b919081101561379d5760051b81013590601e198136030182121561026c5701908135916001600160401b03831161026c57602001823603811361026c579190565b908092918237016000815290565b60208183031261026c578051906001600160401b03821161026c570181601f8201121561026c578051615491816126d6565b9261549f6040519485610719565b8184526020828401011161026c5761261291602080850191016118fd565b90916801000000000000000083101561550457600090156154fc575060ff60015b169160201b906bffffffffffffffffffffffff199060601b16171790565b60ff906154de565b60405162461bcd60e51b81526020600482015260036024820152621c1d1b60ea1b6044820152606490fd5b6002811015610d3657806155435750600190565b8061554f60019261310d565b0361555957600290565b60405162461bcd60e51b8152602060048201526014602482015273496e76616c6964207061796d656e74207479706560601b6044820152606490fdfea26469706673582212204b8b00809a8f25962b3515e12f59578fa515f6b7986dbdfdde75d1a1842a7cb164736f6c63430008130033

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

00000000000000000000000034df93f37f327757684ae502b47c787c3846503700000000000000000000000069c6b6d88fc2f298473737d22bb9156d74b83d590000000000000000000000005efa5e67a91493cf3e9250b80ccc80e0eac7a1e000000000000000000000000003f61a185efeeefdd3ba032afa8a0259337ced64

-----Decoded View---------------
Arg [0] : addressProvider (address): 0x34df93f37F327757684Ae502b47C787C38465037
Arg [1] : _orderManager (address): 0x69c6B6D88fC2f298473737d22Bb9156D74B83d59
Arg [2] : _positionManager (address): 0x5EfA5e67A91493Cf3e9250b80ccC80E0eAc7A1E0
Arg [3] : _pool (address): 0x03f61a185efEEEFdd3Ba032AFa8A0259337CEd64

-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 00000000000000000000000034df93f37f327757684ae502b47c787c38465037
Arg [1] : 00000000000000000000000069c6b6d88fc2f298473737d22bb9156d74b83d59
Arg [2] : 0000000000000000000000005efa5e67a91493cf3e9250b80ccc80e0eac7a1e0
Arg [3] : 00000000000000000000000003f61a185efeeefdd3ba032afa8a0259337ced64


Block Transaction Gas Used Reward
view all blocks sequenced

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

Validator Index Block Amount
View All Withdrawals

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

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