Contract 0x68E8be77f3EB29074A83aE01007fA71cB5Cc5926

 

Contract Overview

Balance:
0 MATIC

MATIC Value:
$0.00

Token:
 
Txn Hash
Method
Block
From
To
Value [Txn Fee]
0xb6964ac665d294e0bd42d674b07fdb45fc71deeffbad34ce65729384bfffce5bSet Oracle233766032022-01-05 16:30:22508 days 1 hr ago0xcedad8c0ae5e0a878c01cc8c81e0ca2dba909ded IN  0x68e8be77f3eb29074a83ae01007fa71cb5cc59260 MATIC0.01948494670
0xe8032a0184d118d1805ebb95f1e136a679ab098e869d0f9a107ec5eb7ae24b5dSet Max Volume F...215297272021-11-18 21:47:28555 days 20 hrs ago0xcedad8c0ae5e0a878c01cc8c81e0ca2dba909ded IN  0x68e8be77f3eb29074a83ae01007fa71cb5cc59260 MATIC0.00562185195
0x530877d4a218f61dfb5d9ce1ae93166f7b57ae6efa912e34eb0ebce6e1f13847Set Close Max Vo...215177412021-11-18 13:45:06556 days 4 hrs ago0xcedad8c0ae5e0a878c01cc8c81e0ca2dba909ded IN  0x68e8be77f3eb29074a83ae01007fa71cb5cc59260 MATIC0.00346896120
0xa56d9970d74ce5a26624988d999c386735520a0bc954e1742e676907728c7c7bSet State Updato...214747312021-11-17 11:24:16557 days 7 hrs ago0xcedad8c0ae5e0a878c01cc8c81e0ca2dba909ded IN  0x68e8be77f3eb29074a83ae01007fa71cb5cc59260 MATIC0.00762234165
0xaf3d119234cc0d390aa81b071a41db5d56c1f34ef8c83186c8bf51d9132147abSet Oracle214747152021-11-17 11:23:44557 days 7 hrs ago0xcedad8c0ae5e0a878c01cc8c81e0ca2dba909ded IN  0x68e8be77f3eb29074a83ae01007fa71cb5cc59260 MATIC0.00433851165
0x1374872810677f5db3b8b50ebd03e9da8f43c11545e288523e2b18970f41e5c50x60008054214746882021-11-17 11:22:50557 days 7 hrs ago0xcedad8c0ae5e0a878c01cc8c81e0ca2dba909ded IN  Create: FeesCalculator0 MATIC0.53258403165
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
FeesCalculator

Compiler Version
v0.8.4+commit.c7e474f2

Optimization Enabled:
Yes with 100 runs

Other Settings:
default evmVersion
File 1 of 5 : FeesCalculator.sol
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8;

import "@openzeppelin/contracts/access/Ownable.sol";

import "./interfaces/IFeesCalculator.sol";

