Contract 0xb144cCe7992f792a7C41C2a341878B28b8A11984

 
Txn Hash Method
Block
From
To
Value [Txn Fee]
0x12064fe19d9db513859b4f8690c5b48d169479b7f72b2b25f80dd7ea785f96920x40957410194738672021-09-24 21:57:195 hrs 19 mins ago0xe8d2ab794b922cb1b0c89bd73777300d6dd1c993 IN  0xb144cce7992f792a7c41c2a341878b28b8a119840 MATIC0.000502871292
0xd99899f84b373851a127495cbfcb45b67377304d62018a6907534ac72f8b1cee0x40957410194205282021-09-23 12:51:591 day 14 hrs ago0xb09c45de1934041d6b4d00917e087248d2aacc26 IN  0xb144cce7992f792a7c41c2a341878b28b8a119840 MATIC0.0057008993
0x52858c49cc5f107a89c0e2cf93207b337e0538d274929994768e15b4b44998910x40957410194205042021-09-23 12:51:111 day 14 hrs ago0xb09c45de1934041d6b4d00917e087248d2aacc26 IN  0xb144cce7992f792a7c41c2a341878b28b8a119840 MATIC0.002423253311
0xa3906d875e5312a274e8bd492e9bafca9f6d8fabf99a4dae60e46683dd7050bd0x40957410193925602021-09-22 17:58:332 days 9 hrs ago0xe8d2ab794b922cb1b0c89bd73777300d6dd1c993 IN  0xb144cce7992f792a7c41c2a341878b28b8a119840 MATIC0.00052083636
0xb704cfb140b0da28bb80c93ada2b56bcf6e0cc9456d9647073f80b04a558576c0xfa829818193639822021-09-21 22:47:453 days 4 hrs ago0xd8b61d6f9577b10d6701ec778cc31f2c9c99af03 IN  0xb144cce7992f792a7c41c2a341878b28b8a119840 MATIC0.0013617975
0x2729a922353571f9d9e17b329d91c809a91dfc04adf5947616a923d2a50f08260xfa829818193627312021-09-21 21:56:463 days 5 hrs ago0xd8b61d6f9577b10d6701ec778cc31f2c9c99af03 IN  0xb144cce7992f792a7c41c2a341878b28b8a119840 MATIC0.00324318
0x5edff7e8f4a8ec973156b16373604c76255f25a470960873e47ca0b93370bb910xfa829818193625492021-09-21 21:50:263 days 5 hrs ago0xd8b61d6f9577b10d6701ec778cc31f2c9c99af03 IN  0xb144cce7992f792a7c41c2a341878b28b8a119840 MATIC0.005098647552
0x520054b7cbcfdede29553e29ab1b0551957d8aa26e81e79694aca4200a6ee9840xfa829818193617652021-09-21 21:14:553 days 6 hrs ago0xd8b61d6f9577b10d6701ec778cc31f2c9c99af03 IN  0xb144cce7992f792a7c41c2a341878b28b8a119840 MATIC0.0108072
0xf629d25ffc504df5399d2aa06673ec9339b0e766e5d1dc6148d9102d3fc326090xfa829818193614502021-09-21 21:01:573 days 6 hrs ago0xd8b61d6f9577b10d6701ec778cc31f2c9c99af03 IN  0xb144cce7992f792a7c41c2a341878b28b8a119840 MATIC0.0108089
0x29db84537cb5120b08fd21749f897ced442d38aaf25981bdc43200300e128e290xfa829818193613502021-09-21 20:58:333 days 6 hrs ago0xd8b61d6f9577b10d6701ec778cc31f2c9c99af03 IN  0xb144cce7992f792a7c41c2a341878b28b8a119840 MATIC0.012323993647
0xc685f3e0d1b6624411f2fbfed36d992feb2ed7716b828bba65293b0289fd763b0xfa829818193610152021-09-21 20:42:243 days 6 hrs ago0xd8b61d6f9577b10d6701ec778cc31f2c9c99af03 IN  0xb144cce7992f792a7c41c2a341878b28b8a119840 MATIC0.007390883068
0x9c843af02261b8b9a0dc1a337b1b90528d91b0b33c72cfbf022365f4de7005e90xfa829818193609602021-09-21 20:40:343 days 6 hrs ago0xd8b61d6f9577b10d6701ec778cc31f2c9c99af03 IN  0xb144cce7992f792a7c41c2a341878b28b8a119840 MATIC0.162126
0x657c4e4581e9979a6eec40934505b09f08e93901696cf2a35cdf400d117c4f9b0xfa829818193608882021-09-21 20:38:023 days 6 hrs ago0xd8b61d6f9577b10d6701ec778cc31f2c9c99af03 IN  0xb144cce7992f792a7c41c2a341878b28b8a119840 MATIC0.008613476476
0x4a743f3f4d22a6d70d71c2e22f4c66dde420851bc0b8120b1329c6a2e952ba9b0xfa829818193608342021-09-21 20:36:143 days 6 hrs ago0xd8b61d6f9577b10d6701ec778cc31f2c9c99af03 IN  0xb144cce7992f792a7c41c2a341878b28b8a119840 MATIC0.008614831354
0x9d53a00ebd1e9f2b231e6c809ffc11d5f2646e8ff5a9d3ad0eeec85eb41875c30x40957410193518482021-09-21 14:53:073 days 12 hrs ago0xd8b61d6f9577b10d6701ec778cc31f2c9c99af03 IN  0xb144cce7992f792a7c41c2a341878b28b8a119840 MATIC0.017520106809
0x01c132181b459cc6f4d88735768d76f198abbc434e7ce4ffdb17034cfc93c6e70xfa829818193131312021-09-20 13:47:574 days 13 hrs ago0xd8b61d6f9577b10d6701ec778cc31f2c9c99af03 IN  0xb144cce7992f792a7c41c2a341878b28b8a119840 MATIC0.011983681822
0x2808047f83ce1b955dda08727a59511bfcc537de1b58374797216c0b7c54ae1a0xfa829818193120182021-09-20 13:05:124 days 14 hrs ago0xb09c45de1934041d6b4d00917e087248d2aacc26 IN  0xb144cce7992f792a7c41c2a341878b28b8a119840 MATIC0.01188913
0x1eefa1ca00b4ccd7d2aa0c236028f21568778ec52412c550cd80397bc16151c90xfa829818193074592021-09-20 10:12:254 days 17 hrs ago0xcea3b38ba474a92202611547615b749212f50967 IN  0xb144cce7992f792a7c41c2a341878b28b8a119840 MATIC0.021400995
0x28c84baf0c9f1da23882342e57875385a0db40f5c08c8c148b597d686dc6e1460xfa829818193074522021-09-20 10:11:554 days 17 hrs ago0xcea3b38ba474a92202611547615b749212f50967 IN  0xb144cce7992f792a7c41c2a341878b28b8a119840 MATIC0.011890175
0xcd66d92d4659415ae76ed49badfbf65feebe6cef9732eb660372a23dacc3b61a0x40957410193062932021-09-20 9:21:374 days 17 hrs ago0xcea3b38ba474a92202611547615b749212f50967 IN  0xb144cce7992f792a7c41c2a341878b28b8a119840 MATIC0.00394568
0x37cdf1626c70a18bbf4ca4b039ca5d9c29a245994edb595675f282f0155f61ab0xfa829818193052662021-09-20 8:41:274 days 18 hrs ago0xcea3b38ba474a92202611547615b749212f50967 IN  0xb144cce7992f792a7c41c2a341878b28b8a119840 MATIC0.0097273
0x3508e0f5e179bc7fe52c35e1fa28325f5ccd441a588d92884545ec5990c4ef900xfa829818192898422021-09-19 23:02:175 days 4 hrs ago0xb98067297cf92a19af502be98064a3f6d78ae8a4 IN  0xb144cce7992f792a7c41c2a341878b28b8a119840 MATIC0.001564685244
0x34f353106c08dfaf2d86ed104cbb551baf1ccc84cb66275234d427dd04d7b13b0x40957410192798252021-09-19 16:33:485 days 10 hrs ago0x9095dc32af9ad499bdfe47ab4bc3db034652ded4 IN  0xb144cce7992f792a7c41c2a341878b28b8a119840 MATIC0.0021901743
0x3a41968b5ca582272e363f104eb6e7310b0ccf2f12ee38d046d31f032f1da23a0x40957410192787622021-09-19 15:48:425 days 11 hrs ago0xb98067297cf92a19af502be98064a3f6d78ae8a4 IN  0xb144cce7992f792a7c41c2a341878b28b8a119840 MATIC0.000546941934
0xb85ac77dcb267e8a275d6b5dd465e1de544869fccff3104c49a6b976baa48e190x01862c78192784812021-09-19 15:39:045 days 11 hrs ago0x5b984a638506797d1e6e50b4e310d8ab377d3f49 IN  0xb144cce7992f792a7c41c2a341878b28b8a119840 MATIC0.00109887
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
PerpetualPoolLite

Compiler Version
v0.8.4+commit.c7e474f2

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 17 : PerpetualPoolLite.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0 <0.9.0;

import '../interface/IPerpetualPoolLite.sol';
import '../interface/ILTokenLite.sol';
import '../interface/IPTokenLite.sol';
import '../interface/IERC20.sol';
import '../interface/IOracle.sol';
import '../interface/IOracleWithUpdate.sol';
import '../interface/ILiquidatorQualifier.sol';
import '../library/SafeMath.sol';
import '../library/SafeERC20.sol';
import '../utils/Migratable.sol';

