Contract 0x09bee0eee3d5b8cfdc7d3b074b32e1aa08c9347d

Contract Overview

Balance:
0 BNB
Txn Hash
Block
From
To
Value [Txn Fee]
0xdee5d46546db9a02f22d8927feba9177a8bc073e1cef46285621d558897037ec80223712021-04-16 7:14:4557 days 4 hrs ago0x20000b9b01e93a39db9d286e9264eff7f2af16e9 IN  Contract Creation0 BNB0.01217216
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0x0cb56f9298a9a366d7b5341fab7eae265adeaf29dac66fd45a3c3c2510d393eb92317772021-05-28 8:09:0215 days 3 hrs ago 0xed87a0a16995fef5d963c8a8f63cd81e6678951f 0x09bee0eee3d5b8cfdc7d3b074b32e1aa08c9347d0 BNB
0x894efae7102784ca378bb24fbe2581744df0f9baf8a1995bff8adb5464827b1192317772021-05-28 8:09:0215 days 3 hrs ago 0xed87a0a16995fef5d963c8a8f63cd81e6678951f 0x09bee0eee3d5b8cfdc7d3b074b32e1aa08c9347d0 BNB
0xca18c999db51acfc8b32a7abac2ae58becb27936cd3162cabff875cc9944a02792317762021-05-28 8:08:5915 days 3 hrs ago 0xed87a0a16995fef5d963c8a8f63cd81e6678951f 0x09bee0eee3d5b8cfdc7d3b074b32e1aa08c9347d0 BNB
0xf20c981e6b31b8960e12b35fcb457972df124edc4e565af149e9e6a1aab38c8f92315782021-05-28 7:59:0515 days 3 hrs ago 0xed87a0a16995fef5d963c8a8f63cd81e6678951f 0x09bee0eee3d5b8cfdc7d3b074b32e1aa08c9347d0 BNB
0x2f3244798831a8e9353420721f8ea34ed3b92ca39977ae623b432b2b26e16aa892315782021-05-28 7:59:0515 days 3 hrs ago 0xed87a0a16995fef5d963c8a8f63cd81e6678951f 0x09bee0eee3d5b8cfdc7d3b074b32e1aa08c9347d0 BNB
0xcfda2716d7fe7042f304cd036b944d006fe8a4ede216748f5c9fe07cb6deb8b792315162021-05-28 7:55:5915 days 4 hrs ago 0xed87a0a16995fef5d963c8a8f63cd81e6678951f 0x09bee0eee3d5b8cfdc7d3b074b32e1aa08c9347d0 BNB
0x0e590e31b97481e6090fa739a79f15f60166145241a46e4f8e39c7f2de97abea92314172021-05-28 7:51:0215 days 4 hrs ago 0xed87a0a16995fef5d963c8a8f63cd81e6678951f 0x09bee0eee3d5b8cfdc7d3b074b32e1aa08c9347d0 BNB
0x5d342f3b054cd75f048e70790d4ce1b9fd2f53bdcc91163b84872bc2f8ab9c5592314162021-05-28 7:50:5915 days 4 hrs ago 0xed87a0a16995fef5d963c8a8f63cd81e6678951f 0x09bee0eee3d5b8cfdc7d3b074b32e1aa08c9347d0 BNB
0xbf636ff78acc17c77458db84bb85117b28b2512acabb2d358972f4b1c9d679c292313802021-05-28 7:49:1115 days 4 hrs ago 0xed87a0a16995fef5d963c8a8f63cd81e6678951f 0x09bee0eee3d5b8cfdc7d3b074b32e1aa08c9347d0 BNB
0xef83fe71b70ac1419b831e22ca29323fea10b4da0b75c00a64d4762258ead6f192310572021-05-28 7:33:0215 days 4 hrs ago 0xed87a0a16995fef5d963c8a8f63cd81e6678951f 0x09bee0eee3d5b8cfdc7d3b074b32e1aa08c9347d0 BNB
0x2148d4b9e68198f22d731f44df7d3ae063ab28fb7869f5301d13249af5536be292310572021-05-28 7:33:0215 days 4 hrs ago 0xed87a0a16995fef5d963c8a8f63cd81e6678951f 0x09bee0eee3d5b8cfdc7d3b074b32e1aa08c9347d0 BNB
0x270026a9d7ece8e5f8ceb8786b0bd537eaa2a155583d2a029be395c360d01b4492309762021-05-28 7:28:5915 days 4 hrs ago 0xed87a0a16995fef5d963c8a8f63cd81e6678951f 0x09bee0eee3d5b8cfdc7d3b074b32e1aa08c9347d0 BNB
0xc0c3850c821fd7983ff2713a5c6fc9d1eecf07c98c58abf6299d6e78e64e22d392308772021-05-28 7:24:0215 days 4 hrs ago 0xed87a0a16995fef5d963c8a8f63cd81e6678951f 0x09bee0eee3d5b8cfdc7d3b074b32e1aa08c9347d0 BNB
0x221c6b1bbe9fb87d97ec9b24cdc8d2fd5e17d797e316bb321f26ecdc32fd1f1692307972021-05-28 7:20:0215 days 4 hrs ago 0xed87a0a16995fef5d963c8a8f63cd81e6678951f 0x09bee0eee3d5b8cfdc7d3b074b32e1aa08c9347d0 BNB
0x99d92e31c5821cf31e749a933fe4615fff1788560c70f6a99b1965a87d3b2afe92307972021-05-28 7:20:0215 days 4 hrs ago 0xed87a0a16995fef5d963c8a8f63cd81e6678951f 0x09bee0eee3d5b8cfdc7d3b074b32e1aa08c9347d0 BNB
0x9b8aad29478e7151afe5943a120d7e83747a6fa6ab0f5f0242e03c230f8b575a92306772021-05-28 7:14:0215 days 4 hrs ago 0xed87a0a16995fef5d963c8a8f63cd81e6678951f 0x09bee0eee3d5b8cfdc7d3b074b32e1aa08c9347d0 BNB
0x62d49ade46b8901bdd27f09542f93f01d03d9bd305aff19ceb96f61c2263017e92306172021-05-28 7:11:0215 days 4 hrs ago 0xed87a0a16995fef5d963c8a8f63cd81e6678951f 0x09bee0eee3d5b8cfdc7d3b074b32e1aa08c9347d0 BNB
0x614365cec8cbaf1d0a72fa128fb42fa0665655fd11c7da677c1317388400919a92305972021-05-28 7:10:0215 days 4 hrs ago 0xed87a0a16995fef5d963c8a8f63cd81e6678951f 0x09bee0eee3d5b8cfdc7d3b074b32e1aa08c9347d0 BNB
0x5ad11ba3f8647164172c533254d8e26cca1eb4ec998833ddfc6dc3c229fd351992303972021-05-28 7:00:0215 days 4 hrs ago 0xed87a0a16995fef5d963c8a8f63cd81e6678951f 0x09bee0eee3d5b8cfdc7d3b074b32e1aa08c9347d0 BNB
0x9a0aea5ecae5a6bb68b157851499dfaa7db2b0fe09d1ca1c77bae417c8a393a592301952021-05-28 6:49:5615 days 5 hrs ago 0xed87a0a16995fef5d963c8a8f63cd81e6678951f 0x09bee0eee3d5b8cfdc7d3b074b32e1aa08c9347d0 BNB
0xa221fc8dc00a64e8e64604652aee850f0741eee642023827c5a650b660b18ff992301572021-05-28 6:48:0215 days 5 hrs ago 0xed87a0a16995fef5d963c8a8f63cd81e6678951f 0x09bee0eee3d5b8cfdc7d3b074b32e1aa08c9347d0 BNB
0x539605220adf2658ded806050e8e65349c1def9149bac129357ebbee9ed029ae92301572021-05-28 6:48:0215 days 5 hrs ago 0xed87a0a16995fef5d963c8a8f63cd81e6678951f 0x09bee0eee3d5b8cfdc7d3b074b32e1aa08c9347d0 BNB
0x1b339d6cc48915e1cc608bdbfda31dd1d5c410bc7ef82d0c3304dbe23877285492299972021-05-28 6:40:0215 days 5 hrs ago 0xed87a0a16995fef5d963c8a8f63cd81e6678951f 0x09bee0eee3d5b8cfdc7d3b074b32e1aa08c9347d0 BNB
0x37184d9d27e5ce1350252907f2bfce00463af9bc86893a8df19688cab39a9b6892297962021-05-28 6:29:5915 days 5 hrs ago 0xed87a0a16995fef5d963c8a8f63cd81e6678951f 0x09bee0eee3d5b8cfdc7d3b074b32e1aa08c9347d0 BNB
0xe9ac90efd8cead471c0a8abeae6660e6a2787c5a860845badd3b9ab0173f254b92296782021-05-28 6:24:0515 days 5 hrs ago 0xed87a0a16995fef5d963c8a8f63cd81e6678951f 0x09bee0eee3d5b8cfdc7d3b074b32e1aa08c9347d0 BNB
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
SystemSettings