contract FeesCalculator is IFeesCalculator, Ownable {

    uint256 private constant PRECISION_DECIMALS = 1e10;

    uint256 private constant FUNDING_FEE_MIN_RATE = 2000;
    uint256 private constant FUNDING_FEE_MAX_RATE = 100000;
    uint256 private constant FUNDING_FEE_BASE_PERIOD = 1 days;

    uint256 private constant MAX_FUNDING_FEE_PERCENTAGE = 1000000;
    uint16 private constant CVI_DECIMALS = 100;

    uint16 private constant MAX_FUNDING_FEE_CVI_THRESHOLD = 55;
    uint16 private constant MIN_FUDNING_FEE_CVI_THRESHOLD = 150;
    uint16 private constant FUNDING_FEE_DIVISION_FACTOR = 5;

    uint16 private constant MAX_PERCENTAGE = 10000;

    uint16 private constant COLATERAL_VALUES_NUM = 101; // From 0.00 to 1.00 inclusive

    uint16 public maxCVIValue;

    uint16 public override depositFeePercent = 0;
    uint16 public override withdrawFeePercent = 0;
    uint16 public override openPositionFeePercent = 15;
    uint16 public override openPositionLPFeePercent = 15;
    uint16 public override closePositionLPFeePercent = 0;
    uint16 public buyingPremiumFeeMaxPercent = 1000;
    uint16 public closingPremiumFeeMaxPercent = 1000;
    uint16 public override closePositionFeePercent = 30;

    uint16 public buyingPremiumThreshold = 6500; // 1.0 is MAX_PERCENTAGE = 10000

    uint16 public closePositionMaxFeePercent = 300;

    uint16 public maxTurbulenceFeePercentToTrim = 100;
    uint16 public turbulenceStepPercent = 1000;
    uint16 public override turbulenceIndicatorPercent = 0;

    uint32 public adjustedVolumeTimestamp;
    uint16 public volumeTimeWindow = 2 hours;
    uint16 public volumeFeeTimeWindow = 1 hours;
    uint16 public maxVolumeFeeDeltaCollateral = 400; // 100% is MAX_PERCENTAGE = 10000
    uint16 public midVolumeFee = 0; // 100% is MAX_PERCENTAGE = 10000
    uint16 public maxVolumeFee = 130; // 100% is MAX_PERCENTAGE = 10000

    uint32 public closeAdjustedVolumeTimestamp;
    uint16 public closeVolumeTimeWindow = 2 hours;
    uint16 public closeVolumeFeeTimeWindow = 1 hours;
    uint16 public closeMaxVolumeFeeDeltaCollateral = 400; // 100% is MAX_PERCENTAGE = 10000
    uint16 public closeMidVolumeFee = 0; // 100% is MAX_PERCENTAGE = 10000
    uint16 public closeMaxVolumeFee = 80; // 100% is MAX_PERCENTAGE = 10000

    uint256 public oracleHeartbeatPeriod = 55 minutes;
    uint256 public closePositionFeeDecayPeriod = 24 hours;
    uint256 public fundingFeeConstantRate = 3000;

    uint16 public turbulenceDeviationThresholdPercent = 7000; // 1.0 is MAX_PERCENTAGE = 10000
    uint16 public turbulenceDeviationPercentage = 500; // 1.0 is MAX_PERCENTAGE = 10000

    uint16[] public collateralToBuyingPremiumMapping = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 6, 8, 9, 11, 14, 16, 20, 24, 29, 35, 42, 52, 63, 77, 94, 115, 140, 172, 212, 261, 323, 399, 495, 615, 765, 953, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000];

    ICVIOracle public cviOracle;
    address public stateUpdator;

    modifier onlyStateUpdator {
        require(msg.sender == stateUpdator, "Not allowed");
        _;
    }

    constructor(ICVIOracle _cviOracle, uint16 _maxCVIValue) {
        maxCVIValue = _maxCVIValue;
        cviOracle = _cviOracle;
    }

    function updateTurbulenceIndicatorPercent(uint256 _totalTime, uint256 _newRounds, uint16 _lastCVIValue, uint16 _currCVIValue) external override onlyStateUpdator {
        uint16 updatedTurbulenceIndicatorPercent = calculateTurbulenceIndicatorPercent(_totalTime, _newRounds, _lastCVIValue, _currCVIValue);

        if (updatedTurbulenceIndicatorPercent != turbulenceIndicatorPercent) {
            turbulenceIndicatorPercent = updatedTurbulenceIndicatorPercent;
        }
    }

    function updateAdjustedTimestamp(uint256 _collateralRatio, uint256 _lastCollateralRatio) external override onlyStateUpdator {
        uint256 deltaCollateral = _collateralRatio - _lastCollateralRatio; // Note: must be greater than 0
        adjustedVolumeTimestamp = getAdjustedTimestamp(adjustedVolumeTimestamp, deltaCollateral, volumeTimeWindow, maxVolumeFeeDeltaCollateral);
    }

    function updateCloseAdjustedTimestamp(uint256 _collateralRatio, uint256 _lastCollateralRatio) external override onlyStateUpdator {
        uint256 deltaCollateral = _lastCollateralRatio - _collateralRatio; // Note: must be greater than 0
        closeAdjustedVolumeTimestamp = getAdjustedTimestamp(closeAdjustedVolumeTimestamp, deltaCollateral, closeVolumeTimeWindow, closeMaxVolumeFeeDeltaCollateral);
    }

    function setOracle(ICVIOracle _cviOracle) external override onlyOwner {
        cviOracle = _cviOracle;
    }

    function setStateUpdator(address _newUpdator) external override onlyOwner {
        stateUpdator = _newUpdator;
    }

    function setDepositFee(uint16 _newDepositFeePercentage) external override onlyOwner {
        require(_newDepositFeePercentage < MAX_PERCENTAGE, "Fee exceeds maximum");
        depositFeePercent = _newDepositFeePercentage;
    }

    function setWithdrawFee(uint16 _newWithdrawFeePercentage) external override onlyOwner {
        require(_newWithdrawFeePercentage < MAX_PERCENTAGE, "Fee exceeds maximum");
        withdrawFeePercent = _newWithdrawFeePercentage;
    }

    function setOpenPositionFee(uint16 _newOpenPositionFeePercentage) external override onlyOwner {
        require(_newOpenPositionFeePercentage < MAX_PERCENTAGE, "Fee exceeds maximum");
        openPositionFeePercent = _newOpenPositionFeePercentage;
    }

    function setClosePositionFee(uint16 _newClosePositionFeePercentage) external override onlyOwner {
        require(_newClosePositionFeePercentage < MAX_PERCENTAGE, "Fee exceeds maximum");
        require(_newClosePositionFeePercentage <= closePositionMaxFeePercent, "Min fee above max fee");
        closePositionFeePercent = _newClosePositionFeePercentage;
    }

    function setOpenPositionLPFee(uint16 _newOpenPositionLPFeePercent) external override onlyOwner {
        require(_newOpenPositionLPFeePercent < MAX_PERCENTAGE, "Fee exceeds maximum");
        openPositionLPFeePercent = _newOpenPositionLPFeePercent;
    }

    function setClosePositionLPFee(uint16 _newClosePositionLPFeePercent) external override onlyOwner {
        require(_newClosePositionLPFeePercent < MAX_PERCENTAGE, "Fee exceeds maximum");
        closePositionLPFeePercent = _newClosePositionLPFeePercent;
    }

    function setClosePositionMaxFee(uint16 _newClosePositionMaxFeePercentage) external override onlyOwner {
        require(_newClosePositionMaxFeePercentage < MAX_PERCENTAGE, "Fee exceeds maximum");
        require(_newClosePositionMaxFeePercentage >= closePositionFeePercent, "Max fee below min fee");
        closePositionMaxFeePercent = _newClosePositionMaxFeePercentage;
    }

    function setClosePositionFeeDecay(uint256 _newClosePositionFeeDecayPeriod) external override onlyOwner {
        require(_newClosePositionFeeDecayPeriod > 0, "Period must be positive");
        closePositionFeeDecayPeriod = _newClosePositionFeeDecayPeriod;
    }

    function setOracleHeartbeatPeriod(uint256 _newOracleHeartbeatPeriod) external override onlyOwner {
        require(_newOracleHeartbeatPeriod > 0, "Heartbeat must be positive");
        oracleHeartbeatPeriod = _newOracleHeartbeatPeriod;
    }

    function setBuyingPremiumFeeMax(uint16 _newBuyingPremiumFeeMaxPercentage) external override onlyOwner {
        require(_newBuyingPremiumFeeMaxPercentage < MAX_PERCENTAGE, "Fee exceeds maximum");
        buyingPremiumFeeMaxPercent = _newBuyingPremiumFeeMaxPercentage;
    }

    function setBuyingPremiumThreshold(uint16 _newBuyingPremiumThreshold) external override onlyOwner {
        require(_newBuyingPremiumThreshold < MAX_PERCENTAGE, "Threshold exceeds maximum");
        buyingPremiumThreshold = _newBuyingPremiumThreshold;   
    }

    function setClosingPremiumFeeMax(uint16 _newClosingPremiumFeeMaxPercentage) external override onlyOwner {
        require(_newClosingPremiumFeeMaxPercentage < MAX_PERCENTAGE, "Fee exceeds maximum");
        closingPremiumFeeMaxPercent = _newClosingPremiumFeeMaxPercentage;
    }

    function setCollateralToBuyingPremiumMapping(uint16[] calldata _newCollateralToBuyingPremiumMapping) external override onlyOwner {
        require(_newCollateralToBuyingPremiumMapping.length == COLATERAL_VALUES_NUM, "Bad mapping size");
        collateralToBuyingPremiumMapping = _newCollateralToBuyingPremiumMapping;
    }

    function setFundingFeeConstantRate(uint16 _newfundingFeeConstantRate) external override onlyOwner {
        require(_newfundingFeeConstantRate < FUNDING_FEE_MAX_RATE, "Fee exceeds maximum");
        fundingFeeConstantRate = _newfundingFeeConstantRate;
    }

    function setTurbulenceStep(uint16 _newTurbulenceStepPercentage) external override onlyOwner {
        require(_newTurbulenceStepPercentage < MAX_PERCENTAGE, "Step exceeds maximum");
        turbulenceStepPercent = _newTurbulenceStepPercentage;
    }
    
    function setMaxTurbulenceFeePercentToTrim(uint16 _newMaxTurbulenceFeePercentToTrim) external override onlyOwner {
        require(_newMaxTurbulenceFeePercentToTrim < MAX_PERCENTAGE, "Fee exceeds maximum");
        maxTurbulenceFeePercentToTrim = _newMaxTurbulenceFeePercentToTrim;
    }

     function setTurbulenceDeviationThresholdPercent(uint16 _newTurbulenceDeviationThresholdPercent) external override onlyOwner {
        require(_newTurbulenceDeviationThresholdPercent < MAX_PERCENTAGE, "Threshold exceeds maximum");
        turbulenceDeviationThresholdPercent = _newTurbulenceDeviationThresholdPercent;
    }

    function setTurbulenceDeviationPercent(uint16 _newTurbulenceDeviationPercentage) external override onlyOwner {
        require(_newTurbulenceDeviationPercentage < MAX_PERCENTAGE, "Deviation exceeds maximum");
        turbulenceDeviationPercentage = _newTurbulenceDeviationPercentage;
    }

    function setVolumeTimeWindow(uint16 _newVolumeTimeWindow) external override onlyOwner {
        volumeTimeWindow = _newVolumeTimeWindow;
    }

    function setVolumeFeeTimeWindow(uint16 _newVolumeFeeTimeWindow) external override onlyOwner {
        volumeFeeTimeWindow = _newVolumeFeeTimeWindow;
    }

    function setMaxVolumeFeeDeltaCollateral(uint16 _newMaxVolumeFeeDeltaCollateral) external override onlyOwner {
        maxVolumeFeeDeltaCollateral = _newMaxVolumeFeeDeltaCollateral;
    }

    function setMidVolumeFee(uint16 _newMidVolumeFee) external override onlyOwner {
        midVolumeFee = _newMidVolumeFee;
    }

    function setMaxVolumeFee(uint16 _newMaxVolumeFee) external override onlyOwner {
        maxVolumeFee = _newMaxVolumeFee;
    }

    function setCloseVolumeTimeWindow(uint16 _newCloseVolumeTimeWindow) external override onlyOwner {
        closeVolumeTimeWindow = _newCloseVolumeTimeWindow;
    }

    function setCloseVolumeFeeTimeWindow(uint16 _newCloseVolumeFeeTimeWindow) external override onlyOwner {
        closeVolumeFeeTimeWindow = _newCloseVolumeFeeTimeWindow;
    }

    function setCloseMaxVolumeFeeDeltaCollateral(uint16 _newCloseMaxVolumeFeeDeltaCollateral) external override onlyOwner {
        closeMaxVolumeFeeDeltaCollateral = _newCloseMaxVolumeFeeDeltaCollateral;
    }

    function setCloseMidVolumeFee(uint16 _newCloseMidVolumeFee) external override onlyOwner {
        closeMidVolumeFee = _newCloseMidVolumeFee;
    }

    function setCloseMaxVolumeFee(uint16 _newCloseMaxVolumeFee) external override onlyOwner {
        closeMaxVolumeFee = _newCloseMaxVolumeFee;
    }

    function calculateTurbulenceIndicatorPercent(uint256 totalTime, uint256 newRounds, uint16 _lastCVIValue, uint16 _currCVIValue) public view override returns (uint16) {
        uint16 updatedTurbulenceIndicatorPercent = turbulenceIndicatorPercent;

        uint256 CVIDeltaPercent = uint256(_currCVIValue > _lastCVIValue ? (_currCVIValue - _lastCVIValue) : (_lastCVIValue - _currCVIValue)) * MAX_PERCENTAGE / _lastCVIValue;
        uint256 maxAllowedTurbulenceTimes = CVIDeltaPercent * MAX_PERCENTAGE / (uint256(turbulenceDeviationThresholdPercent) * turbulenceDeviationPercentage);

        uint256 decayTimes = 0;
        uint256 turbulenceTimes = 0;
        uint256 totalHeartbeats = totalTime / oracleHeartbeatPeriod;
        if (newRounds > totalHeartbeats) {
            turbulenceTimes = newRounds - totalHeartbeats;
            turbulenceTimes = turbulenceTimes >  maxAllowedTurbulenceTimes ? maxAllowedTurbulenceTimes : turbulenceTimes;
            decayTimes = newRounds - turbulenceTimes;
        } else {
            decayTimes = newRounds;
        }

        for (uint256 i = 0; i < decayTimes; i++) {
            updatedTurbulenceIndicatorPercent = updatedTurbulenceIndicatorPercent / 2;
        }

        if (updatedTurbulenceIndicatorPercent < maxTurbulenceFeePercentToTrim) {
            updatedTurbulenceIndicatorPercent = 0;
        }

        for (uint256 i = 0; i < turbulenceTimes; i++) {
            updatedTurbulenceIndicatorPercent = updatedTurbulenceIndicatorPercent + uint16(uint256(buyingPremiumFeeMaxPercent) * turbulenceStepPercent / MAX_PERCENTAGE);
        }

        if (updatedTurbulenceIndicatorPercent > buyingPremiumFeeMaxPercent) {
            updatedTurbulenceIndicatorPercent = buyingPremiumFeeMaxPercent;
        }

        return updatedTurbulenceIndicatorPercent;
    }

    function calculateBuyingPremiumFee(uint168 _tokenAmount, uint8 _leverage, uint256 _collateralRatio, uint256 _lastCollateralRatio, bool _withVolumeFee) external view override returns (uint168 buyingPremiumFee, uint16 combinedPremiumFeePercentage) {
        (buyingPremiumFee, combinedPremiumFeePercentage) =  _calculateBuyingPremiumFeeWithParameters(_tokenAmount, _leverage, _collateralRatio, _lastCollateralRatio, _withVolumeFee, turbulenceIndicatorPercent, adjustedVolumeTimestamp);
    }
    
    function calculateBuyingPremiumFeeWithAddendum(uint168 _tokenAmount, uint8 _leverage, uint256 _collateralRatio, uint256 _lastCollateralRatio, bool _withVolumeFee, uint16 _turbulenceIndicatorPercent) external view override returns (uint168 buyingPremiumFee, uint16 combinedPremiumFeePercentage) {
        (buyingPremiumFee, combinedPremiumFeePercentage) = _calculateBuyingPremiumFeeWithParameters(_tokenAmount, _leverage, _collateralRatio, _lastCollateralRatio, _withVolumeFee, 
            _turbulenceIndicatorPercent, getAdjustedTimestamp(adjustedVolumeTimestamp, _collateralRatio - _lastCollateralRatio, volumeTimeWindow, maxVolumeFeeDeltaCollateral));
    }

    function calculateClosingPremiumFee(uint256 /*_tokenAmount*/, uint256 /*_collateralRatio*/, uint256 /*_lastCollateralRatio*/, bool _withVolumeFee) external view override returns (uint16 combinedPremiumFeePercentage) {
        return _calculateClosingPremiumFee(_withVolumeFee, closeAdjustedVolumeTimestamp);
    }

    function calculateClosingPremiumFeeWithAddendum(uint256 _collateralRatio, uint256 _lastCollateralRatio, bool _withVolumeFee) external view override returns (uint16 combinedPremiumFeePercentage) {
        return _calculateClosingPremiumFee(_withVolumeFee,
            getAdjustedTimestamp(closeAdjustedVolumeTimestamp, _lastCollateralRatio - _collateralRatio, closeVolumeTimeWindow, closeMaxVolumeFeeDeltaCollateral));
    }

    function calculateSingleUnitFundingFee(CVIValue[] memory _cviValues) public override view returns (uint256 fundingFee) {
        for (uint8 i = 0; i < _cviValues.length; i++) {
            fundingFee = fundingFee + calculateSingleUnitPeriodFundingFee(_cviValues[i]);
        }
    }

    function updateSnapshots(uint256 _latestTimestamp, uint256 _blockTimestampSnapshot, uint256 _latestTimestampSnapshot, uint80 latestOracleRoundId) external override view returns (SnapshotUpdate memory snapshotUpdate) {
        (uint16 cviValue, uint80 periodEndRoundId, uint256 periodEndTimestamp) = cviOracle.getCVILatestRoundData();
        snapshotUpdate.cviValue = cviValue;
        snapshotUpdate.cviValueTimestamp = periodEndTimestamp;

        snapshotUpdate.latestSnapshot = _blockTimestampSnapshot;
        if (snapshotUpdate.latestSnapshot != 0) { // Block was already updated
            snapshotUpdate.singleUnitFundingFee = 0;
            return snapshotUpdate;
        }

        if (_latestTimestamp == 0) { // For first recorded block
            snapshotUpdate.latestSnapshot = PRECISION_DECIMALS;
            snapshotUpdate.updatedSnapshot = true;
            snapshotUpdate.newLatestRoundId = periodEndRoundId;
            snapshotUpdate.updatedLatestRoundId = true;
            snapshotUpdate.updatedLatestTimestamp = true;
            snapshotUpdate.singleUnitFundingFee = 0;
            return snapshotUpdate;
        }

        uint80 periodStartRoundId = latestOracleRoundId;
        require(periodEndRoundId >= periodStartRoundId, "Bad round id");

        snapshotUpdate.totalRounds = periodEndRoundId - periodStartRoundId;

        uint256 cviValuesNum = snapshotUpdate.totalRounds > 0 ? 2 : 1;
        IFeesCalculator.CVIValue[] memory cviValues = new IFeesCalculator.CVIValue[](cviValuesNum);
        
        if (snapshotUpdate.totalRounds > 0) {
            (uint16 periodStartCVIValue, uint256 periodStartTimestamp) = cviOracle.getCVIRoundData(periodStartRoundId);
            cviValues[0] = IFeesCalculator.CVIValue(periodEndTimestamp - _latestTimestamp, periodStartCVIValue);
            cviValues[1] = IFeesCalculator.CVIValue(block.timestamp - periodEndTimestamp, cviValue);

            snapshotUpdate.newLatestRoundId = periodEndRoundId;
            snapshotUpdate.updatedLatestRoundId = true;

            snapshotUpdate.totalTime = periodEndTimestamp - periodStartTimestamp;
            snapshotUpdate.updatedTurbulenceData = true;
        } else {
            cviValues[0] = IFeesCalculator.CVIValue(block.timestamp - _latestTimestamp, cviValue);
        }

        snapshotUpdate.singleUnitFundingFee = calculateSingleUnitFundingFee(cviValues);
        snapshotUpdate.latestSnapshot = _latestTimestampSnapshot + snapshotUpdate.singleUnitFundingFee;
        snapshotUpdate.updatedSnapshot = true;
        snapshotUpdate.updatedLatestTimestamp = true;
    }

    function calculateClosePositionFeePercent(uint256 _creationTimestamp, bool _isNoLockPositionAddress) external view override returns (uint16) {
        if (block.timestamp - _creationTimestamp >= closePositionFeeDecayPeriod || _isNoLockPositionAddress) {
            return closePositionFeePercent;
        }

        uint16 decay = uint16((closePositionMaxFeePercent - closePositionFeePercent) * (block.timestamp - _creationTimestamp) / 
            closePositionFeeDecayPeriod);
        return closePositionMaxFeePercent - decay;
    }

    function calculateWithdrawFeePercent(uint256) external view override returns (uint16) {
        return withdrawFeePercent;
    }

    function openPositionFees() external view override returns (uint16 openPositionFeePercentResult, uint16 buyingPremiumFeeMaxPercentResult) {
        openPositionFeePercentResult = openPositionFeePercent;
        buyingPremiumFeeMaxPercentResult = buyingPremiumFeeMaxPercent;
    }

    function calculateSingleUnitPeriodFundingFee(CVIValue memory _cviValue) private view returns (uint256 fundingFee) {
        if (_cviValue.cviValue == 0 || _cviValue.period == 0) {
            return 0;
        }

        uint256 fundingFeeRatePercents = FUNDING_FEE_MAX_RATE;
        uint16 integerCVIValue = _cviValue.cviValue / CVI_DECIMALS;
        if (integerCVIValue > MAX_FUNDING_FEE_CVI_THRESHOLD) {
            if (integerCVIValue >= MIN_FUDNING_FEE_CVI_THRESHOLD) {
                fundingFeeRatePercents = FUNDING_FEE_MIN_RATE;
            } else {
                // Defining as memory to keep function pure and save storage space + reads
                uint24[5] memory fundingFeeCoefficients = [100000, 114869, 131950, 151571, 174110];

                uint256 exponent = (integerCVIValue - MAX_FUNDING_FEE_CVI_THRESHOLD) / FUNDING_FEE_DIVISION_FACTOR;
                uint256 coefficientIndex = (integerCVIValue - MAX_FUNDING_FEE_CVI_THRESHOLD) % FUNDING_FEE_DIVISION_FACTOR;

                // Note: overflow is not possible as the exponent can only get larger, and other parts are constants
                // However, 2 ** exponent can overflow if cvi value is wrong

                require(exponent < 256, "exponent overflow");
                fundingFeeRatePercents = PRECISION_DECIMALS / (2 ** exponent) / fundingFeeCoefficients[coefficientIndex] + fundingFeeConstantRate;

                if (fundingFeeRatePercents > FUNDING_FEE_MAX_RATE) {
                    fundingFeeRatePercents = FUNDING_FEE_MAX_RATE;
                }
            }
        }

        return PRECISION_DECIMALS * _cviValue.cviValue * fundingFeeRatePercents * _cviValue.period /
            FUNDING_FEE_BASE_PERIOD / maxCVIValue / MAX_FUNDING_FEE_PERCENTAGE;
    }

    function _calculateBuyingPremiumFeeWithParameters(uint168 _tokenAmount, uint8 _leverage, uint256 _collateralRatio, uint256 _lastCollateralRatio, bool _withVolumeFee, uint16 _turbulenceIndicatorPercent, uint32 _adjustedVolumeTimestamp) private view returns (uint168 buyingPremiumFee, uint16 combinedPremiumFeePercentage) {
        require(_collateralRatio >= _lastCollateralRatio);

        uint16 buyingPremiumFeePercentage = 0;
        if (_collateralRatio >= PRECISION_DECIMALS) {
            buyingPremiumFeePercentage = calculateRelativePercentage(buyingPremiumFeeMaxPercent, _collateralRatio, _lastCollateralRatio);
        } else {
            if (_collateralRatio >= buyingPremiumThreshold * PRECISION_DECIMALS / MAX_PERCENTAGE) {
                buyingPremiumFeePercentage = calculateRelativePercentage(collateralToBuyingPremiumMapping[_collateralRatio * 10**2 / PRECISION_DECIMALS], _collateralRatio, _lastCollateralRatio);
            }
        }

        uint16 volumeFeePercentage = calculateVolumeFee(_withVolumeFee, _adjustedVolumeTimestamp, volumeTimeWindow, volumeFeeTimeWindow, midVolumeFee, maxVolumeFee);

        combinedPremiumFeePercentage = openPositionLPFeePercent + _turbulenceIndicatorPercent + buyingPremiumFeePercentage + volumeFeePercentage;
        if (combinedPremiumFeePercentage > buyingPremiumFeeMaxPercent) {
            combinedPremiumFeePercentage = buyingPremiumFeeMaxPercent;
        }

        uint256 __buyingPremiumFee = uint256(_tokenAmount) * _leverage * combinedPremiumFeePercentage / MAX_PERCENTAGE;
        buyingPremiumFee = uint168(__buyingPremiumFee);
        require(__buyingPremiumFee == buyingPremiumFee, "Too much tokens");
    }

    function _calculateClosingPremiumFee(bool _withVolumeFee, uint32 _adjustedCloseVolumeTimestamp) private view returns (uint16 combinedPremiumFeePercentage) {
        uint16 closingPremiumFeePercentage = calculateVolumeFee(_withVolumeFee, _adjustedCloseVolumeTimestamp, closeVolumeTimeWindow, closeVolumeFeeTimeWindow, closeMidVolumeFee, closeMaxVolumeFee);

        combinedPremiumFeePercentage = closePositionLPFeePercent + closingPremiumFeePercentage;
        if (combinedPremiumFeePercentage > closingPremiumFeeMaxPercent) {
            combinedPremiumFeePercentage = closingPremiumFeeMaxPercent;
        }
    }

    function calculateVolumeFee(bool _withVolumeFee, uint32 _adjustedVolumeTimestamp, uint16 _volumeTimeWindow, uint16 _volumeFeeTimeWindow, uint16 _midVolumeFee, uint16 _maxVolumeFee) private view returns (uint16 volumeFeePercentage) {
        if (_withVolumeFee) {
            if (_adjustedVolumeTimestamp < block.timestamp - _volumeFeeTimeWindow) {
                volumeFeePercentage = uint16(uint256(_midVolumeFee) * (_adjustedVolumeTimestamp - (block.timestamp - _volumeTimeWindow)) / (_volumeTimeWindow - _volumeFeeTimeWindow));
            } else {
                volumeFeePercentage = uint16(uint256(_midVolumeFee) + (_maxVolumeFee - _midVolumeFee) * (_adjustedVolumeTimestamp - (block.timestamp - _volumeFeeTimeWindow)) / _volumeFeeTimeWindow);
            }
        }
    }

    function calculateRelativePercentage(uint16 _percentage, uint256 _collateralRatio, uint256 _lastCollateralRatio) private view returns (uint16) {
        if (_lastCollateralRatio >= buyingPremiumThreshold * PRECISION_DECIMALS / MAX_PERCENTAGE || _collateralRatio == _lastCollateralRatio) {
            return _percentage;
        }

        return uint16(_percentage * (_collateralRatio - buyingPremiumThreshold * PRECISION_DECIMALS / MAX_PERCENTAGE) / (_collateralRatio - _lastCollateralRatio));
    }

    function getAdjustedTimestamp(uint32 _currAdjustedTimetamp, uint256 _deltaCollateral, uint16 _volumeTimeWindow, uint16 _maxVolumeFeeDeltaCollateral) private view returns (uint32 newAdjustedTimestamp) {
        newAdjustedTimestamp = _currAdjustedTimetamp;

        if (newAdjustedTimestamp < block.timestamp - _volumeTimeWindow) {
            newAdjustedTimestamp = uint32(block.timestamp) - _volumeTimeWindow;
        }

        newAdjustedTimestamp = uint32(newAdjustedTimestamp + uint256(_volumeTimeWindow) * _deltaCollateral / (_maxVolumeFeeDeltaCollateral * PRECISION_DECIMALS / MAX_PERCENTAGE));

        if (newAdjustedTimestamp > block.timestamp) {
            newAdjustedTimestamp = uint32(block.timestamp);
        }
    }
}

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