contract PerpetualPoolLite is IPerpetualPoolLite, Migratable {

    using SafeMath for uint256;
    using SafeMath for int256;
    using SafeERC20 for IERC20;

    int256  constant ONE = 10**18;

    uint256 immutable _decimals;
    int256  immutable _minPoolMarginRatio;
    int256  immutable _minInitialMarginRatio;
    int256  immutable _minMaintenanceMarginRatio;
    int256  immutable _minLiquidationReward;
    int256  immutable _maxLiquidationReward;
    int256  immutable _liquidationCutRatio;
    int256  immutable _protocolFeeCollectRatio;

    address immutable _bTokenAddress;
    address immutable _lTokenAddress;
    address immutable _pTokenAddress;
    address immutable _liquidatorQualifierAddress;
    address immutable _protocolFeeCollector;

    int256  _liquidity;

    uint256 _lastUpdateBlock;
    int256  _protocolFeeAccrued;

    // symbolId => SymbolInfo
    mapping (uint256 => SymbolInfo) _symbols;

    bool private _mutex;
    modifier _lock_() {
        require(!_mutex, 'reentry');
        _mutex = true;
        _;
        _mutex = false;
    }

    constructor (uint256[7] memory parameters, address[5] memory addresses) {
        _controller = msg.sender;

        _minPoolMarginRatio = int256(parameters[0]);
        _minInitialMarginRatio = int256(parameters[1]);
        _minMaintenanceMarginRatio = int256(parameters[2]);
        _minLiquidationReward = int256(parameters[3]);
        _maxLiquidationReward = int256(parameters[4]);
        _liquidationCutRatio = int256(parameters[5]);
        _protocolFeeCollectRatio = int256(parameters[6]);

        _bTokenAddress = addresses[0];
        _lTokenAddress = addresses[1];
        _pTokenAddress = addresses[2];
        _liquidatorQualifierAddress = addresses[3];
        _protocolFeeCollector = addresses[4];

        _decimals = IERC20(addresses[0]).decimals();
    }

    // during a migration, this function is intended to be called in the source pool
    function approveMigration() external override _controller_ {
        require(_migrationTimestamp != 0 && block.timestamp >= _migrationTimestamp, 'PerpetualPool: migrationTimestamp not met yet');
        // approve new pool to pull all base tokens from this pool
        IERC20(_bTokenAddress).safeApprove(_migrationDestination, type(uint256).max);
        // set lToken/pToken to new pool, after redirecting pToken/lToken to new pool, this pool will stop functioning
        ILTokenLite(_lTokenAddress).setPool(_migrationDestination);
        IPTokenLite(_pTokenAddress).setPool(_migrationDestination);
    }

    // during a migration, this function is intended to be called in the target pool
    function executeMigration(address source) external override _controller_ {
        uint256 migrationTimestamp_ = IPerpetualPoolLite(source).migrationTimestamp();
        address migrationDestination_ = IPerpetualPoolLite(source).migrationDestination();
        require(migrationTimestamp_ != 0 && block.timestamp >= migrationTimestamp_, 'PerpetualPool: migrationTimestamp not met yet');
        require(migrationDestination_ == address(this), 'PerpetualPool: not destination pool');

        // transfer bToken to this address
        IERC20(_bTokenAddress).safeTransferFrom(source, address(this), IERC20(_bTokenAddress).balanceOf(source));

        // transfer symbol infos
        uint256[] memory symbolIds = IPTokenLite(_pTokenAddress).getActiveSymbolIds();
        for (uint256 i = 0; i < symbolIds.length; i++) {
            _symbols[symbolIds[i]] = IPerpetualPoolLite(source).getSymbol(symbolIds[i]);
        }

        // transfer state values
        _liquidity = IPerpetualPoolLite(source).getLiquidity();
        _lastUpdateBlock = IPerpetualPoolLite(source).getLastUpdateBlock();
        _protocolFeeAccrued = IPerpetualPoolLite(source).getProtocolFeeAccrued();

        emit ExecuteMigration(migrationTimestamp_, source, migrationDestination_);
    }

    function getParameters() external override view returns (
        int256 minPoolMarginRatio,
        int256 minInitialMarginRatio,
        int256 minMaintenanceMarginRatio,
        int256 minLiquidationReward,
        int256 maxLiquidationReward,
        int256 liquidationCutRatio,
        int256 protocolFeeCollectRatio
    ) {
        return (
            _minPoolMarginRatio,
            _minInitialMarginRatio,
            _minMaintenanceMarginRatio,
            _minLiquidationReward,
            _maxLiquidationReward,
            _liquidationCutRatio,
            _protocolFeeCollectRatio
        );
    }

    function getAddresses() external override view returns (
        address bTokenAddress,
        address lTokenAddress,
        address pTokenAddress,
        address liquidatorQualifierAddress,
        address protocolFeeCollector
    ) {
        return (
            _bTokenAddress,
            _lTokenAddress,
            _pTokenAddress,
            _liquidatorQualifierAddress,
            _protocolFeeCollector
        );
    }

    function getSymbol(uint256 symbolId) external override view returns (SymbolInfo memory) {
        return _symbols[symbolId];
    }

    function getLiquidity() external override view returns (int256) {
        return _liquidity;
    }

    function getLastUpdateBlock() external override view returns (uint256) {
        return _lastUpdateBlock;
    }

    function getProtocolFeeAccrued() external override view returns (int256) {
        return _protocolFeeAccrued;
    }

    function collectProtocolFee() external override {
        uint256 balance = IERC20(_bTokenAddress).balanceOf(address(this)).rescale(_decimals, 18);
        uint256 amount = _protocolFeeAccrued.itou();
        if (amount > balance) amount = balance;
        _protocolFeeAccrued -= amount.utoi();
        _transferOut(_protocolFeeCollector, amount);
        emit ProtocolFeeCollection(_protocolFeeCollector, amount);
    }

    function addSymbol(
        uint256 symbolId,
        string  memory symbol,
        address oracleAddress,
        uint256 multiplier,
        uint256 feeRatio,
        uint256 fundingRateCoefficient
    ) external override _controller_ {
        SymbolInfo storage s = _symbols[symbolId];
        s.symbolId = symbolId;
        s.symbol = symbol;
        s.oracleAddress = oracleAddress;
        s.multiplier = int256(multiplier);
        s.feeRatio = int256(feeRatio);
        s.fundingRateCoefficient = int256(fundingRateCoefficient);

        IPTokenLite(_pTokenAddress).addSymbolId(symbolId);
    }

    function removeSymbol(uint256 symbolId) external override _controller_ {
        delete _symbols[symbolId];
        IPTokenLite(_pTokenAddress).removeSymbolId(symbolId);
    }

    function toggleCloseOnly(uint256 symbolId) external override _controller_ {
        IPTokenLite(_pTokenAddress).toggleCloseOnly(symbolId);
    }

    function setSymbolParameters(uint256 symbolId, address oracleAddress, uint256 feeRatio, uint256 fundingRateCoefficient) external override _controller_ {
        SymbolInfo storage s = _symbols[symbolId];
        s.oracleAddress = oracleAddress;
        s.feeRatio = int256(feeRatio);
        s.fundingRateCoefficient = int256(fundingRateCoefficient);
    }


    //================================================================================
    // Interactions with onchain oracles
    //================================================================================

    function addLiquidity(uint256 bAmount) external override {
        require(bAmount > 0, 'PerpetualPool: 0 bAmount');
        _addLiquidity(msg.sender, bAmount);
    }

    function removeLiquidity(uint256 lShares) external override {
        require(lShares > 0, 'PerpetualPool: 0 lShares');
        _removeLiquidity(msg.sender, lShares);
    }

    function addMargin(uint256 bAmount) external override {
        require(bAmount > 0, 'PerpetualPool: 0 bAmount');
        _addMargin(msg.sender, bAmount);
    }

    function removeMargin(uint256 bAmount) external override {
        require(bAmount > 0, 'PerpetualPool: 0 bAmount');
        _removeMargin(msg.sender, bAmount);
    }

    function trade(uint256 symbolId, int256 tradeVolume) external override {
        require(IPTokenLite(_pTokenAddress).isActiveSymbolId(symbolId), 'PerpetualPool: invalid symbolId');
        require(tradeVolume != 0 && tradeVolume / ONE * ONE == tradeVolume, 'PerpetualPool: invalid tradeVolume');
        _trade(msg.sender, symbolId, tradeVolume);
    }

    function liquidate(address account) external override {
        address liquidator = msg.sender;
        require(
            _liquidatorQualifierAddress == address(0) || ILiquidatorQualifier(_liquidatorQualifierAddress).isQualifiedLiquidator(liquidator),
            'PerpetualPool: not qualified liquidator'
        );
        _liquidate(liquidator, account);
    }


    //================================================================================
    // Interactions with offchain oracles
    //================================================================================

    function addLiquidity(uint256 bAmount, SignedPrice[] memory prices) external override {
        require(bAmount > 0, 'PerpetualPool: 0 bAmount');
        _updateSymbolOracles(prices);
        _addLiquidity(msg.sender, bAmount);
    }

    function removeLiquidity(uint256 lShares, SignedPrice[] memory prices) external override {
        require(lShares > 0, 'PerpetualPool: 0 lShares');
        _updateSymbolOracles(prices);
        _removeLiquidity(msg.sender, lShares);
    }

    function addMargin(uint256 bAmount, SignedPrice[] memory prices) external override {
        require(bAmount > 0, 'PerpetualPool: 0 bAmount');
        _updateSymbolOracles(prices);
        _addMargin(msg.sender, bAmount);
    }

    function removeMargin(uint256 bAmount, SignedPrice[] memory prices) external override {
        require(bAmount > 0, 'PerpetualPool: 0 bAmount');
        _updateSymbolOracles(prices);
        _removeMargin(msg.sender, bAmount);
    }

    function trade(uint256 symbolId, int256 tradeVolume, SignedPrice[] memory prices) external override {
        require(IPTokenLite(_pTokenAddress).isActiveSymbolId(symbolId), 'PerpetualPool: invalid symbolId');
        require(tradeVolume != 0 && tradeVolume / ONE * ONE == tradeVolume, 'PerpetualPool: invalid tradeVolume');
        _updateSymbolOracles(prices);
        _trade(msg.sender, symbolId, tradeVolume);
    }

    function liquidate(address account, SignedPrice[] memory prices) external override {
        address liquidator = msg.sender;
        require(
            _liquidatorQualifierAddress == address(0) || ILiquidatorQualifier(_liquidatorQualifierAddress).isQualifiedLiquidator(liquidator),
            'PerpetualPool: not qualified liquidator'
        );
        _updateSymbolOracles(prices);
        _liquidate(liquidator, account);
    }


    //================================================================================
    // Core logics
    //================================================================================

    function _addLiquidity(address account, uint256 bAmount) internal _lock_ {
        (int256 totalDynamicEquity, ) = _updateSymbolPricesAndFundingRates();
        bAmount = _transferIn(account, bAmount);
        ILTokenLite lToken = ILTokenLite(_lTokenAddress);

        uint256 totalSupply = lToken.totalSupply();
        uint256 lShares;
        if (totalSupply == 0) {
            lShares = bAmount;
        } else {
            lShares = bAmount * totalSupply / totalDynamicEquity.itou();
        }

        lToken.mint(account, lShares);
        _liquidity += bAmount.utoi();

        emit AddLiquidity(account, lShares, bAmount);
    }

    function _removeLiquidity(address account, uint256 lShares) internal _lock_ {
        (int256 totalDynamicEquity, int256 totalAbsCost) = _updateSymbolPricesAndFundingRates();
        ILTokenLite lToken = ILTokenLite(_lTokenAddress);

        uint256 totalSupply = lToken.totalSupply();
        uint256 bAmount = lShares * totalDynamicEquity.itou() / totalSupply;

        _liquidity -= bAmount.utoi();

        require(
            totalAbsCost == 0 || (totalDynamicEquity - bAmount.utoi()) * ONE / totalAbsCost >= _minPoolMarginRatio,
            'PerpetualPool: pool insufficient margin'
        );

        lToken.burn(account, lShares);
        _transferOut(account, bAmount);

        emit RemoveLiquidity(account, lShares, bAmount);
    }

    function _addMargin(address account, uint256 bAmount) internal _lock_ {
        bAmount = _transferIn(account, bAmount);

        IPTokenLite pToken = IPTokenLite(_pTokenAddress);
        if (!pToken.exists(account)) pToken.mint(account);

        pToken.addMargin(account, bAmount.utoi());
        emit AddMargin(account, bAmount);
    }

    function _removeMargin(address account, uint256 bAmount) internal _lock_ {
        _updateSymbolPricesAndFundingRates();
        (uint256[] memory symbolIds,
         IPTokenLite.Position[] memory positions,
         bool[] memory positionUpdates,
         int256 margin) = _settleTraderFundingFee(account);

        int256 amount = bAmount.utoi();
        if (amount >= margin) {
            amount = margin;
            bAmount = amount.itou();
            margin = 0;
        } else {
            margin -= amount;
        }

        require(_getTraderMarginRatio(symbolIds, positions, margin) >= _minInitialMarginRatio, 'PerpetualPool: insufficient margin');

        _updateTraderPortfolio(account, symbolIds, positions, positionUpdates, margin);
        _transferOut(account, bAmount);

        emit RemoveMargin(account, bAmount);
    }

    // struct for temp use in trade function, to prevent stack too deep error
    struct TradeParams {
        int256 tradersNetVolume;
        int256 price;
        int256 multiplier;
        int256 curCost;
        int256 fee;
        int256 realizedCost;
        int256 protocolFee;
    }

    function _trade(address account, uint256 symbolId, int256 tradeVolume) internal _lock_ {
        (int256 totalDynamicEquity, int256 totalAbsCost) = _updateSymbolPricesAndFundingRates();
        (uint256[] memory symbolIds,
         IPTokenLite.Position[] memory positions,
         bool[] memory positionUpdates,
         int256 margin) = _settleTraderFundingFee(account);

        uint256 index;
        for (uint256 i = 0; i < symbolIds.length; i++) {
            if (symbolId == symbolIds[i]) {
                index = i;
                break;
            }
        }

        TradeParams memory params;

        params.tradersNetVolume = _symbols[symbolId].tradersNetVolume;
        params.price = _symbols[symbolId].price;
        params.multiplier = _symbols[symbolId].multiplier;
        params.curCost = tradeVolume * params.price / ONE * params.multiplier / ONE;
        params.fee = params.curCost.abs() * _symbols[symbolId].feeRatio / ONE;

        if (!(positions[index].volume >= 0 && tradeVolume >= 0) && !(positions[index].volume <= 0 && tradeVolume <= 0)) {
            int256 absVolume = positions[index].volume.abs();
            int256 absTradeVolume = tradeVolume.abs();
            if (absVolume <= absTradeVolume) {
                // previous position is totally closed
                params.realizedCost = params.curCost * absVolume / absTradeVolume + positions[index].cost;
            } else {
                // previous position is partially closed
                params.realizedCost = positions[index].cost * absTradeVolume / absVolume + params.curCost;
            }
        }

        // adjust totalAbsCost after trading
        totalAbsCost += ((params.tradersNetVolume + tradeVolume).abs() - params.tradersNetVolume.abs()) *
                        params.price / ONE * params.multiplier / ONE;

        positions[index].volume += tradeVolume;
        positions[index].cost += params.curCost - params.realizedCost;
        positions[index].lastCumulativeFundingRate = _symbols[symbolId].cumulativeFundingRate;
        margin -= params.fee + params.realizedCost;
        positionUpdates[index] = true;

        _symbols[symbolId].tradersNetVolume += tradeVolume;
        _symbols[symbolId].tradersNetCost += params.curCost - params.realizedCost;
        params.protocolFee = params.fee * _protocolFeeCollectRatio / ONE;
        _protocolFeeAccrued += params.protocolFee;
        _liquidity += params.fee - params.protocolFee + params.realizedCost;

        require(totalAbsCost == 0 || totalDynamicEquity * ONE / totalAbsCost >= _minPoolMarginRatio, 'PerpetualPool: insufficient liquidity');
        require(_getTraderMarginRatio(symbolIds, positions, margin) >= _minInitialMarginRatio, 'PerpetualPool: insufficient margin');

        _updateTraderPortfolio(account, symbolIds, positions, positionUpdates, margin);

        emit Trade(account, symbolId, tradeVolume, params.price.itou());
    }

    function _liquidate(address liquidator, address account) internal _lock_ {
        _updateSymbolPricesAndFundingRates();
        (uint256[] memory symbolIds, IPTokenLite.Position[] memory positions, , int256 margin) = _settleTraderFundingFee(account);
        require(_getTraderMarginRatio(symbolIds, positions, margin) < _minMaintenanceMarginRatio, 'PerpetualPool: cannot liquidate');

        int256 netEquity = margin;
        for (uint256 i = 0; i < symbolIds.length; i++) {
            if (positions[i].volume != 0) {
                _symbols[symbolIds[i]].tradersNetVolume -= positions[i].volume;
                _symbols[symbolIds[i]].tradersNetCost -= positions[i].cost;
                netEquity += positions[i].volume * _symbols[symbolIds[i]].price / ONE * _symbols[symbolIds[i]].multiplier / ONE - positions[i].cost;
            }
        }

        int256 reward;
        if (netEquity <= _minLiquidationReward) {
            reward = _minLiquidationReward;
        } else if (netEquity >= _maxLiquidationReward) {
            reward = _maxLiquidationReward;
        } else {
            reward = (netEquity - _minLiquidationReward) * _liquidationCutRatio / ONE + _minLiquidationReward;
        }

        _liquidity += margin - reward;
        IPTokenLite(_pTokenAddress).burn(account);
        _transferOut(liquidator, reward.itou());

        emit Liquidate(account, liquidator, reward.itou());
    }


    //================================================================================
    // Helpers
    //================================================================================

    function _updateSymbolOracles(SignedPrice[] memory prices) internal {
        for (uint256 i = 0; i < prices.length; i++) {
            uint256 symbolId = prices[i].symbolId;
            IOracleWithUpdate(_symbols[symbolId].oracleAddress).updatePrice(
                prices[i].timestamp,
                prices[i].price,
                prices[i].v,
                prices[i].r,
                prices[i].s
            );
        }
    }

    function _updateSymbolPricesAndFundingRates() internal returns (int256 totalDynamicEquity, int256 totalAbsCost) {
        uint256 preBlockNumber = _lastUpdateBlock;
        uint256 curBlockNumber = block.number;
        uint256[] memory symbolIds = IPTokenLite(_pTokenAddress).getActiveSymbolIds();
        totalDynamicEquity = _liquidity;

        for (uint256 i = 0; i < symbolIds.length; i++) {
            SymbolInfo storage s = _symbols[symbolIds[i]];
            if (curBlockNumber > preBlockNumber) {
                s.price = IOracle(s.oracleAddress).getPrice().utoi();
            }
            if (s.tradersNetVolume != 0) {
                int256 cost = s.tradersNetVolume * s.price / ONE * s.multiplier / ONE;
                totalDynamicEquity -= cost - s.tradersNetCost;
                totalAbsCost += cost.abs();
            }
        }

        if (curBlockNumber > preBlockNumber) {
            for (uint256 i = 0; i < symbolIds.length; i++) {
                SymbolInfo storage s = _symbols[symbolIds[i]];
                if (s.tradersNetVolume != 0) {
                    int256 ratePerBlock = s.tradersNetVolume * s.price / ONE * s.price / ONE * s.multiplier / ONE * s.multiplier / ONE * s.fundingRateCoefficient / totalDynamicEquity;
                    int256 delta = ratePerBlock * int256(curBlockNumber - preBlockNumber);
                    unchecked { s.cumulativeFundingRate += delta; }
                }
            }
        }

        _lastUpdateBlock = curBlockNumber;
    }

    function _getTraderPortfolio(address account) internal view returns (
        uint256[] memory symbolIds,
        IPTokenLite.Position[] memory positions,
        bool[] memory positionUpdates,
        int256 margin
    ) {
        IPTokenLite pToken = IPTokenLite(_pTokenAddress);
        symbolIds = pToken.getActiveSymbolIds();

        positions = new IPTokenLite.Position[](symbolIds.length);
        positionUpdates = new bool[](symbolIds.length);
        for (uint256 i = 0; i < symbolIds.length; i++) {
            positions[i] = pToken.getPosition(account, symbolIds[i]);
        }

        margin = pToken.getMargin(account);
    }

    function _updateTraderPortfolio(
        address account,
        uint256[] memory symbolIds,
        IPTokenLite.Position[] memory positions,
        bool[] memory positionUpdates,
        int256 margin
    ) internal {
        IPTokenLite pToken = IPTokenLite(_pTokenAddress);
        for (uint256 i = 0; i < symbolIds.length; i++) {
            if (positionUpdates[i]) {
                pToken.updatePosition(account, symbolIds[i], positions[i]);
            }
        }
        pToken.updateMargin(account, margin);
    }

    function _settleTraderFundingFee(address account) internal returns (
        uint256[] memory symbolIds,
        IPTokenLite.Position[] memory positions,
        bool[] memory positionUpdates,
        int256 margin
    ) {
        (symbolIds, positions, positionUpdates, margin) = _getTraderPortfolio(account);
        int256 funding;
        for (uint256 i = 0; i < symbolIds.length; i++) {
            if (positions[i].volume != 0) {
                int256 cumulativeFundingRate = _symbols[symbolIds[i]].cumulativeFundingRate;
                int256 delta;
                unchecked { delta = cumulativeFundingRate - positions[i].lastCumulativeFundingRate; }
                funding += positions[i].volume * delta / ONE;

                positions[i].lastCumulativeFundingRate = cumulativeFundingRate;
                positionUpdates[i] = true;
            }
        }
        if (funding != 0) {
            margin -= funding;
            _liquidity += funding;
        }
    }

    function _getTraderMarginRatio(
        uint256[] memory symbolIds,
        IPTokenLite.Position[] memory positions,
        int256 margin
    ) internal view returns (int256) {
        int256 totalDynamicEquity = margin;
        int256 totalAbsCost;
        for (uint256 i = 0; i < symbolIds.length; i++) {
            if (positions[i].volume != 0) {
                int256 cost = positions[i].volume * _symbols[symbolIds[i]].price / ONE * _symbols[symbolIds[i]].multiplier / ONE;
                totalDynamicEquity += cost - positions[i].cost;
                totalAbsCost += cost.abs();
            }
        }
        return totalAbsCost == 0 ? type(int256).max : totalDynamicEquity * ONE / totalAbsCost;
    }

    function _deflationCompatibleSafeTransferFrom(address from, address to, uint256 bAmount) internal returns (uint256) {
        IERC20 bToken = IERC20(_bTokenAddress);
        uint256 balance1 = bToken.balanceOf(to);
        bToken.safeTransferFrom(from, to, bAmount);
        uint256 balance2 = bToken.balanceOf(to);
        return balance2 - balance1;
    }

    function _transferIn(address from, uint256 bAmount) internal returns (uint256) {
        uint256 amount = _deflationCompatibleSafeTransferFrom(from, address(this), bAmount.rescale(18, _decimals));
        return amount.rescale(_decimals, 18);
    }

    function _transferOut(address to, uint256 bAmount) internal {
        uint256 amount = bAmount.rescale(18, _decimals);
        uint256 leftover = bAmount - amount.rescale(_decimals, 18);
        // leftover due to decimal precision is accrued to _protocolFeeAccrued
        _protocolFeeAccrued += leftover.utoi();
        IERC20(_bTokenAddress).safeTransfer(to, amount);
    }

}