Compiler Version
v0.6.12+commit.27d51765

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 19 : MMLPToken.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.6.12;

import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";

contract MMLPToken is ERC20Upgradeable, OwnableUpgradeable {
    constructor(string memory _name, string memory _symbol) public {
        __ERC20_init(_name, _symbol);
        __Ownable_init();
    }

    function mint(address _account, uint256 _amount) external onlyOwner {
        _mint(_account, _amount);
    }

    function burn(address _account, uint256 _amount) external onlyOwner {
        _burn(_account, _amount);
    }
}

File 2 of 19 : SystemSettings.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.6.12;
pragma experimental ABIEncoderV2;

// Inheritance
import "@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "./interface/ISystemSettings.sol";
import "./interface/IExchange.sol";
import "./interface/IInsuranceFund.sol";
// Libraries
import "./utils/Decimal.sol";

contract SystemSettings is OwnableUpgradeable, ISystemSettings {
    using Decimal for Decimal.decimal;
    using SafeMathUpgradeable for uint256;

    //
    // EVENTS
    //
    event InsuranceFundFeeRatioChanged(uint256 insuranceFundFeeRatio);
    event LpWithdrawFeeRatioChanged(uint256 lpWithdrawFeeRatio);
    event OvernightFeeRatioChanged(uint256 overnightFeeRatio);
    event OvernightFeeLpShareRatioChanged(uint256 overnightFeeLpShareRatio);
    event FundingFeeLpShareRatioChanged(uint256 fundingFeeLpShareRatio);
    event OvernightFeePeriodChanged(uint256 overnightFeePeriod);

    // only admin
    Decimal.decimal private _insuranceFundFeeRatio;

    // only admin
    Decimal.decimal private _lpWithdrawFeeRatio;

    // only admin
    Decimal.decimal private _overnightFeeRatio;

    // only admin
    Decimal.decimal private _overnightFeeLpShareRatio;

    // only admin
    Decimal.decimal private _fundingFeeLpShareRatio;

    // only admin
    bool public _paused;

    struct ExchangeMap {
        IInsuranceFund insuranceFund;
        bool existed;
        uint256 _nextOvernightFeeTime;
    }

    mapping(address => ExchangeMap) private exchangeMap;
    IExchange[] private exchanges;

    //only admin
    uint256 private _overnightFeePeriod;

    address public _sakePerp;
    //**********************************************************//
    //    Can not change the order of above state variables     //
    //**********************************************************//

    //◥◤◥◤◥◤◥◤◥◤◥◤◥◤◥◤ add state variables below ◥◤◥◤◥◤◥◤◥◤◥◤◥◤◥◤//

    //◢◣◢◣◢◣◢◣◢◣◢◣◢◣◢◣ add state variables above ◢◣◢◣◢◣◢◣◢◣◢◣◢◣◢◣//
    uint256[50] private __gap;

    //
    // MODIFIERS
    //
    modifier onlySakePerp() {
        require(msg.sender == _sakePerp, "only sakePerp");
        _;
    }

    //
    // External
    //
    function initialize(
        address sakePerp,
        uint256 insuranceFundFeeRatio,
        uint256 lpWithdrawFeeRatio,
        uint256 overnightFeeRatio,
        uint256 overnightFeeLpShareRatio,
        uint256 fundingFeeLpShareRatio,
        uint256 overnightFeePeriod
    ) public initializer {
        __Ownable_init();

        _sakePerp = sakePerp;
        _insuranceFundFeeRatio = Decimal.decimal(insuranceFundFeeRatio);
        _lpWithdrawFeeRatio = Decimal.decimal(lpWithdrawFeeRatio);
        _overnightFeeRatio = Decimal.decimal(overnightFeeRatio);
        _overnightFeeLpShareRatio = Decimal.decimal(overnightFeeLpShareRatio);
        _fundingFeeLpShareRatio = Decimal.decimal(fundingFeeLpShareRatio);
        _overnightFeePeriod = overnightFeePeriod;
    }

    /**
     * @notice set SakePerp dependency
     * @dev only owner can call
     * @param sakePerp address
     */

    function setSakePerp(address sakePerp) external onlyOwner {
        require(sakePerp != address(0), "empty address");
        _sakePerp = sakePerp;
    }

    /**
     * @notice set insurancefund fee  ratio
     * @dev only owner can call
     * @param insuranceFundFeeRatio new insurance fund ratio in 18 digits
     */
    function setInsuranceFundFeeRatio(Decimal.decimal memory insuranceFundFeeRatio) public onlyOwner {
        _insuranceFundFeeRatio = insuranceFundFeeRatio;
        emit InsuranceFundFeeRatioChanged(_insuranceFundFeeRatio.toUint());
    }

    /**
     * @notice set lpwithdraw fee  ratio
     * @dev only owner can call
     * @param lpWithdrawFeeRatio new lp withdraw fee ratio in 18 digits
     */
    function setLpWithdrawFeeRatio(Decimal.decimal memory lpWithdrawFeeRatio) public onlyOwner {
        _lpWithdrawFeeRatio = lpWithdrawFeeRatio;
        emit LpWithdrawFeeRatioChanged(_lpWithdrawFeeRatio.toUint());
    }

    /**
     * @notice set overnight fee ratio
     * @dev only owner can call
     * @param overnightFeeRatio new overnight fee ratio in 18 digits
     */
    function setOvernightFeeRatio(Decimal.decimal memory overnightFeeRatio) public onlyOwner {
        _overnightFeeRatio = overnightFeeRatio;
        emit OvernightFeeRatioChanged(_overnightFeeRatio.toUint());
    }

    /**
     * @notice set overnight fee period
     * @dev only owner can call
     * @param overnightFeePeriod new overnight fee period
     */
    function setOvernightFeePeriod(uint256 overnightFeePeriod) public onlyOwner {
        _overnightFeePeriod = overnightFeePeriod;
        emit OvernightFeeLpShareRatioChanged(_overnightFeeLpShareRatio.toUint());
    }

    /**
     * @notice set overnight fee lp share ratio
     * @dev only owner can call
     * @param overnightFeeLpShareRatio new overnight fee ratio in 18 digits
     */
    function setOvernightFeeLpShareRatio(Decimal.decimal memory overnightFeeLpShareRatio) public onlyOwner {
        _overnightFeeLpShareRatio = overnightFeeLpShareRatio;
        emit OvernightFeeLpShareRatioChanged(_overnightFeeLpShareRatio.toUint());
    }

    /**
     * @notice set
     * @dev only owner can call
     * @param fundingFeeLpShareRatio new funding fee lp share ratio in 18 digits
     */
    function setFundingFeeLpShareRatio(Decimal.decimal memory fundingFeeLpShareRatio) public onlyOwner {
        _fundingFeeLpShareRatio = fundingFeeLpShareRatio;
        emit FundingFeeLpShareRatioChanged(_fundingFeeLpShareRatio.toUint());
    }

    /**
     * @notice set next overnight fee time
     * @param _exchange exchange address
     */
    function setNextOvernightFeeTime(IExchange _exchange) public override onlySakePerp {
        require(
            _blockTimestamp() >= exchangeMap[address(_exchange)]._nextOvernightFeeTime,
            "pay overnight fee too early"
        );

        uint256 fundingPeriod = _overnightFeePeriod;
        uint256 fundingBufferPeriod = fundingPeriod.div(2);

        // in order to prevent multiple funding settlement during very short time after network congestion
        uint256 minNextValidOvernightFeeTime = _blockTimestamp().add(fundingBufferPeriod);

        // floor((nextFundingTime + fundingPeriod) / 3600) * 3600
        uint256 nextOvernightFeeTimeOnHourStart =
            exchangeMap[address(_exchange)]._nextOvernightFeeTime.add(fundingPeriod).div(1 hours).mul(1 hours);

        // max(nextFundingTimeOnHourStart, minNextValidFundingTime)
        exchangeMap[address(_exchange)]._nextOvernightFeeTime = nextOvernightFeeTimeOnHourStart >
            minNextValidOvernightFeeTime
            ? nextOvernightFeeTimeOnHourStart
            : minNextValidOvernightFeeTime;
    }

    /**
     * @dev only owner can call
     * @param _exchange IExchange address
     */
    function addExchange(IExchange _exchange, IInsuranceFund _insuranceFund) public onlyOwner {
        require(!isExistedExchange(_exchange), "exchange already added");
        exchangeMap[address(_exchange)].existed = true;
        exchangeMap[address(_exchange)].insuranceFund = _insuranceFund;
        exchanges.push(_exchange);

        exchangeMap[address(_exchange)]._nextOvernightFeeTime = _blockTimestamp()
            .add(_overnightFeePeriod)
            .div(1 hours)
            .mul(1 hours);
    }

    /**
     * @dev only owner can call. no need to call
     * @param _exchange IExchange address
     */
    function removeExchange(IExchange _exchange) external onlyOwner {
        require(isExistedExchange(_exchange), "amm not existed");
        exchangeMap[address(_exchange)].existed = false;
        exchangeMap[address(_exchange)].insuranceFund = IInsuranceFund(address(0));
        uint256 exchangeLength = exchanges.length;
        for (uint256 i = 0; i < exchangeLength; i++) {
            if (exchanges[i] == _exchange) {
                exchanges[i] = exchanges[exchangeLength - 1];
                exchanges.pop();
                break;
            }
        }
    }

    function isExistedExchange(IExchange _exchange) public view override returns (bool) {
        return exchangeMap[address(_exchange)].existed;
    }

    function getAllExchanges() external view override returns (IExchange[] memory) {
        return exchanges;
    }

    function getInsuranceFund(IExchange _exchange) public view override returns (IInsuranceFund) {
        return exchangeMap[address(_exchange)].insuranceFund;
    }

    function insuranceFundFeeRatio() external view override returns (Decimal.decimal memory) {
        return _insuranceFundFeeRatio;
    }

    /**
     * @notice get lp withdraw fee ratio
     * @return lp withdraw fee ratio in 18 digits
     */
    function lpWithdrawFeeRatio() external view override returns (Decimal.decimal memory) {
        return _lpWithdrawFeeRatio;
    }

    function overnightFeeRatio() external view override returns (Decimal.decimal memory) {
        return _overnightFeeRatio;
    }

    function overnightFeeLpShareRatio() external view override returns (Decimal.decimal memory) {
        return _overnightFeeLpShareRatio;
    }

    function fundingFeeLpShareRatio() external view override returns (Decimal.decimal memory) {
        return _fundingFeeLpShareRatio;
    }

    function overnightFeePeriod() external view override returns (uint256) {
        return _overnightFeePeriod;
    }

    function nextOvernightFeeTime(address _exchange) external view override returns (uint256) {
        return exchangeMap[address(_exchange)]._nextOvernightFeeTime;
    }

    function _blockTimestamp() internal view virtual returns (uint256) {
        return block.timestamp;
    }
}