pragma solidity ^0.8.0;

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

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

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

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

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual 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 {
        _setOwner(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");
        _setOwner(newOwner);
    }

    function _setOwner(address newOwner) private {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

File 3 of 5 : IFeesCalculator.sol
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8;

import "./ICVIOracle.sol";

interface IFeesCalculator {

    struct CVIValue {
        uint256 period;
        uint16 cviValue;
    }

    struct SnapshotUpdate {
        uint256 latestSnapshot;
        uint256 singleUnitFundingFee;
        uint256 totalTime;
        uint256 totalRounds;
        uint256 cviValueTimestamp;
        uint80 newLatestRoundId;
        uint16 cviValue;
        bool updatedSnapshot;
        bool updatedLatestRoundId;
        bool updatedLatestTimestamp;
        bool updatedTurbulenceData;
    }

    function updateTurbulenceIndicatorPercent(uint256 totalTime, uint256 newRounds, uint16 lastCVIValue, uint16 currCVIValue) external;
    function updateAdjustedTimestamp(uint256 collateralRatio, uint256 lastCollateralRatio) external;
    function updateCloseAdjustedTimestamp(uint256 collateralRatio, uint256 lastCollateralRatio) external;

    function setOracle(ICVIOracle cviOracle) external;

    function setStateUpdator(address newUpdator) external;

    function setDepositFee(uint16 newDepositFeePercentage) external;
    function setWithdrawFee(uint16 newWithdrawFeePercentage) external;
    function setOpenPositionFee(uint16 newOpenPositionFeePercentage) external;
    function setOpenPositionLPFee(uint16 newOpenPositionLPFeePercent) external;
    function setClosePositionLPFee(uint16 newClosePositionLPFeePercent) external;
    function setClosePositionFee(uint16 newClosePositionFeePercentage) external;
    function setClosePositionMaxFee(uint16 newClosePositionMaxFeePercentage) external;
    function setClosePositionFeeDecay(uint256 newClosePositionFeeDecayPeriod) external;
    
    function setOracleHeartbeatPeriod(uint256 newOracleHeartbeatPeriod) external;
    function setBuyingPremiumFeeMax(uint16 newBuyingPremiumFeeMaxPercentage) external;
    function setBuyingPremiumThreshold(uint16 newBuyingPremiumThreshold) external;
    function setClosingPremiumFeeMax(uint16 newClosingPremiumFeeMaxPercentage) external;
    function setCollateralToBuyingPremiumMapping(uint16[] calldata newCollateralToBuyingPremiumMapping) external;
    function setFundingFeeConstantRate(uint16 newfundingFeeConstantRate) external;
    function setTurbulenceStep(uint16 newTurbulenceStepPercentage) external;
    function setMaxTurbulenceFeePercentToTrim(uint16 newMaxTurbulenceFeePercentToTrim) external;
    function setTurbulenceDeviationThresholdPercent(uint16 newTurbulenceDeviationThresholdPercent) external;
    function setTurbulenceDeviationPercent(uint16 newTurbulenceDeviationPercentage) external;

    function setVolumeTimeWindow(uint16 newVolumeTimeWindow) external;
    function setVolumeFeeTimeWindow(uint16 newVolumeFeeTimeWindow) external;
    function setMaxVolumeFeeDeltaCollateral(uint16 newMaxVolumeFeeDeltaCollateral) external;
    function setMidVolumeFee(uint16 newMidVolumeFee) external;
    function setMaxVolumeFee(uint16 newMaxVolumeFee) external;

    function setCloseVolumeTimeWindow(uint16 newCloseVolumeTimeWindow) external;
    function setCloseVolumeFeeTimeWindow(uint16 newCloseVolumeFeeTimeWindow) external;
    function setCloseMaxVolumeFeeDeltaCollateral(uint16 newCloseMaxVolumeFeeDeltaCollateral) external;
    function setCloseMidVolumeFee(uint16 newCloseMidVolumeFee) external;
    function setCloseMaxVolumeFee(uint16 newCloseMaxVolumeFee) external;

    function calculateTurbulenceIndicatorPercent(uint256 totalTime, uint256 newRounds, uint16 _lastCVIValue, uint16 _currCVIValue) external view returns (uint16);

    function calculateBuyingPremiumFee(uint168 tokenAmount, uint8 leverage, uint256 collateralRatio, uint256 lastCollateralRatio, bool withVolumeFee) external view returns (uint168 buyingPremiumFee, uint16 combinedPremiumFeePercentage);
    function calculateBuyingPremiumFeeWithAddendum(uint168 tokenAmount, uint8 leverage, uint256 collateralRatio, uint256 lastCollateralRatio, bool withVolumeFee, uint16 _turbulenceIndicatorPercent) external view returns (uint168 buyingPremiumFee, uint16 combinedPremiumFeePercentage);

    function calculateClosingPremiumFee(uint256 tokenAmount, uint256 collateralRatio, uint256 lastCollateralRatio, bool withVolumeFee) external view returns (uint16 combinedPremiumFeePercentage);
    function calculateClosingPremiumFeeWithAddendum(uint256 collateralRatio, uint256 lastCollateralRatio, bool withVolumeFee) external view returns (uint16 combinedPremiumFeePercentage);

    function calculateSingleUnitFundingFee(CVIValue[] memory cviValues) external view returns (uint256 fundingFee);
    function updateSnapshots(uint256 latestTimestamp, uint256 blockTimestampSnapshot, uint256 latestTimestampSnapshot, uint80 latestOracleRoundId) external view returns (SnapshotUpdate memory snapshotUpdate);

    function calculateClosePositionFeePercent(uint256 creationTimestamp, bool isNoLockPositionAddress) external view returns (uint16);
    function calculateWithdrawFeePercent(uint256 lastDepositTimestamp) external view returns (uint16);

    function depositFeePercent() external view returns (uint16);
    function withdrawFeePercent() external view returns (uint16);
    function openPositionFeePercent() external view returns (uint16);
    function closePositionFeePercent() external view returns (uint16);
    function openPositionLPFeePercent() external view returns (uint16);
    function closePositionLPFeePercent() external view returns (uint16);

    function openPositionFees() external view returns (uint16 openPositionFeePercentResult, uint16 buyingPremiumFeeMaxPercentResult);

    function turbulenceIndicatorPercent() external view returns (uint16);
}

File 4 of 5 : Context.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

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

File 5 of 5 : ICVIOracle.sol
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8;

interface ICVIOracle {
    function getCVIRoundData(uint80 roundId) external view returns (uint16 cviValue, uint256 cviTimestamp);
    function getCVILatestRoundData() external view returns (uint16 cviValue, uint80 cviRoundId, uint256 cviTimestamp);

    function setDeviationCheck(bool newDeviationCheck) external;
    function setMaxDeviation(uint16 newMaxDeviation) external;
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"contract ICVIOracle","name":"_cviOracle","type":"address"},{"internalType":"uint16","name":"_maxCVIValue","type":"uint16"}],"stateMutability":"nonpayable","type":"constructor"},{"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":"adjustedVolumeTimestamp","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"buyingPremiumFeeMaxPercent","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"buyingPremiumThreshold","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint168","name":"_tokenAmount","type":"uint168"},{"internalType":"uint8","name":"_leverage","type":"uint8"},{"internalType":"uint256","name":"_collateralRatio","type":"uint256"},{"internalType":"uint256","name":"_lastCollateralRatio","type":"uint256"},{"internalType":"bool","name":"_withVolumeFee","type":"bool"}],"name":"calculateBuyingPremiumFee","outputs":[{"internalType":"uint168","name":"buyingPremiumFee","type":"uint168"},{"internalType":"uint16","name":"combinedPremiumFeePercentage","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint168","name":"_tokenAmount","type":"uint168"},{"internalType":"uint8","name":"_leverage","type":"uint8"},{"internalType":"uint256","name":"_collateralRatio","type":"uint256"},{"internalType":"uint256","name":"_lastCollateralRatio","type":"uint256"},{"internalType":"bool","name":"_withVolumeFee","type":"bool"},{"internalType":"uint16","name":"_turbulenceIndicatorPercent","type":"uint16"}],"name":"calculateBuyingPremiumFeeWithAddendum","outputs":[{"internalType":"uint168","name":"buyingPremiumFee","type":"uint168"},{"internalType":"uint16","name":"combinedPremiumFeePercentage","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_creationTimestamp","type":"uint256"},{"internalType":"bool","name":"_isNoLockPositionAddress","type":"bool"}],"name":"calculateClosePositionFeePercent","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"_withVolumeFee","type":"bool"}],"name":"calculateClosingPremiumFee","outputs":[{"internalType":"uint16","name":"combinedPremiumFeePercentage","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_collateralRatio","type":"uint256"},{"internalType":"uint256","name":"_lastCollateralRatio","type":"uint256"},{"internalType":"bool","name":"_withVolumeFee","type":"bool"}],"name":"calculateClosingPremiumFeeWithAddendum","outputs":[{"internalType":"uint16","name":"combinedPremiumFeePercentage","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"period","type":"uint256"},{"internalType":"uint16","name":"cviValue","type":"uint16"}],"internalType":"struct IFeesCalculator.CVIValue[]","name":"_cviValues","type":"tuple[]"}],"name":"calculateSingleUnitFundingFee","outputs":[{"internalType":"uint256","name":"fundingFee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"totalTime","type":"uint256"},{"internalType":"uint256","name":"newRounds","type":"uint256"},{"internalType":"uint16","name":"_lastCVIValue","type":"uint16"},{"internalType":"uint16","name":"_currCVIValue","type":"uint16"}],"name":"calculateTurbulenceIndicatorPercent","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"calculateWithdrawFeePercent","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"closeAdjustedVolumeTimestamp","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"closeMaxVolumeFee","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"closeMaxVolumeFeeDeltaCollateral","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"closeMidVolumeFee","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"closePositionFeeDecayPeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"closePositionFeePercent","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"closePositionLPFeePercent","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"closePositionMaxFeePercent","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"closeVolumeFeeTimeWindow","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"closeVolumeTimeWindow","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"closingPremiumFeeMaxPercent","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"collateralToBuyingPremiumMapping","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"cviOracle","outputs":[{"internalType":"contract ICVIOracle","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"depositFeePercent","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"fundingFeeConstantRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxCVIValue","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxTurbulenceFeePercentToTrim","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxVolumeFee","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxVolumeFeeDeltaCollateral","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"midVolumeFee","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"openPositionFeePercent","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"openPositionFees","outputs":[{"internalType":"uint16","name":"openPositionFeePercentResult","type":"uint16"},{"internalType":"uint16","name":"buyingPremiumFeeMaxPercentResult","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"openPositionLPFeePercent","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"oracleHeartbeatPeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_newBuyingPremiumFeeMaxPercentage","type":"uint16"}],"name":"setBuyingPremiumFeeMax","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_newBuyingPremiumThreshold","type":"uint16"}],"name":"setBuyingPremiumThreshold","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_newCloseMaxVolumeFee","type":"uint16"}],"name":"setCloseMaxVolumeFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_newCloseMaxVolumeFeeDeltaCollateral","type":"uint16"}],"name":"setCloseMaxVolumeFeeDeltaCollateral","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_newCloseMidVolumeFee","type":"uint16"}],"name":"setCloseMidVolumeFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_newClosePositionFeePercentage","type":"uint16"}],"name":"setClosePositionFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newClosePositionFeeDecayPeriod","type":"uint256"}],"name":"setClosePositionFeeDecay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_newClosePositionLPFeePercent","type":"uint16"}],"name":"setClosePositionLPFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_newClosePositionMaxFeePercentage","type":"uint16"}],"name":"setClosePositionMaxFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_newCloseVolumeFeeTimeWindow","type":"uint16"}],"name":"setCloseVolumeFeeTimeWindow","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_newCloseVolumeTimeWindow","type":"uint16"}],"name":"setCloseVolumeTimeWindow","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_newClosingPremiumFeeMaxPercentage","type":"uint16"}],"name":"setClosingPremiumFeeMax","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16[]","name":"_newCollateralToBuyingPremiumMapping","type":"uint16[]"}],"name":"setCollateralToBuyingPremiumMapping","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_newDepositFeePercentage","type":"uint16"}],"name":"setDepositFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_newfundingFeeConstantRate","type":"uint16"}],"name":"setFundingFeeConstantRate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_newMaxTurbulenceFeePercentToTrim","type":"uint16"}],"name":"setMaxTurbulenceFeePercentToTrim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_newMaxVolumeFee","type":"uint16"}],"name":"setMaxVolumeFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_newMaxVolumeFeeDeltaCollateral","type":"uint16"}],"name":"setMaxVolumeFeeDeltaCollateral","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_newMidVolumeFee","type":"uint16"}],"name":"setMidVolumeFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_newOpenPositionFeePercentage","type":"uint16"}],"name":"setOpenPositionFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_newOpenPositionLPFeePercent","type":"uint16"}],"name":"setOpenPositionLPFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ICVIOracle","name":"_cviOracle","type":"address"}],"name":"setOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newOracleHeartbeatPeriod","type":"uint256"}],"name":"setOracleHeartbeatPeriod","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newUpdator","type":"address"}],"name":"setStateUpdator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_newTurbulenceDeviationPercentage","type":"uint16"}],"name":"setTurbulenceDeviationPercent","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_newTurbulenceDeviationThresholdPercent","type":"uint16"}],"name":"setTurbulenceDeviationThresholdPercent","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_newTurbulenceStepPercentage","type":"uint16"}],"name":"setTurbulenceStep","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_newVolumeFeeTimeWindow","type":"uint16"}],"name":"setVolumeFeeTimeWindow","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_newVolumeTimeWindow","type":"uint16"}],"name":"setVolumeTimeWindow","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_newWithdrawFeePercentage","type":"uint16"}],"name":"setWithdrawFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stateUpdator","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"turbulenceDeviationPercentage","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"turbulenceDeviationThresholdPercent","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"turbulenceIndicatorPercent","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"turbulenceStepPercent","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_collateralRatio","type":"uint256"},{"internalType":"uint256","name":"_lastCollateralRatio","type":"uint256"}],"name":"updateAdjustedTimestamp","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_collateralRatio","type":"uint256"},{"internalType":"uint256","name":"_lastCollateralRatio","type":"uint256"}],"name":"updateCloseAdjustedTimestamp","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_latestTimestamp","type":"uint256"},{"internalType":"uint256","name":"_blockTimestampSnapshot","type":"uint256"},{"internalType":"uint256","name":"_latestTimestampSnapshot","type":"uint256"},{"internalType":"uint80","name":"latestOracleRoundId","type":"uint80"}],"name":"updateSnapshots","outputs":[{"components":[{"internalType":"uint256","name":"latestSnapshot","type":"uint256"},{"internalType":"uint256","name":"singleUnitFundingFee","type":"uint256"},{"internalType":"uint256","name":"totalTime","type":"uint256"},{"internalType":"uint256","name":"totalRounds","type":"uint256"},{"internalType":"uint256","name":"cviValueTimestamp","type":"uint256"},{"internalType":"uint80","name":"newLatestRoundId","type":"uint80"},{"internalType":"uint16","name":"cviValue","type":"uint16"},{"internalType":"bool","name":"updatedSnapshot","type":"bool"},{"internalType":"bool","name":"updatedLatestRoundId","type":"bool"},{"internalType":"bool","name":"updatedLatestTimestamp","type":"bool"},{"internalType":"bool","name":"updatedTurbulenceData","type":"bool"}],"internalType":"struct IFeesCalculator.SnapshotUpdate","name":"snapshotUpdate","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_totalTime","type":"uint256"},{"internalType":"uint256","name":"_newRounds","type":"uint256"},{"internalType":"uint16","name":"_lastCVIValue","type":"uint16"},{"internalType":"uint16","name":"_currCVIValue","type":"uint16"}],"name":"updateTurbulenceIndicatorPercent","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"volumeFeeTimeWindow","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"volumeTimeWindow","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdrawFeePercent","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"}]