File 2 of 17 : IPerpetualPoolLite.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0 <0.9.0;

import '../interface/IMigratable.sol';

interface IPerpetualPoolLite is IMigratable {

    struct SymbolInfo {
        uint256 symbolId;
        string  symbol;
        address oracleAddress;
        int256  multiplier;
        int256  feeRatio;
        int256  fundingRateCoefficient;
        int256  price;
        int256  cumulativeFundingRate;
        int256  tradersNetVolume;
        int256  tradersNetCost;
    }

    struct SignedPrice {
        uint256 symbolId;
        uint256 timestamp;
        uint256 price;
        uint8   v;
        bytes32 r;
        bytes32 s;
    }

    event AddLiquidity(address indexed account, uint256 lShares, uint256 bAmount);

    event RemoveLiquidity(address indexed account, uint256 lShares, uint256 bAmount);

    event AddMargin(address indexed account, uint256 bAmount);

    event RemoveMargin(address indexed account, uint256 bAmount);

    event Trade(address indexed account, uint256 indexed symbolId, int256 tradeVolume, uint256 price);

    event Liquidate(address indexed account, address indexed liquidator, uint256 reward);

    event ProtocolFeeCollection(address indexed collector, uint256 amount);

    function getParameters() external view returns (
        int256 minPoolMarginRatio,
        int256 minInitialMarginRatio,
        int256 minMaintenanceMarginRatio,
        int256 minLiquidationReward,
        int256 maxLiquidationReward,
        int256 liquidationCutRatio,
        int256 protocolFeeCollectRatio
    );

    function getAddresses() external view returns (
        address bTokenAddress,
        address lTokenAddress,
        address pTokenAddress,
        address liquidatorQualifierAddress,
        address protocolFeeCollector
    );

    function getSymbol(uint256 symbolId) external view returns (SymbolInfo memory);

    function getLiquidity() external view returns (int256);

    function getLastUpdateBlock() external view returns (uint256);

    function getProtocolFeeAccrued() external view returns (int256);

    function collectProtocolFee() external;

    function addSymbol(
        uint256 symbolId,
        string  memory symbol,
        address oracleAddress,
        uint256 multiplier,
        uint256 feeRatio,
        uint256 fundingRateCoefficient
    ) external;

    function removeSymbol(uint256 symbolId) external;

    function toggleCloseOnly(uint256 symbolId) external;

    function setSymbolParameters(uint256 symbolId, address oracleAddress, uint256 feeRatio, uint256 fundingRateCoefficient) external;

    function addLiquidity(uint256 bAmount) external;

    function removeLiquidity(uint256 lShares) external;

    function addMargin(uint256 bAmount) external;

    function removeMargin(uint256 bAmount) external;

    function trade(uint256 symbolId, int256 tradeVolume) external;

    function liquidate(address account) external;

    function addLiquidity(uint256 bAmount, SignedPrice[] memory prices) external;

    function removeLiquidity(uint256 lShares, SignedPrice[] memory prices) external;

    function addMargin(uint256 bAmount, SignedPrice[] memory prices) external;

    function removeMargin(uint256 bAmount, SignedPrice[] memory prices) external;

    function trade(uint256 symbolId, int256 tradeVolume, SignedPrice[] memory prices) external;

    function liquidate(address account, SignedPrice[] memory prices) external;

}

File 3 of 17 : ILTokenLite.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0 <0.9.0;

import './IERC20.sol';

interface ILTokenLite is IERC20 {

    function pool() external view returns (address);

    function setPool(address newPool) external;

    function mint(address account, uint256 amount) external;

    function burn(address account, uint256 amount) external;

}