File 3 of 19 : IExchange.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.6.12;
pragma experimental ABIEncoderV2;

import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import "../utils/Decimal.sol";
import "../utils/SignedDecimal.sol";
import "../types/ISakePerpVaultTypes.sol";
import "../types/IExchangeTypes.sol";
import "./IExchangeState.sol";

interface IExchange is IExchangeTypes {
    function swapInput(
        Dir _dir,
        Decimal.decimal calldata _quoteAssetAmount,
        Decimal.decimal calldata _baseAssetAmountLimit
    ) external returns (Decimal.decimal memory);

    function swapOutput(
        Dir _dir,
        Decimal.decimal calldata _baseAssetAmount,
        Decimal.decimal calldata _quoteAssetAmountLimit,
        bool _skipFluctuationCheck
    ) external returns (Decimal.decimal memory);

    function migrateLiquidity(Decimal.decimal calldata _liquidityMultiplier, Decimal.decimal calldata _priceLimitRatio)
        external;

    function shutdown() external;

    function settleFunding() external returns (SignedDecimal.signedDecimal memory);

    function calcFee(Decimal.decimal calldata _quoteAssetAmount) external view returns (Decimal.decimal memory);

    function calcBaseAssetAfterLiquidityMigration(
        SignedDecimal.signedDecimal memory _baseAssetAmount,
        Decimal.decimal memory _fromQuoteReserve,
        Decimal.decimal memory _fromBaseReserve
    ) external view returns (SignedDecimal.signedDecimal memory);

    function getInputTwap(Dir _dir, Decimal.decimal calldata _quoteAssetAmount)
        external
        view
        returns (Decimal.decimal memory);

    function getOutputTwap(Dir _dir, Decimal.decimal calldata _baseAssetAmount)
        external
        view
        returns (Decimal.decimal memory);

    function getInputPrice(Dir _dir, Decimal.decimal calldata _quoteAssetAmount)
        external
        view
        returns (Decimal.decimal memory);

    function getOutputPrice(Dir _dir, Decimal.decimal calldata _baseAssetAmount)
        external
        view
        returns (Decimal.decimal memory);

    function getInputPriceWithReserves(
        Dir _dir,
        Decimal.decimal memory _quoteAssetAmount,
        Decimal.decimal memory _quoteAssetPoolAmount,
        Decimal.decimal memory _baseAssetPoolAmount
    ) external view returns (Decimal.decimal memory);