60008054620f000f60d01b6001600160b01b03909116178155600180547fffff00000000000000000000ffffffff00000000000000000000000000000000167c82000001900e101c2000000000000003e80064012c1964001e03e803e817905560028054600160201b600160701b0319166c50000001900e101c2000000000179055610ce460035562015180600455610bb860059081556006805463ffffffff19166301f41b58178155610d20604052608083815260a084905260c084905260e08490526101008490526101208490526101408490526101608490526101808490526101a08490526101c08490526101e08490526102008490526102208490526102408490526102608490526102808490526102a08490526102c08490526102e08490526103008490526103208490526103408490526103608490526103808490526103a08490526103c08490526103e08490526104008490526104208490526104408490526104608490526104808490526104a08490526104c08490526104e08490526105008490526105208490526105408490526105608490526105808490526105a08490526105c08490526105e08490526106008490526106208490526106408490526106608490526106808490526106a08490526106c08490526106e08490526107008490526107208490526107408490526107608490526107808490526107a08490526107c08490526107e0849052610800849052610820849052610840849052610860849052610880939093526108a0919091526108c05260086108e052600961090052600b61092052600e6109405260106109605260146109805260186109a052601d6109c05260236109e052602a610a00526034610a2052603f610a4052604d610a6052605e610a80526073610aa052608c610ac05260ac610ae05260d4610b0052610105610b2052610143610b405261018f610b60526101ef610b8052610267610ba0526102fd610bc0526103b9610be0526103e8610c00819052610c20819052610c40819052610c60819052610c80819052610ca0819052610cc0819052610ce0819052610d005262000321906007906065620003f4565b503480156200032f57600080fd5b5060405162003850380380620038508339810160408190526200035291620004bb565b6200035d33620003a4565b6000805461ffff909216600160a01b0261ffff60a01b19909216919091179055600880546001600160a01b039092166001600160a01b031990921691909117905562000508565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b82805482825590600052602060002090600f01601090048101928215620004925791602002820160005b838211156200046057835183826101000a81548161ffff021916908361ffff16021790555092602001926002016020816001010492830192600103026200041e565b8015620004905782816101000a81549061ffff021916905560020160208160010104928301926001030262000460565b505b50620004a0929150620004a4565b5090565b5b80821115620004a05760008155600101620004a5565b60008060408385031215620004ce578182fd5b82516001600160a01b0381168114620004e5578283fd5b602084015190925061ffff81168114620004fd578182fd5b809150509250929050565b61333880620005186000396000f3fe608060405234801561001057600080fd5b506004361061047f5760003560e01c806390bece4f11610257578063c4680a7111610146578063de732b73116100c3578063f2fde38b11610087578063f2fde38b14610aa6578063f359b46f14610ab9578063f3ce730514610ace578063f751b10714610ae2578063f948b5eb14610af757600080fd5b8063de732b7314610a4a578063dfc4d21314610a5d578063e32d794314610a6b578063e6df898f14610a7e578063e898f33314610a9357600080fd5b8063d7db90c11161010a578063d7db90c1146109f3578063d8846a00146109fc578063d934c20b14610a0f578063d9649b3914610a24578063db9c778b14610a3757600080fd5b8063c4680a711461098e578063cb7241e5146109a3578063cc1252ae146109b6578063cdb3632a146109cb578063d500b42d146109e057600080fd5b8063aac926a0116101d4578063c11387d111610198578063c11387d114610909578063c1176c801461091c578063c31f3f7714610931578063c38e078414610944578063c39ae1691461097957600080fd5b8063aac926a0146108a8578063af2f18c5146108bb578063b0df807d146108ce578063b3d50321146108e1578063baed3a2e146108f657600080fd5b8063a2028d971161021b578063a2028d9714610851578063a3fe27c014610866578063a4b2202714610879578063a6fa3a1514610882578063aa1ae8281461089557600080fd5b806390bece4f146107da578063923d63d3146107ff5780639c631339146108165780639fcf772614610829578063a0722f091461083c57600080fd5b806350e0942b11610373578063759dbcad116102f05780637fdaf750116102b45780637fdaf7501461077557806381005cc314610788578063816f133a146107a85780638a12e1c9146107bd5780638da5cb5b146107d257600080fd5b8063759dbcad146106fb57806376ebae42146107125780637adbf973146107275780637e306de91461073a5780637e3dd0f01461074d57600080fd5b806366733a781161033757806366733a78146106a5578063667dd316146106ba5780636bb1aa4b146106cd5780636f7d7828146106e0578063715018a6146106f357600080fd5b806350e0942b1461062a57806354d16c881461063f57806360b478da14610652578063619a5567146106675780636266124e1461069257600080fd5b80632c1387a71161040157806334fb45f4116103c557806334fb45f4146105c5578063358a123f146105d85780633a087eb7146105eb578063406cab1614610600578063495ef7051461061557600080fd5b80632c1387a71461056b5780632cda452a1461057e5780633017ac171461058c578063322ce8f01461059f578063344a8a28146105b257600080fd5b80630f9076cc116104485780630f9076cc146104ff5780630fe212641461051f5780631ce4e15b146105325780631f3a182414610545578063230f9fca1461055857600080fd5b806236c69a14610484578063024c559714610499578063044b7b57146104ac57806308010273146104bf5780630dbc53bd146104d2575b600080fd5b610497610492366004612bdc565b610b0b565b005b6104976104a7366004612d26565b610b80565b6104976104ba366004612a7d565b610c04565b6104976104cd366004612bdc565b610c55565b6002546104e790600160301b900461ffff1681565b60405161ffff90911681526020015b60405180910390f35b61051261050d366004612e45565b610ca6565b6040516104f69190612f34565b61049761052d366004612bdc565b6110d2565b6104e7610540366004612dbe565b611148565b610497610553366004612bdc565b6112eb565b6104e7610566366004612d8a565b611349565b610497610579366004612bdc565b611395565b6006546104e79061ffff1681565b61049761059a366004612bdc565b6113e6565b6104976105ad366004612bdc565b61145c565b6104976105c0366004612bdc565b6114d2565b6104976105d3366004612bdc565b611523565b6104976105e6366004612b6c565b6115c0565b6001546104e790600160301b900461ffff1681565b6001546104e790600160601b900461ffff1681565b6000546104e790600160c01b900461ffff1681565b6000546104e790600160f01b900461ffff1681565b61049761064d366004612bdc565b611643565b6001546104e790600160e01b900461ffff1681565b60095461067a906001600160a01b031681565b6040516001600160a01b0390911681526020016104f6565b6104976106a0366004612bdc565b611694565b6001546104e790600160201b900461ffff1681565b6104976106c8366004612dbe565b61170a565b6104976106db366004612bdc565b61177e565b60085461067a906001600160a01b031681565b6104976117d0565b61070460055481565b6040519081526020016104f6565b6000546104e790600160e01b900461ffff1681565b610497610735366004612a7d565b61180b565b610497610748366004612d69565b61185c565b60005460015460408051600160d01b90930461ffff90811684529091166020830152016104f6565b610497610783366004612bdc565b6118df565b6104e7610796366004612d26565b50600054600160c01b900461ffff1690565b6001546104e790600160b01b900461ffff1681565b6002546104e790600160501b900461ffff1681565b61067a61197f565b6002546107ea9063ffffffff1681565b60405163ffffffff90911681526020016104f6565b6001546107ea90600160801b900463ffffffff1681565b610497610824366004612bdc565b61198e565b610497610837366004612d69565b6119fa565b6002546104e790600160601b900461ffff1681565b6000546104e790600160d01b900461ffff1681565b610497610874366004612bdc565b611a89565b61070460045481565b6104e7610890366004612d26565b611afd565b6104e76108a3366004612d3e565b611b35565b6104976108b6366004612bdc565b611bd7565b6104976108c9366004612bdc565b611c28565b6104976108dc366004612bdc565b611c9e565b6001546104e790600160c01b900461ffff1681565b610704610904366004612a99565b611d6d565b610497610917366004612bdc565b611dd4565b6001546104e790600160501b900461ffff1681565b61049761093f366004612bdc565b611ea4565b610957610952366004612c4e565b611ef5565b604080516001600160a81b03909316835261ffff9091166020830152016104f6565b6001546104e790600160a01b900461ffff1681565b6002546104e790600160401b900461ffff1681565b6104976109b1366004612bdc565b611f54565b6000546104e790600160b01b900461ffff1681565b6001546104e790600160401b900461ffff1681565b6104976109ee366004612bdc565b611fca565b61070460035481565b610497610a0a366004612bdc565b61201b565b6000546104e790600160a01b900461ffff1681565b6104e7610a32366004612e07565b61206c565b610497610a45366004612d26565b61208c565b610957610a58366004612bf8565b61210a565b6001546104e79061ffff1681565b610497610a79366004612bdc565b61214c565b6002546104e790600160201b900461ffff1681565b610497610aa1366004612bdc565b6121c3565b610497610ab4366004612a7d565b612214565b6001546104e790600160701b900461ffff1681565b6001546104e79062010000900461ffff1681565b6001546104e790600160d01b900461ffff1681565b6006546104e79062010000900461ffff1681565b33610b1461197f565b6001600160a01b031614610b435760405162461bcd60e51b8152600401610b3a90612ecc565b60405180910390fd5b61271061ffff821610610b685760405162461bcd60e51b8152600401610b3a90612f01565b6006805461ffff191661ffff92909216919091179055565b33610b8961197f565b6001600160a01b031614610baf5760405162461bcd60e51b8152600401610b3a90612ecc565b60008111610bff5760405162461bcd60e51b815260206004820152601a60248201527f486561727462656174206d75737420626520706f7369746976650000000000006044820152606401610b3a565b600355565b33610c0d61197f565b6001600160a01b031614610c335760405162461bcd60e51b8152600401610b3a90612ecc565b600980546001600160a01b0319166001600160a01b0392909216919091179055565b33610c5e61197f565b6001600160a01b031614610c845760405162461bcd60e51b8152600401610b3a90612ecc565b6001805461ffff909216600160a01b0261ffff60a01b19909216919091179055565b604080516101608101825260008082526020820181905281830181905260608083018290526080830182905260a0830182905260c0830182905260e08301829052610100830182905261012083018290526101408301829052600854845163c1639a2b60e01b8152945193949293849384936001600160a01b039093169263c1639a2b92600480840193829003018186803b158015610d4457600080fd5b505afa158015610d58573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d7c9190612ce4565b61ffff831660c088015260808701819052898752919450925090508615610dac57505060006020830152506110ca565b87610dee57506402540be4008352600160e084018190526001600160501b0390911660a0840152610100830181905261012083015250600060208201526110ca565b846001600160501b038082169084161015610e3a5760405162461bcd60e51b815260206004820152600c60248201526b109859081c9bdd5b99081a5960a21b6044820152606401610b3a565b610e44818461320a565b6001600160501b031660608601819052600090610e62576001610e65565b60025b60ff16905060008167ffffffffffffffff811115610e9357634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015610ed857816020015b6040805180820190915260008082526020820152815260200190600190039081610eb15790505b5060608801519091501561104757600854604051635a7b84b160e01b81526001600160501b038516600482015260009182916001600160a01b0390911690635a7b84b190602401604080518083038186803b158015610f3657600080fd5b505afa158015610f4a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f6e9190612cb7565b9150915060405180604001604052808e88610f8991906131d6565b81526020018361ffff1681525083600081518110610fb757634e487b7160e01b600052603260045260246000fd5b602002602001018190525060405180604001604052808742610fd991906131d6565b81526020018961ffff168152508360018151811061100757634e487b7160e01b600052603260045260246000fd5b60209081029190910101526001600160501b03871660a08a015260016101008a015261103381876131d6565b60408a015250506001610140880152611098565b60405180604001604052808c4261105e91906131d6565b81526020018761ffff168152508160008151811061108c57634e487b7160e01b600052603260045260246000fd5b60200260200101819052505b6110a181611d6d565b602088018190526110b2908a61305c565b87525050600160e08601819052610120860152505050505b949350505050565b336110db61197f565b6001600160a01b0316146111015760405162461bcd60e51b8152600401610b3a90612ecc565b61271061ffff8216106111265760405162461bcd60e51b8152600401610b3a90612e7a565b6000805461ffff909216600160b01b0261ffff60b01b19909216919091179055565b60015460009061ffff600160701b909104811690829085811690612710908616821061117d5761117886886131b3565b611187565b61118787876131b3565b61ffff166111959190613194565b61119f9190613095565b6006549091506000906111be9061ffff62010000820481169116613194565b6111ca61271084613194565b6111d49190613095565b905060008060006003548b6111e99190613095565b9050808a1115611221576111fd818b6131d6565b915083821161120c578161120e565b835b915061121a828b6131d6565b9250611225565b8992505b60005b8381101561124f5761123b600288613074565b9650806112478161322a565b915050611228565b5060015461ffff600160501b9091048116908716101561126e57600095505b60005b828110156112bf57600154612710906112979061ffff600160601b820481169116613194565b6112a19190613095565b6112ab9088613036565b9650806112b78161322a565b915050611271565b5060015461ffff90811690871611156112dc5760015461ffff1695505b50939998505050505050505050565b336112f461197f565b6001600160a01b03161461131a5760405162461bcd60e51b8152600401610b3a90612ecc565b620186a08161ffff16106113405760405162461bcd60e51b8152600401610b3a90612e7a565b61ffff16600555565b60025460009061138b9083906113869063ffffffff1661136988886131d6565b60025461ffff600160201b8204811691600160401b9004166122b4565b612343565b90505b9392505050565b3361139e61197f565b6001600160a01b0316146113c45760405162461bcd60e51b8152600401610b3a90612ecc565b6002805461ffff909216600160601b0261ffff60601b19909216919091179055565b336113ef61197f565b6001600160a01b0316146114155760405162461bcd60e51b8152600401610b3a90612ecc565b61271061ffff82161061143a5760405162461bcd60e51b8152600401610b3a90612e7a565b6001805461ffff909216600160501b0261ffff60501b19909216919091179055565b3361146561197f565b6001600160a01b03161461148b5760405162461bcd60e51b8152600401610b3a90612ecc565b61271061ffff8216106114b05760405162461bcd60e51b8152600401610b3a90612e7a565b6000805461ffff909216600160c01b0261ffff60c01b19909216919091179055565b336114db61197f565b6001600160a01b0316146115015760405162461bcd60e51b8152600401610b3a90612ecc565b6002805461ffff909216600160501b0261ffff60501b19909216919091179055565b3361152c61197f565b6001600160a01b0316146115525760405162461bcd60e51b8152600401610b3a90612ecc565b61271061ffff82161061159e5760405162461bcd60e51b8152602060048201526014602482015273537465702065786365656473206d6178696d756d60601b6044820152606401610b3a565b6001805461ffff909216600160601b0261ffff60601b19909216919091179055565b336115c961197f565b6001600160a01b0316146115ef5760405162461bcd60e51b8152600401610b3a90612ecc565b606581146116325760405162461bcd60e51b815260206004820152601060248201526f426164206d617070696e672073697a6560801b6044820152606401610b3a565b61163e6007838361297e565b505050565b3361164c61197f565b6001600160a01b0316146116725760405162461bcd60e51b8152600401610b3a90612ecc565b6001805461ffff909216600160e01b0261ffff60e01b19909216919091179055565b3361169d61197f565b6001600160a01b0316146116c35760405162461bcd60e51b8152600401610b3a90612ecc565b61271061ffff8216106116e85760405162461bcd60e51b8152600401610b3a90612e7a565b6000805461ffff909216600160d01b0261ffff60d01b19909216919091179055565b6009546001600160a01b031633146117345760405162461bcd60e51b8152600401610b3a90612ea7565b600061174285858585611148565b60015490915061ffff808316600160701b9092041614611777576001805461ffff60701b1916600160701b61ffff8416021790555b5050505050565b3361178761197f565b6001600160a01b0316146117ad5760405162461bcd60e51b8152600401610b3a90612ecc565b6002805461ffff909216600160201b0265ffff0000000019909216919091179055565b336117d961197f565b6001600160a01b0316146117ff5760405162461bcd60e51b8152600401610b3a90612ecc565b61180960006123cf565b565b3361181461197f565b6001600160a01b03161461183a5760405162461bcd60e51b8152600401610b3a90612ecc565b600880546001600160a01b0319166001600160a01b0392909216919091179055565b6009546001600160a01b031633146118865760405162461bcd60e51b8152600401610b3a90612ea7565b600061189283836131d6565b6002549091506118c09063ffffffff811690839061ffff600160201b8204811691600160401b9004166122b4565b6002805463ffffffff191663ffffffff92909216919091179055505050565b336118e861197f565b6001600160a01b03161461190e5760405162461bcd60e51b8152600401610b3a90612ecc565b61271061ffff82161061195f5760405162461bcd60e51b8152602060048201526019602482015278446576696174696f6e2065786365656473206d6178696d756d60381b6044820152606401610b3a565b6006805461ffff909216620100000263ffff000019909216919091179055565b6000546001600160a01b031690565b3361199761197f565b6001600160a01b0316146119bd5760405162461bcd60e51b8152600401610b3a90612ecc565b61271061ffff8216106119e25760405162461bcd60e51b8152600401610b3a90612e7a565b6001805461ffff191661ffff92909216919091179055565b6009546001600160a01b03163314611a245760405162461bcd60e51b8152600401610b3a90612ea7565b6000611a3082846131d6565b600154909150611a649063ffffffff600160801b82041690839061ffff600160a01b8204811691600160c01b9004166122b4565b600160106101000a81548163ffffffff021916908363ffffffff160217905550505050565b33611a9261197f565b6001600160a01b031614611ab85760405162461bcd60e51b8152600401610b3a90612ecc565b61271061ffff821610611add5760405162461bcd60e51b8152600401610b3a90612e7a565b6001805461ffff909216620100000263ffff000019909216919091179055565b60078181548110611b0d57600080fd5b9060005260206000209060109182820401919006600202915054906101000a900461ffff1681565b600454600090611b4584426131d6565b101580611b4f5750815b15611b685750600154600160201b900461ffff16611bd1565b600454600090611b7885426131d6565b600154611b999061ffff600160201b8204811691600160401b9004166131b3565b61ffff16611ba79190613194565b611bb19190613095565b600154909150611bcd908290600160401b900461ffff166131b3565b9150505b92915050565b33611be061197f565b6001600160a01b031614611c065760405162461bcd60e51b8152600401610b3a90612ecc565b6002805461ffff909216600160301b0261ffff60301b19909216919091179055565b33611c3161197f565b6001600160a01b031614611c575760405162461bcd60e51b8152600401610b3a90612ecc565b61271061ffff821610611c7c5760405162461bcd60e51b8152600401610b3a90612f01565b6001805461ffff909216600160301b0261ffff60301b19909216919091179055565b33611ca761197f565b6001600160a01b031614611ccd5760405162461bcd60e51b8152600401610b3a90612ecc565b61271061ffff821610611cf25760405162461bcd60e51b8152600401610b3a90612e7a565b60015461ffff600160201b90910481169082161015611d4b5760405162461bcd60e51b81526020600482015260156024820152744d6178206665652062656c6f77206d696e2066656560581b6044820152606401610b3a565b6001805461ffff909216600160401b0261ffff60401b19909216919091179055565b6000805b82518160ff161015611dce57611db0838260ff1681518110611da357634e487b7160e01b600052603260045260246000fd5b602002602001015161241f565b611dba908361305c565b915080611dc681613245565b915050611d71565b50919050565b33611ddd61197f565b6001600160a01b031614611e035760405162461bcd60e51b8152600401610b3a90612ecc565b61271061ffff821610611e285760405162461bcd60e51b8152600401610b3a90612e7a565b60015461ffff600160401b90910481169082161115611e815760405162461bcd60e51b81526020600482015260156024820152744d696e206665652061626f7665206d61782066656560581b6044820152606401610b3a565b6001805461ffff909216600160201b0265ffff0000000019909216919091179055565b33611ead61197f565b6001600160a01b031614611ed35760405162461bcd60e51b8152600401610b3a90612ecc565b6001805461ffff909216600160d01b0261ffff60d01b19909216919091179055565b600080611f45888888888888611f40600160109054906101000a900463ffffffff168d8f611f2391906131d6565b60015461ffff600160a01b8204811691600160c01b9004166122b4565b612616565b90999098509650505050505050565b33611f5d61197f565b6001600160a01b031614611f835760405162461bcd60e51b8152600401610b3a90612ecc565b61271061ffff821610611fa85760405162461bcd60e51b8152600401610b3a90612e7a565b6000805461ffff909216600160e01b0261ffff60e01b19909216919091179055565b33611fd361197f565b6001600160a01b031614611ff95760405162461bcd60e51b8152600401610b3a90612ecc565b6001805461ffff909216600160b01b0261ffff60b01b19909216919091179055565b3361202461197f565b6001600160a01b03161461204a5760405162461bcd60e51b8152600401610b3a90612ecc565b6001805461ffff909216600160c01b0261ffff60c01b19909216919091179055565b60025460009061208390839063ffffffff16612343565b95945050505050565b3361209561197f565b6001600160a01b0316146120bb5760405162461bcd60e51b8152600401610b3a90612ecc565b600081116121055760405162461bcd60e51b8152602060048201526017602482015276506572696f64206d75737420626520706f73697469766560481b6044820152606401610b3a565b600455565b60008061213e87878787876001600e9054906101000a900461ffff16600160109054906101000a900463ffffffff16612616565b909890975095505050505050565b3361215561197f565b6001600160a01b03161461217b5760405162461bcd60e51b8152600401610b3a90612ecc565b61271061ffff8216106121a05760405162461bcd60e51b8152600401610b3a90612e7a565b6000805461ffff909216600160f01b026001600160f01b03909216919091179055565b336121cc61197f565b6001600160a01b0316146121f25760405162461bcd60e51b8152600401610b3a90612ecc565b6002805461ffff909216600160401b0261ffff60401b19909216919091179055565b3361221d61197f565b6001600160a01b0316146122435760405162461bcd60e51b8152600401610b3a90612ecc565b6001600160a01b0381166122a85760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610b3a565b6122b1816123cf565b50565b836122c361ffff8416426131d6565b8163ffffffff1610156122e1576122de61ffff8416426131ed565b90505b6127106122f76402540be40061ffff8516613194565b6123019190613095565b61230f8561ffff8616613194565b6123199190613095565b6123299063ffffffff831661305c565b9050428163ffffffff1611156110ca575042949350505050565b6002546000908190612381908590859061ffff600160201b8204811691600160301b8104821691600160501b8204811691600160601b900416612812565b60005490915061239d908290600160f01b900461ffff16613036565b60015490925061ffff62010000909104811690831611156123c85760015462010000900461ffff1691505b5092915050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000816020015161ffff166000148061243757508151155b1561244457506000919050565b6020820151620186a09060009061245d90606490613074565b9050603761ffff821611156125ae57609661ffff821610612482576107d091506125ae565b6040805160a081018252620186a081526201c0b560208201526202036e918101919091526202501360608201526202a81e6080820152600060056124c76037856131b3565b6124d19190613074565b61ffff169050600060056124e66037866131b3565b6124f09190613265565b61ffff169050610100821061253b5760405162461bcd60e51b81526020600482015260116024820152706578706f6e656e74206f766572666c6f7760781b6044820152606401610b3a565b60055483826005811061255e57634e487b7160e01b600052603260045260246000fd5b602002015162ffffff166125738460026130ec565b612582906402540be400613095565b61258c9190613095565b612596919061305c565b9450620186a08511156125aa57620186a094505b5050505b60005484516020860151620f42409261ffff600160a01b9091048116926201518092909187916125e491166402540be400613194565b6125ee9190613194565b6125f89190613194565b6126029190613095565b61260c9190613095565b6110ca9190613095565b6000808587101561262657600080fd5b60006402540be400881061264d576001546126469061ffff1689896128de565b90506126eb565b6001546127109061266f906402540be40090600160301b900461ffff16613194565b6126799190613095565b88106126eb576126e860076402540be4006126958b6064613194565b61269f9190613095565b815481106126bd57634e487b7160e01b600052603260045260246000fd5b90600052602060002090601091828204019190066002029054906101000a900461ffff1689896128de565b90505b600154600090612727908890879061ffff600160a01b8204811691600160b01b8104821691600160d01b8204811691600160e01b900416612812565b90508082876000601c9054906101000a900461ffff166127479190613036565b6127519190613036565b61275b9190613036565b60015490935061ffff908116908416111561277a5760015461ffff1692505b600061271061ffff168461ffff168c60ff168e6001600160a81b03166127a09190613194565b6127aa9190613194565b6127b49190613095565b9050809450846001600160a81b031681146128035760405162461bcd60e51b815260206004820152600f60248201526e546f6f206d75636820746f6b656e7360881b6044820152606401610b3a565b50505097509795505050505050565b600086156128d45761282861ffff8516426131d6565b8663ffffffff1610156128825761283f84866131b3565b61ffff168561ffff164261285391906131d6565b6128639063ffffffff89166131d6565b6128719061ffff8616613194565b61287b9190613095565b90506128d4565b61ffff841661289181426131d6565b6128a19063ffffffff89166131d6565b6128ab85856131b3565b61ffff166128b99190613194565b6128c39190613095565b6128d19061ffff851661305c565b90505b9695505050505050565b60015460009061271090612903906402540be40090600160301b900461ffff16613194565b61290d9190613095565b8210158061291a57508183145b1561292657508261138e565b61293082846131d6565b60015461271090612952906402540be40090600160301b900461ffff16613194565b61295c9190613095565b61296690856131d6565b6129749061ffff8716613194565b61138b9190613095565b82805482825590600052602060002090600f01601090048101928215612a1b5791602002820160005b838211156129eb57833561ffff1683826101000a81548161ffff021916908361ffff16021790555092602001926002016020816001010492830192600103026129a7565b8015612a195782816101000a81549061ffff02191690556002016020816001010492830192600103026129eb565b505b50612a27929150612a2b565b5090565b5b80821115612a275760008155600101612a2c565b80358015158114612a5057600080fd5b919050565b80356001600160a81b0381168114612a5057600080fd5b803560ff81168114612a5057600080fd5b600060208284031215612a8e578081fd5b813561138e816132c8565b60006020808385031215612aab578182fd5b823567ffffffffffffffff80821115612ac2578384fd5b818501915085601f830112612ad5578384fd5b813581811115612ae757612ae76132b2565b612af5848260051b01613005565b8181528481019250838501600683901b85018601891015612b14578687fd5b8694505b82851015612b6057604080828b031215612b30578788fd5b612b38612fdc565b8235815287830135612b49816132dd565b818901528552600195909501949386019301612b18565b50979650505050505050565b60008060208385031215612b7e578081fd5b823567ffffffffffffffff80821115612b95578283fd5b818501915085601f830112612ba8578283fd5b813581811115612bb6578384fd5b8660208260051b8501011115612bca578384fd5b60209290920196919550909350505050565b600060208284031215612bed578081fd5b813561138e816132dd565b600080600080600060a08688031215612c0f578081fd5b612c1886612a55565b9450612c2660208701612a6c565b93506040860135925060608601359150612c4260808701612a40565b90509295509295909350565b60008060008060008060c08789031215612c66578081fd5b612c6f87612a55565b9550612c7d60208801612a6c565b94506040870135935060608701359250612c9960808801612a40565b915060a0870135612ca9816132dd565b809150509295509295509295565b60008060408385031215612cc9578182fd5b8251612cd4816132dd565b6020939093015192949293505050565b600080600060608486031215612cf8578283fd5b8351612d03816132dd565b6020850151909350612d14816132ed565b80925050604084015190509250925092565b600060208284031215612d37578081fd5b5035919050565b60008060408385031215612d50578182fd5b82359150612d6060208401612a40565b90509250929050565b60008060408385031215612d7b578182fd5b50508035926020909101359150565b600080600060608486031215612d9e578081fd5b8335925060208401359150612db560408501612a40565b90509250925092565b60008060008060808587031215612dd3578182fd5b84359350602085013592506040850135612dec816132dd565b91506060850135612dfc816132dd565b939692955090935050565b60008060008060808587031215612e1c578182fd5b843593506020850135925060408501359150612e3a60608601612a40565b905092959194509250565b60008060008060808587031215612e5a578182fd5b8435935060208501359250604085013591506060850135612dfc816132ed565b6020808252601390820152724665652065786365656473206d6178696d756d60681b604082015260600190565b6020808252600b908201526a139bdd08185b1b1bddd95960aa1b604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252601990820152785468726573686f6c642065786365656473206d6178696d756d60381b604082015260600190565b600061016082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015260a0830151612f8360a08401826001600160501b03169052565b5060c0830151612f9960c084018261ffff169052565b5060e0830151612fad60e084018215159052565b506101008381015115159083015261012080840151151590830152610140928301511515929091019190915290565b6040805190810167ffffffffffffffff81118282101715612fff57612fff6132b2565b60405290565b604051601f8201601f1916810167ffffffffffffffff8111828210171561302e5761302e6132b2565b604052919050565b600061ffff80831681851680830382111561305357613053613286565b01949350505050565b6000821982111561306f5761306f613286565b500190565b600061ffff808416806130895761308961329c565b92169190910492915050565b6000826130a4576130a461329c565b500490565b600181815b808511156130e45781600019048211156130ca576130ca613286565b808516156130d757918102915b93841c93908002906130ae565b509250929050565b600061138e838360008261310257506001611bd1565b8161310f57506000611bd1565b8160018114613125576002811461312f5761314b565b6001915050611bd1565b60ff84111561314057613140613286565b50506001821b611bd1565b5060208310610133831016604e8410600b841016171561316e575081810a611bd1565b61317883836130a9565b806000190482111561318c5761318c613286565b029392505050565b60008160001904831182151516156131ae576131ae613286565b500290565b600061ffff838116908316818110156131ce576131ce613286565b039392505050565b6000828210156131e8576131e8613286565b500390565b600063ffffffff838116908316818110156131ce576131ce613286565b60006001600160501b03838116908316818110156131ce576131ce613286565b600060001982141561323e5761323e613286565b5060010190565b600060ff821660ff81141561325c5761325c613286565b60010192915050565b600061ffff8084168061327a5761327a61329c565b92169190910692915050565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146122b157600080fd5b61ffff811681146122b157600080fd5b6001600160501b03811681146122b157600080fdfea264697066735822122085e2a7d505db0eb0dcd2bd539cfe1c93fc8317f8c92abd9a5560f7964a99e47664736f6c63430008040033000000000000000000000000981475d6a0ee63027f7a67574d8eed3bd170d11d0000000000000000000000000000000000000000000000000000000000004e20

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

000000000000000000000000981475d6a0ee63027f7a67574d8eed3bd170d11d0000000000000000000000000000000000000000000000000000000000004e20

-----Decoded View---------------
Arg [0] : _cviOracle (address): 0x981475d6a0ee63027f7a67574d8eed3bd170d11d
Arg [1] : _maxCVIValue (uint16): 20000

-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 000000000000000000000000981475d6a0ee63027f7a67574d8eed3bd170d11d
Arg [1] : 0000000000000000000000000000000000000000000000000000000000004e20


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.