File 4 of 17 : IPTokenLite.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0 <0.9.0;

import './IERC721.sol';

interface IPTokenLite is IERC721 {

    struct Position {
        // position volume, long is positive and short is negative
        int256 volume;
        // the cost the establish this position
        int256 cost;
        // the last cumulativeFundingRate since last funding settlement for this position
        // the overflow for this value in intended
        int256 lastCumulativeFundingRate;
    }

    event UpdateMargin(address indexed owner, int256 amount);

    event UpdatePosition(address indexed owner, uint256 indexed symbolId, int256 volume, int256 cost, int256 lastCumulativeFundingRate);

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

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

    function pool() external view returns (address);

    function totalMinted() external view returns (uint256);

    function totalSupply() external view returns (uint256);

    function setPool(address newPool) external;

    function getActiveSymbolIds() external view returns (uint256[] memory);

    function isActiveSymbolId(uint256 symbolId) external view returns (bool);

    function getNumPositionHolders(uint256 symbolId) external view returns (uint256);

    function addSymbolId(uint256 symbolId) external;

    function removeSymbolId(uint256 symbolId) external;

    function toggleCloseOnly(uint256 symbolId) external;

    function exists(address owner) external view returns (bool);

    function getMargin(address owner) external view returns (int256);

    function updateMargin(address owner, int256 margin) external;

    function addMargin(address owner, int256 delta) external;

    function getPosition(address owner, uint256 symbolId) external view returns (Position memory);

    function updatePosition(address owner, uint256 symbolId, Position memory position) external;

    function mint(address owner) external;

    function burn(address owner) external;

}

File 5 of 17 : IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0 <0.9.0;

interface IERC20 {

    event Approval(address indexed owner, address indexed spender, uint256 amount);

    event Transfer(address indexed from, address indexed to, uint256 amount);

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

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

    function decimals() external view returns (uint8);

    function totalSupply() external view returns (uint256);

    function balanceOf(address account) external view returns (uint256);

    function allowance(address owner, address spender) external view returns (uint256);

    function approve(address spender, uint256 amount) external returns (bool);

    function transfer(address to, uint256 amount) external returns (bool);

    function transferFrom(address from, address to, uint256 amount) external returns (bool);

}

File 6 of 17 : IOracle.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0 <0.9.0;

interface IOracle {

    function getPrice() external returns (uint256);

}

File 7 of 17 : IOracleWithUpdate.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0 <0.9.0;

interface IOracleWithUpdate {

    function getPrice() external returns (uint256);

    function updatePrice(uint256 timestamp, uint256 price, uint8 v, bytes32 r, bytes32 s) external;

}

File 8 of 17 : ILiquidatorQualifier.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0 <0.9.0;

interface ILiquidatorQualifier {

    function isQualifiedLiquidator(address liquidator) external view returns (bool);

}

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

pragma solidity >=0.8.0 <0.9.0;

library SafeMath {

    uint256 constant UMAX = 2**255 - 1;
    int256  constant IMIN = -2**255;

    /// convert uint256 to int256
    function utoi(uint256 a) internal pure returns (int256) {
        require(a <= UMAX, 'UIO');
        return int256(a);
    }

    /// convert int256 to uint256
    function itou(int256 a) internal pure returns (uint256) {
        require(a >= 0, 'IUO');
        return uint256(a);
    }

    /// take abs of int256
    function abs(int256 a) internal pure returns (int256) {
        require(a != IMIN, 'AO');
        return a >= 0 ? a : -a;
    }


    /// rescale a uint256 from base 10**decimals1 to 10**decimals2
    function rescale(uint256 a, uint256 decimals1, uint256 decimals2) internal pure returns (uint256) {
        return decimals1 == decimals2 ? a : a * (10 ** decimals2) / (10 ** decimals1);
    }

    /// rescale a int256 from base 10**decimals1 to 10**decimals2
    function rescale(int256 a, uint256 decimals1, uint256 decimals2) internal pure returns (int256) {
        return decimals1 == decimals2 ? a : a * utoi(10 ** decimals2) / utoi(10 ** decimals1);
    }

    /// reformat a uint256 to be a valid 10**decimals base value
    /// the reformatted value is still in 10**18 base
    function reformat(uint256 a, uint256 decimals) internal pure returns (uint256) {
        return decimals == 18 ? a : rescale(rescale(a, 18, decimals), decimals, 18);
    }

    /// reformat a int256 to be a valid 10**decimals base value
    /// the reformatted value is still in 10**18 base
    function reformat(int256 a, uint256 decimals) internal pure returns (int256) {
        return decimals == 18 ? a : rescale(rescale(a, 18, decimals), decimals, 18);
    }

    /// ceiling value away from zero, return a valid 10**decimals base value, but still in 10**18 based
    function ceil(int256 a, uint256 decimals) internal pure returns (int256) {
        if (reformat(a, decimals) == a) {
            return a;
        } else {
            int256 b = rescale(a, 18, decimals);
            b += a > 0 ? int256(1) : int256(-1);
            return rescale(b, decimals, 18);
        }
    }

    function divCeil(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 quotient = a / b;
        uint256 remainder = a - quotient * b;
        if (remainder > 0) {
            return quotient + 1;
        } else {
            return quotient;
        }
    }

    function sqrt(uint256 x) internal pure returns (uint256 y) {
        uint256 z = x / 2 + 1;
        y = x;
        while (z < y) {
            y = z;
            z = (x / z + z) / 2;
        }
    }

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

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

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

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

}

File 10 of 17 : SafeERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0 <0.9.0;