    function getOutputPriceWithReserves(
        Dir _dir,
        Decimal.decimal memory _baseAssetAmount,
        Decimal.decimal memory _quoteAssetPoolAmount,
        Decimal.decimal memory _baseAssetPoolAmount
    ) external view returns (Decimal.decimal memory);

    function getSpotPrice() external view returns (Decimal.decimal memory);

    function getLiquidityHistoryLength() external view returns (uint256);

    // overridden by state variable
    function quoteAsset() external view returns (IERC20Upgradeable);

    function open() external view returns (bool);

    // can not be overridden by state variable due to type `Deciaml.decimal`
    function getSettlementPrice() external view returns (Decimal.decimal memory);

    function getCumulativeNotional() external view returns (SignedDecimal.signedDecimal memory);

    function getMaxHoldingBaseAsset() external view returns (Decimal.decimal memory);

    function getOpenInterestNotionalCap() external view returns (Decimal.decimal memory);

    function getLiquidityChangedSnapshots(uint256 i) external view returns (LiquidityChangedSnapshot memory);

    function mint(
        ISakePerpVaultTypes.Risk _level,
        address account,
        uint256 amount
    ) external;

    function burn(
        ISakePerpVaultTypes.Risk _level,
        address account,
        uint256 amount
    ) external;

    function getMMUnrealizedPNL(Decimal.decimal memory _baseAssetReserve, Decimal.decimal memory _quoteAssetReserve)
        external
        view
        returns (SignedDecimal.signedDecimal memory);

    function moveAMMPriceToOracle(uint256 _oraclePrice, bytes32 _priceFeedKey) external;

    function setPriceFeed(address _priceFeed) external;

    function getReserve() external view returns (Decimal.decimal memory, Decimal.decimal memory);

    function initMarginRatio() external view returns (Decimal.decimal memory);

    function maintenanceMarginRatio() external view returns (Decimal.decimal memory);

    function liquidationFeeRatio() external view returns (Decimal.decimal memory);

    function maxLiquidationFee() external view returns (Decimal.decimal memory);

    function spreadRatio() external view returns (Decimal.decimal memory);

    function priceFeedKey() external view returns (bytes32);

    function tradeLimitRatio() external view returns (uint256);

    function priceAdjustRatio() external view returns (uint256);

    function fluctuationLimitRatio() external view returns (uint256);

    function fundingPeriod() external view returns (uint256);

    function adjustTotalPosition(
        SignedDecimal.signedDecimal memory adjustedPosition,
        SignedDecimal.signedDecimal memory oldAdjustedPosition
    ) external;

    function getTotalPositionSize() external view returns (SignedDecimal.signedDecimal memory);

    function exchangeState() external view returns (IExchangeState);
}

File 4 of 19 : IExchangeState.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.6.12;
pragma experimental ABIEncoderV2;

import "../types/IExchangeTypes.sol";
import "../types/ISakePerpVaultTypes.sol";
import "../utils/Decimal.sol";
import "../utils/SignedDecimal.sol";
import "../MMLPToken.sol";

interface IExchangeState {
    function getMaxHoldingBaseAsset() external view returns (Decimal.decimal memory);

    function getOpenInterestNotionalCap() external view returns (Decimal.decimal memory);

    function initMarginRatio() external view returns (Decimal.decimal memory);

    function maintenanceMarginRatio() external view returns (Decimal.decimal memory);

    function liquidationFeeRatio() external view returns (Decimal.decimal memory);

    function maxLiquidationFee() external view returns (Decimal.decimal memory);

    function spreadRatio() external view returns (Decimal.decimal memory);

    function getInputPriceWithReserves(
        IExchangeTypes.Dir _dir,
        Decimal.decimal memory _quoteAssetAmount,
        Decimal.decimal memory _quoteAssetPoolAmount,
        Decimal.decimal memory _baseAssetPoolAmount
    ) external pure returns (Decimal.decimal memory);

    function getOutputPriceWithReserves(
        IExchangeTypes.Dir _dir,
        Decimal.decimal memory _baseAssetAmount,
        Decimal.decimal memory _quoteAssetPoolAmount,
        Decimal.decimal memory _baseAssetPoolAmount
    ) external pure returns (Decimal.decimal memory);

    function calcFee(Decimal.decimal calldata _quoteAssetAmount) external view returns (Decimal.decimal memory);

    function mint(
        ISakePerpVaultTypes.Risk _level,
        address account,
        uint256 amount
    ) external;

    function burn(
        ISakePerpVaultTypes.Risk _level,
        address account,
        uint256 amount
    ) external;

    function getLPToken(ISakePerpVaultTypes.Risk _level) external view returns (MMLPToken);
}

File 5 of 19 : IInsuranceFund.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.6.12;
pragma experimental ABIEncoderV2;

import "../utils/Decimal.sol";
import "./IExchange.sol";

interface IInsuranceFund {
    function withdraw(Decimal.decimal calldata _amount) external returns (Decimal.decimal memory badDebt);

    function setExchange(IExchange _exchange) external;

    function setBeneficiary(address _beneficiary) external;
}

File 6 of 19 : ISystemSettings.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.6.12;
pragma experimental ABIEncoderV2;

import "./IExchange.sol";
import "./IInsuranceFund.sol";
import "../utils/Decimal.sol";

interface ISystemSettings {
    function insuranceFundFeeRatio() external view returns (Decimal.decimal memory);

    function lpWithdrawFeeRatio() external view returns (Decimal.decimal memory);

    function overnightFeeRatio() external view returns (Decimal.decimal memory);

    function overnightFeeLpShareRatio() external view returns (Decimal.decimal memory);

    function fundingFeeLpShareRatio() external view returns (Decimal.decimal memory);

    function overnightFeePeriod() external view returns (uint256);

    function isExistedExchange(IExchange _exchange) external view returns (bool);

    function getAllExchanges() external view returns (IExchange[] memory);

    function getInsuranceFund(IExchange _exchange) external view returns (IInsuranceFund);

    function setNextOvernightFeeTime(IExchange _exchange) external;

    function nextOvernightFeeTime(address _exchange) external view returns (uint256);
}

File 7 of 19 : IExchangeTypes.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.6.12;
pragma experimental ABIEncoderV2;

import "../utils/Decimal.sol";
import "../utils/SignedDecimal.sol";

interface IExchangeTypes {
    /**
     * @notice asset direction, used in getInputPrice, getOutputPrice, swapInput and swapOutput
     * @param ADD_TO_AMM add asset to Amm
     * @param REMOVE_FROM_AMM remove asset from Amm
     */
    enum Dir {ADD_TO_AMM, REMOVE_FROM_AMM}

    struct LiquidityChangedSnapshot {
        SignedDecimal.signedDecimal cumulativeNotional;
        // the base/quote reserve of amm right before liquidity changed
        Decimal.decimal quoteAssetReserve;
        Decimal.decimal baseAssetReserve;
        // total position size owned by amm after last snapshot taken
        // `totalPositionSize` = currentBaseAssetReserve - lastLiquidityChangedHistoryItem.baseAssetReserve + prevTotalPositionSize
        SignedDecimal.signedDecimal totalPositionSize;
    }
}

File 8 of 19 : ISakePerpVaultTypes.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.6.12;
pragma experimental ABIEncoderV2;

interface ISakePerpVaultTypes {
    /**
     * @notice pool types
     * @param HIGH high risk pool
     * @param LOW low risk pool
     */
    enum Risk {HIGH, LOW}
}

File 9 of 19 : Decimal.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.6.12;

import "@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol";
import "./DecimalMath.sol";

library Decimal {
    using DecimalMath for uint256;
    using SafeMathUpgradeable for uint256;

    struct decimal {
        uint256 d;
    }

    function zero() internal pure returns (decimal memory) {
        return decimal(0);
    }

    function one() internal pure returns (decimal memory) {
        return decimal(DecimalMath.unit(18));
    }

    function toUint(decimal memory x) internal pure returns (uint256) {
        return x.d;
    }

    function modD(decimal memory x, decimal memory y) internal pure returns (decimal memory) {
        return decimal(x.d.mul(DecimalMath.unit(18)) % y.d);
    }

    function cmp(decimal memory x, decimal memory y) internal pure returns (int8) {
        if (x.d > y.d) {
            return 1;
        } else if (x.d < y.d) {
            return -1;
        }
        return 0;
    }

    /// @dev add two decimals
    function addD(decimal memory x, decimal memory y) internal pure returns (decimal memory) {
        decimal memory t;
        t.d = x.d.add(y.d);
        return t;
    }

    /// @dev subtract two decimals
    function subD(decimal memory x, decimal memory y) internal pure returns (decimal memory) {
        decimal memory t;
        t.d = x.d.sub(y.d);
        return t;
    }

    /// @dev multiple two decimals
    function mulD(decimal memory x, decimal memory y) internal pure returns (decimal memory) {
        decimal memory t;
        t.d = x.d.muld(y.d);
        return t;
    }

    /// @dev multiple a decimal by a uint256
    function mulScalar(decimal memory x, uint256 y) internal pure returns (decimal memory) {
        decimal memory t;
        t.d = x.d.mul(y);
        return t;
    }

    /// @dev divide two decimals
    function divD(decimal memory x, decimal memory y) internal pure returns (decimal memory) {
        decimal memory t;
        t.d = x.d.divd(y.d);
        return t;
    }

    /// @dev divide a decimal by a uint256
    function divScalar(decimal memory x, uint256 y) internal pure returns (decimal memory) {
        decimal memory t;
        t.d = x.d.div(y);
        return t;
    }
}

File 10 of 19 : DecimalMath.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.6.12;

import "@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol";

/// @dev Implements simple fixed point math add, sub, mul and div operations.
/// @author Alberto Cuesta Cañada
library DecimalMath {
    using SafeMathUpgradeable for uint256;

    /// @dev Returns 1 in the fixed point representation, with `decimals` decimals.
    function unit(uint8 decimals) internal pure returns (uint256) {
        return 10**uint256(decimals);
    }

    /// @dev Adds x and y, assuming they are both fixed point with 18 decimals.
    function addd(uint256 x, uint256 y) internal pure returns (uint256) {
        return x.add(y);
    }

    /// @dev Subtracts y from x, assuming they are both fixed point with 18 decimals.
    function subd(uint256 x, uint256 y) internal pure returns (uint256) {
        return x.sub(y);
    }

    /// @dev Multiplies x and y, assuming they are both fixed point with 18 digits.
    function muld(uint256 x, uint256 y) internal pure returns (uint256) {
        return muld(x, y, 18);
    }

    /// @dev Multiplies x and y, assuming they are both fixed point with `decimals` digits.
    function muld(
        uint256 x,
        uint256 y,
        uint8 decimals
    ) internal pure returns (uint256) {
        return x.mul(y).div(unit(decimals));
    }

    /// @dev Divides x between y, assuming they are both fixed point with 18 digits.
    function divd(uint256 x, uint256 y) internal pure returns (uint256) {
        return divd(x, y, 18);
    }

    /// @dev Divides x between y, assuming they are both fixed point with `decimals` digits.
    function divd(
        uint256 x,
        uint256 y,
        uint8 decimals
    ) internal pure returns (uint256) {
        return x.mul(unit(decimals)).div(y);
    }
}

File 11 of 19 : SignedDecimal.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.6.12;

import "@openzeppelin/contracts-upgradeable/math/SignedSafeMathUpgradeable.sol";
import "./SignedDecimalMath.sol";
import "./Decimal.sol";

library SignedDecimal {
    using SignedDecimalMath for int256;
    using SignedSafeMathUpgradeable for int256;

    struct signedDecimal {
        int256 d;
    }

    function zero() internal pure returns (signedDecimal memory) {
        return signedDecimal(0);
    }

    function toInt(signedDecimal memory x) internal pure returns (int256) {
        return x.d;
    }

    function isNegative(signedDecimal memory x) internal pure returns (bool) {
        if (x.d < 0) {
            return true;
        }
        return false;
    }

    function abs(signedDecimal memory x) internal pure returns (Decimal.decimal memory) {
        Decimal.decimal memory t;
        if (x.d < 0) {
            t.d = uint256(0 - x.d);
        } else {
            t.d = uint256(x.d);
        }
        return t;
    }

    /// @dev add two decimals
    function addD(signedDecimal memory x, signedDecimal memory y) internal pure returns (signedDecimal memory) {
        signedDecimal memory t;
        t.d = x.d.add(y.d);
        return t;
    }

    /// @dev subtract two decimals
    function subD(signedDecimal memory x, signedDecimal memory y) internal pure returns (signedDecimal memory) {
        signedDecimal memory t;
        t.d = x.d.sub(y.d);
        return t;
    }

    /// @dev multiple two decimals
    function mulD(signedDecimal memory x, signedDecimal memory y) internal pure returns (signedDecimal memory) {
        signedDecimal memory t;
        t.d = x.d.muld(y.d);
        return t;
    }

    /// @dev multiple a signedDecimal by a int256
    function mulScalar(signedDecimal memory x, int256 y) internal pure returns (signedDecimal memory) {
        signedDecimal memory t;
        t.d = x.d.mul(y);
        return t;
    }

    /// @dev divide two decimals
    function divD(signedDecimal memory x, signedDecimal memory y) internal pure returns (signedDecimal memory) {
        signedDecimal memory t;
        t.d = x.d.divd(y.d);
        return t;
    }

    /// @dev divide a signedDecimal by a int256
    function divScalar(signedDecimal memory x, int256 y) internal pure returns (signedDecimal memory) {
        signedDecimal memory t;
        t.d = x.d.div(y);
        return t;
    }
}

File 12 of 19 : SignedDecimalMath.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.6.12;

import "@openzeppelin/contracts-upgradeable/math/SignedSafeMathUpgradeable.sol";

/// @dev Implements simple signed fixed point math add, sub, mul and div operations.
library SignedDecimalMath {
    using SignedSafeMathUpgradeable for int256;

    /// @dev Returns 1 in the fixed point representation, with `decimals` decimals.
    function unit(uint8 decimals) internal pure returns (int256) {
        return int256(10**uint256(decimals));
    }

    /// @dev Adds x and y, assuming they are both fixed point with 18 decimals.
    function addd(int256 x, int256 y) internal pure returns (int256) {
        return x.add(y);
    }

    /// @dev Subtracts y from x, assuming they are both fixed point with 18 decimals.
    function subd(int256 x, int256 y) internal pure returns (int256) {
        return x.sub(y);
    }

    /// @dev Multiplies x and y, assuming they are both fixed point with 18 digits.
    function muld(int256 x, int256 y) internal pure returns (int256) {
        return muld(x, y, 18);
    }

    /// @dev Multiplies x and y, assuming they are both fixed point with `decimals` digits.
    function muld(
        int256 x,
        int256 y,
        uint8 decimals
    ) internal pure returns (int256) {
        return x.mul(y).div(unit(decimals));
    }

    /// @dev Divides x between y, assuming they are both fixed point with 18 digits.
    function divd(int256 x, int256 y) internal pure returns (int256) {
        return divd(x, y, 18);
    }

    /// @dev Divides x between y, assuming they are both fixed point with `decimals` digits.
    function divd(
        int256 x,
        int256 y,
        uint8 decimals
    ) internal pure returns (int256) {
        return x.mul(unit(decimals)).div(y);
    }
}