import "../interface/IERC20.sol";
import "./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;

    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    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'
        // solhint-disable-next-line max-line-length
        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));
    }

    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 newAllowance = token.allowance(address(this), spender) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 newAllowance = token.allowance(address(this), spender) - value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    /**
     * @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");
        if (returndata.length > 0) { // Return data is optional
            // solhint-disable-next-line max-line-length
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 11 of 17 : Migratable.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0 <0.9.0;

import '../interface/IMigratable.sol';
import './Ownable.sol';

abstract contract Migratable is IMigratable, Ownable {

    // migration timestamp, zero means not set
    // migration timestamp can only be set with a grace period, e.x. 3-365 days, and the
    // migration destination must also be set when setting migration timestamp
    // users can use this grace period to verify the desination contract code
    uint256 _migrationTimestamp;

    // the destination address the source contract will migrate to, after the grace period
    address _migrationDestination;

    function migrationTimestamp() public override view returns (uint256) {
        return _migrationTimestamp;
    }

    function migrationDestination() public override view returns (address) {
        return _migrationDestination;
    }

    // prepare a migration process, the timestamp and desination will be set at this stage
    // and the migration grace period starts
    function prepareMigration(address target, uint256 graceDays) public override _controller_ {
        require(target != address(0), 'Migratable: target 0');
        require(graceDays >= 3 && graceDays <= 365, 'Migratable: graceDays must be 3-365');

        _migrationTimestamp = block.timestamp + graceDays * 1 days;
        _migrationDestination = target;

        emit PrepareMigration(_migrationTimestamp, address(this), _migrationDestination);
    }

}

File 12 of 17 : IMigratable.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0 <0.9.0;

import './IOwnable.sol';

interface IMigratable is IOwnable {

    event PrepareMigration(uint256 migrationTimestamp, address source, address target);

    event ExecuteMigration(uint256 migrationTimestamp, address source, address target);

    function migrationTimestamp() external view returns (uint256);

    function migrationDestination() external view returns (address);

    function prepareMigration(address target, uint256 graceDays) external;

    function approveMigration() external;

    function executeMigration(address source) external;

}

File 13 of 17 : IOwnable.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0 <0.9.0;

interface IOwnable {

    function controller() external view returns (address);

    function setNewController(address newController) external;

    function claimNewController() external;

}

File 14 of 17 : IERC721.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0 <0.9.0;

import "./IERC165.sol";

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721 is IERC165 {
    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables `operator` to manage the `tokenId` token.
     */
    event Approval(address indexed owner, address indexed operator, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables or disables `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /**
     * @dev Returns the number of tokens in `owner`'s account.
     */
    function balanceOf(address owner) external view returns (uint256);

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address);

    /**
     * @dev Returns the 'tokenId' owned by 'owner'
     *
     * Requirements:
     *
     *  - `owner` must exist
     */
    function getTokenId(address owner) external view returns (uint256);

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address);

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);

    /**
     * @dev Gives permission to `operator` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address
     * clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address operator, uint256 tokenId) external;

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token
     *   by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 tokenId) external;

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first
     * that contract recipients are aware of the ERC721 protocol to prevent
     * tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be have been allowed to move this token
     *   by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement
     *   {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId) external;

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token
     *   by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement
     *   {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;
}

File 15 of 17 : IERC165.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0 <0.9.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

File 16 of 17 : Address.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0 <0.9.0;

/**
 * @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
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        // solhint-disable-next-line no-inline-assembly
        assembly { size := extcodesize(account) }
        return size > 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://diligence.consensys.net/posts/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.5.11/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");

        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (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 functionCall(target, data, "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");
        require(isContract(target), "Address: call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.call{ value: value }(data);
        return _verifyCallResult(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) {
        require(isContract(target), "Address: static call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.staticcall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
        if (success) {
            return returndata;
        } else {
            // 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

                // solhint-disable-next-line no-inline-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 17 of 17 : Ownable.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0 <0.9.0;

import '../interface/IOwnable.sol';

abstract contract Ownable is IOwnable {

    address _controller;

    address _newController;

    modifier _controller_() {
        require(msg.sender == _controller, 'Ownable: only controller');
        _;
    }

    function controller() public override view returns (address) {
        return _controller;
    }

    function setNewController(address newController) public override _controller_ {
        _newController = newController;
    }

    // a claim step is needed to prevent set controller to a wrong address and forever lost control
    function claimNewController() public override {
        require(msg.sender == _newController, 'Ownable: not allowed');
        _controller = _newController;
    }

}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"uint256[7]","name":"parameters","type":"uint256[7]"},{"internalType":"address[5]","name":"addresses","type":"address[5]"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"lShares","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"bAmount","type":"uint256"}],"name":"AddLiquidity","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"bAmount","type":"uint256"}],"name":"AddMargin","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"migrationTimestamp","type":"uint256"},{"indexed":false,"internalType":"address","name":"source","type":"address"},{"indexed":false,"internalType":"address","name":"target","type":"address"}],"name":"ExecuteMigration","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"liquidator","type":"address"},{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"}],"name":"Liquidate","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"migrationTimestamp","type":"uint256"},{"indexed":false,"internalType":"address","name":"source","type":"address"},{"indexed":false,"internalType":"address","name":"target","type":"address"}],"name":"PrepareMigration","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"collector","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ProtocolFeeCollection","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"lShares","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"bAmount","type":"uint256"}],"name":"RemoveLiquidity","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"bAmount","type":"uint256"}],"name":"RemoveMargin","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"uint256","name":"symbolId","type":"uint256"},{"indexed":false,"internalType":"int256","name":"tradeVolume","type":"int256"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"}],"name":"Trade","type":"event"},{"inputs":[{"internalType":"uint256","name":"bAmount","type":"uint256"},{"components":[{"internalType":"uint256","name":"symbolId","type":"uint256"},{"internalType":"uint256","name":"timestamp","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct IPerpetualPoolLite.SignedPrice[]","name":"prices","type":"tuple[]"}],"name":"addLiquidity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"bAmount","type":"uint256"}],"name":"addLiquidity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"bAmount","type":"uint256"}],"name":"addMargin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"bAmount","type":"uint256"},{"components":[{"internalType":"uint256","name":"symbolId","type":"uint256"},{"internalType":"uint256","name":"timestamp","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct IPerpetualPoolLite.SignedPrice[]","name":"prices","type":"tuple[]"}],"name":"addMargin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"symbolId","type":"uint256"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"address","name":"oracleAddress","type":"address"},{"internalType":"uint256","name":"multiplier","type":"uint256"},{"internalType":"uint256","name":"feeRatio","type":"uint256"},{"internalType":"uint256","name":"fundingRateCoefficient","type":"uint256"}],"name":"addSymbol","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"approveMigration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimNewController","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"collectProtocolFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"controller","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"source","type":"address"}],"name":"executeMigration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getAddresses","outputs":[{"internalType":"address","name":"bTokenAddress","type":"address"},{"internalType":"address","name":"lTokenAddress","type":"address"},{"internalType":"address","name":"pTokenAddress","type":"address"},{"internalType":"address","name":"liquidatorQualifierAddress","type":"address"},{"internalType":"address","name":"protocolFeeCollector","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLastUpdateBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLiquidity","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getParameters","outputs":[{"internalType":"int256","name":"minPoolMarginRatio","type":"int256"},{"internalType":"int256","name":"minInitialMarginRatio","type":"int256"},{"internalType":"int256","name":"minMaintenanceMarginRatio","type":"int256"},{"internalType":"int256","name":"minLiquidationReward","type":"int256"},{"internalType":"int256","name":"maxLiquidationReward","type":"int256"},{"internalType":"int256","name":"liquidationCutRatio","type":"int256"},{"internalType":"int256","name":"protocolFeeCollectRatio","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getProtocolFeeAccrued","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"symbolId","type":"uint256"}],"name":"getSymbol","outputs":[{"components":[{"internalType":"uint256","name":"symbolId","type":"uint256"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"address","name":"oracleAddress","type":"address"},{"internalType":"int256","name":"multiplier","type":"int256"},{"internalType":"int256","name":"feeRatio","type":"int256"},{"internalType":"int256","name":"fundingRateCoefficient","type":"int256"},{"internalType":"int256","name":"price","type":"int256"},{"internalType":"int256","name":"cumulativeFundingRate","type":"int256"},{"internalType":"int256","name":"tradersNetVolume","type":"int256"},{"internalType":"int256","name":"tradersNetCost","type":"int256"}],"internalType":"struct IPerpetualPoolLite.SymbolInfo","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"liquidate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"components":[{"internalType":"uint256","name":"symbolId","type":"uint256"},{"internalType":"uint256","name":"timestamp","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct IPerpetualPoolLite.SignedPrice[]","name":"prices","type":"tuple[]"}],"name":"liquidate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"migrationDestination","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"migrationTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint256","name":"graceDays","type":"uint256"}],"name":"prepareMigration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"lShares","type":"uint256"}],"name":"removeLiquidity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"lShares","type":"uint256"},{"components":[{"internalType":"uint256","name":"symbolId","type":"uint256"},{"internalType":"uint256","name":"timestamp","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct IPerpetualPoolLite.SignedPrice[]","name":"prices","type":"tuple[]"}],"name":"removeLiquidity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"bAmount","type":"uint256"},{"components":[{"internalType":"uint256","name":"symbolId","type":"uint256"},{"internalType":"uint256","name":"timestamp","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct IPerpetualPoolLite.SignedPrice[]","name":"prices","type":"tuple[]"}],"name":"removeMargin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"bAmount","type":"uint256"}],"name":"removeMargin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"symbolId","type":"uint256"}],"name":"removeSymbol","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newController","type":"address"}],"name":"setNewController","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"symbolId","type":"uint256"},{"internalType":"address","name":"oracleAddress","type":"address"},{"internalType":"uint256","name":"feeRatio","type":"uint256"},{"internalType":"uint256","name":"fundingRateCoefficient","type":"uint256"}],"name":"setSymbolParameters","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"symbolId","type":"uint256"}],"name":"toggleCloseOnly","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"symbolId","type":"uint256"},{"internalType":"int256","name":"tradeVolume","type":"int256"},{"components":[{"internalType":"uint256","name":"symbolId","type":"uint256"},{"internalType":"uint256","name":"timestamp","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct IPerpetualPoolLite.SignedPrice[]","name":"prices","type":"tuple[]"}],"name":"trade","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"symbolId","type":"uint256"},{"internalType":"int256","name":"tradeVolume","type":"int256"}],"name":"trade","outputs":[],"stateMutability":"nonpayable","type":"function"}]

6102206040523480156200001257600080fd5b506040516200574538038062005745833981016040819052620000359162000155565b600080546001600160a01b03191633179055815160a090815260208084015160c090815260408086015160e0526060808701516101005260808088015161012052948701516101405291860151610160528451821b6001600160601b03199081166101805285840151831b81166101a05285820151831b81166101c05285830151831b81166101e0529385015190911b909216610200528251825163313ce56760e01b815292516001600160a01b039091169263313ce567926004808301939192829003018186803b1580156200010b57600080fd5b505afa15801562000120573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000146919062000235565b60ff1660805250620002c79050565b6000806101808084860312156200016a578283fd5b84601f85011262000179578283fd5b620001836200025f565b808560e087018881111562000196578687fd5b865b6007811015620001b957825185526020948501949092019160010162000198565b508296508860ff890112620001cc578586fd5b620001d662000296565b93508392509050868401881015620001ec578485fd5b8493505b6005841015620002275780516001600160a01b038116811462000211578586fd5b83526001939093019260209283019201620001f0565b508093505050509250929050565b60006020828403121562000247578081fd5b815160ff8116811462000258578182fd5b9392505050565b60405160e081016001600160401b03811182821017156200029057634e487b7160e01b600052604160045260246000fd5b60405290565b60405160a081016001600160401b03811182821017156200029057634e487b7160e01b600052604160045260246000fd5b60805160a05160c05160e051610100516101205161014051610160516101805160601c6101a05160601c6101c05160601c6101e05160601c6102005160601c6152a5620004a0600039600081816103e60152818161198101526119a80152600081816103be0152818161072f0152818161077d015281816114420152611490015260008181610394015281816105fa0152818161095601528181610c94015281816113d70152818161164f0152818161181401528181611ab4015281816129b5015281816130ef0152818161354801528181613c9e0152613fcc01526000818161036c015281816108d801528181612c290152612e3f0152600081816103470152818161088b01528181610be201528181610c68015281816118bf0152818161350e01526142ee015260008181610512015261233b0152600081816104ec015261292c0152600081816104c6015281816128b401526128dc0152600081816104a0015281816128660152818161288e0152612902015260008181610478015261257501526000818161045201528181612466015261331e01526000818161042f015281816123cb0152612f2001526000818161189201528181613481015281816134af01528181613f330152613f6401526152a56000f3fe608060405234801561001057600080fd5b50600436106101e55760003560e01c80637b725c1e1161010f578063c7405e76116100a2578063f11f854f11610071578063f11f854f1461059a578063f3f6073c146105ad578063f77c4791146105c0578063fa829818146105d157600080fd5b8063c7405e7614610564578063caa4b46a14610577578063d608c07d1461057f578063e7f2ee6e1461058757600080fd5b8063a43be948116100de578063a43be94814610416578063a5ea11da14610429578063a69baa761461053e578063c546bc971461055157600080fd5b80637b725c1e1461030b578063802ec515146103135780639c8f9f2314610326578063a39fac121461033957600080fd5b806351dfdb4811610187578063677528cb11610156578063677528cb146102ad578063747d81da146102c057806379a87b19146102d35780637b245e69146102f857600080fd5b806351dfdb481461025f57806358c700a31461027257806359baef401461027a5780636418413c1461028d57600080fd5b80632f865568116101c35780632f8655681461021e578063325564ec14610231578063409574101461023957806351c6590a1461024c57600080fd5b806301862c78146101ea57806307e2ee0f146101ff5780630910a51014610216575b600080fd5b6101fd6101f8366004614aa1565b6105e4565b005b6005545b6040519081526020015b60405180910390f35b600454610203565b6101fd61022c366004614757565b61072c565b6101fd610821565b6101fd610247366004614a52565b6109b8565b6101fd61025a3660046149fe565b6109eb565b6101fd61026d366004614757565b610a18565b600254610203565b6101fd610288366004614757565b611073565b6102a061029b3660046149fe565b6110bf565b60405161020d9190614d9a565b6101fd6102bb3660046147dc565b61123a565b6101fd6102ce3660046149fe565b611397565b6003546001600160a01b03165b6040516001600160a01b03909116815260200161020d565b6101fd61030636600461478f565b61143f565b6101fd611539565b6101fd610321366004614aee565b6115ae565b6101fd6103343660046149fe565b6116b6565b604080516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811682527f0000000000000000000000000000000000000000000000000000000000000000811660208301527f00000000000000000000000000000000000000000000000000000000000000008116928201929092527f0000000000000000000000000000000000000000000000000000000000000000821660608201527f000000000000000000000000000000000000000000000000000000000000000091909116608082015260a00161020d565b6101fd6104243660046149fe565b61170b565b604080517f000000000000000000000000000000000000000000000000000000000000000081527f000000000000000000000000000000000000000000000000000000000000000060208201527f0000000000000000000000000000000000000000000000000000000000000000918101919091527f000000000000000000000000000000000000000000000000000000000000000060608201527f000000000000000000000000000000000000000000000000000000000000000060808201527f000000000000000000000000000000000000000000000000000000000000000060a08201527f000000000000000000000000000000000000000000000000000000000000000060c082015260e00161020d565b6101fd61054c366004614a52565b611735565b6101fd61055f3660046149fe565b611768565b6101fd610572366004614a52565b611843565b6101fd611876565b600654610203565b6101fd610595366004614a16565b611a0d565b6101fd6105a83660046149fe565b611a74565b6101fd6105bb366004614a80565b611a9e565b6000546001600160a01b03166102e0565b6101fd6105df366004614a52565b611bd3565b604051631d49654560e31b8152600481018490527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063ea4b2a289060240160206040518083038186803b15801561064457600080fd5b505afa158015610658573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061067c9190614899565b6106cd5760405162461bcd60e51b815260206004820152601f60248201527f50657270657475616c506f6f6c3a20696e76616c69642073796d626f6c49640060448201526064015b60405180910390fd5b81158015906106f7575081670de0b6b3a76400006106eb8183614f57565b6106f59190615084565b145b6107135760405162461bcd60e51b81526004016106c490614bf3565b61071c81611c31565b610727338484611df4565b505050565b337f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031615806107f757506040516337c203bd60e21b81526001600160a01b0382811660048301527f0000000000000000000000000000000000000000000000000000000000000000169063df080ef49060240160206040518083038186803b1580156107bf57600080fd5b505afa1580156107d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107f79190614899565b6108135760405162461bcd60e51b81526004016106c490614cf0565b61081d8183612524565b5050565b6000546001600160a01b0316331461084b5760405162461bcd60e51b81526004016106c490614c35565b6002541580159061085e57506002544210155b61087a5760405162461bcd60e51b81526004016106c490614c6c565b6003546108b6906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081169116600019612a85565b60035460405163221b8a9560e11b81526001600160a01b0391821660048201527f000000000000000000000000000000000000000000000000000000000000000090911690634437152a90602401600060405180830381600087803b15801561091e57600080fd5b505af1158015610932573d6000803e3d6000fd5b505060035460405163221b8a9560e11b81526001600160a01b0391821660048201527f00000000000000000000000000000000000000000000000000000000000000009091169250634437152a9150602401600060405180830381600087803b15801561099e57600080fd5b505af11580156109b2573d6000803e3d6000fd5b50505050565b600082116109d85760405162461bcd60e51b81526004016106c490614cb9565b6109e181611c31565b61081d3383612bdc565b60008111610a0b5760405162461bcd60e51b81526004016106c490614cb9565b610a153382612bdc565b50565b6000546001600160a01b03163314610a425760405162461bcd60e51b81526004016106c490614c35565b6000816001600160a01b03166358c700a36040518163ffffffff1660e01b815260040160206040518083038186803b158015610a7d57600080fd5b505afa158015610a91573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ab591906148b9565b90506000826001600160a01b03166379a87b196040518163ffffffff1660e01b815260040160206040518083038186803b158015610af257600080fd5b505afa158015610b06573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b2a9190614773565b90508115801590610b3b5750814210155b610b575760405162461bcd60e51b81526004016106c490614c6c565b6001600160a01b0381163014610bbb5760405162461bcd60e51b815260206004820152602360248201527f50657270657475616c506f6f6c3a206e6f742064657374696e6174696f6e20706044820152621bdbdb60ea1b60648201526084016106c4565b6040516370a0823160e01b81526001600160a01b038481166004830152610c9091859130917f0000000000000000000000000000000000000000000000000000000000000000909116906370a082319060240160206040518083038186803b158015610c2657600080fd5b505afa158015610c3a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c5e91906148b9565b6001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016929190612dc4565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166380d0afec6040518163ffffffff1660e01b815260040160006040518083038186803b158015610ceb57600080fd5b505afa158015610cff573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610d279190810190614807565b905060005b8151811015610ec157846001600160a01b0316636418413c838381518110610d6457634e487b7160e01b600052603260045260246000fd5b60200260200101516040518263ffffffff1660e01b8152600401610d8a91815260200190565b60006040518083038186803b158015610da257600080fd5b505afa158015610db6573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610dde919081019061492b565b60076000848481518110610e0257634e487b7160e01b600052603260045260246000fd5b60200260200101518152602001908152602001600020600082015181600001556020820151816001019080519060200190610e3e929190614569565b5060408201516002820180546001600160a01b0319166001600160a01b03909216919091179055606082015160038201556080820151600482015560a0820151600582015560c0820151600682015560e0820151600782015561010082015160088201556101209091015160099091015580610eb9816151e3565b915050610d2c565b50836001600160a01b0316630910a5106040518163ffffffff1660e01b815260040160206040518083038186803b158015610efb57600080fd5b505afa158015610f0f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f3391906148b9565b600481905550836001600160a01b03166307e2ee0f6040518163ffffffff1660e01b815260040160206040518083038186803b158015610f7257600080fd5b505afa158015610f86573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610faa91906148b9565b600581905550836001600160a01b031663d608c07d6040518163ffffffff1660e01b815260040160206040518083038186803b158015610fe957600080fd5b505afa158015610ffd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061102191906148b9565b600655604080518481526001600160a01b03868116602083015284168183015290517f18ce2512842fddee8c808fb717780a66007d1da9a942dd32625813c82d53c3429181900360600190a150505050565b6000546001600160a01b0316331461109d5760405162461bcd60e51b81526004016106c490614c35565b600180546001600160a01b0319166001600160a01b0392909216919091179055565b61111e604051806101400160405280600081526020016060815260200160006001600160a01b03168152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b600760008381526020019081526020016000206040518061014001604052908160008201548152602001600182018054611157906151a8565b80601f0160208091040260200160405190810160405280929190818152602001828054611183906151a8565b80156111d05780601f106111a5576101008083540402835291602001916111d0565b820191906000526020600020905b8154815290600101906020018083116111b357829003601f168201915b505050918352505060028201546001600160a01b03166020820152600382015460408201526004820154606082015260058201546080820152600682015460a0820152600782015460c0820152600882015460e08201526009909101546101009091015292915050565b6000546001600160a01b031633146112645760405162461bcd60e51b81526004016106c490614c35565b6001600160a01b0382166112b15760405162461bcd60e51b815260206004820152601460248201527304d696772617461626c653a2074617267657420360641b60448201526064016106c4565b600381101580156112c4575061016d8111155b61131c5760405162461bcd60e51b815260206004820152602360248201527f4d696772617461626c653a20677261636544617973206d75737420626520332d60448201526233363560e81b60648201526084016106c4565b6113298162015180615107565b6113339042614f3f565b6002819055600380546001600160a01b0319166001600160a01b038516908117909155604080519283523060208401528201527fe2a3b7ba8269be3ca7ba4627f844bb9abd978e9b05d290dc89d4b107f9e3dda79060600160405180910390a15050565b6000546001600160a01b031633146113c15760405162461bcd60e51b81526004016106c490614c35565b604051633a3ec0ed60e11b8152600481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063747d81da906024015b600060405180830381600087803b15801561142457600080fd5b505af1158015611438573d6000803e3d6000fd5b5050505050565b337f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316158061150a57506040516337c203bd60e21b81526001600160a01b0382811660048301527f0000000000000000000000000000000000000000000000000000000000000000169063df080ef49060240160206040518083038186803b1580156114d257600080fd5b505afa1580156114e6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061150a9190614899565b6115265760405162461bcd60e51b81526004016106c490614cf0565b61152f82611c31565b6107278184612524565b6001546001600160a01b0316331461158a5760405162461bcd60e51b815260206004820152601460248201527313dddb98589b194e881b9bdd08185b1b1bddd95960621b60448201526064016106c4565b600154600080546001600160a01b0319166001600160a01b03909216919091179055565b6000546001600160a01b031633146115d85760405162461bcd60e51b81526004016106c490614c35565b600086815260076020908152604090912087815586519091611601916001840191890190614569565b506002810180546001600160a01b0319166001600160a01b038781169190911790915560038201859055600480830185905560058301849055604051634f435b7760e11b81529081018990527f000000000000000000000000000000000000000000000000000000000000000090911690639e86b6ee90602401600060405180830381600087803b15801561169557600080fd5b505af11580156116a9573d6000803e3d6000fd5b5050505050505050505050565b600081116117015760405162461bcd60e51b815260206004820152601860248201527750657270657475616c506f6f6c3a2030206c53686172657360401b60448201526064016106c4565b610a153382612dfc565b6000811161172b5760405162461bcd60e51b81526004016106c490614cb9565b610a153382613093565b600082116117555760405162461bcd60e51b81526004016106c490614cb9565b61175e81611c31565b61081d3383613093565b6000546001600160a01b031633146117925760405162461bcd60e51b81526004016106c490614c35565b6000818152600760205260408120818155906117b160018301826145e9565b506002810180546001600160a01b031916905560006003820181905560048083018290556005830182905560068301829055600783018290556008830182905560099092015560405163539f601b60e01b81529081018290526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063539f601b9060240161140a565b600082116118635760405162461bcd60e51b81526004016106c490614cb9565b61186c81611c31565b61081d3383613294565b6040516370a0823160e01b8152306004820152600090611940907f0000000000000000000000000000000000000000000000000000000000000000906012906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906370a082319060240160206040518083038186803b15801561190157600080fd5b505afa158015611915573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061193991906148b9565b91906133b8565b9050600061194f6006546133fc565b90508181111561195c5750805b61196581613438565b600660008282546119769190615126565b909155506119a690507f000000000000000000000000000000000000000000000000000000000000000082613477565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03167fdc9b9c7c232fac9d635ce55b58e41cca2c16aa6ad39a73973ce276d479ad6f2d82604051611a0191815260200190565b60405180910390a25050565b6000546001600160a01b03163314611a375760405162461bcd60e51b81526004016106c490614c35565b6000938452600760205260409093206002810180546001600160a01b0319166001600160a01b039490941693909317909255600482015560050155565b60008111611a945760405162461bcd60e51b81526004016106c490614cb9565b610a153382613294565b604051631d49654560e31b8152600481018390527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063ea4b2a289060240160206040518083038186803b158015611afe57600080fd5b505afa158015611b12573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b369190614899565b611b825760405162461bcd60e51b815260206004820152601f60248201527f50657270657475616c506f6f6c3a20696e76616c69642073796d626f6c49640060448201526064016106c4565b8015801590611bac575080670de0b6b3a7640000611ba08183614f57565b611baa9190615084565b145b611bc85760405162461bcd60e51b81526004016106c490614bf3565b61081d338383611df4565b60008211611c1e5760405162461bcd60e51b815260206004820152601860248201527750657270657475616c506f6f6c3a2030206c53686172657360401b60448201526064016106c4565b611c2781611c31565b61081d3383612dfc565b60005b815181101561081d576000828281518110611c5f57634e487b7160e01b600052603260045260246000fd5b602090810291909101810151516000818152600790925260409091206002015484519192506001600160a01b0316906357c9739890859085908110611cb457634e487b7160e01b600052603260045260246000fd5b602002602001015160200151858581518110611ce057634e487b7160e01b600052603260045260246000fd5b602002602001015160400151868681518110611d0c57634e487b7160e01b600052603260045260246000fd5b602002602001015160600151878781518110611d3857634e487b7160e01b600052603260045260246000fd5b602002602001015160800151888881518110611d6457634e487b7160e01b600052603260045260246000fd5b602090810291909101015160a001516040516001600160e01b031960e088901b1681526004810195909552602485019390935260ff90911660448401526064830152608482015260a401600060405180830381600087803b158015611dc857600080fd5b505af1158015611ddc573d6000803e3d6000fd5b50505050508080611dec906151e3565b915050611c34565b60085460ff1615611e175760405162461bcd60e51b81526004016106c490614d79565b6008805460ff19166001179055600080611e2f613535565b91509150600080600080611e42896138aa565b929650909450925090506000805b8551811015611ea257858181518110611e7957634e487b7160e01b600052603260045260246000fd5b60200260200101518a1415611e9057809150611ea2565b80611e9a816151e3565b915050611e50565b50611ee36040518060e00160405280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b60008a8152600760208181526040808420600881015486526006810154868401908152948f9052929091526003909101549083018190529051670de0b6b3a764000091908290611f33908d615084565b611f3d9190614f57565b611f479190615084565b611f519190614f57565b6060820190815260008b8152600760205260409020600401549051670de0b6b3a76400009190611f8090613a79565b611f8a9190615084565b611f949190614f57565b60808201528451600090869084908110611fbe57634e487b7160e01b600052603260045260246000fd5b60200260200101516000015112158015611fd9575060008912155b1580156120205750600085838151811061200357634e487b7160e01b600052603260045260246000fd5b6020026020010151600001511315801561201e575060008913155b155b1561212657600061205b86848151811061204a57634e487b7160e01b600052603260045260246000fd5b602002602001015160000151613a79565b905060006120688b613a79565b90508082136120cc5786848151811061209157634e487b7160e01b600052603260045260246000fd5b602002602001015160200151818385606001516120ae9190615084565b6120b89190614f57565b6120c29190614efe565b60a0840152612123565b826060015182828987815181106120f357634e487b7160e01b600052603260045260246000fd5b6020026020010151602001516121099190615084565b6121139190614f57565b61211d9190614efe565b60a08401525b50505b670de0b6b3a76400008160400151670de0b6b3a7640000836020015161214f8560000151613a79565b6121678e87600001516121629190614efe565b613a79565b6121719190615126565b61217b9190615084565b6121859190614f57565b61218f9190615084565b6121999190614f57565b6121a39088614efe565b9650888583815181106121c657634e487b7160e01b600052603260045260246000fd5b60200260200101516000018181516121de9190614efe565b90525060a081015160608201516121f59190615126565b85838151811061221557634e487b7160e01b600052603260045260246000fd5b602002602001015160200181815161222d9190614efe565b90525060008a81526007602081905260409091200154855186908490811061226557634e487b7160e01b600052603260045260246000fd5b602002602001015160400181815250508060a0015181608001516122899190614efe565b6122939084615126565b925060018483815181106122b757634e487b7160e01b600052603260045260246000fd5b91151560209283029190910182015260008b815260079091526040812060080180548b92906122e7908490614efe565b909155505060a081015160608201516123009190615126565b60008b81526007602052604081206009018054909190612321908490614efe565b90915550506080810151670de0b6b3a764000090612360907f000000000000000000000000000000000000000000000000000000000000000090615084565b61236a9190614f57565b60c0820181905260068054600090612383908490614efe565b909155505060a081015160c082015160808301516123a19190615126565b6123ab9190614efe565b600460008282546123bc9190614efe565b909155505086158061240a57507f0000000000000000000000000000000000000000000000000000000000000000876123fd670de0b6b3a76400008b615084565b6124079190614f57565b12155b6124645760405162461bcd60e51b815260206004820152602560248201527f50657270657475616c506f6f6c3a20696e73756666696369656e74206c697175604482015264696469747960d81b60648201526084016106c4565b7f0000000000000000000000000000000000000000000000000000000000000000612490878786613acc565b12156124ae5760405162461bcd60e51b81526004016106c490614d37565b6124bb8b87878787613c9c565b898b6001600160a01b03167fafa6e0e09d86154337d4461488269397cc1ca7b75db98a37ec57735846064f478b6124f585602001516133fc565b6040805192835260208301919091520160405180910390a350506008805460ff19169055505050505050505050565b60085460ff16156125475760405162461bcd60e51b81526004016106c490614d79565b6008805460ff1916600117905561255c613535565b5050600080600061256c846138aa565b935050925092507f000000000000000000000000000000000000000000000000000000000000000061259f848484613acc565b126125ec5760405162461bcd60e51b815260206004820152601f60248201527f50657270657475616c506f6f6c3a2063616e6e6f74206c69717569646174650060448201526064016106c4565b8060005b84518110156128615783818151811061261957634e487b7160e01b600052603260045260246000fd5b60200260200101516000015160001461284f5783818151811061264c57634e487b7160e01b600052603260045260246000fd5b6020026020010151600001516007600087848151811061267c57634e487b7160e01b600052603260045260246000fd5b6020026020010151815260200190815260200160002060080160008282546126a49190615126565b925050819055508381815181106126cb57634e487b7160e01b600052603260045260246000fd5b602002602001015160200151600760008784815181106126fb57634e487b7160e01b600052603260045260246000fd5b6020026020010151815260200190815260200160002060090160008282546127239190615126565b9250508190555083818151811061274a57634e487b7160e01b600052603260045260246000fd5b602002602001015160200151670de0b6b3a76400006007600088858151811061278357634e487b7160e01b600052603260045260246000fd5b6020026020010151815260200190815260200160002060030154670de0b6b3a7640000600760008a87815181106127ca57634e487b7160e01b600052603260045260246000fd5b602002602001015181526020019081526020016000206006015488868151811061280457634e487b7160e01b600052603260045260246000fd5b60200260200101516000015161281a9190615084565b6128249190614f57565b61282e9190615084565b6128389190614f57565b6128429190615126565b61284c9083614efe565b91505b80612859816151e3565b9150506125f0565b5060007f000000000000000000000000000000000000000000000000000000000000000082136128b257507f0000000000000000000000000000000000000000000000000000000000000000612976565b7f0000000000000000000000000000000000000000000000000000000000000000821261290057507f0000000000000000000000000000000000000000000000000000000000000000612976565b7f0000000000000000000000000000000000000000000000000000000000000000670de0b6b3a76400007f00000000000000000000000000000000000000000000000000000000000000006129558386615126565b61295f9190615084565b6129699190614f57565b6129739190614efe565b90505b6129808184615126565b600460008282546129919190614efe565b909155505060405163226bf2d160e21b81526001600160a01b0387811660048301527f000000000000000000000000000000000000000000000000000000000000000016906389afcb4490602401600060405180830381600087803b1580156129f957600080fd5b505af1158015612a0d573d6000803e3d6000fd5b50505050612a2387612a1e836133fc565b613477565b866001600160a01b0316866001600160a01b03167faef3faf684172084346f7dc2cc3bb1328d1cc23caec12dd9a82d4a4e56c00b17612a61846133fc565b60405190815260200160405180910390a350506008805460ff191690555050505050565b801580612b0e5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b158015612ad457600080fd5b505afa158015612ae8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b0c91906148b9565b155b612b795760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b60648201526084016106c4565b6040516001600160a01b03831660248201526044810182905261072790849063095ea7b360e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613e51565b60085460ff1615612bff5760405162461bcd60e51b81526004016106c490614d79565b6008805460ff191660011790556000612c16613535565b509050612c238383613f23565b915060007f000000000000000000000000000000000000000000000000000000000000000090506000816001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015612c8557600080fd5b505afa158015612c99573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cbd91906148b9565b9050600081612ccd575083612ced565b612cd6846133fc565b612ce08387615107565b612cea9190614f85565b90505b6040516340c10f1960e01b81526001600160a01b038781166004830152602482018390528416906340c10f1990604401600060405180830381600087803b158015612d3757600080fd5b505af1158015612d4b573d6000803e3d6000fd5b50505050612d5885613438565b60046000828254612d699190614efe565b909155505060408051828152602081018790526001600160a01b038816917f06239653922ac7bea6aa2b19dc486b9361821d37712eb796adfd38d81de278ca910160405180910390a250506008805460ff1916905550505050565b6040516001600160a01b03808516602483015283166044820152606481018290526109b29085906323b872dd60e01b90608401612ba5565b60085460ff1615612e1f5760405162461bcd60e51b81526004016106c490614d79565b6008805460ff19166001179055600080612e37613535565b9150915060007f000000000000000000000000000000000000000000000000000000000000000090506000816001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015612e9b57600080fd5b505afa158015612eaf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ed391906148b9565b9050600081612ee1866133fc565b612eeb9088615107565b612ef59190614f85565b9050612f0081613438565b60046000828254612f119190615126565b9091555050831580612f7357507f000000000000000000000000000000000000000000000000000000000000000084670de0b6b3a7640000612f5284613438565b612f5c9089615126565b612f669190615084565b612f709190614f57565b12155b612fcf5760405162461bcd60e51b815260206004820152602760248201527f50657270657475616c506f6f6c3a20706f6f6c20696e73756666696369656e746044820152661036b0b933b4b760c91b60648201526084016106c4565b604051632770a7eb60e21b81526001600160a01b03888116600483015260248201889052841690639dc29fac90604401600060405180830381600087803b15801561301957600080fd5b505af115801561302d573d6000803e3d6000fd5b5050505061303b8782613477565b60408051878152602081018390526001600160a01b038916917f0fbf06c058b90cb038a618f8c2acbf6145f8b3570fd1fa56abb8f0f3f05b36e891015b60405180910390a250506008805460ff191690555050505050565b60085460ff16156130b65760405162461bcd60e51b81526004016106c490614d79565b6008805460ff191660011790556130cd8282613f23565b604051637b51e92760e11b81526001600160a01b0384811660048301529192507f00000000000000000000000000000000000000000000000000000000000000009182169063f6a3d24e9060240160206040518083038186803b15801561313357600080fd5b505afa158015613147573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061316b9190614899565b6131cb576040516335313c2160e11b81526001600160a01b038481166004830152821690636a62784290602401600060405180830381600087803b1580156131b257600080fd5b505af11580156131c6573d6000803e3d6000fd5b505050505b806001600160a01b031663ac2681c6846131e485613438565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401600060405180830381600087803b15801561322a57600080fd5b505af115801561323e573d6000803e3d6000fd5b50505050826001600160a01b03167f278e696bd0cd4a7d1260ced26c40cd01c2b088f441889e4148240ac81069b3488360405161327d91815260200190565b60405180910390a250506008805460ff1916905550565b60085460ff16156132b75760405162461bcd60e51b81526004016106c490614d79565b6008805460ff191660011790556132cc613535565b50506000806000806132dd866138aa565b935093509350935060006132f086613438565b905081811261330f575080613304816133fc565b95506000915061331c565b6133198183615126565b91505b7f0000000000000000000000000000000000000000000000000000000000000000613348868685613acc565b12156133665760405162461bcd60e51b81526004016106c490614d37565b6133738786868686613c9c565b61337d8787613477565b866001600160a01b03167f318a9cd646c737e6331915189b674d6d06ae71b28df0f50e7a6dfe101a1293878760405161307891815260200190565b60008183146133f0576133cc83600a614fdc565b6133d783600a614fdc565b6133e19086615107565b6133eb9190614f85565b6133f2565b835b90505b9392505050565b6000808212156134345760405162461bcd60e51b815260206004820152600360248201526249554f60e81b60448201526064016106c4565b5090565b60006001600160ff1b038211156134345760405162461bcd60e51b815260206004820152600360248201526255494f60e81b60448201526064016106c4565b60006134a58260127f00000000000000000000000000000000000000000000000000000000000000006133b8565b905060006134d5827f000000000000000000000000000000000000000000000000000000000000000060126133b8565b6134df9084615165565b90506134ea81613438565b600660008282546134fb9190614efe565b909155506109b290506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168584613f92565b60008060006005549050600043905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166380d0afec6040518163ffffffff1660e01b815260040160006040518083038186803b15801561359f57600080fd5b505afa1580156135b3573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526135db9190810190614807565b9050600454945060005b815181101561375e5760006007600084848151811061361457634e487b7160e01b600052603260045260246000fd5b602002602001015181526020019081526020016000209050848411156136c157600281015460408051634c6afee560e11b815290516136bb926001600160a01b0316916398d5fdca9160048083019260209291908290030181600087803b15801561367e57600080fd5b505af1158015613692573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136b691906148b9565b613438565b60068201555b60088101541561374b576000670de0b6b3a76400008260030154670de0b6b3a7640000846006015485600801546136f89190615084565b6137029190614f57565b61370c9190615084565b6137169190614f57565b90508160090154816137289190615126565b6137329089615126565b975061373d81613a79565b6137479088614efe565b9650505b5080613756816151e3565b9150506135e5565b50828211156138a15760005b815181101561389f5760006007600084848151811061379957634e487b7160e01b600052603260045260246000fd5b602002602001015181526020019081526020016000209050806008015460001461388c576000878260050154670de0b6b3a76400008460030154670de0b6b3a76400008660030154670de0b6b3a76400008860060154670de0b6b3a76400008a600601548b6008015461380c9190615084565b6138169190614f57565b6138209190615084565b61382a9190614f57565b6138349190615084565b61383e9190614f57565b6138489190615084565b6138529190614f57565b61385c9190615084565b6138669190614f57565b905060006138748787615165565b61387e9083615084565b600784018054909101905550505b5080613897816151e3565b91505061376a565b505b50600555509091565b606080606060006138ba85613fc2565b929650909450925090506000805b8551811015613a46578481815181106138f157634e487b7160e01b600052603260045260246000fd5b602002602001015160000151600014613a345760006007600088848151811061392a57634e487b7160e01b600052603260045260246000fd5b60200260200101518152602001908152602001600020600701549050600086838151811061396857634e487b7160e01b600052603260045260246000fd5b60200260200101516040015182039050670de0b6b3a7640000818885815181106139a257634e487b7160e01b600052603260045260246000fd5b6020026020010151600001516139b89190615084565b6139c29190614f57565b6139cc9085614efe565b9350818784815181106139ef57634e487b7160e01b600052603260045260246000fd5b602002602001015160400181815250506001868481518110613a2157634e487b7160e01b600052603260045260246000fd5b9115156020928302919091019091015250505b80613a3e816151e3565b9150506138c8565b508015613a7157613a578183615126565b91508060046000828254613a6b9190614efe565b90915550505b509193509193565b6000600160ff1b821415613ab45760405162461bcd60e51b8152602060048201526002602482015261414f60f01b60448201526064016106c4565b600082121561343457613ac6826151fe565b92915050565b60008181805b8651811015613c6057858181518110613afb57634e487b7160e01b600052603260045260246000fd5b602002602001015160000151600014613c4e576000670de0b6b3a7640000600760008a8581518110613b3d57634e487b7160e01b600052603260045260246000fd5b6020026020010151815260200190815260200160002060030154670de0b6b3a7640000600760008c8781518110613b8457634e487b7160e01b600052603260045260246000fd5b60200260200101518152602001908152602001600020600601548a8681518110613bbe57634e487b7160e01b600052603260045260246000fd5b602002602001015160000151613bd49190615084565b613bde9190614f57565b613be89190615084565b613bf29190614f57565b9050868281518110613c1457634e487b7160e01b600052603260045260246000fd5b60200260200101516020015181613c2b9190615126565b613c359085614efe565b9350613c4081613a79565b613c4a9084614efe565b9250505b80613c58816151e3565b915050613ad2565b508015613c895780613c7a670de0b6b3a764000084615084565b613c849190614f57565b613c92565b6001600160ff1b035b9695505050505050565b7f000000000000000000000000000000000000000000000000000000000000000060005b8551811015613de657838181518110613ce957634e487b7160e01b600052603260045260246000fd5b602002602001015115613dd457816001600160a01b031663f733fed788888481518110613d2657634e487b7160e01b600052603260045260246000fd5b6020026020010151888581518110613d4e57634e487b7160e01b600052603260045260246000fd5b602090810291909101810151604080516001600160e01b031960e088901b1681526001600160a01b0390951660048601526024850193909352805160448501529081015160648401520151608482015260a401600060405180830381600087803b158015613dbb57600080fd5b505af1158015613dcf573d6000803e3d6000fd5b505050505b80613dde816151e3565b915050613cc0565b50604051631a9c941f60e01b81526001600160a01b03878116600483015260248201849052821690631a9c941f90604401600060405180830381600087803b158015613e3157600080fd5b505af1158015613e45573d6000803e3d6000fd5b50505050505050505050565b6000613ea6826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166142bd9092919063ffffffff16565b8051909150156107275780806020019051810190613ec49190614899565b6107275760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016106c4565b600080613f5c8430613f578660127f00000000000000000000000000000000000000000000000000000000000000006133b8565b6142cc565b9050613f8a817f000000000000000000000000000000000000000000000000000000000000000060126133b8565b949350505050565b6040516001600160a01b03831660248201526044810182905261072790849063a9059cbb60e01b90606401612ba5565b60608060606000807f00000000000000000000000000000000000000000000000000000000000000009050806001600160a01b03166380d0afec6040518163ffffffff1660e01b815260040160006040518083038186803b15801561402657600080fd5b505afa15801561403a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526140629190810190614807565b945084516001600160401b0381111561408b57634e487b7160e01b600052604160045260246000fd5b6040519080825280602002602001820160405280156140e057816020015b6140cd60405180606001604052806000815260200160008152602001600081525090565b8152602001906001900390816140a95790505b50935084516001600160401b0381111561410a57634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015614133578160200160208202803683370190505b50925060005b855181101561423957816001600160a01b0316633adbb5af8888848151811061417257634e487b7160e01b600052603260045260246000fd5b60200260200101516040518363ffffffff1660e01b81526004016141ab9291906001600160a01b03929092168252602082015260400190565b60606040518083038186803b1580156141c357600080fd5b505afa1580156141d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906141fb91906148d1565b85828151811061421b57634e487b7160e01b600052603260045260246000fd5b60200260200101819052508080614231906151e3565b915050614139565b50604051637c27c4d160e11b81526001600160a01b03878116600483015282169063f84f89a29060240160206040518083038186803b15801561427b57600080fd5b505afa15801561428f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906142b391906148b9565b9150509193509193565b60606133f28484600085614418565b6040516370a0823160e01b81526001600160a01b0383811660048301526000917f0000000000000000000000000000000000000000000000000000000000000000918391908316906370a082319060240160206040518083038186803b15801561433557600080fd5b505afa158015614349573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061436d91906148b9565b90506143846001600160a01b038316878787612dc4565b6040516370a0823160e01b81526001600160a01b038681166004830152600091908416906370a082319060240160206040518083038186803b1580156143c957600080fd5b505afa1580156143dd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061440191906148b9565b905061440d8282615165565b979650505050505050565b6060824710156144795760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016106c4565b843b6144c75760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016106c4565b600080866001600160a01b031685876040516144e39190614bc4565b60006040518083038185875af1925050503d8060008114614520576040519150601f19603f3d011682016040523d82523d6000602084013e614525565b606091505b509150915061440d8282866060831561453f5750816133f5565b82511561454f5782518084602001fd5b8160405162461bcd60e51b81526004016106c49190614be0565b828054614575906151a8565b90600052602060002090601f01602090048101928261459757600085556145dd565b82601f106145b057805160ff19168380011785556145dd565b828001600101855582156145dd579182015b828111156145dd5782518255916020019190600101906145c2565b5061343492915061461f565b5080546145f5906151a8565b6000825580601f10614605575050565b601f016020900490600052602060002090810190610a1591905b5b808211156134345760008155600101614620565b803561463f8161525a565b919050565b805161463f8161525a565b600082601f83011261465f578081fd5b8135602061467461466f83614eb4565b614e84565b8281528181019085830160c080860288018501891015614692578687fd5b865b868110156147065781838b0312156146aa578788fd5b6146b2614e39565b8335815286840135878201526040808501359082015260608085013560ff811681146146dc578a8bfd5b908201526080848101359082015260a0808501359082015285529385019391810191600101614694565b509198975050505050505050565b600082601f830112614724578081fd5b815161473261466f82614ed7565b818152846020838601011115614746578283fd5b613f8a82602083016020870161517c565b600060208284031215614768578081fd5b81356133f58161525a565b600060208284031215614784578081fd5b81516133f58161525a565b600080604083850312156147a1578081fd5b82356147ac8161525a565b915060208301356001600160401b038111156147c6578182fd5b6147d28582860161464f565b9150509250929050565b600080604083850312156147ee578182fd5b82356147f98161525a565b946020939093013593505050565b60006020808385031215614819578182fd5b82516001600160401b0381111561482e578283fd5b8301601f8101851361483e578283fd5b805161484c61466f82614eb4565b80828252848201915084840188868560051b870101111561486b578687fd5b8694505b8385101561488d57805183526001949094019391850191850161486f565b50979650505050505050565b6000602082840312156148aa578081fd5b815180151581146133f5578182fd5b6000602082840312156148ca578081fd5b5051919050565b6000606082840312156148e2578081fd5b604051606081018181106001600160401b038211171561490457614904615244565b80604052508251815260208301516020820152604083015160408201528091505092915050565b60006020828403121561493c578081fd5b81516001600160401b0380821115614952578283fd5b908301906101408286031215614966578283fd5b61496e614e61565b82518152602083015182811115614983578485fd5b61498f87828601614714565b6020830152506149a160408401614644565b6040820152606083015160608201526080830151608082015260a083015160a082015260c083015160c082015260e083015160e0820152610100915081830151828201526101209150818301518282015280935050505092915050565b600060208284031215614a0f578081fd5b5035919050565b60008060008060808587031215614a2b578182fd5b843593506020850135614a3d8161525a565b93969395505050506040820135916060013590565b60008060408385031215614a64578182fd5b8235915060208301356001600160401b038111156147c6578182fd5b60008060408385031215614a92578182fd5b50508035926020909101359150565b600080600060608486031215614ab5578081fd5b833592506020840135915060408401356001600160401b03811115614ad8578182fd5b614ae48682870161464f565b9150509250925092565b60008060008060008060c08789031215614b06578384fd5b8635955060208701356001600160401b03811115614b22578485fd5b8701601f81018913614b32578485fd5b8035614b4061466f82614ed7565b8181528a6020838501011115614b54578687fd5b816020840160208301379081016020018690529550614b77905060408801614634565b9350606087013592506080870135915060a087013590509295509295509295565b60008151808452614bb081602086016020860161517c565b601f01601f19169290920160200192915050565b60008251614bd681846020870161517c565b9190910192915050565b6020815260006133f56020830184614b98565b60208082526022908201527f50657270657475616c506f6f6c3a20696e76616c6964207472616465566f6c756040820152616d6560f01b606082015260800190565b60208082526018908201527f4f776e61626c653a206f6e6c7920636f6e74726f6c6c65720000000000000000604082015260600190565b6020808252602d908201527f50657270657475616c506f6f6c3a206d6967726174696f6e54696d657374616d60408201526c1c081b9bdd081b595d081e595d609a1b606082015260800190565b60208082526018908201527f50657270657475616c506f6f6c3a20302062416d6f756e740000000000000000604082015260600190565b60208082526027908201527f50657270657475616c506f6f6c3a206e6f74207175616c6966696564206c69716040820152663ab4b230ba37b960c91b606082015260800190565b60208082526022908201527f50657270657475616c506f6f6c3a20696e73756666696369656e74206d61726760408201526134b760f11b606082015260800190565b6020808252600790820152667265656e74727960c81b604082015260600190565b602081528151602082015260006020830151610140806040850152614dc3610160850183614b98565b91506040850151614ddf60608601826001600160a01b03169052565b5060608501516080850152608085015160a085015260a085015160c085015260c085015160e085015260e0850151610100818187015280870151915050610120818187015280870151838701525050508091505092915050565b60405160c081016001600160401b0381118282101715614e5b57614e5b615244565b60405290565b60405161014081016001600160401b0381118282101715614e5b57614e5b615244565b604051601f8201601f191681016001600160401b0381118282101715614eac57614eac615244565b604052919050565b60006001600160401b03821115614ecd57614ecd615244565b5060051b60200190565b60006001600160401b03821115614ef057614ef0615244565b50601f01601f191660200190565b600080821280156001600160ff1b0384900385131615614f2057614f20615218565b600160ff1b8390038412811615614f3957614f39615218565b50500190565b60008219821115614f5257614f52615218565b500190565b600082614f6657614f6661522e565b600160ff1b821460001984141615614f8057614f80615218565b500590565b600082614f9457614f9461522e565b500490565b600181815b80851115614fd4578160001904821115614fba57614fba615218565b80851615614fc757918102915b93841c9390800290614f9e565b509250929050565b60006133f58383600082614ff257506001613ac6565b81614fff57506000613ac6565b8160018114615015576002811461501f5761503b565b6001915050613ac6565b60ff84111561503057615030615218565b50506001821b613ac6565b5060208310610133831016604e8410600b841016171561505e575081810a613ac6565b6150688383614f99565b806000190482111561507c5761507c615218565b029392505050565b60006001600160ff1b03818413828413808216868404861116156150aa576150aa615218565b600160ff1b848712828116878305891216156150c8576150c8615218565b8587129250878205871284841616156150e3576150e3615218565b878505871281841616156150f9576150f9615218565b505050929093029392505050565b600081600019048311821515161561512157615121615218565b500290565b60008083128015600160ff1b85018412161561514457615144615218565b6001600160ff1b038401831381161561515f5761515f615218565b50500390565b60008282101561517757615177615218565b500390565b60005b8381101561519757818101518382015260200161517f565b838111156109b25750506000910152565b600181811c908216806151bc57607f821691505b602082108114156151dd57634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156151f7576151f7615218565b5060010190565b6000600160ff1b82141561521457615214615218565b0390565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610a1557600080fdfea2646970667358221220e0a1ebc6cfa829355463e8964f3fa70657f539eefb715b1558df3f1796bbf01364736f6c634300080400330000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000016345785d8a000000000000000000000000000000000000000000000000000000b1a2bc2ec50000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003635c9adc5dea0000000000000000000000000000000000000000000000000000006f05b59d3b2000000000000000000000000000000000000000000000000000002c68af0bb140000000000000000000000000000c2132d05d31c914a87c6611c10748aeb04b58e8f00000000000000000000000035c8b3bb6ce67d9bf6b14a5ffc121a79d6247d07000000000000000000000000dc3ed843f0c411eea1b84c0277cdfc5b71e220590000000000000000000000000000000000000000000000000000000000000000000000000000000000000000dcca8b2810888e6ad79821bf2e3efacda874da29

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

0000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000016345785d8a000000000000000000000000000000000000000000000000000000b1a2bc2ec50000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003635c9adc5dea0000000000000000000000000000000000000000000000000000006f05b59d3b2000000000000000000000000000000000000000000000000000002c68af0bb140000000000000000000000000000c2132d05d31c914a87c6611c10748aeb04b58e8f00000000000000000000000035c8b3bb6ce67d9bf6b14a5ffc121a79d6247d07000000000000000000000000dc3ed843f0c411eea1b84c0277cdfc5b71e220590000000000000000000000000000000000000000000000000000000000000000000000000000000000000000dcca8b2810888e6ad79821bf2e3efacda874da29

-----Decoded View---------------
Arg [0] : parameters (uint256[7]): 1000000000000000000,100000000000000000,50000000000000000,0,1000000000000000000000,500000000000000000,200000000000000000
Arg [1] : addresses (address[5]): 0xc2132d05d31c914a87c6611c10748aeb04b58e8f,0x35c8b3bb6ce67d9bf6b14a5ffc121a79d6247d07,0xdc3ed843f0c411eea1b84c0277cdfc5b71e22059,0x0000000000000000000000000000000000000000,0xdcca8b2810888e6ad79821bf2e3efacda874da29

-----Encoded View---------------
12 Constructor Arguments found :
Arg [0] : 0000000000000000000000000000000000000000000000000de0b6b3a7640000
Arg [1] : 000000000000000000000000000000000000000000000000016345785d8a0000
Arg [2] : 00000000000000000000000000000000000000000000000000b1a2bc2ec50000
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [4] : 00000000000000000000000000000000000000000000003635c9adc5dea00000
Arg [5] : 00000000000000000000000000000000000000000000000006f05b59d3b20000
Arg [6] : 00000000000000000000000000000000000000000000000002c68af0bb140000
Arg [7] : 000000000000000000000000c2132d05d31c914a87c6611c10748aeb04b58e8f
Arg [8] : 00000000000000000000000035c8b3bb6ce67d9bf6b14a5ffc121a79d6247d07
Arg [9] : 000000000000000000000000dc3ed843f0c411eea1b84c0277cdfc5b71e22059
Arg [10] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [11] : 000000000000000000000000dcca8b2810888e6ad79821bf2e3efacda874da29


Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.