File 13 of 19 : ContextUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;
import "../proxy/Initializable.sol";

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

    function __Context_init_unchained() internal initializer {
    }
    function _msgSender() internal view virtual returns (address payable) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes memory) {
        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
        return msg.data;
    }
    uint256[50] private __gap;
}

File 14 of 19 : OwnableUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

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

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    function __Ownable_init() internal initializer {
        __Context_init_unchained();
        __Ownable_init_unchained();
    }

    function __Ownable_init_unchained() internal initializer {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }

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

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(_owner == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

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

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

File 15 of 19 : SafeMathUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeMathUpgradeable {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");

        return c;
    }

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

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;

        return c;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }

        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");

        return c;
    }

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

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

        return c;
    }

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

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

File 16 of 19 : SignedSafeMathUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @title SignedSafeMath
 * @dev Signed math operations with safety checks that revert on error.
 */
library SignedSafeMathUpgradeable {
    int256 constant private _INT256_MIN = -2**255;

    /**
     * @dev Returns the multiplication of two signed integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(int256 a, int256 b) internal pure returns (int256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }

        require(!(a == -1 && b == _INT256_MIN), "SignedSafeMath: multiplication overflow");

        int256 c = a * b;
        require(c / a == b, "SignedSafeMath: multiplication overflow");

        return c;
    }

    /**
     * @dev Returns the integer division of two signed integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(int256 a, int256 b) internal pure returns (int256) {
        require(b != 0, "SignedSafeMath: division by zero");
        require(!(b == -1 && a == _INT256_MIN), "SignedSafeMath: division overflow");

        int256 c = a / b;

        return c;
    }

    /**
     * @dev Returns the subtraction of two signed integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(int256 a, int256 b) internal pure returns (int256) {
        int256 c = a - b;
        require((b >= 0 && c <= a) || (b < 0 && c > a), "SignedSafeMath: subtraction overflow");

        return c;
    }

    /**
     * @dev Returns the addition of two signed integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(int256 a, int256 b) internal pure returns (int256) {
        int256 c = a + b;
        require((b >= 0 && c >= a) || (b < 0 && c < a), "SignedSafeMath: addition overflow");

        return c;
    }
}

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

// solhint-disable-next-line compiler-version
pragma solidity >=0.4.24 <0.8.0;


/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 * 
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {UpgradeableProxy-constructor}.
 * 
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 */
abstract contract Initializable {

    /**
     * @dev Indicates that the contract has been initialized.
     */
    bool private _initialized;

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

    /**
     * @dev Modifier to protect an initializer function from being invoked twice.
     */
    modifier initializer() {
        require(_initializing || _isConstructor() || !_initialized, "Initializable: contract is already initialized");

        bool isTopLevelCall = !_initializing;
        if (isTopLevelCall) {
            _initializing = true;
            _initialized = true;
        }

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }

    /// @dev Returns true if and only if the function is running in the constructor
    function _isConstructor() private view returns (bool) {
        // extcodesize checks the size of the code stored in an address, and
        // address returns the current address. Since the code is still not
        // deployed when running a constructor, any checks on its code size will
        // yield zero, making it an effective way to detect if a contract is
        // under construction or not.
        address self = address(this);
        uint256 cs;
        // solhint-disable-next-line no-inline-assembly
        assembly { cs := extcodesize(self) }
        return cs == 0;
    }
}

File 18 of 19 : ERC20Upgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

import "../../GSN/ContextUpgradeable.sol";
import "./IERC20Upgradeable.sol";
import "../../math/SafeMathUpgradeable.sol";
import "../../proxy/Initializable.sol";

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 * For a generic mechanism see {ERC20PresetMinterPauser}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * We have followed general OpenZeppelin guidelines: functions revert instead
 * of returning `false` on failure. This behavior is nonetheless conventional
 * and does not conflict with the expectations of ERC20 applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IERC20-approve}.
 */
contract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable {
    using SafeMathUpgradeable for uint256;

    mapping (address => uint256) private _balances;

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

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;
    uint8 private _decimals;

    /**
     * @dev Sets the values for {name} and {symbol}, initializes {decimals} with
     * a default value of 18.
     *
     * To select a different value for {decimals}, use {_setupDecimals}.
     *
     * All three of these values are immutable: they can only be set once during
     * construction.
     */
    function __ERC20_init(string memory name_, string memory symbol_) internal initializer {
        __Context_init_unchained();
        __ERC20_init_unchained(name_, symbol_);
    }

    function __ERC20_init_unchained(string memory name_, string memory symbol_) internal initializer {
        _name = name_;
        _symbol = symbol_;
        _decimals = 18;
    }

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

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

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

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

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

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

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

    /**
     * @dev See {IERC20-approve}.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        _approve(_msgSender(), spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * Requirements:
     *
     * - `sender` and `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     * - the caller must have allowance for ``sender``'s tokens of at least
     * `amount`.
     */
    function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(sender, recipient, amount);
        _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
        return true;
    }

    /**
     * @dev Atomically increases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
        return true;
    }

    /**
     * @dev Atomically decreases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `spender` must have allowance for the caller of at least
     * `subtractedValue`.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
        return true;
    }

    /**
     * @dev Moves tokens `amount` from `sender` to `recipient`.
     *
     * This is internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * Requirements:
     *
     * - `sender` cannot be the zero address.
     * - `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     */
    function _transfer(address sender, address recipient, uint256 amount) internal virtual {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(sender, recipient, amount);

        _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
        _balances[recipient] = _balances[recipient].add(amount);
        emit Transfer(sender, recipient, amount);
    }

    /** @dev Creates `amount` tokens and assigns them to `account`, increasing
     * the total supply.
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     */
    function _mint(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: mint to the zero address");

        _beforeTokenTransfer(address(0), account, amount);

        _totalSupply = _totalSupply.add(amount);
        _balances[account] = _balances[account].add(amount);
        emit Transfer(address(0), account, amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, reducing the
     * total supply.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     * - `account` must have at least `amount` tokens.
     */
    function _burn(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: burn from the zero address");

        _beforeTokenTransfer(account, address(0), amount);

        _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
        _totalSupply = _totalSupply.sub(amount);
        emit Transfer(account, address(0), amount);
    }

    /**
     * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
     *
     * This internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     */
    function _approve(address owner, address spender, uint256 amount) internal virtual {
        require(owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");

        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }

    /**
     * @dev Sets {decimals} to a value other than the default one of 18.
     *
     * WARNING: This function should only be called from the constructor. Most
     * applications that interact with token contracts will not expect
     * {decimals} to ever change, and may work incorrectly if it does.
     */
    function _setupDecimals(uint8 decimals_) internal {
        _decimals = decimals_;
    }

    /**
     * @dev Hook that is called before any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * will be to transferred to `to`.
     * - when `from` is zero, `amount` tokens will be minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
    uint256[44] private __gap;
}

File 19 of 19 : IERC20Upgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20Upgradeable {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

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

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

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

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

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

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

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

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"fundingFeeLpShareRatio","type":"uint256"}],"name":"FundingFeeLpShareRatioChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"insuranceFundFeeRatio","type":"uint256"}],"name":"InsuranceFundFeeRatioChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"lpWithdrawFeeRatio","type":"uint256"}],"name":"LpWithdrawFeeRatioChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"overnightFeeLpShareRatio","type":"uint256"}],"name":"OvernightFeeLpShareRatioChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"overnightFeePeriod","type":"uint256"}],"name":"OvernightFeePeriodChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"overnightFeeRatio","type":"uint256"}],"name":"OvernightFeeRatioChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[],"name":"_paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_sakePerp","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IExchange","name":"_exchange","type":"address"},{"internalType":"contract IInsuranceFund","name":"_insuranceFund","type":"address"}],"name":"addExchange","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"fundingFeeLpShareRatio","outputs":[{"components":[{"internalType":"uint256","name":"d","type":"uint256"}],"internalType":"struct Decimal.decimal","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAllExchanges","outputs":[{"internalType":"contract IExchange[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IExchange","name":"_exchange","type":"address"}],"name":"getInsuranceFund","outputs":[{"internalType":"contract IInsuranceFund","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"sakePerp","type":"address"},{"internalType":"uint256","name":"insuranceFundFeeRatio","type":"uint256"},{"internalType":"uint256","name":"lpWithdrawFeeRatio","type":"uint256"},{"internalType":"uint256","name":"overnightFeeRatio","type":"uint256"},{"internalType":"uint256","name":"overnightFeeLpShareRatio","type":"uint256"},{"internalType":"uint256","name":"fundingFeeLpShareRatio","type":"uint256"},{"internalType":"uint256","name":"overnightFeePeriod","type":"uint256"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"insuranceFundFeeRatio","outputs":[{"components":[{"internalType":"uint256","name":"d","type":"uint256"}],"internalType":"struct Decimal.decimal","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IExchange","name":"_exchange","type":"address"}],"name":"isExistedExchange","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lpWithdrawFeeRatio","outputs":[{"components":[{"internalType":"uint256","name":"d","type":"uint256"}],"internalType":"struct Decimal.decimal","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_exchange","type":"address"}],"name":"nextOvernightFeeTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"overnightFeeLpShareRatio","outputs":[{"components":[{"internalType":"uint256","name":"d","type":"uint256"}],"internalType":"struct Decimal.decimal","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"overnightFeePeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"overnightFeeRatio","outputs":[{"components":[{"internalType":"uint256","name":"d","type":"uint256"}],"internalType":"struct Decimal.decimal","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IExchange","name":"_exchange","type":"address"}],"name":"removeExchange","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"d","type":"uint256"}],"internalType":"struct Decimal.decimal","name":"fundingFeeLpShareRatio","type":"tuple"}],"name":"setFundingFeeLpShareRatio","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"d","type":"uint256"}],"internalType":"struct Decimal.decimal","name":"insuranceFundFeeRatio","type":"tuple"}],"name":"setInsuranceFundFeeRatio","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"d","type":"uint256"}],"internalType":"struct Decimal.decimal","name":"lpWithdrawFeeRatio","type":"tuple"}],"name":"setLpWithdrawFeeRatio","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IExchange","name":"_exchange","type":"address"}],"name":"setNextOvernightFeeTime","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"d","type":"uint256"}],"internalType":"struct Decimal.decimal","name":"overnightFeeLpShareRatio","type":"tuple"}],"name":"setOvernightFeeLpShareRatio","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"overnightFeePeriod","type":"uint256"}],"name":"setOvernightFeePeriod","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"d","type":"uint256"}],"internalType":"struct Decimal.decimal","name":"overnightFeeRatio","type":"tuple"}],"name":"setOvernightFeeRatio","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sakePerp","type":"address"}],"name":"setSakePerp","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]

608060405234801561001057600080fd5b5061150d806100206000396000f3fe608060405234801561001057600080fd5b506004361061018e5760003560e01c80638a6284c2116100de578063ada8788e11610097578063e50bda3811610071578063e50bda3814610313578063ed99da311461031b578063f0ccffef1461032e578063f2fde38b146103415761018e565b8063ada8788e146102f0578063b3f885f2146102f8578063ca6769f5146103005761018e565b80638a6284c2146102895780638d4235631461029c5780638da5cb5b146102af5780638e0be369146102b7578063914691bd146102ca5780639cade438146102dd5761018e565b8063575dc7b31161014b578063715018a611610125578063715018a61461023b5780637ed2958a146102435780637f604b45146102635780638142951a146102765761018e565b8063575dc7b31461021857806357de0c5b146102205780635da7c8ec146102335761018e565b806316c61ccc146101935780632119158f146101b1578063275348f1146101d157806329458529146101d957806337c03fb6146101ee5780633dd9738714610203575b600080fd5b61019b610354565b6040516101a89190611232565b60405180910390f35b6101c46101bf3660046110d4565b61035d565b6040516101a891906114b9565b6101c461037b565b6101e1610381565b6040516101a891906114af565b6101f661039d565b6040516101a891906111e5565b6102166102113660046110d4565b6103ff565b005b6101e1610485565b61019b61022e3660046110d4565b6104a1565b6101e16104c6565b6102166104e2565b6102566102513660046110d4565b610561565b6040516101a891906111d1565b610216610271366004611144565b61057f565b6102166102843660046110f0565b61069d565b61021661029736600461117c565b6107a0565b6102166102aa36600461117c565b61082d565b6102566108a2565b6102166102c53660046110d4565b6108b1565b6102166102d836600461117c565b610a13565b6102166102eb3660046111b9565b610a88565b6101e1610afd565b610256610b19565b61021661030e36600461117c565b610b28565b6101e1610b9d565b6102166103293660046110d4565b610bb9565b61021661033c36600461117c565b610cb4565b61021661034f3660046110d4565b610d29565b606a5460ff1681565b6001600160a01b03166000908152606b602052604090206001015490565b606d5490565b6103896110c1565b506040805160208101909152606654815290565b6060606c8054806020026020016040519081016040528092919081815260200182805480156103f557602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116103d7575b5050505050905090565b610407610de0565b6033546001600160a01b0390811691161461043d5760405162461bcd60e51b8152600401610434906113ec565b60405180910390fd5b6001600160a01b0381166104635760405162461bcd60e51b81526004016104349061130d565b606e80546001600160a01b0319166001600160a01b0392909216919091179055565b61048d6110c1565b506040805160208101909152606854815290565b6001600160a01b03166000908152606b6020526040902054600160a01b900460ff1690565b6104ce6110c1565b506040805160208101909152606954815290565b6104ea610de0565b6033546001600160a01b039081169116146105175760405162461bcd60e51b8152600401610434906113ec565b6033546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3603380546001600160a01b0319169055565b6001600160a01b039081166000908152606b60205260409020541690565b610587610de0565b6033546001600160a01b039081169116146105b45760405162461bcd60e51b8152600401610434906113ec565b6105bd826104a1565b156105da5760405162461bcd60e51b81526004016104349061147f565b6001600160a01b038083166000818152606b6020526040812080549385166001600160a01b031960ff60a01b19909516600160a01b178516179055606c805460018101825591527f2b4a51ab505fc96a0952efda2ba61bcd3078d4c02c39a186ec16f21883fbe016018054909216179055606d5461067a90610e109061067490829061066e90610668610de4565b90610de8565b90610e16565b90610e58565b6001600160a01b039092166000908152606b602052604090206001019190915550565b600054610100900460ff16806106b657506106b6610e92565b806106c4575060005460ff16155b6106e05760405162461bcd60e51b81526004016104349061135d565b600054610100900460ff1615801561070b576000805460ff1961ff0019909116610100171660011790555b610713610e98565b606e80546001600160a01b0319166001600160a01b038a16179055604080516020808201835290899052606589905581518082018352889052606688905581518082018352879052606787905581518082018352869052606886905581519081019091528390526069839055606d8290558015610796576000805461ff00191690555b5050505050505050565b6107a8610de0565b6033546001600160a01b039081169116146107d55760405162461bcd60e51b8152600401610434906113ec565b8051606881905560408051602081019091529081527f9848100361049da71143c7e565145bf681d3ace1002e4c651e1dcbc67d0f87119061081590610f2b565b60405161082291906114b9565b60405180910390a150565b610835610de0565b6033546001600160a01b039081169116146108625760405162461bcd60e51b8152600401610434906113ec565b8051606981905560408051602081019091529081527fbbed2535a3cc81cbec2bb70a929a01f1884d32b888174cf181762044c39e67029061081590610f2b565b6033546001600160a01b031690565b6108b9610de0565b6033546001600160a01b039081169116146108e65760405162461bcd60e51b8152600401610434906113ec565b6108ef816104a1565b61090b5760405162461bcd60e51b815260040161043490611334565b6001600160a01b0381166000908152606b6020526040812080546001600160a81b0319169055606c54905b81811015610a0e57826001600160a01b0316606c828154811061095557fe5b6000918252602090912001546001600160a01b03161415610a0657606c600183038154811061098057fe5b600091825260209091200154606c80546001600160a01b0390921691839081106109a657fe5b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550606c8054806109df57fe5b600082815260209020810160001990810180546001600160a01b0319169055019055610a0e565b600101610936565b505050565b610a1b610de0565b6033546001600160a01b03908116911614610a485760405162461bcd60e51b8152600401610434906113ec565b8051606681905560408051602081019091529081527f2046b3b23f3308135c4909307170e9c451797b0d5b0010a43ac55537874ba0059061081590610f2b565b610a90610de0565b6033546001600160a01b03908116911614610abd5760405162461bcd60e51b8152600401610434906113ec565b606d819055604080516020810190915260685481527f9848100361049da71143c7e565145bf681d3ace1002e4c651e1dcbc67d0f87119061081590610f2b565b610b056110c1565b506040805160208101909152606554815290565b606e546001600160a01b031681565b610b30610de0565b6033546001600160a01b03908116911614610b5d5760405162461bcd60e51b8152600401610434906113ec565b8051606581905560408051602081019091529081527f39e8a98b864997e5c86ae3887711e4b871e6f023e6b968feb7c75e41135764ff9061081590610f2b565b610ba56110c1565b506040805160208101909152606754815290565b606e546001600160a01b03163314610be35760405162461bcd60e51b815260040161043490611421565b6001600160a01b0381166000908152606b6020526040902060010154610c07610de4565b1015610c255760405162461bcd60e51b815260040161043490611448565b606d546000610c35826002610e16565b90506000610c4582610668610de4565b6001600160a01b0385166000908152606b602052604081206001015491925090610c7d90610e109061067490829061066e9089610de8565b9050818111610c8c5781610c8e565b805b6001600160a01b039095166000908152606b602052604090206001019490945550505050565b610cbc610de0565b6033546001600160a01b03908116911614610ce95760405162461bcd60e51b8152600401610434906113ec565b8051606781905560408051602081019091529081527f648c14aaad4917fb4b21a26204029346e658b9d13f49d7a4a1308ebf587240da9061081590610f2b565b610d31610de0565b6033546001600160a01b03908116911614610d5e5760405162461bcd60e51b8152600401610434906113ec565b6001600160a01b038116610d845760405162461bcd60e51b815260040161043490611290565b6033546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3603380546001600160a01b0319166001600160a01b0392909216919091179055565b3390565b4290565b600082820183811015610e0d5760405162461bcd60e51b8152600401610434906112d6565b90505b92915050565b6000610e0d83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250610f2f565b600082610e6757506000610e10565b82820282848281610e7457fe5b0414610e0d5760405162461bcd60e51b8152600401610434906113ab565b303b1590565b600054610100900460ff1680610eb15750610eb1610e92565b80610ebf575060005460ff16155b610edb5760405162461bcd60e51b81526004016104349061135d565b600054610100900460ff16158015610f06576000805460ff1961ff0019909116610100171660011790555b610f0e610f66565b610f16610fe7565b8015610f28576000805461ff00191690555b50565b5190565b60008183610f505760405162461bcd60e51b8152600401610434919061123d565b506000838581610f5c57fe5b0495945050505050565b600054610100900460ff1680610f7f5750610f7f610e92565b80610f8d575060005460ff16155b610fa95760405162461bcd60e51b81526004016104349061135d565b600054610100900460ff16158015610f16576000805460ff1961ff0019909116610100171660011790558015610f28576000805461ff001916905550565b600054610100900460ff16806110005750611000610e92565b8061100e575060005460ff16155b61102a5760405162461bcd60e51b81526004016104349061135d565b600054610100900460ff16158015611055576000805460ff1961ff0019909116610100171660011790555b600061105f610de0565b603380546001600160a01b0319166001600160a01b038316908117909155604051919250906000907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a3508015610f28576000805461ff001916905550565b6040518060200160405280600081525090565b6000602082840312156110e5578081fd5b8135610e0d816114c2565b600080600080600080600060e0888a03121561110a578283fd5b8735611115816114c2565b9960208901359950604089013598606081013598506080810135975060a0810135965060c00135945092505050565b60008060408385031215611156578182fd5b8235611161816114c2565b91506020830135611171816114c2565b809150509250929050565b60006020828403121561118d578081fd5b6040516020810181811067ffffffffffffffff821117156111ac578283fd5b6040529135825250919050565b6000602082840312156111ca578081fd5b5035919050565b6001600160a01b0391909116815260200190565b6020808252825182820181905260009190848201906040850190845b818110156112265783516001600160a01b031683529284019291840191600101611201565b50909695505050505050565b901515815260200190565b6000602080835283518082850152825b818110156112695785810183015185820160400152820161124d565b8181111561127a5783604083870101525b50601f01601f1916929092016040019392505050565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b6020808252600d908201526c656d707479206164647265737360981b604082015260600190565b6020808252600f908201526e185b5b481b9bdd08195e1a5cdd1959608a1b604082015260600190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252600d908201526c06f6e6c792073616b655065727609c1b604082015260600190565b6020808252601b908201527f706179206f7665726e696768742066656520746f6f206561726c790000000000604082015260600190565b602080825260169082015275195e18da185b99d948185b1c9958591e48185919195960521b604082015260600190565b9051815260200190565b90815260200190565b6001600160a01b0381168114610f2857600080fdfea2646970667358221220cee844493cd6ed1865113bba054266c76862b34fc3ee27e4ff4cff0c2d01653c64736f6c634300060c0033

Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading