ETH Price: $2,630.14 (+1.27%)

Contract

0xf039d6cF87E5D0315f3Eb286Bbeb39A7B3fe30df
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
0x61018060191397252024-02-02 9:09:11259 days ago1706864951IN
 Create: Prime
0 ETH0.1095412621.04693613

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
Prime

Compiler Version
v0.8.13+commit.abaa5c0e

Optimization Enabled:
Yes with 200 runs

Other Settings:
london EvmVersion, BSD-3-Clause license
File 1 of 29 : Prime.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.13;

import { SafeERC20Upgradeable, IERC20Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
import { AccessControlledV8 } from "@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol";
import { ResilientOracleInterface } from "@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol";
import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import { MaxLoopsLimitHelper } from "@venusprotocol/solidity-utilities/contracts/MaxLoopsLimitHelper.sol";
import { TimeManagerV8 } from "@venusprotocol/solidity-utilities/contracts/TimeManagerV8.sol";

import { IERC20MetadataUpgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol";

import { PrimeStorageV1 } from "./PrimeStorage.sol";
import { Scores } from "./libs/Scores.sol";

import { IPrimeLiquidityProvider } from "./Interfaces/IPrimeLiquidityProvider.sol";
import { IPrime } from "./Interfaces/IPrime.sol";
import { IXVSVault } from "./Interfaces/IXVSVault.sol";
import { IVToken } from "./Interfaces/IVToken.sol";
import { InterfaceComptroller } from "./Interfaces/InterfaceComptroller.sol";
import { PoolRegistryInterface } from "./Interfaces/IPoolRegistry.sol";

/**
 * @title Prime
 * @author Venus
 * @notice Prime Token is used to provide extra rewards to the users who have staked a minimum of `MINIMUM_STAKED_XVS` XVS in the XVSVault for `STAKING_PERIOD` days
 * @custom:security-contact https://github.com/VenusProtocol/venus-protocol
 */
contract Prime is IPrime, AccessControlledV8, PausableUpgradeable, MaxLoopsLimitHelper, PrimeStorageV1, TimeManagerV8 {
    using SafeERC20Upgradeable for IERC20Upgradeable;

    /// @notice address of wrapped native token contract
    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable
    address public immutable WRAPPED_NATIVE_TOKEN;

    /// @notice address of native market contract
    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable
    address public immutable NATIVE_MARKET;

    /// @notice minimum amount of XVS user needs to stake to become a prime member
    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable
    uint256 public immutable MINIMUM_STAKED_XVS;

    /// @notice maximum XVS taken in account when calculating user score
    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable
    uint256 public immutable MAXIMUM_XVS_CAP;

    /// @notice number of days user need to stake to claim prime token
    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable
    uint256 public immutable STAKING_PERIOD;

    /// @notice Emitted when prime token is minted
    event Mint(address indexed user, bool isIrrevocable);

    /// @notice Emitted when prime token is burned
    event Burn(address indexed user);

    /// @notice Emitted when a market is added to prime program
    event MarketAdded(
        address indexed comptroller,
        address indexed market,
        uint256 supplyMultiplier,
        uint256 borrowMultiplier
    );

    /// @notice Emitted when mint limits are updated
    event MintLimitsUpdated(
        uint256 indexed oldIrrevocableLimit,
        uint256 indexed oldRevocableLimit,
        uint256 indexed newIrrevocableLimit,
        uint256 newRevocableLimit
    );

    /// @notice Emitted when user score is updated
    event UserScoreUpdated(address indexed user);

    /// @notice Emitted when alpha is updated
    event AlphaUpdated(
        uint128 indexed oldNumerator,
        uint128 indexed oldDenominator,
        uint128 indexed newNumerator,
        uint128 newDenominator
    );

    /// @notice Emitted when multiplier is updated
    event MultiplierUpdated(
        address indexed market,
        uint256 indexed oldSupplyMultiplier,
        uint256 indexed oldBorrowMultiplier,
        uint256 newSupplyMultiplier,
        uint256 newBorrowMultiplier
    );

    /// @notice Emitted when interest is claimed
    event InterestClaimed(address indexed user, address indexed market, uint256 amount);

    /// @notice Emitted when revocable token is upgraded to irrevocable token
    event TokenUpgraded(address indexed user);

    /// @notice Emitted when stakedAt is updated
    event StakedAtUpdated(address indexed user, uint256 timestamp);

    /// @notice Error thrown when market is not supported
    error MarketNotSupported();

    /// @notice Error thrown when mint limit is reached
    error InvalidLimit();

    /// @notice Error thrown when user is not eligible to claim prime token
    error IneligibleToClaim();

    /// @notice Error thrown when user needs to wait more time to claim prime token
    error WaitMoreTime();

    /// @notice Error thrown when user has no prime token
    error UserHasNoPrimeToken();

    /// @notice Error thrown when no score updates are required
    error NoScoreUpdatesRequired();

    /// @notice Error thrown when market already exists
    error MarketAlreadyExists();

    /// @notice Error thrown when asset already exists
    error AssetAlreadyExists();

    /// @notice Error thrown when invalid address is passed
    error InvalidAddress();

    /// @notice Error thrown when invalid alpha arguments are passed
    error InvalidAlphaArguments();

    /// @notice Error thrown when invalid vToken is passed
    error InvalidVToken();

    /// @notice Error thrown when invalid length is passed
    error InvalidLength();

    /// @notice Error thrown when timestamp is invalid
    error InvalidTimestamp();

    /// @notice Error thrown when invalid comptroller is passed
    error InvalidComptroller();

    /**
     * @notice Prime constructor
     * @param _wrappedNativeToken Address of wrapped native token
     * @param _nativeMarket Address of native market
     * @param _blocksPerYear total blocks per year
     * @param _stakingPeriod total number of seconds for which user needs to stake to claim prime token
     * @param _minimumStakedXVS minimum amount of XVS user needs to stake to become a prime member (scaled by 1e18)
     * @param _maximumXVSCap maximum XVS taken in account when calculating user score (scaled by 1e18)
     * @param _timeBased A boolean indicating whether the contract is based on time or block.
     */
    /// @custom:oz-upgrades-unsafe-allow constructor
    constructor(
        address _wrappedNativeToken,
        address _nativeMarket,
        uint256 _blocksPerYear,
        uint256 _stakingPeriod,
        uint256 _minimumStakedXVS,
        uint256 _maximumXVSCap,
        bool _timeBased
    ) TimeManagerV8(_timeBased, _blocksPerYear) {
        WRAPPED_NATIVE_TOKEN = _wrappedNativeToken;
        NATIVE_MARKET = _nativeMarket;
        STAKING_PERIOD = _stakingPeriod;
        MINIMUM_STAKED_XVS = _minimumStakedXVS;
        MAXIMUM_XVS_CAP = _maximumXVSCap;

        // Note that the contract is upgradeable. Use initialize() or reinitializers
        // to set the state variables.
        _disableInitializers();
    }

    /**
     * @notice Prime initializer
     * @param xvsVault_ Address of XVSVault
     * @param xvsVaultRewardToken_ Address of XVSVault reward token
     * @param xvsVaultPoolId_ Pool id of XVSVault
     * @param alphaNumerator_ numerator of alpha. If alpha is 0.5 then numerator is 1.
              alphaDenominator_ must be greater than alphaNumerator_, alphaDenominator_ cannot be zero and alphaNumerator_ cannot be zero
     * @param alphaDenominator_ denominator of alpha. If alpha is 0.5 then denominator is 2.
              alpha is alphaNumerator_/alphaDenominator_. So, 0 < alpha < 1
     * @param accessControlManager_ Address of AccessControlManager
     * @param primeLiquidityProvider_ Address of PrimeLiquidityProvider
     * @param comptroller_ Address of core pool comptroller
     * @param oracle_ Address of Oracle
     * @param loopsLimit_ Maximum number of loops allowed in a single transaction
     * @custom:error Throw InvalidAddress if any of the address is invalid
     */
    function initialize(
        address xvsVault_,
        address xvsVaultRewardToken_,
        uint256 xvsVaultPoolId_,
        uint128 alphaNumerator_,
        uint128 alphaDenominator_,
        address accessControlManager_,
        address primeLiquidityProvider_,
        address comptroller_,
        address oracle_,
        uint256 loopsLimit_
    ) external initializer {
        if (xvsVault_ == address(0)) revert InvalidAddress();
        if (xvsVaultRewardToken_ == address(0)) revert InvalidAddress();
        if (oracle_ == address(0)) revert InvalidAddress();
        if (primeLiquidityProvider_ == address(0)) revert InvalidAddress();

        _checkAlphaArguments(alphaNumerator_, alphaDenominator_);

        alphaNumerator = alphaNumerator_;
        alphaDenominator = alphaDenominator_;
        xvsVaultRewardToken = xvsVaultRewardToken_;
        xvsVaultPoolId = xvsVaultPoolId_;
        xvsVault = xvsVault_;
        nextScoreUpdateRoundId = 0;
        primeLiquidityProvider = primeLiquidityProvider_;
        corePoolComptroller = comptroller_;
        oracle = ResilientOracleInterface(oracle_);

        __AccessControlled_init(accessControlManager_);
        __Pausable_init();
        _setMaxLoopsLimit(loopsLimit_);

        _pause();
    }

    /**
     * @notice Prime initializer V2 for initializing pool registry
     * @param poolRegistry_ Address of IL pool registry
     */
    function initializeV2(address poolRegistry_) external reinitializer(2) {
        poolRegistry = poolRegistry_;
    }

    /**
     * @notice Returns boosted pending interest accrued for a user for all markets
     * @param user the account for which to get the accrued interests
     * @return pendingRewards the number of underlying tokens accrued by the user for all markets
     */
    function getPendingRewards(address user) external returns (PendingReward[] memory pendingRewards) {
        address[] storage allMarkets = _allMarkets;
        uint256 marketsLength = allMarkets.length;

        pendingRewards = new PendingReward[](marketsLength);
        for (uint256 i; i < marketsLength; ) {
            address market = allMarkets[i];
            uint256 interestAccrued = getInterestAccrued(market, user);
            uint256 accrued = interests[market][user].accrued;

            pendingRewards[i] = PendingReward({
                vToken: market,
                rewardToken: _getUnderlying(market),
                amount: interestAccrued + accrued
            });

            unchecked {
                ++i;
            }
        }
    }

    /**
     * @notice Update total score of multiple users and market
     * @param users accounts for which we need to update score
     * @custom:error Throw NoScoreUpdatesRequired if no score updates are required
     * @custom:error Throw UserHasNoPrimeToken if user has no prime token
     * @custom:event Emits UserScoreUpdated event
     */
    function updateScores(address[] calldata users) external {
        if (pendingScoreUpdates == 0) revert NoScoreUpdatesRequired();
        if (nextScoreUpdateRoundId == 0) revert NoScoreUpdatesRequired();

        for (uint256 i; i < users.length; ) {
            address user = users[i];

            if (!tokens[user].exists) revert UserHasNoPrimeToken();
            if (isScoreUpdated[nextScoreUpdateRoundId][user]) {
                unchecked {
                    ++i;
                }
                continue;
            }

            address[] storage allMarkets = _allMarkets;
            uint256 marketsLength = allMarkets.length;

            for (uint256 j; j < marketsLength; ) {
                address market = allMarkets[j];
                _executeBoost(user, market);
                _updateScore(user, market);

                unchecked {
                    ++j;
                }
            }

            --pendingScoreUpdates;
            isScoreUpdated[nextScoreUpdateRoundId][user] = true;

            unchecked {
                ++i;
            }

            emit UserScoreUpdated(user);
        }
    }

    /**
     * @notice Update value of alpha
     * @param _alphaNumerator numerator of alpha. If alpha is 0.5 then numerator is 1
     * @param _alphaDenominator denominator of alpha. If alpha is 0.5 then denominator is 2
     * @custom:event Emits AlphaUpdated event
     * @custom:access Controlled by ACM
     */
    function updateAlpha(uint128 _alphaNumerator, uint128 _alphaDenominator) external {
        _checkAccessAllowed("updateAlpha(uint128,uint128)");
        _checkAlphaArguments(_alphaNumerator, _alphaDenominator);

        emit AlphaUpdated(alphaNumerator, alphaDenominator, _alphaNumerator, _alphaDenominator);

        alphaNumerator = _alphaNumerator;
        alphaDenominator = _alphaDenominator;

        uint256 marketslength = _allMarkets.length;

        for (uint256 i; i < marketslength; ) {
            accrueInterest(_allMarkets[i]);

            unchecked {
                ++i;
            }
        }

        _startScoreUpdateRound();
    }

    /**
     * @notice Update multipliers for a market
     * @param market address of the market vToken
     * @param supplyMultiplier new supply multiplier for the market, scaled by 1e18
     * @param borrowMultiplier new borrow multiplier for the market, scaled by 1e18
     * @custom:error Throw MarketNotSupported if market is not supported
     * @custom:event Emits MultiplierUpdated event
     * @custom:access Controlled by ACM
     */
    function updateMultipliers(address market, uint256 supplyMultiplier, uint256 borrowMultiplier) external {
        _checkAccessAllowed("updateMultipliers(address,uint256,uint256)");

        Market storage _market = markets[market];
        if (!_market.exists) revert MarketNotSupported();

        accrueInterest(market);

        emit MultiplierUpdated(
            market,
            _market.supplyMultiplier,
            _market.borrowMultiplier,
            supplyMultiplier,
            borrowMultiplier
        );
        _market.supplyMultiplier = supplyMultiplier;
        _market.borrowMultiplier = borrowMultiplier;

        _startScoreUpdateRound();
    }

    /**
     * @notice Update staked at timestamp for multiple users
     * @param users accounts for which we need to update staked at timestamp
     * @param timestamps new staked at timestamp for the users
     * @custom:error Throw InvalidLength if users and timestamps length are not equal
     * @custom:event Emits StakedAtUpdated event for each user
     * @custom:access Controlled by ACM
     */
    function setStakedAt(address[] calldata users, uint256[] calldata timestamps) external {
        _checkAccessAllowed("setStakedAt(address[],uint256[])");
        if (users.length != timestamps.length) revert InvalidLength();

        for (uint256 i; i < users.length; ) {
            if (timestamps[i] > block.timestamp) revert InvalidTimestamp();

            stakedAt[users[i]] = timestamps[i];
            emit StakedAtUpdated(users[i], timestamps[i]);

            unchecked {
                ++i;
            }
        }
    }

    /**
     * @notice Add a market to prime program
     * @param comptroller address of the comptroller
     * @param market address of the market vToken
     * @param supplyMultiplier the multiplier for supply cap. It should be converted to 1e18
     * @param borrowMultiplier the multiplier for borrow cap. It should be converted to 1e18
     * @custom:error Throw MarketAlreadyExists if market already exists
     * @custom:error Throw InvalidVToken if market is not valid
     * @custom:event Emits MarketAdded event
     * @custom:access Controlled by ACM
     */
    function addMarket(
        address comptroller,
        address market,
        uint256 supplyMultiplier,
        uint256 borrowMultiplier
    ) external {
        _checkAccessAllowed("addMarket(address,address,uint256,uint256)");

        if (comptroller == address(0)) revert InvalidComptroller();

        if (
            comptroller != corePoolComptroller &&
            PoolRegistryInterface(poolRegistry).getPoolByComptroller(comptroller).comptroller != comptroller
        ) revert InvalidComptroller();

        Market storage _market = markets[market];
        if (_market.exists) revert MarketAlreadyExists();

        bool isMarketExist = InterfaceComptroller(comptroller).markets(market);
        if (!isMarketExist) revert InvalidVToken();

        delete _market.rewardIndex;
        _market.supplyMultiplier = supplyMultiplier;
        _market.borrowMultiplier = borrowMultiplier;
        delete _market.sumOfMembersScore;
        _market.exists = true;

        address underlying = _getUnderlying(market);

        if (vTokenForAsset[underlying] != address(0)) revert AssetAlreadyExists();
        vTokenForAsset[underlying] = market;

        _allMarkets.push(market);
        _startScoreUpdateRound();

        _ensureMaxLoops(_allMarkets.length);

        emit MarketAdded(comptroller, market, supplyMultiplier, borrowMultiplier);
    }

    /**
     * @notice Set limits for total tokens that can be minted
     * @param _irrevocableLimit total number of irrevocable tokens that can be minted
     * @param _revocableLimit total number of revocable tokens that can be minted
     * @custom:error Throw InvalidLimit if any of the limit is less than total tokens minted
     * @custom:event Emits MintLimitsUpdated event
     * @custom:access Controlled by ACM
     */
    function setLimit(uint256 _irrevocableLimit, uint256 _revocableLimit) external {
        _checkAccessAllowed("setLimit(uint256,uint256)");
        if (_irrevocableLimit < totalIrrevocable || _revocableLimit < totalRevocable) revert InvalidLimit();

        emit MintLimitsUpdated(irrevocableLimit, revocableLimit, _irrevocableLimit, _revocableLimit);

        revocableLimit = _revocableLimit;
        irrevocableLimit = _irrevocableLimit;
    }

    /**
     * @notice Set the limit for the loops can iterate to avoid the DOS
     * @param loopsLimit Number of loops limit
     * @custom:event Emits MaxLoopsLimitUpdated event on success
     * @custom:access Controlled by ACM
     */
    function setMaxLoopsLimit(uint256 loopsLimit) external {
        _checkAccessAllowed("setMaxLoopsLimit(uint256)");
        _setMaxLoopsLimit(loopsLimit);
    }

    /**
     * @notice Directly issue prime tokens to users
     * @param isIrrevocable are the tokens being issued
     * @param users list of address to issue tokens to
     * @custom:access Controlled by ACM
     */
    function issue(bool isIrrevocable, address[] calldata users) external {
        _checkAccessAllowed("issue(bool,address[])");

        if (isIrrevocable) {
            for (uint256 i; i < users.length; ) {
                Token storage userToken = tokens[users[i]];
                if (userToken.exists && !userToken.isIrrevocable) {
                    _upgrade(users[i]);
                } else {
                    _mint(true, users[i]);
                    _initializeMarkets(users[i]);
                }

                unchecked {
                    ++i;
                }
            }
        } else {
            for (uint256 i; i < users.length; ) {
                _mint(false, users[i]);
                _initializeMarkets(users[i]);

                unchecked {
                    ++i;
                }
            }
        }
    }

    /**
     * @notice Executed by XVSVault whenever user's XVSVault balance changes
     * @param user the account address whose balance was updated
     */
    function xvsUpdated(address user) external {
        uint256 totalStaked = _xvsBalanceOfUser(user);
        bool isAccountEligible = _isEligible(totalStaked);

        uint256 userStakedAt = stakedAt[user];
        Token memory token = tokens[user];

        if (token.exists && !isAccountEligible) {
            delete stakedAt[user];
            emit StakedAtUpdated(user, 0);

            if (token.isIrrevocable) {
                _accrueInterestAndUpdateScore(user);
            } else {
                _burn(user);
            }
        } else if (!isAccountEligible && !token.exists && userStakedAt != 0) {
            delete stakedAt[user];
            emit StakedAtUpdated(user, 0);
        } else if (userStakedAt == 0 && isAccountEligible && !token.exists) {
            stakedAt[user] = block.timestamp;
            emit StakedAtUpdated(user, block.timestamp);
        } else if (token.exists && isAccountEligible) {
            _accrueInterestAndUpdateScore(user);

            if (stakedAt[user] == 0) {
                stakedAt[user] = block.timestamp;
                emit StakedAtUpdated(user, block.timestamp);
            }
        }
    }

    /**
     * @notice accrues interes and updates score for an user for a specific market
     * @param user the account address for which to accrue interest and update score
     * @param market the market for which to accrue interest and update score
     */
    function accrueInterestAndUpdateScore(address user, address market) external {
        _executeBoost(user, market);
        _updateScore(user, market);
    }

    /**
     * @notice For claiming prime token when staking period is completed
     */
    function claim() external {
        uint256 userStakedAt = stakedAt[msg.sender];
        if (userStakedAt == 0) revert IneligibleToClaim();
        if (block.timestamp - userStakedAt < STAKING_PERIOD) revert WaitMoreTime();

        _mint(false, msg.sender);
        _initializeMarkets(msg.sender);
    }

    /**
     * @notice For burning any prime token
     * @param user the account address for which the prime token will be burned
     * @custom:access Controlled by ACM
     */
    function burn(address user) external {
        _checkAccessAllowed("burn(address)");
        _burn(user);
    }

    /**
     * @notice To pause or unpause claiming of interest
     * @custom:access Controlled by ACM
     */
    function togglePause() external {
        _checkAccessAllowed("togglePause()");
        if (paused()) {
            _unpause();
        } else {
            _pause();
        }
    }

    /**
     * @notice For user to claim boosted yield
     * @param vToken the market for which claim the accrued interest
     * @return amount the amount of tokens transferred to the msg.sender
     */
    function claimInterest(address vToken) external whenNotPaused returns (uint256) {
        return _claimInterest(vToken, msg.sender);
    }

    /**
     * @notice For user to claim boosted yield
     * @param vToken the market for which claim the accrued interest
     * @param user the user for which to claim the accrued interest
     * @return amount the amount of tokens transferred to the user
     */
    function claimInterest(address vToken, address user) external whenNotPaused returns (uint256) {
        return _claimInterest(vToken, user);
    }

    /**
     * @notice Retrieves an array of all available markets
     * @return an array of addresses representing all available markets
     */
    function getAllMarkets() external view returns (address[] memory) {
        return _allMarkets;
    }

    /**
     * @notice Retrieves the core pool comptroller address
     * @return the core pool comptroller address
     */
    function comptroller() external view returns (address) {
        return corePoolComptroller;
    }

    /**
     * @notice fetch the numbers of seconds remaining for staking period to complete
     * @param user the account address for which we are checking the remaining time
     * @return timeRemaining the number of seconds the user needs to wait to claim prime token
     */
    function claimTimeRemaining(address user) external view returns (uint256) {
        uint256 userStakedAt = stakedAt[user];
        if (userStakedAt == 0) return STAKING_PERIOD;

        uint256 totalTimeStaked;
        unchecked {
            totalTimeStaked = block.timestamp - userStakedAt;
        }

        if (totalTimeStaked < STAKING_PERIOD) {
            unchecked {
                return STAKING_PERIOD - totalTimeStaked;
            }
        }
        return 0;
    }

    /**
     * @notice Returns if user is a prime holder
     * @return isPrimeHolder true if user is a prime holder
     */
    function isUserPrimeHolder(address user) external view returns (bool) {
        return tokens[user].exists;
    }

    /**
     * @notice Returns supply and borrow APR for user for a given market
     * @param market the market for which to fetch the APR
     * @param user the account for which to get the APR
     * @return aprInfo APR information for the user for the given market
     */
    function calculateAPR(address market, address user) external view returns (APRInfo memory aprInfo) {
        IVToken vToken = IVToken(market);
        uint256 borrow = vToken.borrowBalanceStored(user);
        uint256 exchangeRate = vToken.exchangeRateStored();
        uint256 balanceOfAccount = vToken.balanceOf(user);
        uint256 supply = (exchangeRate * balanceOfAccount) / EXP_SCALE;

        aprInfo.userScore = interests[market][user].score;
        aprInfo.totalScore = markets[market].sumOfMembersScore;

        aprInfo.xvsBalanceForScore = _xvsBalanceForScore(_xvsBalanceOfUser(user));
        Capital memory capital = _capitalForScore(aprInfo.xvsBalanceForScore, borrow, supply, address(vToken));

        aprInfo.capital = capital.capital;
        aprInfo.cappedSupply = capital.cappedSupply;
        aprInfo.cappedBorrow = capital.cappedBorrow;
        aprInfo.supplyCapUSD = capital.supplyCapUSD;
        aprInfo.borrowCapUSD = capital.borrowCapUSD;

        (aprInfo.supplyAPR, aprInfo.borrowAPR) = _calculateUserAPR(
            market,
            supply,
            borrow,
            aprInfo.cappedSupply,
            aprInfo.cappedBorrow,
            aprInfo.userScore,
            aprInfo.totalScore
        );
    }

    /**
     * @notice Returns supply and borrow APR for estimated supply, borrow and XVS staked
     * @param market the market for which to fetch the APR
     * @param user the account for which to get the APR
     * @return aprInfo APR information for the user for the given market
     */
    function estimateAPR(
        address market,
        address user,
        uint256 borrow,
        uint256 supply,
        uint256 xvsStaked
    ) external view returns (APRInfo memory aprInfo) {
        aprInfo.totalScore = markets[market].sumOfMembersScore - interests[market][user].score;

        aprInfo.xvsBalanceForScore = _xvsBalanceForScore(xvsStaked);
        Capital memory capital = _capitalForScore(aprInfo.xvsBalanceForScore, borrow, supply, market);

        aprInfo.capital = capital.capital;
        aprInfo.cappedSupply = capital.cappedSupply;
        aprInfo.cappedBorrow = capital.cappedBorrow;
        aprInfo.supplyCapUSD = capital.supplyCapUSD;
        aprInfo.borrowCapUSD = capital.borrowCapUSD;

        uint256 decimals = IERC20MetadataUpgradeable(_getUnderlying(market)).decimals();
        aprInfo.capital = aprInfo.capital * (10 ** (18 - decimals));

        aprInfo.userScore = Scores._calculateScore(
            aprInfo.xvsBalanceForScore,
            aprInfo.capital,
            alphaNumerator,
            alphaDenominator
        );

        aprInfo.totalScore = aprInfo.totalScore + aprInfo.userScore;

        (aprInfo.supplyAPR, aprInfo.borrowAPR) = _calculateUserAPR(
            market,
            supply,
            borrow,
            aprInfo.cappedSupply,
            aprInfo.cappedBorrow,
            aprInfo.userScore,
            aprInfo.totalScore
        );
    }

    /**
     * @notice Distributes income from market since last distribution
     * @param vToken the market for which to distribute the income
     * @custom:error Throw MarketNotSupported if market is not supported
     */
    function accrueInterest(address vToken) public {
        Market storage market = markets[vToken];

        if (!market.exists) revert MarketNotSupported();

        address underlying = _getUnderlying(vToken);

        IPrimeLiquidityProvider _primeLiquidityProvider = IPrimeLiquidityProvider(primeLiquidityProvider);
        _primeLiquidityProvider.accrueTokens(underlying);
        uint256 totalAccruedInPLP = _primeLiquidityProvider.tokenAmountAccrued(underlying);
        uint256 unreleasedPLPAccruedInterest = totalAccruedInPLP - unreleasedPLPIncome[underlying];
        uint256 distributionIncome = unreleasedPLPAccruedInterest;

        if (distributionIncome == 0) {
            return;
        }

        unreleasedPLPIncome[underlying] = totalAccruedInPLP;

        uint256 delta;
        if (market.sumOfMembersScore != 0) {
            delta = ((distributionIncome * EXP_SCALE) / market.sumOfMembersScore);
        }

        market.rewardIndex += delta;
    }

    /**
     * @notice Returns boosted interest accrued for a user
     * @param vToken the market for which to fetch the accrued interest
     * @param user the account for which to get the accrued interest
     * @return interestAccrued the number of underlying tokens accrued by the user since the last accrual
     */
    function getInterestAccrued(address vToken, address user) public returns (uint256) {
        accrueInterest(vToken);

        return _interestAccrued(vToken, user);
    }

    /**
     * @notice accrues interest and updates score of all markets for an user
     * @param user the account address for which to accrue interest and update score
     */
    function _accrueInterestAndUpdateScore(address user) internal {
        address[] storage allMarkets = _allMarkets;
        uint256 marketsLength = allMarkets.length;

        for (uint256 i; i < marketsLength; ) {
            address market = allMarkets[i];
            _executeBoost(user, market);
            _updateScore(user, market);

            unchecked {
                ++i;
            }
        }
    }

    /**
     * @notice Initializes all the markets for the user when a prime token is minted
     * @param account the account address for which markets needs to be initialized
     */
    function _initializeMarkets(address account) internal {
        address[] storage allMarkets = _allMarkets;
        uint256 marketsLength = allMarkets.length;

        for (uint256 i; i < marketsLength; ) {
            address market = allMarkets[i];
            accrueInterest(market);

            interests[market][account].rewardIndex = markets[market].rewardIndex;

            uint256 score = _calculateScore(market, account);
            interests[market][account].score = score;
            markets[market].sumOfMembersScore = markets[market].sumOfMembersScore + score;

            unchecked {
                ++i;
            }
        }
    }

    /**
     * @notice calculate the current score of user
     * @param market the market for which to calculate the score
     * @param user the account for which to calculate the score
     * @return score the score of the user
     */
    function _calculateScore(address market, address user) internal returns (uint256) {
        uint256 xvsBalanceForScore = _xvsBalanceForScore(_xvsBalanceOfUser(user));

        IVToken vToken = IVToken(market);
        uint256 borrow = vToken.borrowBalanceStored(user);
        uint256 exchangeRate = vToken.exchangeRateStored();
        uint256 balanceOfAccount = vToken.balanceOf(user);
        uint256 supply = (exchangeRate * balanceOfAccount) / EXP_SCALE;

        address xvsToken = IXVSVault(xvsVault).xvsAddress();
        oracle.updateAssetPrice(xvsToken);
        oracle.updatePrice(market);

        Capital memory capital = _capitalForScore(xvsBalanceForScore, borrow, supply, market);

        uint256 decimals = IERC20MetadataUpgradeable(_getUnderlying(market)).decimals();

        capital.capital = capital.capital * (10 ** (18 - decimals));

        return Scores._calculateScore(xvsBalanceForScore, capital.capital, alphaNumerator, alphaDenominator);
    }

    /**
     * @notice To transfer the accrued interest to user
     * @param vToken the market for which to claim
     * @param user the account for which to get the accrued interest
     * @return amount the amount of tokens transferred to the user
     * @custom:event Emits InterestClaimed event
     */
    function _claimInterest(address vToken, address user) internal returns (uint256) {
        uint256 amount = getInterestAccrued(vToken, user);
        amount += interests[vToken][user].accrued;

        interests[vToken][user].rewardIndex = markets[vToken].rewardIndex;
        delete interests[vToken][user].accrued;

        address underlying = _getUnderlying(vToken);
        IERC20Upgradeable asset = IERC20Upgradeable(underlying);

        if (amount > asset.balanceOf(address(this))) {
            delete unreleasedPLPIncome[underlying];
            IPrimeLiquidityProvider(primeLiquidityProvider).releaseFunds(address(asset));
        }

        asset.safeTransfer(user, amount);

        emit InterestClaimed(user, vToken, amount);

        return amount;
    }

    /**
     * @notice Used to mint a new prime token
     * @param isIrrevocable is the tokens being issued is irrevocable
     * @param user token owner
     * @custom:error Throw IneligibleToClaim if user is not eligible to claim prime token
     * @custom:event Emits Mint event
     */
    function _mint(bool isIrrevocable, address user) internal {
        Token storage token = tokens[user];
        if (token.exists) revert IneligibleToClaim();

        token.exists = true;
        token.isIrrevocable = isIrrevocable;

        if (isIrrevocable) {
            ++totalIrrevocable;
        } else {
            ++totalRevocable;
        }

        if (totalIrrevocable > irrevocableLimit || totalRevocable > revocableLimit) revert InvalidLimit();
        _updateRoundAfterTokenMinted(user);

        emit Mint(user, isIrrevocable);
    }

    /**
     * @notice Used to burn a new prime token
     * @param user owner whose prime token to burn
     * @custom:error Throw UserHasNoPrimeToken if user has no prime token
     * @custom:event Emits Burn event
     */
    function _burn(address user) internal {
        Token memory token = tokens[user];
        if (!token.exists) revert UserHasNoPrimeToken();

        address[] storage allMarkets = _allMarkets;
        uint256 marketsLength = allMarkets.length;

        for (uint256 i; i < marketsLength; ) {
            address market = allMarkets[i];
            _executeBoost(user, market);
            markets[market].sumOfMembersScore = markets[market].sumOfMembersScore - interests[market][user].score;

            delete interests[market][user].score;
            delete interests[market][user].rewardIndex;

            unchecked {
                ++i;
            }
        }

        if (token.isIrrevocable) {
            --totalIrrevocable;
        } else {
            --totalRevocable;
        }

        delete tokens[user].exists;
        delete tokens[user].isIrrevocable;

        _updateRoundAfterTokenBurned(user);

        emit Burn(user);
    }

    /**
     * @notice Used to upgrade an token
     * @param user owner whose prime token to upgrade
     * @custom:error Throw InvalidLimit if total irrevocable tokens exceeds the limit
     * @custom:event Emits TokenUpgraded event
     */
    function _upgrade(address user) internal {
        Token storage userToken = tokens[user];

        userToken.isIrrevocable = true;
        ++totalIrrevocable;
        --totalRevocable;

        if (totalIrrevocable > irrevocableLimit) revert InvalidLimit();

        emit TokenUpgraded(user);
    }

    /**
     * @notice Accrue rewards for the user. Must be called before updating score
     * @param user account for which we need to accrue rewards
     * @param vToken the market for which we need to accrue rewards
     */
    function _executeBoost(address user, address vToken) internal {
        if (!markets[vToken].exists || !tokens[user].exists) {
            return;
        }

        accrueInterest(vToken);
        interests[vToken][user].accrued += _interestAccrued(vToken, user);
        interests[vToken][user].rewardIndex = markets[vToken].rewardIndex;
    }

    /**
     * @notice Update total score of user and market. Must be called after changing account's borrow or supply balance.
     * @param user account for which we need to update score
     * @param market the market for which we need to score
     */
    function _updateScore(address user, address market) internal {
        Market storage _market = markets[market];
        if (!_market.exists || !tokens[user].exists) {
            return;
        }

        uint256 score = _calculateScore(market, user);
        _market.sumOfMembersScore = _market.sumOfMembersScore - interests[market][user].score + score;

        interests[market][user].score = score;
    }

    /**
     * @notice Verify new alpha arguments
     * @param _alphaNumerator numerator of alpha. If alpha is 0.5 then numerator is 1
     * @param _alphaDenominator denominator of alpha. If alpha is 0.5 then denominator is 2
     * @custom:error Throw InvalidAlphaArguments if alpha is invalid
     */
    function _checkAlphaArguments(uint128 _alphaNumerator, uint128 _alphaDenominator) internal pure {
        if (_alphaNumerator >= _alphaDenominator || _alphaNumerator == 0) {
            revert InvalidAlphaArguments();
        }
    }

    /**
     * @notice starts round to update scores of a particular or all markets
     */
    function _startScoreUpdateRound() internal {
        nextScoreUpdateRoundId++;
        totalScoreUpdatesRequired = totalIrrevocable + totalRevocable;
        pendingScoreUpdates = totalScoreUpdatesRequired;
    }

    /**
     * @notice update the required score updates when token is burned before round is completed
     */
    function _updateRoundAfterTokenBurned(address user) internal {
        if (totalScoreUpdatesRequired != 0) --totalScoreUpdatesRequired;

        if (pendingScoreUpdates != 0 && !isScoreUpdated[nextScoreUpdateRoundId][user]) {
            --pendingScoreUpdates;
        }
    }

    /**
     * @notice update the required score updates when token is minted before round is completed
     */
    function _updateRoundAfterTokenMinted(address user) internal {
        if (totalScoreUpdatesRequired != 0) isScoreUpdated[nextScoreUpdateRoundId][user] = true;
    }

    /**
     * @notice fetch the current XVS balance of user in the XVSVault
     * @param user the account address
     * @return xvsBalance the XVS balance of user
     */
    function _xvsBalanceOfUser(address user) internal view returns (uint256) {
        (uint256 xvs, , uint256 pendingWithdrawals) = IXVSVault(xvsVault).getUserInfo(
            xvsVaultRewardToken,
            xvsVaultPoolId,
            user
        );
        return (xvs - pendingWithdrawals);
    }

    /**
     * @notice calculate the current XVS balance that will be used in calculation of score
     * @param xvs the actual XVS balance of user
     * @return xvsBalanceForScore the XVS balance to use in score
     */
    function _xvsBalanceForScore(uint256 xvs) internal view returns (uint256) {
        if (xvs > MAXIMUM_XVS_CAP) {
            return MAXIMUM_XVS_CAP;
        }
        return xvs;
    }

    /**
     * @notice calculate the capital for calculation of score
     * @param xvs the actual XVS balance of user
     * @param borrow the borrow balance of user
     * @param supply the supply balance of user
     * @param market the market vToken address
     * @return capital the capital to use in calculation of score
     */
    function _capitalForScore(
        uint256 xvs,
        uint256 borrow,
        uint256 supply,
        address market
    ) internal view returns (Capital memory capital) {
        address xvsToken = IXVSVault(xvsVault).xvsAddress();

        uint256 xvsPrice = oracle.getPrice(xvsToken);
        capital.borrowCapUSD = (xvsPrice * ((xvs * markets[market].borrowMultiplier) / EXP_SCALE)) / EXP_SCALE;
        capital.supplyCapUSD = (xvsPrice * ((xvs * markets[market].supplyMultiplier) / EXP_SCALE)) / EXP_SCALE;

        uint256 tokenPrice = oracle.getUnderlyingPrice(market);
        uint256 supplyUSD = (tokenPrice * supply) / EXP_SCALE;
        uint256 borrowUSD = (tokenPrice * borrow) / EXP_SCALE;

        if (supplyUSD >= capital.supplyCapUSD) {
            supply = supplyUSD != 0 ? (supply * capital.supplyCapUSD) / supplyUSD : 0;
        }

        if (borrowUSD >= capital.borrowCapUSD) {
            borrow = borrowUSD != 0 ? (borrow * capital.borrowCapUSD) / borrowUSD : 0;
        }

        capital.capital = supply + borrow;
        capital.cappedSupply = supply;
        capital.cappedBorrow = borrow;
    }

    /**
     * @notice Used to get if the XVS balance is eligible for prime token
     * @param amount amount of XVS
     * @return isEligible true if the staked XVS amount is enough to consider the associated user eligible for a Prime token, false otherwise
     */
    function _isEligible(uint256 amount) internal view returns (bool) {
        if (amount >= MINIMUM_STAKED_XVS) {
            return true;
        }

        return false;
    }

    /**
     * @notice Calculate the interests accrued by the user in the market, since the last accrual
     * @param vToken the market for which to calculate the accrued interest
     * @param user the user for which to calculate the accrued interest
     * @return interestAccrued the number of underlying tokens accrued by the user since the last accrual
     */
    function _interestAccrued(address vToken, address user) internal view returns (uint256) {
        Interest memory interest = interests[vToken][user];
        uint256 index = markets[vToken].rewardIndex - interest.rewardIndex;

        uint256 score = interest.score;

        return (index * score) / EXP_SCALE;
    }

    /**
     * @notice Returns the underlying token associated with the VToken, or wrapped native token if the market is native market
     * @param vToken the market whose underlying token will be returned
     * @return underlying The address of the underlying token associated with the VToken, or the address of the WRAPPED_NATIVE_TOKEN token if the market is NATIVE_MARKET
     */
    function _getUnderlying(address vToken) internal view returns (address) {
        if (vToken == NATIVE_MARKET) {
            return WRAPPED_NATIVE_TOKEN;
        }
        return IVToken(vToken).underlying();
    }

    //////////////////////////////////////////////////
    //////////////// APR Calculation ////////////////
    ////////////////////////////////////////////////

    /**
     * @notice the total income that's going to be distributed in a year to prime token holders
     * @param vToken the market for which to fetch the total income that's going to distributed in a year
     * @return amount the total income
     */
    function incomeDistributionYearly(address vToken) public view returns (uint256 amount) {
        uint256 totalIncomePerBlockOrSecondFromPLP = IPrimeLiquidityProvider(primeLiquidityProvider)
            .getEffectiveDistributionSpeed(_getUnderlying(vToken));
        amount = blocksOrSecondsPerYear * totalIncomePerBlockOrSecondFromPLP;
    }

    /**
     * @notice used to calculate the supply and borrow APR of the user
     * @param vToken the market for which to fetch the APR
     * @param totalSupply the total token supply of the user
     * @param totalBorrow the total tokens borrowed by the user
     * @param totalCappedSupply the total token capped supply of the user
     * @param totalCappedBorrow the total capped tokens borrowed by the user
     * @param userScore the score of the user
     * @param totalScore the total market score
     * @return supplyAPR the supply APR of the user
     * @return borrowAPR the borrow APR of the user
     */
    function _calculateUserAPR(
        address vToken,
        uint256 totalSupply,
        uint256 totalBorrow,
        uint256 totalCappedSupply,
        uint256 totalCappedBorrow,
        uint256 userScore,
        uint256 totalScore
    ) internal view returns (uint256 supplyAPR, uint256 borrowAPR) {
        if (totalScore == 0) return (0, 0);

        uint256 userYearlyIncome = (userScore * incomeDistributionYearly(vToken)) / totalScore;

        uint256 totalCappedValue = totalCappedSupply + totalCappedBorrow;

        if (totalCappedValue == 0) return (0, 0);

        uint256 maximumBps = MAXIMUM_BPS;
        uint256 userSupplyIncomeYearly;
        uint256 userBorrowIncomeYearly;
        userSupplyIncomeYearly = (userYearlyIncome * totalCappedSupply) / totalCappedValue;
        userBorrowIncomeYearly = (userYearlyIncome * totalCappedBorrow) / totalCappedValue;
        supplyAPR = totalSupply == 0 ? 0 : ((userSupplyIncomeYearly * maximumBps) / totalSupply);
        borrowAPR = totalBorrow == 0 ? 0 : ((userBorrowIncomeYearly * maximumBps) / totalBorrow);
    }
}

File 2 of 29 : Ownable2StepUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable2Step.sol)

pragma solidity ^0.8.0;

import "./OwnableUpgradeable.sol";
import "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module which provides 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} and {acceptOwnership}.
 *
 * This module is used through inheritance. It will make available all functions
 * from parent (Ownable).
 */
abstract contract Ownable2StepUpgradeable is Initializable, OwnableUpgradeable {
    function __Ownable2Step_init() internal onlyInitializing {
        __Ownable_init_unchained();
    }

    function __Ownable2Step_init_unchained() internal onlyInitializing {
    }
    address private _pendingOwner;

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

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

    /**
     * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual override onlyOwner {
        _pendingOwner = newOwner;
        emit OwnershipTransferStarted(owner(), newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual override {
        delete _pendingOwner;
        super._transferOwnership(newOwner);
    }

    /**
     * @dev The new owner accepts the ownership transfer.
     */
    function acceptOwnership() public virtual {
        address sender = _msgSender();
        require(pendingOwner() == sender, "Ownable2Step: caller is not the new owner");
        _transferOwnership(sender);
    }

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

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

pragma solidity ^0.8.0;

import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/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 onlyInitializing {
        __Ownable_init_unchained();
    }

    function __Ownable_init_unchained() internal onlyInitializing {
        _transferOwnership(_msgSender());
    }

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

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

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

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

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

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

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

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

pragma solidity ^0.8.2;

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

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

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

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

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

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

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

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

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

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

File 5 of 29 : PausableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)

pragma solidity ^0.8.0;

import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";

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

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

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    function __Pausable_init() internal onlyInitializing {
        __Pausable_init_unchained();
    }

    function __Pausable_init_unchained() internal onlyInitializing {
        _paused = false;
    }

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

File 7 of 29 : IERC20MetadataUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC20Upgradeable.sol";

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

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

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

File 8 of 29 : IERC20PermitUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 */
interface IERC20PermitUpgradeable {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

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

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

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

pragma solidity ^0.8.0;

import "../IERC20Upgradeable.sol";
import "../extensions/IERC20PermitUpgradeable.sol";
import "../../../utils/AddressUpgradeable.sol";

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

File 11 of 29 : ContextUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;
import "../proxy/utils/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 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 onlyInitializing {
    }

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

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

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

File 12 of 29 : SafeCastUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.

pragma solidity ^0.8.0;

/**
 * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow
 * checks.
 *
 * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
 * easily result in undesired exploitation or bugs, since developers usually
 * assume that overflows raise errors. `SafeCast` restores this intuition by
 * reverting the transaction when such 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.
 *
 * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing
 * all math on `uint256` and `int256` and then downcasting.
 */
library SafeCastUpgradeable {
    /**
     * @dev Returns the downcasted uint248 from uint256, reverting on
     * overflow (when the input is greater than largest uint248).
     *
     * Counterpart to Solidity's `uint248` operator.
     *
     * Requirements:
     *
     * - input must fit into 248 bits
     *
     * _Available since v4.7._
     */
    function toUint248(uint256 value) internal pure returns (uint248) {
        require(value <= type(uint248).max, "SafeCast: value doesn't fit in 248 bits");
        return uint248(value);
    }

    /**
     * @dev Returns the downcasted uint240 from uint256, reverting on
     * overflow (when the input is greater than largest uint240).
     *
     * Counterpart to Solidity's `uint240` operator.
     *
     * Requirements:
     *
     * - input must fit into 240 bits
     *
     * _Available since v4.7._
     */
    function toUint240(uint256 value) internal pure returns (uint240) {
        require(value <= type(uint240).max, "SafeCast: value doesn't fit in 240 bits");
        return uint240(value);
    }

    /**
     * @dev Returns the downcasted uint232 from uint256, reverting on
     * overflow (when the input is greater than largest uint232).
     *
     * Counterpart to Solidity's `uint232` operator.
     *
     * Requirements:
     *
     * - input must fit into 232 bits
     *
     * _Available since v4.7._
     */
    function toUint232(uint256 value) internal pure returns (uint232) {
        require(value <= type(uint232).max, "SafeCast: value doesn't fit in 232 bits");
        return uint232(value);
    }

    /**
     * @dev Returns the downcasted uint224 from uint256, reverting on
     * overflow (when the input is greater than largest uint224).
     *
     * Counterpart to Solidity's `uint224` operator.
     *
     * Requirements:
     *
     * - input must fit into 224 bits
     *
     * _Available since v4.2._
     */
    function toUint224(uint256 value) internal pure returns (uint224) {
        require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits");
        return uint224(value);
    }

    /**
     * @dev Returns the downcasted uint216 from uint256, reverting on
     * overflow (when the input is greater than largest uint216).
     *
     * Counterpart to Solidity's `uint216` operator.
     *
     * Requirements:
     *
     * - input must fit into 216 bits
     *
     * _Available since v4.7._
     */
    function toUint216(uint256 value) internal pure returns (uint216) {
        require(value <= type(uint216).max, "SafeCast: value doesn't fit in 216 bits");
        return uint216(value);
    }

    /**
     * @dev Returns the downcasted uint208 from uint256, reverting on
     * overflow (when the input is greater than largest uint208).
     *
     * Counterpart to Solidity's `uint208` operator.
     *
     * Requirements:
     *
     * - input must fit into 208 bits
     *
     * _Available since v4.7._
     */
    function toUint208(uint256 value) internal pure returns (uint208) {
        require(value <= type(uint208).max, "SafeCast: value doesn't fit in 208 bits");
        return uint208(value);
    }

    /**
     * @dev Returns the downcasted uint200 from uint256, reverting on
     * overflow (when the input is greater than largest uint200).
     *
     * Counterpart to Solidity's `uint200` operator.
     *
     * Requirements:
     *
     * - input must fit into 200 bits
     *
     * _Available since v4.7._
     */
    function toUint200(uint256 value) internal pure returns (uint200) {
        require(value <= type(uint200).max, "SafeCast: value doesn't fit in 200 bits");
        return uint200(value);
    }

    /**
     * @dev Returns the downcasted uint192 from uint256, reverting on
     * overflow (when the input is greater than largest uint192).
     *
     * Counterpart to Solidity's `uint192` operator.
     *
     * Requirements:
     *
     * - input must fit into 192 bits
     *
     * _Available since v4.7._
     */
    function toUint192(uint256 value) internal pure returns (uint192) {
        require(value <= type(uint192).max, "SafeCast: value doesn't fit in 192 bits");
        return uint192(value);
    }

    /**
     * @dev Returns the downcasted uint184 from uint256, reverting on
     * overflow (when the input is greater than largest uint184).
     *
     * Counterpart to Solidity's `uint184` operator.
     *
     * Requirements:
     *
     * - input must fit into 184 bits
     *
     * _Available since v4.7._
     */
    function toUint184(uint256 value) internal pure returns (uint184) {
        require(value <= type(uint184).max, "SafeCast: value doesn't fit in 184 bits");
        return uint184(value);
    }

    /**
     * @dev Returns the downcasted uint176 from uint256, reverting on
     * overflow (when the input is greater than largest uint176).
     *
     * Counterpart to Solidity's `uint176` operator.
     *
     * Requirements:
     *
     * - input must fit into 176 bits
     *
     * _Available since v4.7._
     */
    function toUint176(uint256 value) internal pure returns (uint176) {
        require(value <= type(uint176).max, "SafeCast: value doesn't fit in 176 bits");
        return uint176(value);
    }

    /**
     * @dev Returns the downcasted uint168 from uint256, reverting on
     * overflow (when the input is greater than largest uint168).
     *
     * Counterpart to Solidity's `uint168` operator.
     *
     * Requirements:
     *
     * - input must fit into 168 bits
     *
     * _Available since v4.7._
     */
    function toUint168(uint256 value) internal pure returns (uint168) {
        require(value <= type(uint168).max, "SafeCast: value doesn't fit in 168 bits");
        return uint168(value);
    }

    /**
     * @dev Returns the downcasted uint160 from uint256, reverting on
     * overflow (when the input is greater than largest uint160).
     *
     * Counterpart to Solidity's `uint160` operator.
     *
     * Requirements:
     *
     * - input must fit into 160 bits
     *
     * _Available since v4.7._
     */
    function toUint160(uint256 value) internal pure returns (uint160) {
        require(value <= type(uint160).max, "SafeCast: value doesn't fit in 160 bits");
        return uint160(value);
    }

    /**
     * @dev Returns the downcasted uint152 from uint256, reverting on
     * overflow (when the input is greater than largest uint152).
     *
     * Counterpart to Solidity's `uint152` operator.
     *
     * Requirements:
     *
     * - input must fit into 152 bits
     *
     * _Available since v4.7._
     */
    function toUint152(uint256 value) internal pure returns (uint152) {
        require(value <= type(uint152).max, "SafeCast: value doesn't fit in 152 bits");
        return uint152(value);
    }

    /**
     * @dev Returns the downcasted uint144 from uint256, reverting on
     * overflow (when the input is greater than largest uint144).
     *
     * Counterpart to Solidity's `uint144` operator.
     *
     * Requirements:
     *
     * - input must fit into 144 bits
     *
     * _Available since v4.7._
     */
    function toUint144(uint256 value) internal pure returns (uint144) {
        require(value <= type(uint144).max, "SafeCast: value doesn't fit in 144 bits");
        return uint144(value);
    }

    /**
     * @dev Returns the downcasted uint136 from uint256, reverting on
     * overflow (when the input is greater than largest uint136).
     *
     * Counterpart to Solidity's `uint136` operator.
     *
     * Requirements:
     *
     * - input must fit into 136 bits
     *
     * _Available since v4.7._
     */
    function toUint136(uint256 value) internal pure returns (uint136) {
        require(value <= type(uint136).max, "SafeCast: value doesn't fit in 136 bits");
        return uint136(value);
    }

    /**
     * @dev Returns the downcasted uint128 from uint256, reverting on
     * overflow (when the input is greater than largest uint128).
     *
     * Counterpart to Solidity's `uint128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     *
     * _Available since v2.5._
     */
    function toUint128(uint256 value) internal pure returns (uint128) {
        require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits");
        return uint128(value);
    }

    /**
     * @dev Returns the downcasted uint120 from uint256, reverting on
     * overflow (when the input is greater than largest uint120).
     *
     * Counterpart to Solidity's `uint120` operator.
     *
     * Requirements:
     *
     * - input must fit into 120 bits
     *
     * _Available since v4.7._
     */
    function toUint120(uint256 value) internal pure returns (uint120) {
        require(value <= type(uint120).max, "SafeCast: value doesn't fit in 120 bits");
        return uint120(value);
    }

    /**
     * @dev Returns the downcasted uint112 from uint256, reverting on
     * overflow (when the input is greater than largest uint112).
     *
     * Counterpart to Solidity's `uint112` operator.
     *
     * Requirements:
     *
     * - input must fit into 112 bits
     *
     * _Available since v4.7._
     */
    function toUint112(uint256 value) internal pure returns (uint112) {
        require(value <= type(uint112).max, "SafeCast: value doesn't fit in 112 bits");
        return uint112(value);
    }

    /**
     * @dev Returns the downcasted uint104 from uint256, reverting on
     * overflow (when the input is greater than largest uint104).
     *
     * Counterpart to Solidity's `uint104` operator.
     *
     * Requirements:
     *
     * - input must fit into 104 bits
     *
     * _Available since v4.7._
     */
    function toUint104(uint256 value) internal pure returns (uint104) {
        require(value <= type(uint104).max, "SafeCast: value doesn't fit in 104 bits");
        return uint104(value);
    }

    /**
     * @dev Returns the downcasted uint96 from uint256, reverting on
     * overflow (when the input is greater than largest uint96).
     *
     * Counterpart to Solidity's `uint96` operator.
     *
     * Requirements:
     *
     * - input must fit into 96 bits
     *
     * _Available since v4.2._
     */
    function toUint96(uint256 value) internal pure returns (uint96) {
        require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits");
        return uint96(value);
    }

    /**
     * @dev Returns the downcasted uint88 from uint256, reverting on
     * overflow (when the input is greater than largest uint88).
     *
     * Counterpart to Solidity's `uint88` operator.
     *
     * Requirements:
     *
     * - input must fit into 88 bits
     *
     * _Available since v4.7._
     */
    function toUint88(uint256 value) internal pure returns (uint88) {
        require(value <= type(uint88).max, "SafeCast: value doesn't fit in 88 bits");
        return uint88(value);
    }

    /**
     * @dev Returns the downcasted uint80 from uint256, reverting on
     * overflow (when the input is greater than largest uint80).
     *
     * Counterpart to Solidity's `uint80` operator.
     *
     * Requirements:
     *
     * - input must fit into 80 bits
     *
     * _Available since v4.7._
     */
    function toUint80(uint256 value) internal pure returns (uint80) {
        require(value <= type(uint80).max, "SafeCast: value doesn't fit in 80 bits");
        return uint80(value);
    }

    /**
     * @dev Returns the downcasted uint72 from uint256, reverting on
     * overflow (when the input is greater than largest uint72).
     *
     * Counterpart to Solidity's `uint72` operator.
     *
     * Requirements:
     *
     * - input must fit into 72 bits
     *
     * _Available since v4.7._
     */
    function toUint72(uint256 value) internal pure returns (uint72) {
        require(value <= type(uint72).max, "SafeCast: value doesn't fit in 72 bits");
        return uint72(value);
    }

    /**
     * @dev Returns the downcasted uint64 from uint256, reverting on
     * overflow (when the input is greater than largest uint64).
     *
     * Counterpart to Solidity's `uint64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     *
     * _Available since v2.5._
     */
    function toUint64(uint256 value) internal pure returns (uint64) {
        require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits");
        return uint64(value);
    }

    /**
     * @dev Returns the downcasted uint56 from uint256, reverting on
     * overflow (when the input is greater than largest uint56).
     *
     * Counterpart to Solidity's `uint56` operator.
     *
     * Requirements:
     *
     * - input must fit into 56 bits
     *
     * _Available since v4.7._
     */
    function toUint56(uint256 value) internal pure returns (uint56) {
        require(value <= type(uint56).max, "SafeCast: value doesn't fit in 56 bits");
        return uint56(value);
    }

    /**
     * @dev Returns the downcasted uint48 from uint256, reverting on
     * overflow (when the input is greater than largest uint48).
     *
     * Counterpart to Solidity's `uint48` operator.
     *
     * Requirements:
     *
     * - input must fit into 48 bits
     *
     * _Available since v4.7._
     */
    function toUint48(uint256 value) internal pure returns (uint48) {
        require(value <= type(uint48).max, "SafeCast: value doesn't fit in 48 bits");
        return uint48(value);
    }

    /**
     * @dev Returns the downcasted uint40 from uint256, reverting on
     * overflow (when the input is greater than largest uint40).
     *
     * Counterpart to Solidity's `uint40` operator.
     *
     * Requirements:
     *
     * - input must fit into 40 bits
     *
     * _Available since v4.7._
     */
    function toUint40(uint256 value) internal pure returns (uint40) {
        require(value <= type(uint40).max, "SafeCast: value doesn't fit in 40 bits");
        return uint40(value);
    }

    /**
     * @dev Returns the downcasted uint32 from uint256, reverting on
     * overflow (when the input is greater than largest uint32).
     *
     * Counterpart to Solidity's `uint32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     *
     * _Available since v2.5._
     */
    function toUint32(uint256 value) internal pure returns (uint32) {
        require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits");
        return uint32(value);
    }

    /**
     * @dev Returns the downcasted uint24 from uint256, reverting on
     * overflow (when the input is greater than largest uint24).
     *
     * Counterpart to Solidity's `uint24` operator.
     *
     * Requirements:
     *
     * - input must fit into 24 bits
     *
     * _Available since v4.7._
     */
    function toUint24(uint256 value) internal pure returns (uint24) {
        require(value <= type(uint24).max, "SafeCast: value doesn't fit in 24 bits");
        return uint24(value);
    }

    /**
     * @dev Returns the downcasted uint16 from uint256, reverting on
     * overflow (when the input is greater than largest uint16).
     *
     * Counterpart to Solidity's `uint16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     *
     * _Available since v2.5._
     */
    function toUint16(uint256 value) internal pure returns (uint16) {
        require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits");
        return uint16(value);
    }

    /**
     * @dev Returns the downcasted uint8 from uint256, reverting on
     * overflow (when the input is greater than largest uint8).
     *
     * Counterpart to Solidity's `uint8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits
     *
     * _Available since v2.5._
     */
    function toUint8(uint256 value) internal pure returns (uint8) {
        require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits");
        return uint8(value);
    }

    /**
     * @dev Converts a signed int256 into an unsigned uint256.
     *
     * Requirements:
     *
     * - input must be greater than or equal to 0.
     *
     * _Available since v3.0._
     */
    function toUint256(int256 value) internal pure returns (uint256) {
        require(value >= 0, "SafeCast: value must be positive");
        return uint256(value);
    }

    /**
     * @dev Returns the downcasted int248 from int256, reverting on
     * overflow (when the input is less than smallest int248 or
     * greater than largest int248).
     *
     * Counterpart to Solidity's `int248` operator.
     *
     * Requirements:
     *
     * - input must fit into 248 bits
     *
     * _Available since v4.7._
     */
    function toInt248(int256 value) internal pure returns (int248 downcasted) {
        downcasted = int248(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 248 bits");
    }

    /**
     * @dev Returns the downcasted int240 from int256, reverting on
     * overflow (when the input is less than smallest int240 or
     * greater than largest int240).
     *
     * Counterpart to Solidity's `int240` operator.
     *
     * Requirements:
     *
     * - input must fit into 240 bits
     *
     * _Available since v4.7._
     */
    function toInt240(int256 value) internal pure returns (int240 downcasted) {
        downcasted = int240(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 240 bits");
    }

    /**
     * @dev Returns the downcasted int232 from int256, reverting on
     * overflow (when the input is less than smallest int232 or
     * greater than largest int232).
     *
     * Counterpart to Solidity's `int232` operator.
     *
     * Requirements:
     *
     * - input must fit into 232 bits
     *
     * _Available since v4.7._
     */
    function toInt232(int256 value) internal pure returns (int232 downcasted) {
        downcasted = int232(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 232 bits");
    }

    /**
     * @dev Returns the downcasted int224 from int256, reverting on
     * overflow (when the input is less than smallest int224 or
     * greater than largest int224).
     *
     * Counterpart to Solidity's `int224` operator.
     *
     * Requirements:
     *
     * - input must fit into 224 bits
     *
     * _Available since v4.7._
     */
    function toInt224(int256 value) internal pure returns (int224 downcasted) {
        downcasted = int224(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 224 bits");
    }

    /**
     * @dev Returns the downcasted int216 from int256, reverting on
     * overflow (when the input is less than smallest int216 or
     * greater than largest int216).
     *
     * Counterpart to Solidity's `int216` operator.
     *
     * Requirements:
     *
     * - input must fit into 216 bits
     *
     * _Available since v4.7._
     */
    function toInt216(int256 value) internal pure returns (int216 downcasted) {
        downcasted = int216(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 216 bits");
    }

    /**
     * @dev Returns the downcasted int208 from int256, reverting on
     * overflow (when the input is less than smallest int208 or
     * greater than largest int208).
     *
     * Counterpart to Solidity's `int208` operator.
     *
     * Requirements:
     *
     * - input must fit into 208 bits
     *
     * _Available since v4.7._
     */
    function toInt208(int256 value) internal pure returns (int208 downcasted) {
        downcasted = int208(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 208 bits");
    }

    /**
     * @dev Returns the downcasted int200 from int256, reverting on
     * overflow (when the input is less than smallest int200 or
     * greater than largest int200).
     *
     * Counterpart to Solidity's `int200` operator.
     *
     * Requirements:
     *
     * - input must fit into 200 bits
     *
     * _Available since v4.7._
     */
    function toInt200(int256 value) internal pure returns (int200 downcasted) {
        downcasted = int200(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 200 bits");
    }

    /**
     * @dev Returns the downcasted int192 from int256, reverting on
     * overflow (when the input is less than smallest int192 or
     * greater than largest int192).
     *
     * Counterpart to Solidity's `int192` operator.
     *
     * Requirements:
     *
     * - input must fit into 192 bits
     *
     * _Available since v4.7._
     */
    function toInt192(int256 value) internal pure returns (int192 downcasted) {
        downcasted = int192(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 192 bits");
    }

    /**
     * @dev Returns the downcasted int184 from int256, reverting on
     * overflow (when the input is less than smallest int184 or
     * greater than largest int184).
     *
     * Counterpart to Solidity's `int184` operator.
     *
     * Requirements:
     *
     * - input must fit into 184 bits
     *
     * _Available since v4.7._
     */
    function toInt184(int256 value) internal pure returns (int184 downcasted) {
        downcasted = int184(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 184 bits");
    }

    /**
     * @dev Returns the downcasted int176 from int256, reverting on
     * overflow (when the input is less than smallest int176 or
     * greater than largest int176).
     *
     * Counterpart to Solidity's `int176` operator.
     *
     * Requirements:
     *
     * - input must fit into 176 bits
     *
     * _Available since v4.7._
     */
    function toInt176(int256 value) internal pure returns (int176 downcasted) {
        downcasted = int176(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 176 bits");
    }

    /**
     * @dev Returns the downcasted int168 from int256, reverting on
     * overflow (when the input is less than smallest int168 or
     * greater than largest int168).
     *
     * Counterpart to Solidity's `int168` operator.
     *
     * Requirements:
     *
     * - input must fit into 168 bits
     *
     * _Available since v4.7._
     */
    function toInt168(int256 value) internal pure returns (int168 downcasted) {
        downcasted = int168(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 168 bits");
    }

    /**
     * @dev Returns the downcasted int160 from int256, reverting on
     * overflow (when the input is less than smallest int160 or
     * greater than largest int160).
     *
     * Counterpart to Solidity's `int160` operator.
     *
     * Requirements:
     *
     * - input must fit into 160 bits
     *
     * _Available since v4.7._
     */
    function toInt160(int256 value) internal pure returns (int160 downcasted) {
        downcasted = int160(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 160 bits");
    }

    /**
     * @dev Returns the downcasted int152 from int256, reverting on
     * overflow (when the input is less than smallest int152 or
     * greater than largest int152).
     *
     * Counterpart to Solidity's `int152` operator.
     *
     * Requirements:
     *
     * - input must fit into 152 bits
     *
     * _Available since v4.7._
     */
    function toInt152(int256 value) internal pure returns (int152 downcasted) {
        downcasted = int152(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 152 bits");
    }

    /**
     * @dev Returns the downcasted int144 from int256, reverting on
     * overflow (when the input is less than smallest int144 or
     * greater than largest int144).
     *
     * Counterpart to Solidity's `int144` operator.
     *
     * Requirements:
     *
     * - input must fit into 144 bits
     *
     * _Available since v4.7._
     */
    function toInt144(int256 value) internal pure returns (int144 downcasted) {
        downcasted = int144(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 144 bits");
    }

    /**
     * @dev Returns the downcasted int136 from int256, reverting on
     * overflow (when the input is less than smallest int136 or
     * greater than largest int136).
     *
     * Counterpart to Solidity's `int136` operator.
     *
     * Requirements:
     *
     * - input must fit into 136 bits
     *
     * _Available since v4.7._
     */
    function toInt136(int256 value) internal pure returns (int136 downcasted) {
        downcasted = int136(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 136 bits");
    }

    /**
     * @dev Returns the downcasted int128 from int256, reverting on
     * overflow (when the input is less than smallest int128 or
     * greater than largest int128).
     *
     * Counterpart to Solidity's `int128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     *
     * _Available since v3.1._
     */
    function toInt128(int256 value) internal pure returns (int128 downcasted) {
        downcasted = int128(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 128 bits");
    }

    /**
     * @dev Returns the downcasted int120 from int256, reverting on
     * overflow (when the input is less than smallest int120 or
     * greater than largest int120).
     *
     * Counterpart to Solidity's `int120` operator.
     *
     * Requirements:
     *
     * - input must fit into 120 bits
     *
     * _Available since v4.7._
     */
    function toInt120(int256 value) internal pure returns (int120 downcasted) {
        downcasted = int120(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 120 bits");
    }

    /**
     * @dev Returns the downcasted int112 from int256, reverting on
     * overflow (when the input is less than smallest int112 or
     * greater than largest int112).
     *
     * Counterpart to Solidity's `int112` operator.
     *
     * Requirements:
     *
     * - input must fit into 112 bits
     *
     * _Available since v4.7._
     */
    function toInt112(int256 value) internal pure returns (int112 downcasted) {
        downcasted = int112(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 112 bits");
    }

    /**
     * @dev Returns the downcasted int104 from int256, reverting on
     * overflow (when the input is less than smallest int104 or
     * greater than largest int104).
     *
     * Counterpart to Solidity's `int104` operator.
     *
     * Requirements:
     *
     * - input must fit into 104 bits
     *
     * _Available since v4.7._
     */
    function toInt104(int256 value) internal pure returns (int104 downcasted) {
        downcasted = int104(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 104 bits");
    }

    /**
     * @dev Returns the downcasted int96 from int256, reverting on
     * overflow (when the input is less than smallest int96 or
     * greater than largest int96).
     *
     * Counterpart to Solidity's `int96` operator.
     *
     * Requirements:
     *
     * - input must fit into 96 bits
     *
     * _Available since v4.7._
     */
    function toInt96(int256 value) internal pure returns (int96 downcasted) {
        downcasted = int96(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 96 bits");
    }

    /**
     * @dev Returns the downcasted int88 from int256, reverting on
     * overflow (when the input is less than smallest int88 or
     * greater than largest int88).
     *
     * Counterpart to Solidity's `int88` operator.
     *
     * Requirements:
     *
     * - input must fit into 88 bits
     *
     * _Available since v4.7._
     */
    function toInt88(int256 value) internal pure returns (int88 downcasted) {
        downcasted = int88(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 88 bits");
    }

    /**
     * @dev Returns the downcasted int80 from int256, reverting on
     * overflow (when the input is less than smallest int80 or
     * greater than largest int80).
     *
     * Counterpart to Solidity's `int80` operator.
     *
     * Requirements:
     *
     * - input must fit into 80 bits
     *
     * _Available since v4.7._
     */
    function toInt80(int256 value) internal pure returns (int80 downcasted) {
        downcasted = int80(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 80 bits");
    }

    /**
     * @dev Returns the downcasted int72 from int256, reverting on
     * overflow (when the input is less than smallest int72 or
     * greater than largest int72).
     *
     * Counterpart to Solidity's `int72` operator.
     *
     * Requirements:
     *
     * - input must fit into 72 bits
     *
     * _Available since v4.7._
     */
    function toInt72(int256 value) internal pure returns (int72 downcasted) {
        downcasted = int72(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 72 bits");
    }

    /**
     * @dev Returns the downcasted int64 from int256, reverting on
     * overflow (when the input is less than smallest int64 or
     * greater than largest int64).
     *
     * Counterpart to Solidity's `int64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     *
     * _Available since v3.1._
     */
    function toInt64(int256 value) internal pure returns (int64 downcasted) {
        downcasted = int64(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 64 bits");
    }

    /**
     * @dev Returns the downcasted int56 from int256, reverting on
     * overflow (when the input is less than smallest int56 or
     * greater than largest int56).
     *
     * Counterpart to Solidity's `int56` operator.
     *
     * Requirements:
     *
     * - input must fit into 56 bits
     *
     * _Available since v4.7._
     */
    function toInt56(int256 value) internal pure returns (int56 downcasted) {
        downcasted = int56(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 56 bits");
    }

    /**
     * @dev Returns the downcasted int48 from int256, reverting on
     * overflow (when the input is less than smallest int48 or
     * greater than largest int48).
     *
     * Counterpart to Solidity's `int48` operator.
     *
     * Requirements:
     *
     * - input must fit into 48 bits
     *
     * _Available since v4.7._
     */
    function toInt48(int256 value) internal pure returns (int48 downcasted) {
        downcasted = int48(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 48 bits");
    }

    /**
     * @dev Returns the downcasted int40 from int256, reverting on
     * overflow (when the input is less than smallest int40 or
     * greater than largest int40).
     *
     * Counterpart to Solidity's `int40` operator.
     *
     * Requirements:
     *
     * - input must fit into 40 bits
     *
     * _Available since v4.7._
     */
    function toInt40(int256 value) internal pure returns (int40 downcasted) {
        downcasted = int40(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 40 bits");
    }

    /**
     * @dev Returns the downcasted int32 from int256, reverting on
     * overflow (when the input is less than smallest int32 or
     * greater than largest int32).
     *
     * Counterpart to Solidity's `int32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     *
     * _Available since v3.1._
     */
    function toInt32(int256 value) internal pure returns (int32 downcasted) {
        downcasted = int32(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 32 bits");
    }

    /**
     * @dev Returns the downcasted int24 from int256, reverting on
     * overflow (when the input is less than smallest int24 or
     * greater than largest int24).
     *
     * Counterpart to Solidity's `int24` operator.
     *
     * Requirements:
     *
     * - input must fit into 24 bits
     *
     * _Available since v4.7._
     */
    function toInt24(int256 value) internal pure returns (int24 downcasted) {
        downcasted = int24(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 24 bits");
    }

    /**
     * @dev Returns the downcasted int16 from int256, reverting on
     * overflow (when the input is less than smallest int16 or
     * greater than largest int16).
     *
     * Counterpart to Solidity's `int16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     *
     * _Available since v3.1._
     */
    function toInt16(int256 value) internal pure returns (int16 downcasted) {
        downcasted = int16(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 16 bits");
    }

    /**
     * @dev Returns the downcasted int8 from int256, reverting on
     * overflow (when the input is less than smallest int8 or
     * greater than largest int8).
     *
     * Counterpart to Solidity's `int8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits
     *
     * _Available since v3.1._
     */
    function toInt8(int256 value) internal pure returns (int8 downcasted) {
        downcasted = int8(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 8 bits");
    }

    /**
     * @dev Converts an unsigned uint256 into a signed int256.
     *
     * Requirements:
     *
     * - input must be less than or equal to maxInt256.
     *
     * _Available since v3.0._
     */
    function toInt256(uint256 value) internal pure returns (int256) {
        // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
        require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256");
        return int256(value);
    }
}

File 13 of 29 : IAccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)

pragma solidity ^0.8.0;

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControl {
    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted signaling this.
     *
     * _Available since v3.1._
     */
    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call, an admin role
     * bearer except when using {AccessControl-_setupRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) external view returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) external;
}

File 14 of 29 : AccessControlledV8.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.13;

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

import "./IAccessControlManagerV8.sol";

/**
 * @title AccessControlledV8
 * @author Venus
 * @notice This contract is helper between access control manager and actual contract. This contract further inherited by other contract (using solidity 0.8.13)
 * to integrate access controlled mechanism. It provides initialise methods and verifying access methods.
 */
abstract contract AccessControlledV8 is Initializable, Ownable2StepUpgradeable {
    /// @notice Access control manager contract
    IAccessControlManagerV8 private _accessControlManager;

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

    /// @notice Emitted when access control manager contract address is changed
    event NewAccessControlManager(address oldAccessControlManager, address newAccessControlManager);

    /// @notice Thrown when the action is prohibited by AccessControlManager
    error Unauthorized(address sender, address calledContract, string methodSignature);

    function __AccessControlled_init(address accessControlManager_) internal onlyInitializing {
        __Ownable2Step_init();
        __AccessControlled_init_unchained(accessControlManager_);
    }

    function __AccessControlled_init_unchained(address accessControlManager_) internal onlyInitializing {
        _setAccessControlManager(accessControlManager_);
    }

    /**
     * @notice Sets the address of AccessControlManager
     * @dev Admin function to set address of AccessControlManager
     * @param accessControlManager_ The new address of the AccessControlManager
     * @custom:event Emits NewAccessControlManager event
     * @custom:access Only Governance
     */
    function setAccessControlManager(address accessControlManager_) external onlyOwner {
        _setAccessControlManager(accessControlManager_);
    }

    /**
     * @notice Returns the address of the access control manager contract
     */
    function accessControlManager() external view returns (IAccessControlManagerV8) {
        return _accessControlManager;
    }

    /**
     * @dev Internal function to set address of AccessControlManager
     * @param accessControlManager_ The new address of the AccessControlManager
     */
    function _setAccessControlManager(address accessControlManager_) internal {
        require(address(accessControlManager_) != address(0), "invalid acess control manager address");
        address oldAccessControlManager = address(_accessControlManager);
        _accessControlManager = IAccessControlManagerV8(accessControlManager_);
        emit NewAccessControlManager(oldAccessControlManager, accessControlManager_);
    }

    /**
     * @notice Reverts if the call is not allowed by AccessControlManager
     * @param signature Method signature
     */
    function _checkAccessAllowed(string memory signature) internal view {
        bool isAllowedToCall = _accessControlManager.isAllowedToCall(msg.sender, signature);

        if (!isAllowedToCall) {
            revert Unauthorized(msg.sender, address(this), signature);
        }
    }
}

File 15 of 29 : IAccessControlManagerV8.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.13;

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

/**
 * @title IAccessControlManagerV8
 * @author Venus
 * @notice Interface implemented by the `AccessControlManagerV8` contract.
 */
interface IAccessControlManagerV8 is IAccessControl {
    function giveCallPermission(address contractAddress, string calldata functionSig, address accountToPermit) external;

    function revokeCallPermission(
        address contractAddress,
        string calldata functionSig,
        address accountToRevoke
    ) external;

    function isAllowedToCall(address account, string calldata functionSig) external view returns (bool);

    function hasPermission(
        address account,
        address contractAddress,
        string calldata functionSig
    ) external view returns (bool);
}

File 16 of 29 : OracleInterface.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.13;

interface OracleInterface {
    function getPrice(address asset) external view returns (uint256);
}

interface ResilientOracleInterface is OracleInterface {
    function updatePrice(address vToken) external;

    function updateAssetPrice(address asset) external;

    function getUnderlyingPrice(address vToken) external view returns (uint256);
}

interface TwapInterface is OracleInterface {
    function updateTwap(address asset) external returns (uint256);
}

interface BoundValidatorInterface {
    function validatePriceWithAnchorPrice(
        address asset,
        uint256 reporterPrice,
        uint256 anchorPrice
    ) external view returns (bool);
}

File 17 of 29 : MaxLoopsLimitHelper.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.13;

/**
 * @title MaxLoopsLimitHelper
 * @author Venus
 * @notice Abstract contract used to avoid collection with too many items that would generate gas errors and DoS.
 */
abstract contract MaxLoopsLimitHelper {
    // Limit for the loops to avoid the DOS
    uint256 public maxLoopsLimit;

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

    /// @notice Emitted when max loops limit is set
    event MaxLoopsLimitUpdated(uint256 oldMaxLoopsLimit, uint256 newmaxLoopsLimit);

    /// @notice Thrown an error on maxLoopsLimit exceeds for any loop
    error MaxLoopsLimitExceeded(uint256 loopsLimit, uint256 requiredLoops);

    /**
     * @notice Set the limit for the loops can iterate to avoid the DOS
     * @param limit Limit for the max loops can execute at a time
     */
    function _setMaxLoopsLimit(uint256 limit) internal {
        require(limit > maxLoopsLimit, "Comptroller: Invalid maxLoopsLimit");

        uint256 oldMaxLoopsLimit = maxLoopsLimit;
        maxLoopsLimit = limit;

        emit MaxLoopsLimitUpdated(oldMaxLoopsLimit, limit);
    }

    /**
     * @notice Compare the maxLoopsLimit with number of the times loop iterate
     * @param len Length of the loops iterate
     * @custom:error MaxLoopsLimitExceeded error is thrown when loops length exceeds maxLoopsLimit
     */
    function _ensureMaxLoops(uint256 len) internal view {
        if (len > maxLoopsLimit) {
            revert MaxLoopsLimitExceeded(maxLoopsLimit, len);
        }
    }
}

File 18 of 29 : TimeManagerV8.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.13;

import { SECONDS_PER_YEAR } from "./constants.sol";

abstract contract TimeManagerV8 {
    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable
    uint256 public immutable blocksOrSecondsPerYear;

    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable
    bool public immutable isTimeBased;

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

    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable
    function() view returns (uint256) private immutable _getCurrentSlot;

    /// @notice Thrown when blocks per year is invalid
    error InvalidBlocksPerYear();

    /// @notice Thrown when time based but blocks per year is provided
    error InvalidTimeBasedConfiguration();

    /**
     * @param timeBased_ A boolean indicating whether the contract is based on time or block
     * If timeBased is true than blocksPerYear_ param is ignored as blocksOrSecondsPerYear is set to SECONDS_PER_YEAR
     * @param blocksPerYear_ The number of blocks per year
     * @custom:error InvalidBlocksPerYear is thrown if blocksPerYear entered is zero and timeBased is false
     * @custom:error InvalidTimeBasedConfiguration is thrown if blocksPerYear entered is non zero and timeBased is true
     * @custom:oz-upgrades-unsafe-allow constructor
     */
    constructor(bool timeBased_, uint256 blocksPerYear_) {
        if (!timeBased_ && blocksPerYear_ == 0) {
            revert InvalidBlocksPerYear();
        }

        if (timeBased_ && blocksPerYear_ != 0) {
            revert InvalidTimeBasedConfiguration();
        }

        isTimeBased = timeBased_;
        blocksOrSecondsPerYear = timeBased_ ? SECONDS_PER_YEAR : blocksPerYear_;
        _getCurrentSlot = timeBased_ ? _getBlockTimestamp : _getBlockNumber;
    }

    /**
     * @dev Function to simply retrieve block number or block timestamp
     * @return Current block number or block timestamp
     */
    function getBlockNumberOrTimestamp() public view virtual returns (uint256) {
        return _getCurrentSlot();
    }

    /**
     * @dev Returns the current timestamp in seconds
     * @return The current timestamp
     */
    function _getBlockTimestamp() private view returns (uint256) {
        return block.timestamp;
    }

    /**
     * @dev Returns the current block number
     * @return The current block number
     */
    function _getBlockNumber() private view returns (uint256) {
        return block.number;
    }
}

File 19 of 29 : constants.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.13;

/// @dev Base unit for computations, usually used in scaling (multiplications, divisions)
uint256 constant EXP_SCALE = 1e18;

/// @dev A unit (literal one) in EXP_SCALE, usually used in additions/subtractions
uint256 constant MANTISSA_ONE = EXP_SCALE;

/// @dev The approximate number of seconds per year
uint256 constant SECONDS_PER_YEAR = 31_536_000;

File 20 of 29 : IPoolRegistry.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.13;

/**
 * @title PoolRegistryInterface
 * @author Venus
 * @notice Interface implemented by `PoolRegistry`.
 */
interface PoolRegistryInterface {
    /**
     * @notice Struct for a Venus interest rate pool.
     */
    struct VenusPool {
        string name;
        address creator;
        address comptroller;
        uint256 blockPosted;
        uint256 timestampPosted;
    }

    /// @notice Get a pool by comptroller address
    function getPoolByComptroller(address comptroller) external view returns (VenusPool memory);
}

File 21 of 29 : IPrime.sol
pragma solidity 0.8.13;

import { PrimeStorageV1 } from "../PrimeStorage.sol";

/**
 * @title IPrime
 * @author Venus
 * @notice Interface for Prime Token
 */
interface IPrime {
    struct APRInfo {
        // supply APR of the user in BPS
        uint256 supplyAPR;
        // borrow APR of the user in BPS
        uint256 borrowAPR;
        // total score of the market
        uint256 totalScore;
        // score of the user
        uint256 userScore;
        // capped XVS balance of the user
        uint256 xvsBalanceForScore;
        // capital of the user
        uint256 capital;
        // capped supply of the user
        uint256 cappedSupply;
        // capped borrow of the user
        uint256 cappedBorrow;
        // capped supply of user in USD
        uint256 supplyCapUSD;
        // capped borrow of user in USD
        uint256 borrowCapUSD;
    }

    struct Capital {
        // capital of the user
        uint256 capital;
        // capped supply of the user
        uint256 cappedSupply;
        // capped borrow of the user
        uint256 cappedBorrow;
        // capped supply of user in USD
        uint256 supplyCapUSD;
        // capped borrow of user in USD
        uint256 borrowCapUSD;
    }

    /**
     * @notice Returns boosted pending interest accrued for a user for all markets
     * @param user the account for which to get the accrued interests
     * @return pendingRewards the number of underlying tokens accrued by the user for all markets
     */
    function getPendingRewards(address user) external returns (PrimeStorageV1.PendingReward[] memory pendingRewards);

    /**
     * @notice Update total score of multiple users and market
     * @param users accounts for which we need to update score
     */
    function updateScores(address[] memory users) external;

    /**
     * @notice Update value of alpha
     * @param _alphaNumerator numerator of alpha. If alpha is 0.5 then numerator is 1
     * @param _alphaDenominator denominator of alpha. If alpha is 0.5 then denominator is 2
     */
    function updateAlpha(uint128 _alphaNumerator, uint128 _alphaDenominator) external;

    /**
     * @notice Update multipliers for a market
     * @param market address of the market vToken
     * @param supplyMultiplier new supply multiplier for the market, scaled by 1e18
     * @param borrowMultiplier new borrow multiplier for the market, scaled by 1e18
     */
    function updateMultipliers(address market, uint256 supplyMultiplier, uint256 borrowMultiplier) external;

    /**
     * @notice Add a market to prime program
     * @param comptroller address of the comptroller
     * @param market address of the market vToken
     * @param supplyMultiplier the multiplier for supply cap. It should be converted to 1e18
     * @param borrowMultiplier the multiplier for borrow cap. It should be converted to 1e18
     */
    function addMarket(
        address comptroller,
        address market,
        uint256 supplyMultiplier,
        uint256 borrowMultiplier
    ) external;

    /**
     * @notice Set limits for total tokens that can be minted
     * @param _irrevocableLimit total number of irrevocable tokens that can be minted
     * @param _revocableLimit total number of revocable tokens that can be minted
     */
    function setLimit(uint256 _irrevocableLimit, uint256 _revocableLimit) external;

    /**
     * @notice Directly issue prime tokens to users
     * @param isIrrevocable are the tokens being issued
     * @param users list of address to issue tokens to
     */
    function issue(bool isIrrevocable, address[] calldata users) external;

    /**
     * @notice Executed by XVSVault whenever user's XVSVault balance changes
     * @param user the account address whose balance was updated
     */
    function xvsUpdated(address user) external;

    /**
     * @notice accrues interest and updates score for an user for a specific market
     * @param user the account address for which to accrue interest and update score
     * @param market the market for which to accrue interest and update score
     */
    function accrueInterestAndUpdateScore(address user, address market) external;

    /**
     * @notice For claiming prime token when staking period is completed
     */
    function claim() external;

    /**
     * @notice For burning any prime token
     * @param user the account address for which the prime token will be burned
     */
    function burn(address user) external;

    /**
     * @notice To pause or unpause claiming of interest
     */
    function togglePause() external;

    /**
     * @notice For user to claim boosted yield
     * @param vToken the market for which claim the accrued interest
     * @return amount the amount of tokens transferred to the user
     */
    function claimInterest(address vToken) external returns (uint256);

    /**
     * @notice For user to claim boosted yield
     * @param vToken the market for which claim the accrued interest
     * @param user the user for which to claim the accrued interest
     * @return amount the amount of tokens transferred to the user
     */
    function claimInterest(address vToken, address user) external returns (uint256);

    /**
     * @notice Distributes income from market since last distribution
     * @param vToken the market for which to distribute the income
     */
    function accrueInterest(address vToken) external;

    /**
     * @notice Returns boosted interest accrued for a user
     * @param vToken the market for which to fetch the accrued interest
     * @param user the account for which to get the accrued interest
     * @return interestAccrued the number of underlying tokens accrued by the user since the last accrual
     */
    function getInterestAccrued(address vToken, address user) external returns (uint256);

    /**
     * @notice Retrieves an array of all available markets
     * @return an array of addresses representing all available markets
     */
    function getAllMarkets() external view returns (address[] memory);

    /**
     * @notice fetch the numbers of seconds remaining for staking period to complete
     * @param user the account address for which we are checking the remaining time
     * @return timeRemaining the number of seconds the user needs to wait to claim prime token
     */
    function claimTimeRemaining(address user) external view returns (uint256);

    /**
     * @notice Returns supply and borrow APR for user for a given market
     * @param market the market for which to fetch the APR
     * @param user the account for which to get the APR
     * @return aprInfo APR information for the user for the given market
     */
    function calculateAPR(address market, address user) external view returns (APRInfo memory aprInfo);

    /**
     * @notice Returns supply and borrow APR for estimated supply, borrow and XVS staked
     * @param market the market for which to fetch the APR
     * @param user the account for which to get the APR
     * @param borrow hypothetical borrow amount
     * @param supply hypothetical supply amount
     * @param xvsStaked hypothetical staked XVS amount
     * @return aprInfo APR information for the user for the given market
     */
    function estimateAPR(
        address market,
        address user,
        uint256 borrow,
        uint256 supply,
        uint256 xvsStaked
    ) external view returns (APRInfo memory aprInfo);

    /**
     * @notice the total income that's going to be distributed in a year to prime token holders
     * @param vToken the market for which to fetch the total income that's going to distributed in a year
     * @return amount the total income
     */
    function incomeDistributionYearly(address vToken) external view returns (uint256 amount);

    /**
     * @notice Returns if user is a prime holder
     * @return isPrimeHolder true if user is a prime holder
     */
    function isUserPrimeHolder(address user) external view returns (bool);

    /**
     * @notice Set the limit for the loops can iterate to avoid the DOS
     * @param loopsLimit Number of loops limit
     */
    function setMaxLoopsLimit(uint256 loopsLimit) external;

    /**
     * @notice Update staked at timestamp for multiple users
     * @param users accounts for which we need to update staked at timestamp
     * @param timestamps new staked at timestamp for the users
     */
    function setStakedAt(address[] calldata users, uint256[] calldata timestamps) external;
}

File 22 of 29 : IPrimeLiquidityProvider.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.13;

import { IERC20Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";

/**
 * @title IPrimeLiquidityProvider
 * @author Venus
 * @notice Interface for PrimeLiquidityProvider
 */
interface IPrimeLiquidityProvider {
    /**
     * @notice Initialize the distribution of the token
     * @param tokens_ Array of addresses of the tokens to be intialized
     */
    function initializeTokens(address[] calldata tokens_) external;

    /**
     * @notice Pause fund transfer of tokens to Prime contract
     */
    function pauseFundsTransfer() external;

    /**
     * @notice Resume fund transfer of tokens to Prime contract
     */
    function resumeFundsTransfer() external;

    /**
     * @notice Set distribution speed (amount of token distribute per block or second)
     * @param tokens_ Array of addresses of the tokens
     * @param distributionSpeeds_ New distribution speeds for tokens
     */
    function setTokensDistributionSpeed(address[] calldata tokens_, uint256[] calldata distributionSpeeds_) external;

    /**
     * @notice Set max distribution speed for token (amount of maximum token distribute per block or second)
     * @param tokens_ Array of addresses of the tokens
     * @param maxDistributionSpeeds_ New distribution speeds for tokens
     */
    function setMaxTokensDistributionSpeed(
        address[] calldata tokens_,
        uint256[] calldata maxDistributionSpeeds_
    ) external;

    /**
     * @notice Set the prime token contract address
     * @param prime_ The new address of the prime token contract
     */
    function setPrimeToken(address prime_) external;

    /**
     * @notice Claim all the token accrued till last block or second
     * @param token_ The token to release to the Prime contract
     */
    function releaseFunds(address token_) external;

    /**
     * @notice A public function to sweep accidental ERC-20 transfers to this contract. Tokens are sent to user
     * @param token_ The address of the ERC-20 token to sweep
     * @param to_ The address of the recipient
     * @param amount_ The amount of tokens needs to transfer
     */
    function sweepToken(IERC20Upgradeable token_, address to_, uint256 amount_) external;

    /**
     * @notice Accrue token by updating the distribution state
     * @param token_ Address of the token
     */
    function accrueTokens(address token_) external;

    /**
     * @notice Set the limit for the loops can iterate to avoid the DOS
     * @param loopsLimit Limit for the max loops can execute at a time
     */
    function setMaxLoopsLimit(uint256 loopsLimit) external;

    /**
     * @notice Get rewards per block or second for token
     * @param token_ Address of the token
     * @return speed returns the per block or second reward
     */
    function getEffectiveDistributionSpeed(address token_) external view returns (uint256);

    /**
     * @notice Get the amount of tokens accrued
     * @param token_ Address of the token
     * @return Amount of tokens that are accrued
     */
    function tokenAmountAccrued(address token_) external view returns (uint256);
}

File 23 of 29 : IVToken.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.13;

interface IVToken {
    function borrowBalanceStored(address account) external view returns (uint256);

    function exchangeRateStored() external view returns (uint256);

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

    function underlying() external view returns (address);

    function totalBorrows() external view returns (uint256);

    function borrowRatePerBlock() external view returns (uint256);

    function reserveFactorMantissa() external view returns (uint256);

    function decimals() external view returns (uint8);
}

File 24 of 29 : IXVSVault.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.13;

interface IXVSVault {
    function getUserInfo(
        address _rewardToken,
        uint256 _pid,
        address _user
    ) external view returns (uint256 amount, uint256 rewardDebt, uint256 pendingWithdrawals);

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

File 25 of 29 : InterfaceComptroller.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.13;

interface InterfaceComptroller {
    function markets(address) external view returns (bool);
}

File 26 of 29 : PrimeStorage.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.13;

import { ResilientOracleInterface } from "@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol";

/**
 * @title PrimeStorageV1
 * @author Venus
 * @notice Storage for Prime Token
 */
contract PrimeStorageV1 {
    struct Token {
        bool exists;
        bool isIrrevocable;
    }

    struct Market {
        uint256 supplyMultiplier;
        uint256 borrowMultiplier;
        uint256 rewardIndex;
        uint256 sumOfMembersScore;
        bool exists;
    }

    struct Interest {
        uint256 accrued;
        uint256 score;
        uint256 rewardIndex;
    }

    struct PendingReward {
        address vToken;
        address rewardToken;
        uint256 amount;
    }

    /// @notice Base unit for computations, usually used in scaling (multiplications, divisions)
    uint256 internal constant EXP_SCALE = 1e18;

    /// @notice maximum BPS = 100%
    uint256 internal constant MAXIMUM_BPS = 1e4;

    /// @notice Mapping to get prime token's metadata
    mapping(address => Token) public tokens;

    /// @notice  Tracks total irrevocable tokens minted
    uint256 public totalIrrevocable;

    /// @notice  Tracks total revocable tokens minted
    uint256 public totalRevocable;

    /// @notice  Indicates maximum revocable tokens that can be minted
    uint256 public revocableLimit;

    /// @notice  Indicates maximum irrevocable tokens that can be minted
    uint256 public irrevocableLimit;

    /// @notice Tracks when prime token eligible users started staking for claiming prime token
    mapping(address => uint256) public stakedAt;

    /// @notice vToken to market configuration
    mapping(address => Market) public markets;

    /// @notice vToken to user to user index
    mapping(address => mapping(address => Interest)) public interests;

    /// @notice A list of boosted markets
    address[] internal _allMarkets;

    /// @notice numerator of alpha. Ex: if alpha is 0.5 then this will be 1
    uint128 public alphaNumerator;

    /// @notice denominator of alpha. Ex: if alpha is 0.5 then this will be 2
    uint128 public alphaDenominator;

    /// @notice address of XVS vault
    address public xvsVault;

    /// @notice address of XVS vault reward token
    address public xvsVaultRewardToken;

    /// @notice address of XVS vault pool id
    uint256 public xvsVaultPoolId;

    /// @notice mapping to check if a account's score was updated in the round
    mapping(uint256 => mapping(address => bool)) public isScoreUpdated;

    /// @notice unique id for next round
    uint256 public nextScoreUpdateRoundId;

    /// @notice total number of accounts whose score needs to be updated
    uint256 public totalScoreUpdatesRequired;

    /// @notice total number of accounts whose score is yet to be updated
    uint256 public pendingScoreUpdates;

    /// @notice mapping used to find if an asset is part of prime markets
    mapping(address => address) public vTokenForAsset;

    /// @notice Address of core pool comptroller contract
    address internal corePoolComptroller;

    /// @notice unreleased income from PLP that's already distributed to prime holders
    /// @dev mapping of asset address => amount
    mapping(address => uint256) public unreleasedPLPIncome;

    /// @notice The address of PLP contract
    address public primeLiquidityProvider;

    /// @notice The address of ResilientOracle contract
    ResilientOracleInterface public oracle;

    /// @notice The address of PoolRegistry contract
    address public poolRegistry;

    /// @dev This empty reserved space is put in place to allow future versions to add new
    /// variables without shifting down storage in the inheritance chain.
    uint256[26] private __gap;
}

File 27 of 29 : FixedMath.sol
// SPDX-License-Identifier: MIT
// solhint-disable var-name-mixedcase

pragma solidity 0.8.13;

import { SafeCastUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol";
import { FixedMath0x } from "./FixedMath0x.sol";

using SafeCastUpgradeable for uint256;

error InvalidFixedPoint();

/**
 * @title FixedMath
 * @author Venus
 * @notice FixedMath library is used for complex mathematical operations
 */
library FixedMath {
    error InvalidFraction(uint256 n, uint256 d);

    /**
     * @notice Convert some uint256 fraction `n` numerator / `d` denominator to a fixed-point number `f`.
     * @param n numerator
     * @param d denominator
     * @return fixed-point number
     */
    function _toFixed(uint256 n, uint256 d) internal pure returns (int256) {
        if (d.toInt256() < n.toInt256()) revert InvalidFraction(n, d);

        return (n.toInt256() * FixedMath0x.FIXED_1) / int256(d.toInt256());
    }

    /**
     * @notice Divide some unsigned int `u` by a fixed point number `f`
     * @param u unsigned dividend
     * @param f fixed point divisor, in FIXED_1 units
     * @return unsigned int quotient
     */
    function _uintDiv(uint256 u, int256 f) internal pure returns (uint256) {
        if (f < 0) revert InvalidFixedPoint();
        // multiply `u` by FIXED_1 to cancel out the built-in FIXED_1 in f
        return uint256((u.toInt256() * FixedMath0x.FIXED_1) / f);
    }

    /**
     * @notice Multiply some unsigned int `u` by a fixed point number `f`
     * @param u unsigned multiplicand
     * @param f fixed point multiplier, in FIXED_1 units
     * @return unsigned int product
     */
    function _uintMul(uint256 u, int256 f) internal pure returns (uint256) {
        if (f < 0) revert InvalidFixedPoint();
        // divide the product by FIXED_1 to cancel out the built-in FIXED_1 in f
        return uint256((u.toInt256() * f) / FixedMath0x.FIXED_1);
    }

    /// @notice see FixedMath0x
    function _ln(int256 x) internal pure returns (int256) {
        return FixedMath0x._ln(x);
    }

    /// @notice see FixedMath0x
    function _exp(int256 x) internal pure returns (int256) {
        return FixedMath0x._exp(x);
    }
}

File 28 of 29 : FixedMath0x.sol
// SPDX-License-Identifier: MIT
// solhint-disable max-line-length

pragma solidity 0.8.13;

// Below is code from 0x's LibFixedMath.sol. Changes:
// - addition of 0.8-style errors
// - removal of unused functions
// - added comments for clarity
// https://github.com/0xProject/exchange-v3/blob/aae46bef841bfd1cc31028f41793db4fe7197084/contracts/staking/contracts/src/libs/LibFixedMath.sol

/*

  Copyright 2017 Bprotocol Foundation, 2019 ZeroEx Intl.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

*/
/// Thrown when the natural log function is given too large of an argument
error LnTooLarge(int256 x);
/// Thrown when the natural log would have returned a number outside of ℝ
error LnNonRealResult(int256 x);
/// Thrown when exp is given too large of an argument
error ExpTooLarge(int256 x);
/// Thrown when an unsigned value is too large to be converted to a signed value
error UnsignedValueTooLarge(uint256 x);

/**
 * @title FixedMath0x
 * @notice Signed, fixed-point, 127-bit precision math library
 */
library FixedMath0x {
    // Base for the fixed point numbers (this is our 1)
    int256 internal constant FIXED_1 = int256(0x0000000000000000000000000000000080000000000000000000000000000000);
    // Maximum ln argument (1)
    int256 private constant LN_MAX_VAL = FIXED_1;
    // Minimum ln argument. Notice this is related to EXP_MIN_VAL (e ^ -63.875)
    int256 private constant LN_MIN_VAL = int256(0x0000000000000000000000000000000000000000000000000000000733048c5a);
    // Maximum exp argument (0)
    int256 private constant EXP_MAX_VAL = 0;
    // Minimum exp argument. Notice this is related to LN_MIN_VAL (-63.875)
    int256 private constant EXP_MIN_VAL = -int256(0x0000000000000000000000000000001ff0000000000000000000000000000000);

    /// @dev Get the natural logarithm of a fixed-point number 0 < `x` <= LN_MAX_VAL
    function _ln(int256 x) internal pure returns (int256 r) {
        if (x > LN_MAX_VAL) {
            revert LnTooLarge(x);
        }
        if (x <= 0) {
            revert LnNonRealResult(x);
        }
        if (x == FIXED_1) {
            return 0;
        }
        if (x <= LN_MIN_VAL) {
            return EXP_MIN_VAL;
        }

        int256 y;
        int256 z;
        int256 w;

        // Rewrite the input as a quotient of negative natural exponents and a single residual q, such that 1 < q < 2
        // For example: log(0.3) = log(e^-1 * e^-0.25 * 1.0471028872385522)
        //              = 1 - 0.25 - log(1 + 0.0471028872385522)
        // e ^ -32
        if (x <= int256(0x00000000000000000000000000000000000000000001c8464f76164760000000)) {
            r -= int256(0x0000000000000000000000000000001000000000000000000000000000000000); // - 32
            x = (x * FIXED_1) / int256(0x00000000000000000000000000000000000000000001c8464f76164760000000); // / e ^ -32
        }
        // e ^ -16
        if (x <= int256(0x00000000000000000000000000000000000000f1aaddd7742e90000000000000)) {
            r -= int256(0x0000000000000000000000000000000800000000000000000000000000000000); // - 16
            x = (x * FIXED_1) / int256(0x00000000000000000000000000000000000000f1aaddd7742e90000000000000); // / e ^ -16
        }
        // e ^ -8
        if (x <= int256(0x00000000000000000000000000000000000afe10820813d78000000000000000)) {
            r -= int256(0x0000000000000000000000000000000400000000000000000000000000000000); // - 8
            x = (x * FIXED_1) / int256(0x00000000000000000000000000000000000afe10820813d78000000000000000); // / e ^ -8
        }
        // e ^ -4
        if (x <= int256(0x0000000000000000000000000000000002582ab704279ec00000000000000000)) {
            r -= int256(0x0000000000000000000000000000000200000000000000000000000000000000); // - 4
            x = (x * FIXED_1) / int256(0x0000000000000000000000000000000002582ab704279ec00000000000000000); // / e ^ -4
        }
        // e ^ -2
        if (x <= int256(0x000000000000000000000000000000001152aaa3bf81cc000000000000000000)) {
            r -= int256(0x0000000000000000000000000000000100000000000000000000000000000000); // - 2
            x = (x * FIXED_1) / int256(0x000000000000000000000000000000001152aaa3bf81cc000000000000000000); // / e ^ -2
        }
        // e ^ -1
        if (x <= int256(0x000000000000000000000000000000002f16ac6c59de70000000000000000000)) {
            r -= int256(0x0000000000000000000000000000000080000000000000000000000000000000); // - 1
            x = (x * FIXED_1) / int256(0x000000000000000000000000000000002f16ac6c59de70000000000000000000); // / e ^ -1
        }
        // e ^ -0.5
        if (x <= int256(0x000000000000000000000000000000004da2cbf1be5828000000000000000000)) {
            r -= int256(0x0000000000000000000000000000000040000000000000000000000000000000); // - 0.5
            x = (x * FIXED_1) / int256(0x000000000000000000000000000000004da2cbf1be5828000000000000000000); // / e ^ -0.5
        }
        // e ^ -0.25
        if (x <= int256(0x0000000000000000000000000000000063afbe7ab2082c000000000000000000)) {
            r -= int256(0x0000000000000000000000000000000020000000000000000000000000000000); // - 0.25
            x = (x * FIXED_1) / int256(0x0000000000000000000000000000000063afbe7ab2082c000000000000000000); // / e ^ -0.25
        }
        // e ^ -0.125
        if (x <= int256(0x0000000000000000000000000000000070f5a893b608861e1f58934f97aea57d)) {
            r -= int256(0x0000000000000000000000000000000010000000000000000000000000000000); // - 0.125
            x = (x * FIXED_1) / int256(0x0000000000000000000000000000000070f5a893b608861e1f58934f97aea57d); // / e ^ -0.125
        }
        // `x` is now our residual in the range of 1 <= x <= 2 (or close enough).

        // Add the taylor series for log(1 + z), where z = x - 1
        z = y = x - FIXED_1;
        w = (y * y) / FIXED_1;
        r += (z * (0x100000000000000000000000000000000 - y)) / 0x100000000000000000000000000000000;
        z = (z * w) / FIXED_1; // add y^01 / 01 - y^02 / 02
        r += (z * (0x0aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - y)) / 0x200000000000000000000000000000000;
        z = (z * w) / FIXED_1; // add y^03 / 03 - y^04 / 04
        r += (z * (0x099999999999999999999999999999999 - y)) / 0x300000000000000000000000000000000;
        z = (z * w) / FIXED_1; // add y^05 / 05 - y^06 / 06
        r += (z * (0x092492492492492492492492492492492 - y)) / 0x400000000000000000000000000000000;
        z = (z * w) / FIXED_1; // add y^07 / 07 - y^08 / 08
        r += (z * (0x08e38e38e38e38e38e38e38e38e38e38e - y)) / 0x500000000000000000000000000000000;
        z = (z * w) / FIXED_1; // add y^09 / 09 - y^10 / 10
        r += (z * (0x08ba2e8ba2e8ba2e8ba2e8ba2e8ba2e8b - y)) / 0x600000000000000000000000000000000;
        z = (z * w) / FIXED_1; // add y^11 / 11 - y^12 / 12
        r += (z * (0x089d89d89d89d89d89d89d89d89d89d89 - y)) / 0x700000000000000000000000000000000;
        z = (z * w) / FIXED_1; // add y^13 / 13 - y^14 / 14
        r += (z * (0x088888888888888888888888888888888 - y)) / 0x800000000000000000000000000000000; // add y^15 / 15 - y^16 / 16
    }

    /// @dev Compute the natural exponent for a fixed-point number EXP_MIN_VAL <= `x` <= 1
    function _exp(int256 x) internal pure returns (int256 r) {
        if (x < EXP_MIN_VAL) {
            // Saturate to zero below EXP_MIN_VAL.
            return 0;
        }
        if (x == 0) {
            return FIXED_1;
        }
        if (x > EXP_MAX_VAL) {
            revert ExpTooLarge(x);
        }

        // Rewrite the input as a product of natural exponents and a
        // single residual q, where q is a number of small magnitude.
        // For example: e^-34.419 = e^(-32 - 2 - 0.25 - 0.125 - 0.044)
        //              = e^-32 * e^-2 * e^-0.25 * e^-0.125 * e^-0.044
        //              -> q = -0.044

        // Multiply with the taylor series for e^q
        int256 y;
        int256 z;
        // q = x % 0.125 (the residual)
        z = y = x % 0x0000000000000000000000000000000010000000000000000000000000000000;
        z = (z * y) / FIXED_1;
        r += z * 0x10e1b3be415a0000; // add y^02 * (20! / 02!)
        z = (z * y) / FIXED_1;
        r += z * 0x05a0913f6b1e0000; // add y^03 * (20! / 03!)
        z = (z * y) / FIXED_1;
        r += z * 0x0168244fdac78000; // add y^04 * (20! / 04!)
        z = (z * y) / FIXED_1;
        r += z * 0x004807432bc18000; // add y^05 * (20! / 05!)
        z = (z * y) / FIXED_1;
        r += z * 0x000c0135dca04000; // add y^06 * (20! / 06!)
        z = (z * y) / FIXED_1;
        r += z * 0x0001b707b1cdc000; // add y^07 * (20! / 07!)
        z = (z * y) / FIXED_1;
        r += z * 0x000036e0f639b800; // add y^08 * (20! / 08!)
        z = (z * y) / FIXED_1;
        r += z * 0x00000618fee9f800; // add y^09 * (20! / 09!)
        z = (z * y) / FIXED_1;
        r += z * 0x0000009c197dcc00; // add y^10 * (20! / 10!)
        z = (z * y) / FIXED_1;
        r += z * 0x0000000e30dce400; // add y^11 * (20! / 11!)
        z = (z * y) / FIXED_1;
        r += z * 0x000000012ebd1300; // add y^12 * (20! / 12!)
        z = (z * y) / FIXED_1;
        r += z * 0x0000000017499f00; // add y^13 * (20! / 13!)
        z = (z * y) / FIXED_1;
        r += z * 0x0000000001a9d480; // add y^14 * (20! / 14!)
        z = (z * y) / FIXED_1;
        r += z * 0x00000000001c6380; // add y^15 * (20! / 15!)
        z = (z * y) / FIXED_1;
        r += z * 0x000000000001c638; // add y^16 * (20! / 16!)
        z = (z * y) / FIXED_1;
        r += z * 0x0000000000001ab8; // add y^17 * (20! / 17!)
        z = (z * y) / FIXED_1;
        r += z * 0x000000000000017c; // add y^18 * (20! / 18!)
        z = (z * y) / FIXED_1;
        r += z * 0x0000000000000014; // add y^19 * (20! / 19!)
        z = (z * y) / FIXED_1;
        r += z * 0x0000000000000001; // add y^20 * (20! / 20!)
        r = r / 0x21c3677c82b40000 + y + FIXED_1; // divide by 20! and then add y^1 / 1! + y^0 / 0!

        // Multiply with the non-residual terms.
        x = -x;
        // e ^ -32
        if ((x & int256(0x0000000000000000000000000000001000000000000000000000000000000000)) != 0) {
            r =
                (r * int256(0x00000000000000000000000000000000000000f1aaddd7742e56d32fb9f99744)) /
                int256(0x0000000000000000000000000043cbaf42a000812488fc5c220ad7b97bf6e99e); // * e ^ -32
        }
        // e ^ -16
        if ((x & int256(0x0000000000000000000000000000000800000000000000000000000000000000)) != 0) {
            r =
                (r * int256(0x00000000000000000000000000000000000afe10820813d65dfe6a33c07f738f)) /
                int256(0x000000000000000000000000000005d27a9f51c31b7c2f8038212a0574779991); // * e ^ -16
        }
        // e ^ -8
        if ((x & int256(0x0000000000000000000000000000000400000000000000000000000000000000)) != 0) {
            r =
                (r * int256(0x0000000000000000000000000000000002582ab704279e8efd15e0265855c47a)) /
                int256(0x0000000000000000000000000000001b4c902e273a58678d6d3bfdb93db96d02); // * e ^ -8
        }
        // e ^ -4
        if ((x & int256(0x0000000000000000000000000000000200000000000000000000000000000000)) != 0) {
            r =
                (r * int256(0x000000000000000000000000000000001152aaa3bf81cb9fdb76eae12d029571)) /
                int256(0x00000000000000000000000000000003b1cc971a9bb5b9867477440d6d157750); // * e ^ -4
        }
        // e ^ -2
        if ((x & int256(0x0000000000000000000000000000000100000000000000000000000000000000)) != 0) {
            r =
                (r * int256(0x000000000000000000000000000000002f16ac6c59de6f8d5d6f63c1482a7c86)) /
                int256(0x000000000000000000000000000000015bf0a8b1457695355fb8ac404e7a79e3); // * e ^ -2
        }
        // e ^ -1
        if ((x & int256(0x0000000000000000000000000000000080000000000000000000000000000000)) != 0) {
            r =
                (r * int256(0x000000000000000000000000000000004da2cbf1be5827f9eb3ad1aa9866ebb3)) /
                int256(0x00000000000000000000000000000000d3094c70f034de4b96ff7d5b6f99fcd8); // * e ^ -1
        }
        // e ^ -0.5
        if ((x & int256(0x0000000000000000000000000000000040000000000000000000000000000000)) != 0) {
            r =
                (r * int256(0x0000000000000000000000000000000063afbe7ab2082ba1a0ae5e4eb1b479dc)) /
                int256(0x00000000000000000000000000000000a45af1e1f40c333b3de1db4dd55f29a7); // * e ^ -0.5
        }
        // e ^ -0.25
        if ((x & int256(0x0000000000000000000000000000000020000000000000000000000000000000)) != 0) {
            r =
                (r * int256(0x0000000000000000000000000000000070f5a893b608861e1f58934f97aea57d)) /
                int256(0x00000000000000000000000000000000910b022db7ae67ce76b441c27035c6a1); // * e ^ -0.25
        }
        // e ^ -0.125
        if ((x & int256(0x0000000000000000000000000000000010000000000000000000000000000000)) != 0) {
            r =
                (r * int256(0x00000000000000000000000000000000783eafef1c0a8f3978c7f81824d62ebf)) /
                int256(0x0000000000000000000000000000000088415abbe9a76bead8d00cf112e4d4a8); // * e ^ -0.125
        }
    }
}

File 29 of 29 : Scores.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.13;

import { SafeCastUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol";
import { FixedMath } from "./FixedMath.sol";

using SafeCastUpgradeable for uint256;

/**
 * @title Scores
 * @author Venus
 * @notice Scores library is used to calculate score of users
 */
library Scores {
    /**
     * @notice Calculate a membership score given some amount of `xvs` and `capital`, along
     *  with some 𝝰 = `alphaNumerator` / `alphaDenominator`.
     * @param xvs amount of xvs (xvs, 1e18 decimal places)
     * @param capital amount of capital (1e18 decimal places)
     * @param alphaNumerator alpha param numerator
     * @param alphaDenominator alpha param denominator
     * @return membership score with 1e18 decimal places
     *
     * @dev 𝝰 must be in the range [0, 1]
     */
    function _calculateScore(
        uint256 xvs,
        uint256 capital,
        uint256 alphaNumerator,
        uint256 alphaDenominator
    ) internal pure returns (uint256) {
        // Score function is:
        // xvs^𝝰 * capital^(1-𝝰)
        //    = capital * capital^(-𝝰) * xvs^𝝰
        //    = capital * (xvs / capital)^𝝰
        //    = capital * (e ^ (ln(xvs / capital))) ^ 𝝰
        //    = capital * e ^ (𝝰 * ln(xvs / capital))     (1)
        // or
        //    = capital / ( 1 / e ^ (𝝰 * ln(xvs / capital)))
        //    = capital / (e ^ (𝝰 * ln(xvs / capital)) ^ -1)
        //    = capital / e ^ (𝝰 * -1 * ln(xvs / capital))
        //    = capital / e ^ (𝝰 * ln(capital / xvs))     (2)
        //
        // To avoid overflows, use (1) when xvs < capital and
        // use (2) when capital < xvs

        // If any side is 0, exit early
        if (xvs == 0 || capital == 0) return 0;

        // If both sides are equal, we have:
        // xvs^𝝰 * capital^(1-𝝰)
        //    = xvs^𝝰 * xvs^(1-𝝰)
        //    = xvs^(𝝰 + 1 - 𝝰)     = xvs
        if (xvs == capital) return xvs;

        bool lessxvsThanCapital = xvs < capital;

        // (xvs / capital) or (capital / xvs), always in range (0, 1)
        int256 ratio = lessxvsThanCapital ? FixedMath._toFixed(xvs, capital) : FixedMath._toFixed(capital, xvs);

        // e ^ ( ln(ratio) * 𝝰 )
        int256 exponentiation = FixedMath._exp(
            (FixedMath._ln(ratio) * alphaNumerator.toInt256()) / alphaDenominator.toInt256()
        );

        if (lessxvsThanCapital) {
            // capital * e ^ (𝝰 * ln(xvs / capital))
            return FixedMath._uintMul(capital, exponentiation);
        }

        // capital / e ^ (𝝰 * ln(capital / xvs))
        return FixedMath._uintDiv(capital, exponentiation);
    }
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_wrappedNativeToken","type":"address"},{"internalType":"address","name":"_nativeMarket","type":"address"},{"internalType":"uint256","name":"_blocksPerYear","type":"uint256"},{"internalType":"uint256","name":"_stakingPeriod","type":"uint256"},{"internalType":"uint256","name":"_minimumStakedXVS","type":"uint256"},{"internalType":"uint256","name":"_maximumXVSCap","type":"uint256"},{"internalType":"bool","name":"_timeBased","type":"bool"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AssetAlreadyExists","type":"error"},{"inputs":[{"internalType":"int256","name":"x","type":"int256"}],"name":"ExpTooLarge","type":"error"},{"inputs":[],"name":"IneligibleToClaim","type":"error"},{"inputs":[],"name":"InvalidAddress","type":"error"},{"inputs":[],"name":"InvalidAlphaArguments","type":"error"},{"inputs":[],"name":"InvalidBlocksPerYear","type":"error"},{"inputs":[],"name":"InvalidComptroller","type":"error"},{"inputs":[],"name":"InvalidFixedPoint","type":"error"},{"inputs":[{"internalType":"uint256","name":"n","type":"uint256"},{"internalType":"uint256","name":"d","type":"uint256"}],"name":"InvalidFraction","type":"error"},{"inputs":[],"name":"InvalidLength","type":"error"},{"inputs":[],"name":"InvalidLimit","type":"error"},{"inputs":[],"name":"InvalidTimeBasedConfiguration","type":"error"},{"inputs":[],"name":"InvalidTimestamp","type":"error"},{"inputs":[],"name":"InvalidVToken","type":"error"},{"inputs":[{"internalType":"int256","name":"x","type":"int256"}],"name":"LnNonRealResult","type":"error"},{"inputs":[{"internalType":"int256","name":"x","type":"int256"}],"name":"LnTooLarge","type":"error"},{"inputs":[],"name":"MarketAlreadyExists","type":"error"},{"inputs":[],"name":"MarketNotSupported","type":"error"},{"inputs":[{"internalType":"uint256","name":"loopsLimit","type":"uint256"},{"internalType":"uint256","name":"requiredLoops","type":"uint256"}],"name":"MaxLoopsLimitExceeded","type":"error"},{"inputs":[],"name":"NoScoreUpdatesRequired","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"calledContract","type":"address"},{"internalType":"string","name":"methodSignature","type":"string"}],"name":"Unauthorized","type":"error"},{"inputs":[],"name":"UserHasNoPrimeToken","type":"error"},{"inputs":[],"name":"WaitMoreTime","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint128","name":"oldNumerator","type":"uint128"},{"indexed":true,"internalType":"uint128","name":"oldDenominator","type":"uint128"},{"indexed":true,"internalType":"uint128","name":"newNumerator","type":"uint128"},{"indexed":false,"internalType":"uint128","name":"newDenominator","type":"uint128"}],"name":"AlphaUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"}],"name":"Burn","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"market","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"InterestClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"comptroller","type":"address"},{"indexed":true,"internalType":"address","name":"market","type":"address"},{"indexed":false,"internalType":"uint256","name":"supplyMultiplier","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"borrowMultiplier","type":"uint256"}],"name":"MarketAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldMaxLoopsLimit","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newmaxLoopsLimit","type":"uint256"}],"name":"MaxLoopsLimitUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"bool","name":"isIrrevocable","type":"bool"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"oldIrrevocableLimit","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"oldRevocableLimit","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"newIrrevocableLimit","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newRevocableLimit","type":"uint256"}],"name":"MintLimitsUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"market","type":"address"},{"indexed":true,"internalType":"uint256","name":"oldSupplyMultiplier","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"oldBorrowMultiplier","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newSupplyMultiplier","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newBorrowMultiplier","type":"uint256"}],"name":"MultiplierUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldAccessControlManager","type":"address"},{"indexed":false,"internalType":"address","name":"newAccessControlManager","type":"address"}],"name":"NewAccessControlManager","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"StakedAtUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"}],"name":"TokenUpgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"}],"name":"UserScoreUpdated","type":"event"},{"inputs":[],"name":"MAXIMUM_XVS_CAP","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MINIMUM_STAKED_XVS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"NATIVE_MARKET","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"STAKING_PERIOD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WRAPPED_NATIVE_TOKEN","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"accessControlManager","outputs":[{"internalType":"contract IAccessControlManagerV8","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"vToken","type":"address"}],"name":"accrueInterest","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"market","type":"address"}],"name":"accrueInterestAndUpdateScore","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"comptroller","type":"address"},{"internalType":"address","name":"market","type":"address"},{"internalType":"uint256","name":"supplyMultiplier","type":"uint256"},{"internalType":"uint256","name":"borrowMultiplier","type":"uint256"}],"name":"addMarket","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"alphaDenominator","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"alphaNumerator","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"blocksOrSecondsPerYear","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"},{"internalType":"address","name":"user","type":"address"}],"name":"calculateAPR","outputs":[{"components":[{"internalType":"uint256","name":"supplyAPR","type":"uint256"},{"internalType":"uint256","name":"borrowAPR","type":"uint256"},{"internalType":"uint256","name":"totalScore","type":"uint256"},{"internalType":"uint256","name":"userScore","type":"uint256"},{"internalType":"uint256","name":"xvsBalanceForScore","type":"uint256"},{"internalType":"uint256","name":"capital","type":"uint256"},{"internalType":"uint256","name":"cappedSupply","type":"uint256"},{"internalType":"uint256","name":"cappedBorrow","type":"uint256"},{"internalType":"uint256","name":"supplyCapUSD","type":"uint256"},{"internalType":"uint256","name":"borrowCapUSD","type":"uint256"}],"internalType":"struct IPrime.APRInfo","name":"aprInfo","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"vToken","type":"address"}],"name":"claimInterest","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"vToken","type":"address"},{"internalType":"address","name":"user","type":"address"}],"name":"claimInterest","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"claimTimeRemaining","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"comptroller","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"},{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"borrow","type":"uint256"},{"internalType":"uint256","name":"supply","type":"uint256"},{"internalType":"uint256","name":"xvsStaked","type":"uint256"}],"name":"estimateAPR","outputs":[{"components":[{"internalType":"uint256","name":"supplyAPR","type":"uint256"},{"internalType":"uint256","name":"borrowAPR","type":"uint256"},{"internalType":"uint256","name":"totalScore","type":"uint256"},{"internalType":"uint256","name":"userScore","type":"uint256"},{"internalType":"uint256","name":"xvsBalanceForScore","type":"uint256"},{"internalType":"uint256","name":"capital","type":"uint256"},{"internalType":"uint256","name":"cappedSupply","type":"uint256"},{"internalType":"uint256","name":"cappedBorrow","type":"uint256"},{"internalType":"uint256","name":"supplyCapUSD","type":"uint256"},{"internalType":"uint256","name":"borrowCapUSD","type":"uint256"}],"internalType":"struct IPrime.APRInfo","name":"aprInfo","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAllMarkets","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getBlockNumberOrTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"vToken","type":"address"},{"internalType":"address","name":"user","type":"address"}],"name":"getInterestAccrued","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"getPendingRewards","outputs":[{"components":[{"internalType":"address","name":"vToken","type":"address"},{"internalType":"address","name":"rewardToken","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct PrimeStorageV1.PendingReward[]","name":"pendingRewards","type":"tuple[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"vToken","type":"address"}],"name":"incomeDistributionYearly","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"xvsVault_","type":"address"},{"internalType":"address","name":"xvsVaultRewardToken_","type":"address"},{"internalType":"uint256","name":"xvsVaultPoolId_","type":"uint256"},{"internalType":"uint128","name":"alphaNumerator_","type":"uint128"},{"internalType":"uint128","name":"alphaDenominator_","type":"uint128"},{"internalType":"address","name":"accessControlManager_","type":"address"},{"internalType":"address","name":"primeLiquidityProvider_","type":"address"},{"internalType":"address","name":"comptroller_","type":"address"},{"internalType":"address","name":"oracle_","type":"address"},{"internalType":"uint256","name":"loopsLimit_","type":"uint256"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"poolRegistry_","type":"address"}],"name":"initializeV2","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"interests","outputs":[{"internalType":"uint256","name":"accrued","type":"uint256"},{"internalType":"uint256","name":"score","type":"uint256"},{"internalType":"uint256","name":"rewardIndex","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"irrevocableLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"isScoreUpdated","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isTimeBased","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"isUserPrimeHolder","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"isIrrevocable","type":"bool"},{"internalType":"address[]","name":"users","type":"address[]"}],"name":"issue","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"markets","outputs":[{"internalType":"uint256","name":"supplyMultiplier","type":"uint256"},{"internalType":"uint256","name":"borrowMultiplier","type":"uint256"},{"internalType":"uint256","name":"rewardIndex","type":"uint256"},{"internalType":"uint256","name":"sumOfMembersScore","type":"uint256"},{"internalType":"bool","name":"exists","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxLoopsLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nextScoreUpdateRoundId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"oracle","outputs":[{"internalType":"contract ResilientOracleInterface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingScoreUpdates","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"poolRegistry","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"primeLiquidityProvider","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"revocableLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"accessControlManager_","type":"address"}],"name":"setAccessControlManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_irrevocableLimit","type":"uint256"},{"internalType":"uint256","name":"_revocableLimit","type":"uint256"}],"name":"setLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"loopsLimit","type":"uint256"}],"name":"setMaxLoopsLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"users","type":"address[]"},{"internalType":"uint256[]","name":"timestamps","type":"uint256[]"}],"name":"setStakedAt","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"stakedAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"togglePause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"tokens","outputs":[{"internalType":"bool","name":"exists","type":"bool"},{"internalType":"bool","name":"isIrrevocable","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalIrrevocable","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalRevocable","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalScoreUpdatesRequired","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"unreleasedPLPIncome","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint128","name":"_alphaNumerator","type":"uint128"},{"internalType":"uint128","name":"_alphaDenominator","type":"uint128"}],"name":"updateAlpha","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"},{"internalType":"uint256","name":"supplyMultiplier","type":"uint256"},{"internalType":"uint256","name":"borrowMultiplier","type":"uint256"}],"name":"updateMultipliers","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"users","type":"address[]"}],"name":"updateScores","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"vTokenForAsset","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"xvsUpdated","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"xvsVault","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"xvsVaultPoolId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"xvsVaultRewardToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]

6101806040523480156200001257600080fd5b5060405162005fbd38038062005fbd833981016040819052620000359162000201565b80858115801562000044575080155b1562000063576040516302723dfb60e21b815260040160405180910390fd5b8180156200007057508015155b156200008f5760405163ae0fcab360e01b815260040160405180910390fd5b81151560a05281620000a25780620000a8565b6301e133805b60805281620000c3576200011b60201b620025fb17620000d0565b6200011f60201b620025ff175b6001600160401b031660c05250506001600160a01b0380881660e0528616610100526101608490526101208390526101408290526200010e62000123565b505050505050506200027a565b4390565b4290565b600054610100900460ff1615620001905760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff90811614620001e2576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b80516001600160a01b0381168114620001fc57600080fd5b919050565b600080600080600080600060e0888a0312156200021d57600080fd5b6200022888620001e4565b96506200023860208901620001e4565b955060408801519450606088015193506080880151925060a0880151915060c088015180151581146200026a57600080fd5b8091505092959891949750929550565b60805160a05160c05160e05161010051610120516101405161016051615c9762000326600039600081816103f00152818161107701528181612182015281816121ad01526121d5015260008181610ac301528181613416015261343f0152600081816105a40152612a180152600081816109330152612ebf01526000818161043f0152612ef901526000612132015260006108f80152600081816105cb01526113a60152615c976000f3fe608060405234801561001057600080fd5b50600436106103e65760003560e01c80639f6506ce1161020a578063cdaa21b711610125578063e30c3978116100b8578063ef36bbde11610087578063ef36bbde14610a57578063f2fde38b14610a78578063f6ed201714610a8b578063fa6d5f1814610aab578063fe1006ad14610abe57600080fd5b8063e30c3978146109c5578063e4676f37146109d6578063e4860339146109e9578063ee6b13fc14610a2d57600080fd5b8063d88b9d2e116100f4578063d88b9d2e14610996578063da6ab4f8146109a0578063e18f8822146109aa578063e1d146fb146109bd57600080fd5b8063cdaa21b71461092e578063ce85361314610955578063cf329d1614610970578063d65bd2411461098357600080fd5b8063ba437c681161019d578063c3db3c361161016c578063c3db3c36146108e1578063c4ae3168146108eb578063c7ad0895146108f3578063c86d1a781461091a57600080fd5b8063ba437c68146108a8578063bc5dc4c3146108bb578063bd212c0e146108ce578063be26317e146108d857600080fd5b8063b1a250f2116101d9578063b1a250f2146107a2578063b4a0bdf3146107b5578063b7f2d258146107c6578063b9eb69f61461085257600080fd5b80639f6506ce14610765578063a15753dc1461076f578063afcff50f14610779578063b0772d0b1461078d57600080fd5b80635fe3b5671161030557806380d45a2d1161029857806389afcb441161026757806389afcb44146106945780638da5cb5b146106a75780638e8f294b146106b85780639198e515146107235780639565d3d21461073657600080fd5b806380d45a2d14610650578063856c3aa41461066357806388bead731461066d57806388d742c21461068157600080fd5b806379ba5097116102d457806379ba5097146105f55780637dafcd89146105fd5780637dc0d1d0146106105780637ef820701461062457600080fd5b80635fe3b5671461058d5780636426b4a71461059f5780636857249c146105c6578063715018a6146105ed57600080fd5b806337f23cd31161037d57806355d36c981161034c57806355d36c9814610549578063594a67ee1461055c5780635c975abb1461056f5780635d536d301461057a57600080fd5b806337f23cd3146104e757806338f6a434146104fa578063487b0dfb146105375780634e71d92d1461054157600080fd5b80631bffac89116103b95780631bffac891461048d578063207add91146104ae57806324e6baf2146104c157806329b6eca9146104d457600080fd5b80630104db1b146103eb5780630e32cb86146104255780631b3f8c5e1461043a5780631b9ce57514610479575b600080fd5b6104127f000000000000000000000000000000000000000000000000000000000000000081565b6040519081526020015b60405180910390f35b6104386104333660046150ac565b610ae5565b005b6104617f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b03909116815260200161041c565b61013754610461906001600160a01b031681565b61041261049b3660046150ac565b6101406020526000908152604090205481565b6104386104bc3660046150c9565b610af9565b6104386104cf366004615137565b610bb4565b6104386104e23660046150ac565b610d80565b6104386104f53660046150ac565b610e38565b6105276105083660046150ac565b6001600160a01b0316600090815261012d602052604090205460ff1690565b604051901515815260200161041c565b6104126101395481565b610438611044565b610438610557366004615179565b6110d3565b61043861056a3660046151ae565b61119e565b60c95460ff16610527565b6104126105883660046150ac565b611316565b61013f546001600160a01b0316610461565b6104127f000000000000000000000000000000000000000000000000000000000000000081565b6104127f000000000000000000000000000000000000000000000000000000000000000081565b6104386113d1565b6104386113e5565b61043861060b366004615228565b61145c565b61014254610461906001600160a01b031681565b61013654610638906001600160801b031681565b6040516001600160801b03909116815260200161041c565b61043861065e36600461527d565b6115e6565b6104126101315481565b61013854610461906001600160a01b031681565b61041261068f3660046150ac565b61162d565b6104386106a23660046150ac565b611649565b6033546001600160a01b0316610461565b6106f96106c63660046150ac565b61013360205260009081526040902080546001820154600283015460038401546004909401549293919290919060ff1685565b6040805195865260208601949094529284019190915260608301521515608082015260a00161041c565b6104386107313660046150ac565b611680565b610527610744366004615296565b61013a60209081526000928352604080842090915290825290205460ff1681565b61041261012f5481565b61041261013b5481565b61014354610461906001600160a01b031681565b610795611844565b60405161041c91906152c6565b6104386107b036600461532a565b6118a7565b6097546001600160a01b0316610461565b6107d96107d43660046153e4565b611abc565b60405161041c9190600061014082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015260a083015160a083015260c083015160c083015260e083015160e083015261010080840151818401525061012080840151818401525092915050565b61088d610860366004615435565b61013460209081526000928352604080842090915290825290208054600182015460029092015490919083565b6040805193845260208401929092529082015260600161041c565b6104126108b6366004615435565b611c76565b6104386108c9366004615463565b611c93565b61041261013c5481565b61041260fb5481565b61041261013d5481565b610438611fb1565b6105277f000000000000000000000000000000000000000000000000000000000000000081565b61014154610461906001600160a01b031681565b6104617f000000000000000000000000000000000000000000000000000000000000000081565b6101365461063890600160801b90046001600160801b031681565b61043861097e366004615435565b611ffa565b610412610991366004615435565b612012565b61041261012e5481565b6104126101305481565b6104386109b83660046154a9565b612027565b61041261212b565b6065546001600160a01b0316610461565b6104126109e43660046150ac565b61215e565b610a166109f73660046150ac565b61012d6020526000908152604090205460ff8082169161010090041682565b60408051921515835290151560208301520161041c565b610461610a3b3660046150ac565b61013e602052600090815260409020546001600160a01b031681565b610412610a653660046150ac565b6101326020526000908152604090205481565b610438610a863660046150ac565b612206565b610a9e610a993660046150ac565b612277565b60405161041c91906154dc565b6107d9610ab9366004615435565b6123b9565b6104127f000000000000000000000000000000000000000000000000000000000000000081565b610aed612603565b610af68161265d565b50565b610b376040518060400160405280601981526020017f7365744c696d69742875696e743235362c75696e74323536290000000000000081525061271b565b61012e54821080610b4a575061012f5481105b15610b685760405163e55fb50960e01b815260040160405180910390fd5b8161013054610131547f6c52f3e195bdc534883e903e0612c49261a466aacd492501870b0a0ac0b1835584604051610ba291815260200190565b60405180910390a46101305561013155565b61013d54600003610bd85760405163071a45dd60e31b815260040160405180910390fd5b61013b54600003610bfc5760405163071a45dd60e31b815260040160405180910390fd5b60005b81811015610d7b576000838383818110610c1b57610c1b615541565b9050602002016020810190610c3091906150ac565b6001600160a01b038116600090815261012d602052604090205490915060ff16610c6d57604051633aeb927b60e11b815260040160405180910390fd5b61013b54600090815261013a602090815260408083206001600160a01b038516845290915290205460ff1615610ca65750600101610bff565b610135805460005b81811015610cfe576000838281548110610cca57610cca615541565b6000918252602090912001546001600160a01b03169050610ceb85826127b5565b610cf58582612891565b50600101610cae565b5061013d60008154610d0f9061556d565b9091555061013b54600090815261013a602090815260408083206001600160a01b0387168085529252808320805460ff19166001908117909155905196019590917fa699df4aa8f89fc1f5408fe78ae114651f18b25ed1601680e4c70c15177d8b1b91a2505050610bff565b505050565b600054600290610100900460ff16158015610da2575060005460ff8083169116105b610dc75760405162461bcd60e51b8152600401610dbe90615584565b60405180910390fd5b6000805461014380546001600160a01b0319166001600160a01b03861617905561ff001961010060ff851661ffff19909316831717169091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020015b60405180910390a15050565b6000610e438261296e565b90506000610e5082612a14565b6001600160a01b0384166000908152610132602090815260408083205461012d83529281902081518083019092525460ff808216158015808552610100909304909116151593830193909352939450919290610eaa575082155b15610f0c576001600160a01b03851660008181526101326020908152604080832083905551918252600080516020615c18833981519152910160405180910390a2806020015115610f0357610efe85612a4d565b61103d565b610efe85612aa5565b82158015610f1957508051155b8015610f2457508115155b15610f6b576001600160a01b03851660008181526101326020908152604080832083905551918252600080516020615c1883398151915291015b60405180910390a261103d565b81158015610f765750825b8015610f8157508051155b15610fc3576001600160a01b0385166000818152610132602090815260409182902042908190559151918252600080516020615c188339815191529101610f5e565b80518015610fce5750825b1561103d57610fdc85612a4d565b6001600160a01b03851660009081526101326020526040812054900361103d576001600160a01b0385166000818152610132602090815260409182902042908190559151918252600080516020615c18833981519152910160405180910390a25b5050505050565b3360009081526101326020526040812054908190036110755760405162c4e3d160e01b815260040160405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006110a082426155d2565b10156110bf5760405163beb98cab60e01b815260040160405180910390fd5b6110ca600033612c79565b610af633612d8a565b6110f46040518060600160405280602a8152602001615bee602a913961271b565b6001600160a01b038316600090815261013360205260409020600481015460ff1661113257604051630ff2e4a960e31b815260040160405180910390fd5b61113b84611680565b6001810154815460408051868152602081018690526001600160a01b038816917f91e78a55b6df3a0eac1c12a64572a8c0faced385bafba688817f5ce6daa33537910160405180910390a482815560018101829055611198612e87565b50505050565b6111dc6040518060400160405280602081526020017f7365745374616b6564417428616464726573735b5d2c75696e743235365b5d2981525061271b565b8281146111fc5760405163251f56a160e21b815260040160405180910390fd5b60005b8381101561103d574283838381811061121a5761121a615541565b9050602002013511156112405760405163b7d0949760e01b815260040160405180910390fd5b82828281811061125257611252615541565b90506020020135610132600087878581811061127057611270615541565b905060200201602081019061128591906150ac565b6001600160a01b031681526020810191909152604001600020558484828181106112b1576112b1615541565b90506020020160208101906112c691906150ac565b6001600160a01b0316600080516020615c188339815191528484848181106112f0576112f0615541565b9050602002013560405161130691815260200190565b60405180910390a26001016111ff565b6101415460009081906001600160a01b031663a666642b61133685612ebb565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa15801561137a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061139e91906155e9565b90506113ca817f0000000000000000000000000000000000000000000000000000000000000000615602565b9392505050565b6113d9612603565b6113e36000612f7f565b565b60655433906001600160a01b031681146114535760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b6064820152608401610dbe565b610af681612f7f565b61149260405180604001604052806015815260200174697373756528626f6f6c2c616464726573735b5d2960581b81525061271b565b82156115a75760005b8181101561119857600061012d60008585858181106114bc576114bc615541565b90506020020160208101906114d191906150ac565b6001600160a01b031681526020810191909152604001600020805490915060ff16801561150557508054610100900460ff16155b1561153e5761153984848481811061151f5761151f615541565b905060200201602081019061153491906150ac565b612f98565b61159e565b61156f600185858581811061155557611555615541565b905060200201602081019061156a91906150ac565b612c79565b61159e84848481811061158457611584615541565b905060200201602081019061159991906150ac565b612d8a565b5060010161149b565b60005b81811015611198576115c9600084848481811061155557611555615541565b6115de83838381811061158457611584615541565b6001016115aa565b6116246040518060400160405280601981526020017f7365744d61784c6f6f70734c696d69742875696e74323536290000000000000081525061271b565b610af681613048565b60006116376130e2565b6116418233613128565b90505b919050565b6116776040518060400160405280600d81526020016c6275726e28616464726573732960981b81525061271b565b610af681612aa5565b6001600160a01b038116600090815261013360205260409020600481015460ff166116be57604051630ff2e4a960e31b815260040160405180910390fd5b60006116c983612ebb565b61014154604051638aadf79960e01b81526001600160a01b0380841660048301529293509116908190638aadf79990602401600060405180830381600087803b15801561171557600080fd5b505af1158015611729573d6000803e3d6000fd5b505060405163fa7781ff60e01b81526001600160a01b038581166004830152600093508416915063fa7781ff90602401602060405180830381865afa158015611776573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061179a91906155e9565b6001600160a01b03841660009081526101406020526040812054919250906117c290836155d2565b90508060008190036117d75750505050505050565b6001600160a01b038516600090815261014060205260408120849055600387015415611821576003870154611814670de0b6b3a764000084615602565b61181e9190615637565b90505b80876002016000828254611835919061564b565b90915550505050505050505050565b606061013580548060200260200160405190810160405280929190818152602001828054801561189d57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161187f575b5050505050905090565b600054610100900460ff16158080156118c75750600054600160ff909116105b806118e15750303b1580156118e1575060005460ff166001145b6118fd5760405162461bcd60e51b8152600401610dbe90615584565b6000805460ff191660011790558015611920576000805461ff0019166101001790555b6001600160a01b038b166119475760405163e6c4247b60e01b815260040160405180910390fd5b6001600160a01b038a1661196e5760405163e6c4247b60e01b815260040160405180910390fd5b6001600160a01b0383166119955760405163e6c4247b60e01b815260040160405180910390fd5b6001600160a01b0385166119bc5760405163e6c4247b60e01b815260040160405180910390fd5b6119c6888861330b565b6001600160801b03878116600160801b02908916176101365561013880546001600160a01b03808d166001600160a01b0319928316179092556101398b905561013780548e8416908316179055600061013b55610141805488841690831617905561013f8054878416908316179055610142805492861692909116919091179055611a5086613351565b611a58613389565b611a6182613048565b611a696133b8565b8015611aaf576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050505050505050565b611ac4615044565b6001600160a01b03808716600081815261013460209081526040808320948a1683529381528382206001015492825261013390529190912060030154611b0a91906155d2565b6040820152611b1882613412565b60808201819052600090611b2e9086868a613467565b805160a0840152602081015160c0840152604081015160e08401526060810151610100840152608081015161012084015290506000611b6c88612ebb565b6001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ba9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bcd9190615663565b60ff169050611bdd8160126155d2565b611be890600a61576a565b8360a00151611bf79190615602565b60a08401819052608084015161013654611c2592906001600160801b0380821691600160801b900416613775565b606084018190526040840151611c3b919061564b565b836040018181525050611c638886888660c001518760e001518860600151896040015161382d565b6020850152835250909695505050505050565b6000611c806130e2565b611c8a8383613128565b90505b92915050565b611cb46040518060600160405280602a8152602001615c38602a913961271b565b6001600160a01b038416611cdb576040516383aebebd60e01b815260040160405180910390fd5b61013f546001600160a01b03858116911614801590611d79575061014354604051637aee632d60e01b81526001600160a01b0386811660048301819052921690637aee632d90602401600060405180830381865afa158015611d41573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611d69919081019061581d565b604001516001600160a01b031614155b15611d97576040516383aebebd60e01b815260040160405180910390fd5b6001600160a01b038316600090815261013360205260409020600481015460ff1615611dd657604051630313b28560e01b815260040160405180910390fd5b604051638e8f294b60e01b81526001600160a01b03858116600483015260009190871690638e8f294b90602401602060405180830381865afa158015611e20573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e449190615913565b905080611e6457604051633d21810360e21b815260040160405180910390fd5b60006002830181905584835560018084018590556003840182905560048401805460ff19169091179055611e9786612ebb565b6001600160a01b03808216600090815261013e60205260409020549192501615611ed45760405163dc0d0aab60e01b815260040160405180910390fd5b6001600160a01b03808216600090815261013e6020526040812080549289166001600160a01b03199384168117909155610135805460018101825592527fdf37d27e88e3bd0b85262482997e409a463f5be0ebb19232abf994dd8474090d9091018054909216179055611f45612e87565b61013554611f5290613919565b856001600160a01b0316876001600160a01b03167f1322eaea77217179bf4ef6084dc2f48c897e0d5a6b8365213804360e4d8ba9a28787604051611fa0929190918252602082015260400190565b60405180910390a350505050505050565b611fdf6040518060400160405280600d81526020016c746f67676c655061757365282960981b81525061271b565b60c95460ff1615611ff2576113e361394a565b6113e36133b8565b61200482826127b5565b61200e8282612891565b5050565b600061201d83611680565b611c8a8383613983565b6120656040518060400160405280601c81526020017f757064617465416c7068612875696e743132382c75696e74313238290000000081525061271b565b61206f828261330b565b610136546040516001600160801b03838116825284811692600160801b81048216929116907f9122c3fdea272423a0586803b53902139919baf05be731f04724ef8f363d378d9060200160405180910390a46001600160801b03818116600160801b0290831617610136556101355460005b818110156121225761211a610135828154811061210057612100615541565b6000918252602090912001546001600160a01b0316611680565b6001016120e1565b50610d7b612e87565b60006121597f000000000000000000000000000000000000000000000000000000000000000063ffffffff16565b905090565b6001600160a01b038116600090815261013260205260408120548082036121a757507f000000000000000000000000000000000000000000000000000000000000000092915050565b428190037f00000000000000000000000000000000000000000000000000000000000000008110156121fc577f0000000000000000000000000000000000000000000000000000000000000000039392505050565b5060009392505050565b61220e612603565b606580546001600160a01b0383166001600160a01b0319909116811790915561223f6033546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6101358054606091908067ffffffffffffffff81111561229957612299615776565b6040519080825280602002602001820160405280156122e457816020015b60408051606081018252600080825260208083018290529282015282526000199092019101816122b75790505b50925060005b818110156123b157600083828154811061230657612306615541565b60009182526020822001546001600160a01b031691506123268288612012565b6001600160a01b03808416600081815261013460209081526040808320948d168352938152908390205483516060810190945291835292935091810161236b85612ebb565b6001600160a01b03168152602001612383838561564b565b81525087858151811061239857612398615541565b60200260200101819052508360010193505050506122ea565b505050919050565b6123c1615044565b6040516395dd919360e01b81526001600160a01b03838116600483015284916000918316906395dd919390602401602060405180830381865afa15801561240c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061243091906155e9565b90506000826001600160a01b031663182df0f56040518163ffffffff1660e01b8152600401602060405180830381865afa158015612472573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061249691906155e9565b6040516370a0823160e01b81526001600160a01b0387811660048301529192506000918516906370a0823190602401602060405180830381865afa1580156124e2573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061250691906155e9565b90506000670de0b6b3a764000061251d8385615602565b6125279190615637565b6001600160a01b03808a16600081815261013460209081526040808320948d1683529381528382206001015460608c01529181526101339091528190206003015490880152905061257f61257a8861296e565b613412565b6080870181905260009061259590868489613467565b805160a0890152602081015160c0890181905260408083015160e08b018190526060808501516101008d015260808501516101208d01528b0151918b01519394506125e7938d9387938b93919261382d565b602089015287525094979650505050505050565b4390565b4290565b6033546001600160a01b031633146113e35760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610dbe565b6001600160a01b0381166126c15760405162461bcd60e51b815260206004820152602560248201527f696e76616c696420616365737320636f6e74726f6c206d616e61676572206164604482015264647265737360d81b6064820152608401610dbe565b609780546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f66fd58e82f7b31a2a5c30e0888f3093efe4e111b00cd2b0c31fe014601293aa09101610e2c565b6097546040516318c5e8ab60e01b81526000916001600160a01b0316906318c5e8ab9061274e903390869060040161595c565b602060405180830381865afa15801561276b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061278f9190615913565b90508061200e57333083604051634a3fa29360e01b8152600401610dbe93929190615980565b6001600160a01b0381166000908152610133602052604090206004015460ff1615806127fb57506001600160a01b038216600090815261012d602052604090205460ff16155b15612804575050565b61280d81611680565b6128178183613983565b6001600160a01b038083166000908152610134602090815260408083209387168352929052908120805490919061284f90849061564b565b90915550506001600160a01b03908116600090815261013360209081526040808320600290810154610134845282852096909516845294909152902090910155565b6001600160a01b038116600090815261013360205260409020600481015460ff1615806128d857506001600160a01b038316600090815261012d602052604090205460ff16155b156128e257505050565b60006128ee8385613a1a565b6001600160a01b03808516600090815261013460209081526040808320938916835292905220600101546003840154919250829161292c91906155d2565b612936919061564b565b6003909201919091556001600160a01b0391821660009081526101346020908152604080832095909416825293909352912060010155565b6101375461013854610139546040516398e1b31b60e01b81526001600160a01b03928316600482015260248101919091528382166044820152600092839283929116906398e1b31b90606401606060405180830381865afa1580156129d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129fb91906159ac565b92505091508082612a0c91906155d2565b949350505050565b60007f00000000000000000000000000000000000000000000000000000000000000008210612a4557506001919050565b506000919050565b610135805460005b81811015611198576000838281548110612a7157612a71615541565b6000918252602090912001546001600160a01b03169050612a9285826127b5565b612a9c8582612891565b50600101612a55565b6001600160a01b038116600090815261012d602090815260409182902082518084019093525460ff808216151580855261010090920416151591830191909152612b0257604051633aeb927b60e11b815260040160405180910390fd5b610135805460005b81811015612bdb576000838281548110612b2657612b26615541565b6000918252602090912001546001600160a01b03169050612b4786826127b5565b6001600160a01b03808216600081815261013460209081526040808320948b1683529381528382206001015492825261013390529190912060030154612b8d91906155d2565b6001600160a01b039182166000908152610133602090815260408083206003019390935561013481528282209389168252929092528120600180820183905560029091019190915501612b0a565b50826020015115612bff5761012e60008154612bf69061556d565b90915550612c14565b61012f60008154612c0f9061556d565b909155505b6001600160a01b038416600090815261012d60205260409020805461ffff19169055612c3f84613daa565b6040516001600160a01b038516907fe22de1457cb61fb61b60176bc4235a9abd19466126b46692bc14fc573f09924990600090a250505050565b6001600160a01b038116600090815261012d60205260409020805460ff1615612cb45760405162c4e3d160e01b815260040160405180910390fd5b8054831580156101000261ffff19909216919091176001178255612ceb5761012e60008154612ce2906159da565b90915550612d00565b61012f60008154612cfb906159da565b909155505b6101315461012e541180612d1957506101305461012f54115b15612d375760405163e55fb50960e01b815260040160405180910390fd5b612d4082613e1e565b816001600160a01b03167fdd032f28700d4e4b1719b8fa26918a7d68608b4e36def571ce5fe7a3ecd69f4584604051612d7d911515815260200190565b60405180910390a2505050565b610135805460005b81811015611198576000838281548110612dae57612dae615541565b6000918252602090912001546001600160a01b03169050612dce81611680565b6001600160a01b038082166000908152610133602090815260408083206002908101546101348452828520958b1685529490925282200191909155612e138287613a1a565b6001600160a01b03808416600081815261013460209081526040808320948c1683529381528382206001018590559181526101339091522060030154909150612e5d90829061564b565b6001600160a01b039092166000908152610133602052604090206003019190915550600101612d92565b61013b8054906000612e98836159da565b919050555061012f5461012e54612eaf919061564b565b61013c81905561013d55565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b031603612f1d57507f0000000000000000000000000000000000000000000000000000000000000000919050565b816001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015612f5b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061164191906159f3565b606580546001600160a01b0319169055610af681613e5c565b6001600160a01b038116600090815261012d60205260408120805461ff00191661010017815561012e805491929091612fd0906159da565b9091555061012f8054600090612fe59061556d565b909155506101315461012e5411156130105760405163e55fb50960e01b815260040160405180910390fd5b6040516001600160a01b038316907f5272e69bcef8da96614ac4a5d1e95ca02c35ea627bf7ecf389ec88d8d78b86bb90600090a25050565b60fb5481116130a45760405162461bcd60e51b815260206004820152602260248201527f436f6d7074726f6c6c65723a20496e76616c6964206d61784c6f6f70734c696d6044820152611a5d60f21b6064820152608401610dbe565b60fb80549082905560408051828152602081018490527fc2d09fef144f7c8a86f71ea459f8fc17f675768eb1ae369cbd77fb31d467aafa9101610e2c565b60c95460ff16156113e35760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610dbe565b6000806131358484612012565b6001600160a01b0380861660009081526101346020908152604080832093881683529290522054909150613169908261564b565b6001600160a01b038581166000908152610133602090815260408083206002908101546101348452828520958a16855294909252822090810192909255908190559091506131b685612ebb565b6040516370a0823160e01b815230600482015290915081906001600160a01b038216906370a0823190602401602060405180830381865afa1580156131ff573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061322391906155e9565b8311156132a0576001600160a01b03828116600090815261014060205260408082209190915561014154905163192e7a7b60e01b8152838316600482015291169063192e7a7b90602401600060405180830381600087803b15801561328757600080fd5b505af115801561329b573d6000803e3d6000fd5b505050505b6132b46001600160a01b0382168685613eae565b856001600160a01b0316856001600160a01b03167fc7edf5cfe443c04a10a60ff6084c847114348c55b257a01d62700326219adbba856040516132f991815260200190565b60405180910390a35090949350505050565b806001600160801b0316826001600160801b031610158061333357506001600160801b038216155b1561200e57604051630381eb6d60e61b815260040160405180910390fd5b600054610100900460ff166133785760405162461bcd60e51b8152600401610dbe90615a10565b613380613f00565b610af681613f2f565b600054610100900460ff166133b05760405162461bcd60e51b8152600401610dbe90615a10565b6113e3613f56565b6133c06130e2565b60c9805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586133f53390565b6040516001600160a01b03909116815260200160405180910390a1565b60007f000000000000000000000000000000000000000000000000000000000000000082111561346357507f0000000000000000000000000000000000000000000000000000000000000000919050565b5090565b6134996040518060a0016040528060008152602001600081526020016000815260200160008152602001600081525090565b6101375460408051631ac5701b60e11b815290516000926001600160a01b03169163358ae0369160048083019260209291908290030181865afa1580156134e4573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061350891906159f3565b610142546040516341976e0960e01b81526001600160a01b038084166004830152929350600092909116906341976e0990602401602060405180830381865afa158015613559573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061357d91906155e9565b6001600160a01b03851660009081526101336020526040902060010154909150670de0b6b3a76400009081906135b3908a615602565b6135bd9190615637565b6135c79083615602565b6135d19190615637565b60808401526001600160a01b03841660009081526101336020526040902054670de0b6b3a7640000908190613606908a615602565b6136109190615637565b61361a9083615602565b6136249190615637565b60608401526101425460405163fc57d4df60e01b81526001600160a01b038681166004830152600092169063fc57d4df90602401602060405180830381865afa158015613675573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061369991906155e9565b90506000670de0b6b3a76400006136b08884615602565b6136ba9190615637565b90506000670de0b6b3a76400006136d18a85615602565b6136db9190615637565b90508560600151821061371557816000036136f7576000613712565b818660600151896137089190615602565b6137129190615637565b97505b8560800151811061374d578060000361372f57600061374a565b8086608001518a6137409190615602565b61374a9190615637565b98505b613757898961564b565b86525050505060208201939093526040810193909352509092915050565b6000841580613782575083155b1561378f57506000612a0c565b83850361379d575083612a0c565b8385106000816137b6576137b18688613f89565b6137c0565b6137c08787613f89565b905060006137fb6137d086613ff1565b6137d988613ff1565b6137e28561405b565b6137ec9190615a5b565b6137f69190615ae0565b614066565b905082156138175761380d8782614071565b9350505050612a0c565b61382187826140a3565b98975050505050505050565b600080826000036138435750600090508061390d565b60008361384f8b611316565b6138599087615602565b6138639190615637565b90506000613871878961564b565b9050806000036138895760008093509350505061390d565b6127106000808361389a8c87615602565b6138a49190615637565b9150836138b18b87615602565b6138bb9190615637565b90508c156138dd578c6138ce8484615602565b6138d89190615637565b6138e0565b60005b96508b15613902578b6138f38483615602565b6138fd9190615637565b613905565b60005b955050505050505b97509795505050505050565b60fb54811115610af65760fb5460405163792bfb1b60e11b8152600481019190915260248101829052604401610dbe565b6139526140d5565b60c9805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa336133f5565b6001600160a01b0380831660008181526101346020908152604080832094861683529381528382208451606081018652815481526001820154818401526002918201548187018190529484526101339092529382209093015490929183916139eb91906155d2565b6020830151909150670de0b6b3a7640000613a068284615602565b613a109190615637565b9695505050505050565b600080613a2961257a8461296e565b6040516395dd919360e01b81526001600160a01b0385811660048301529192508591600091908316906395dd919390602401602060405180830381865afa158015613a78573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a9c91906155e9565b90506000826001600160a01b031663182df0f56040518163ffffffff1660e01b8152600401602060405180830381865afa158015613ade573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b0291906155e9565b6040516370a0823160e01b81526001600160a01b0388811660048301529192506000918516906370a0823190602401602060405180830381865afa158015613b4e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b7291906155e9565b90506000670de0b6b3a7640000613b898385615602565b613b939190615637565b9050600061013760009054906101000a90046001600160a01b03166001600160a01b031663358ae0366040518163ffffffff1660e01b8152600401602060405180830381865afa158015613beb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c0f91906159f3565b6101425460405163b62cad6960e01b81526001600160a01b03808416600483015292935091169063b62cad6990602401600060405180830381600087803b158015613c5957600080fd5b505af1158015613c6d573d6000803e3d6000fd5b5050610142546040516396e85ced60e01b81526001600160a01b038e8116600483015290911692506396e85ced9150602401600060405180830381600087803b158015613cb957600080fd5b505af1158015613ccd573d6000803e3d6000fd5b505050506000613cdf8887858e613467565b90506000613cec8c612ebb565b6001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015613d29573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d4d9190615663565b60ff169050613d5d8160126155d2565b613d6890600a61576a565b8251613d749190615602565b80835261013654613d9a918b916001600160801b0380821691600160801b900416613775565b9c9b505050505050505050505050565b61013c5415613dc85761013c60008154613dc39061556d565b909155505b61013d5415801590613e02575061013b54600090815261013a602090815260408083206001600160a01b038516845290915290205460ff16155b15610af65761013d60008154613e179061556d565b9091555050565b61013c5415610af65761013b54600090815261013a602090815260408083206001600160a01b03851684529091529020805460ff1916600117905550565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610d7b90849061411e565b600054610100900460ff16613f275760405162461bcd60e51b8152600401610dbe90615a10565b6113e36141f3565b600054610100900460ff16610aed5760405162461bcd60e51b8152600401610dbe90615a10565b600054610100900460ff16613f7d5760405162461bcd60e51b8152600401610dbe90615a10565b60c9805460ff19169055565b6000613f9483613ff1565b613f9d83613ff1565b1215613fc6576040516360c1ae3960e01b81526004810184905260248101839052604401610dbe565b613fcf82613ff1565b6001607f1b613fdd85613ff1565b613fe79190615a5b565b611c8a9190615ae0565b60006001600160ff1b038211156134635760405162461bcd60e51b815260206004820152602860248201527f53616665436173743a2076616c756520646f65736e27742066697420696e2061604482015267371034b73a191a9b60c11b6064820152608401610dbe565b600061164182614223565b600061164182614810565b60008082121561409457604051639603648160e01b815260040160405180910390fd5b6001607f1b82613fdd85613ff1565b6000808212156140c657604051639603648160e01b815260040160405180910390fd5b816001607f1b613fdd85613ff1565b60c95460ff166113e35760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610dbe565b6000614173826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316614f219092919063ffffffff16565b90508051600014806141945750808060200190518101906141949190615913565b610d7b5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610dbe565b600054610100900460ff1661421a5760405162461bcd60e51b8152600401610dbe90615a10565b6113e333612f7f565b60006001607f1b82131561424d57604051633ce23a3d60e11b815260048101839052602401610dbe565b60008213614271576040516330ecaa3d60e21b815260048101839052602401610dbe565b6001607f1b820361428457506000919050565b640733048c5a821361429e576116416101ff607c1b615b0e565b60008060006a01c8464f7616476000000085136142ec576142c3600160841b85615b2a565b93506a01c8464f761647600000006142df6001607f1b87615a5b565b6142e99190615ae0565b94505b6cf1aaddd7742e9000000000000085136143395761430e600160831b85615b2a565b93506cf1aaddd7742e9000000000000061432c6001607f1b87615a5b565b6143369190615ae0565b94505b6615fc21041027af603f1b851361438057614358600160821b85615b2a565b93506615fc21041027af603f1b6143736001607f1b87615a5b565b61437d9190615ae0565b94505b660960aadc109e7b60461b85136143c75761439f600160811b85615b2a565b9350660960aadc109e7b60461b6143ba6001607f1b87615a5b565b6143c49190615ae0565b94505b660454aaa8efe073604a1b851361440e576143e6600160801b85615b2a565b9350660454aaa8efe073604a1b6144016001607f1b87615a5b565b61440b9190615ae0565b94505b6602f16ac6c59de7604c1b85136144555761442d6001607f1b85615b2a565b93506602f16ac6c59de7604c1b6144486001607f1b87615a5b565b6144529190615ae0565b94505b6609b4597e37cb05604b1b851361449c576144746001607e1b85615b2a565b93506609b4597e37cb05604b1b61448f6001607f1b87615a5b565b6144999190615ae0565b94505b6618ebef9eac820b604a1b85136144e3576144bb6001607d1b85615b2a565b93506618ebef9eac820b604a1b6144d66001607f1b87615a5b565b6144e09190615ae0565b94505b6f70f5a893b608861e1f58934f97aea57d8513614536576145086001607c1b85615b2a565b93506f70f5a893b608861e1f58934f97aea57d6145296001607f1b87615a5b565b6145339190615ae0565b94505b6145446001607f1b86615b2a565b92508291506001607f1b6145588380615a5b565b6145629190615ae0565b9050600160801b6145738482615b2a565b61457d9084615a5b565b6145879190615ae0565b6145919085615b69565b93506001607f1b6145a28284615a5b565b6145ac9190615ae0565b9150600160811b6145cd846faaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa615b2a565b6145d79084615a5b565b6145e19190615ae0565b6145eb9085615b69565b93506001607f1b6145fc8284615a5b565b6146069190615ae0565b9150600360801b614627846f99999999999999999999999999999999615b2a565b6146319084615a5b565b61463b9190615ae0565b6146459085615b69565b93506001607f1b6146568284615a5b565b6146609190615ae0565b9150600160821b614681846f92492492492492492492492492492492615b2a565b61468b9084615a5b565b6146959190615ae0565b61469f9085615b69565b93506001607f1b6146b08284615a5b565b6146ba9190615ae0565b9150600560801b6146db846f8e38e38e38e38e38e38e38e38e38e38e615b2a565b6146e59084615a5b565b6146ef9190615ae0565b6146f99085615b69565b93506001607f1b61470a8284615a5b565b6147149190615ae0565b9150600360811b614735846f8ba2e8ba2e8ba2e8ba2e8ba2e8ba2e8b615b2a565b61473f9084615a5b565b6147499190615ae0565b6147539085615b69565b93506001607f1b6147648284615a5b565b61476e9190615ae0565b9150600760801b61478f846f89d89d89d89d89d89d89d89d89d89d89615b2a565b6147999084615a5b565b6147a39190615ae0565b6147ad9085615b69565b93506001607f1b6147be8284615a5b565b6147c89190615ae0565b9150600160831b6147e9846f88888888888888888888888888888888615b2a565b6147f39084615a5b565b6147fd9190615ae0565b6148079085615b69565b95945050505050565b60006148206101ff607c1b615b0e565b82121561482f57506000919050565b8160000361484257506001607f1b919050565b600082131561486757604051631086170d60e01b815260048101839052602401610dbe565b6000806148786001607c1b85615baa565b91508190506001607f1b61488c8280615a5b565b6148969190615ae0565b90506148aa816710e1b3be415a0000615a5b565b6148b49084615b69565b92506001607f1b6148c58383615a5b565b6148cf9190615ae0565b90506148e3816705a0913f6b1e0000615a5b565b6148ed9084615b69565b92506001607f1b6148fe8383615a5b565b6149089190615ae0565b905061491c81670168244fdac78000615a5b565b6149269084615b69565b92506001607f1b6149378383615a5b565b6149419190615ae0565b905061495481664807432bc18000615a5b565b61495e9084615b69565b92506001607f1b61496f8383615a5b565b6149799190615ae0565b905061498c81660c0135dca04000615a5b565b6149969084615b69565b92506001607f1b6149a78383615a5b565b6149b19190615ae0565b90506149c4816601b707b1cdc000615a5b565b6149ce9084615b69565b92506001607f1b6149df8383615a5b565b6149e99190615ae0565b90506149fb816536e0f639b800615a5b565b614a059084615b69565b92506001607f1b614a168383615a5b565b614a209190615ae0565b9050614a3281650618fee9f800615a5b565b614a3c9084615b69565b92506001607f1b614a4d8383615a5b565b614a579190615ae0565b9050614a6881649c197dcc00615a5b565b614a729084615b69565b92506001607f1b614a838383615a5b565b614a8d9190615ae0565b9050614a9e81640e30dce400615a5b565b614aa89084615b69565b92506001607f1b614ab98383615a5b565b614ac39190615ae0565b9050614ad48164012ebd1300615a5b565b614ade9084615b69565b92506001607f1b614aef8383615a5b565b614af99190615ae0565b9050614b09816317499f00615a5b565b614b139084615b69565b92506001607f1b614b248383615a5b565b614b2e9190615ae0565b9050614b3e816301a9d480615a5b565b614b489084615b69565b92506001607f1b614b598383615a5b565b614b639190615ae0565b9050614b7281621c6380615a5b565b614b7c9084615b69565b92506001607f1b614b8d8383615a5b565b614b979190615ae0565b9050614ba6816201c638615a5b565b614bb09084615b69565b92506001607f1b614bc18383615a5b565b614bcb9190615ae0565b9050614bd981611ab8615a5b565b614be39084615b69565b92506001607f1b614bf48383615a5b565b614bfe9190615ae0565b9050614c0c8161017c615a5b565b614c169084615b69565b92506001607f1b614c278383615a5b565b614c319190615ae0565b9050614c3e816014615a5b565b614c489084615b69565b92506001607f1b614c598383615a5b565b614c639190615ae0565b9050614c70816001615a5b565b614c7a9084615b69565b92506001607f1b82614c946721c3677c82b4000086615ae0565b614c9e9190615b69565b614ca89190615b69565b9250614cb384615b0e565b9350600160841b841615614cf9577243cbaf42a000812488fc5c220ad7b97bf6e99e614cec6cf1aaddd7742e56d32fb9f9974485615a5b565b614cf69190615ae0565b92505b600160831b841615614d3e577105d27a9f51c31b7c2f8038212a0574779991614d316e0afe10820813d65dfe6a33c07f738f85615a5b565b614d3b9190615ae0565b92505b600160821b841615614d8357701b4c902e273a58678d6d3bfdb93db96d02614d766f02582ab704279e8efd15e0265855c47a85615a5b565b614d809190615ae0565b92505b600160811b841615614dc8577003b1cc971a9bb5b9867477440d6d157750614dbb6f1152aaa3bf81cb9fdb76eae12d02957185615a5b565b614dc59190615ae0565b92505b600160801b841615614e0d5770015bf0a8b1457695355fb8ac404e7a79e3614e006f2f16ac6c59de6f8d5d6f63c1482a7c8685615a5b565b614e0a9190615ae0565b92505b6001607f1b841615614e51576fd3094c70f034de4b96ff7d5b6f99fcd8614e446f4da2cbf1be5827f9eb3ad1aa9866ebb385615a5b565b614e4e9190615ae0565b92505b6001607e1b841615614e95576fa45af1e1f40c333b3de1db4dd55f29a7614e886f63afbe7ab2082ba1a0ae5e4eb1b479dc85615a5b565b614e929190615ae0565b92505b6001607d1b841615614ed9576f910b022db7ae67ce76b441c27035c6a1614ecc6f70f5a893b608861e1f58934f97aea57d85615a5b565b614ed69190615ae0565b92505b6001607c1b841615614f1a576f88415abbe9a76bead8d00cf112e4d4a8614f106f783eafef1c0a8f3978c7f81824d62ebf85615a5b565b612a0c9190615ae0565b5050919050565b6060612a0c848460008585600080866001600160a01b03168587604051614f489190615bbe565b60006040518083038185875af1925050503d8060008114614f85576040519150601f19603f3d011682016040523d82523d6000602084013e614f8a565b606091505b5091509150614f9b87838387614fa6565b979650505050505050565b6060831561501557825160000361500e576001600160a01b0385163b61500e5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610dbe565b5081612a0c565b612a0c838381511561502a5781518083602001fd5b8060405162461bcd60e51b8152600401610dbe9190615bda565b604051806101400160405280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6001600160a01b0381168114610af657600080fd5b6000602082840312156150be57600080fd5b81356113ca81615097565b600080604083850312156150dc57600080fd5b50508035926020909101359150565b60008083601f8401126150fd57600080fd5b50813567ffffffffffffffff81111561511557600080fd5b6020830191508360208260051b850101111561513057600080fd5b9250929050565b6000806020838503121561514a57600080fd5b823567ffffffffffffffff81111561516157600080fd5b61516d858286016150eb565b90969095509350505050565b60008060006060848603121561518e57600080fd5b833561519981615097565b95602085013595506040909401359392505050565b600080600080604085870312156151c457600080fd5b843567ffffffffffffffff808211156151dc57600080fd5b6151e8888389016150eb565b9096509450602087013591508082111561520157600080fd5b5061520e878288016150eb565b95989497509550505050565b8015158114610af657600080fd5b60008060006040848603121561523d57600080fd5b83356152488161521a565b9250602084013567ffffffffffffffff81111561526457600080fd5b615270868287016150eb565b9497909650939450505050565b60006020828403121561528f57600080fd5b5035919050565b600080604083850312156152a957600080fd5b8235915060208301356152bb81615097565b809150509250929050565b6020808252825182820181905260009190848201906040850190845b818110156153075783516001600160a01b0316835292840192918401916001016152e2565b50909695505050505050565b80356001600160801b038116811461164457600080fd5b6000806000806000806000806000806101408b8d03121561534a57600080fd5b8a3561535581615097565b995060208b013561536581615097565b985060408b0135975061537a60608c01615313565b965061538860808c01615313565b955060a08b013561539881615097565b945060c08b01356153a881615097565b935060e08b01356153b881615097565b92506101008b01356153c981615097565b809250506101208b013590509295989b9194979a5092959850565b600080600080600060a086880312156153fc57600080fd5b853561540781615097565b9450602086013561541781615097565b94979496505050506040830135926060810135926080909101359150565b6000806040838503121561544857600080fd5b823561545381615097565b915060208301356152bb81615097565b6000806000806080858703121561547957600080fd5b843561548481615097565b9350602085013561549481615097565b93969395505050506040820135916060013590565b600080604083850312156154bc57600080fd5b6154c583615313565b91506154d360208401615313565b90509250929050565b602080825282518282018190526000919060409081850190868401855b8281101561553457815180516001600160a01b03908116865287820151168786015285015185850152606090930192908501906001016154f9565b5091979650505050505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60008161557c5761557c615557565b506000190190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b6000828210156155e4576155e4615557565b500390565b6000602082840312156155fb57600080fd5b5051919050565b600081600019048311821515161561561c5761561c615557565b500290565b634e487b7160e01b600052601260045260246000fd5b60008261564657615646615621565b500490565b6000821982111561565e5761565e615557565b500190565b60006020828403121561567557600080fd5b815160ff811681146113ca57600080fd5b600181815b808511156156c15781600019048211156156a7576156a7615557565b808516156156b457918102915b93841c939080029061568b565b509250929050565b6000826156d857506001611c8d565b816156e557506000611c8d565b81600181146156fb576002811461570557615721565b6001915050611c8d565b60ff84111561571657615716615557565b50506001821b611c8d565b5060208310610133831016604e8410600b8410161715615744575081810a611c8d565b61574e8383615686565b806000190482111561576257615762615557565b029392505050565b6000611c8a83836156c9565b634e487b7160e01b600052604160045260246000fd5b60405160a0810167ffffffffffffffff811182821017156157af576157af615776565b60405290565b604051601f8201601f1916810167ffffffffffffffff811182821017156157de576157de615776565b604052919050565b60005b838110156158015781810151838201526020016157e9565b838111156111985750506000910152565b805161164481615097565b6000602080838503121561583057600080fd5b825167ffffffffffffffff8082111561584857600080fd5b9084019060a0828703121561585c57600080fd5b61586461578c565b82518281111561587357600080fd5b8301601f8101881361588457600080fd5b80518381111561589657615896615776565b6158a8601f8201601f191687016157b5565b935080845288868284010111156158be57600080fd5b6158cd818786018885016157e6565b50508181526158dd848401615812565b848201526158ed60408401615812565b604082015260608301516060820152608083015160808201528094505050505092915050565b60006020828403121561592557600080fd5b81516113ca8161521a565b600081518084526159488160208601602086016157e6565b601f01601f19169290920160200192915050565b6001600160a01b0383168152604060208201819052600090612a0c90830184615930565b6001600160a01b0384811682528316602082015260606040820181905260009061480790830184615930565b6000806000606084860312156159c157600080fd5b8351925060208401519150604084015190509250925092565b6000600182016159ec576159ec615557565b5060010190565b600060208284031215615a0557600080fd5b81516113ca81615097565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60006001600160ff1b0381841382841380821686840486111615615a8157615a81615557565b600160ff1b6000871282811687830589121615615aa057615aa0615557565b60008712925087820587128484161615615abc57615abc615557565b87850587128184161615615ad257615ad2615557565b505050929093029392505050565b600082615aef57615aef615621565b600160ff1b821460001984141615615b0957615b09615557565b500590565b6000600160ff1b8201615b2357615b23615557565b5060000390565b60008083128015600160ff1b850184121615615b4857615b48615557565b6001600160ff1b0384018313811615615b6357615b63615557565b50500390565b600080821280156001600160ff1b0384900385131615615b8b57615b8b615557565b600160ff1b8390038412811615615ba457615ba4615557565b50500190565b600082615bb957615bb9615621565b500790565b60008251615bd08184602087016157e6565b9190910192915050565b602081526000611c8a602083018461593056fe7570646174654d756c7469706c6965727328616464726573732c75696e743235362c75696e743235362909d2594e8892daceca055f74be758146a8b8b1167444d0b4ccb96e74168198cc6164644d61726b657428616464726573732c616464726573732c75696e743235362c75696e7432353629a2646970667358221220f73f8d2a2c97164147552d8810882faa3aca58c483e6eefd94dfc63a6813840f64736f6c634300080d00330000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002819a0000000000000000000000000000000000000000000000000000000000076a70000000000000000000000000000000000000000000000003635c9adc5dea0000000000000000000000000000000000000000000000000152d02c7e14af68000000000000000000000000000000000000000000000000000000000000000000000

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106103e65760003560e01c80639f6506ce1161020a578063cdaa21b711610125578063e30c3978116100b8578063ef36bbde11610087578063ef36bbde14610a57578063f2fde38b14610a78578063f6ed201714610a8b578063fa6d5f1814610aab578063fe1006ad14610abe57600080fd5b8063e30c3978146109c5578063e4676f37146109d6578063e4860339146109e9578063ee6b13fc14610a2d57600080fd5b8063d88b9d2e116100f4578063d88b9d2e14610996578063da6ab4f8146109a0578063e18f8822146109aa578063e1d146fb146109bd57600080fd5b8063cdaa21b71461092e578063ce85361314610955578063cf329d1614610970578063d65bd2411461098357600080fd5b8063ba437c681161019d578063c3db3c361161016c578063c3db3c36146108e1578063c4ae3168146108eb578063c7ad0895146108f3578063c86d1a781461091a57600080fd5b8063ba437c68146108a8578063bc5dc4c3146108bb578063bd212c0e146108ce578063be26317e146108d857600080fd5b8063b1a250f2116101d9578063b1a250f2146107a2578063b4a0bdf3146107b5578063b7f2d258146107c6578063b9eb69f61461085257600080fd5b80639f6506ce14610765578063a15753dc1461076f578063afcff50f14610779578063b0772d0b1461078d57600080fd5b80635fe3b5671161030557806380d45a2d1161029857806389afcb441161026757806389afcb44146106945780638da5cb5b146106a75780638e8f294b146106b85780639198e515146107235780639565d3d21461073657600080fd5b806380d45a2d14610650578063856c3aa41461066357806388bead731461066d57806388d742c21461068157600080fd5b806379ba5097116102d457806379ba5097146105f55780637dafcd89146105fd5780637dc0d1d0146106105780637ef820701461062457600080fd5b80635fe3b5671461058d5780636426b4a71461059f5780636857249c146105c6578063715018a6146105ed57600080fd5b806337f23cd31161037d57806355d36c981161034c57806355d36c9814610549578063594a67ee1461055c5780635c975abb1461056f5780635d536d301461057a57600080fd5b806337f23cd3146104e757806338f6a434146104fa578063487b0dfb146105375780634e71d92d1461054157600080fd5b80631bffac89116103b95780631bffac891461048d578063207add91146104ae57806324e6baf2146104c157806329b6eca9146104d457600080fd5b80630104db1b146103eb5780630e32cb86146104255780631b3f8c5e1461043a5780631b9ce57514610479575b600080fd5b6104127f000000000000000000000000000000000000000000000000000000000076a70081565b6040519081526020015b60405180910390f35b6104386104333660046150ac565b610ae5565b005b6104617f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b03909116815260200161041c565b61013754610461906001600160a01b031681565b61041261049b3660046150ac565b6101406020526000908152604090205481565b6104386104bc3660046150c9565b610af9565b6104386104cf366004615137565b610bb4565b6104386104e23660046150ac565b610d80565b6104386104f53660046150ac565b610e38565b6105276105083660046150ac565b6001600160a01b0316600090815261012d602052604090205460ff1690565b604051901515815260200161041c565b6104126101395481565b610438611044565b610438610557366004615179565b6110d3565b61043861056a3660046151ae565b61119e565b60c95460ff16610527565b6104126105883660046150ac565b611316565b61013f546001600160a01b0316610461565b6104127f00000000000000000000000000000000000000000000003635c9adc5dea0000081565b6104127f00000000000000000000000000000000000000000000000000000000002819a081565b6104386113d1565b6104386113e5565b61043861060b366004615228565b61145c565b61014254610461906001600160a01b031681565b61013654610638906001600160801b031681565b6040516001600160801b03909116815260200161041c565b61043861065e36600461527d565b6115e6565b6104126101315481565b61013854610461906001600160a01b031681565b61041261068f3660046150ac565b61162d565b6104386106a23660046150ac565b611649565b6033546001600160a01b0316610461565b6106f96106c63660046150ac565b61013360205260009081526040902080546001820154600283015460038401546004909401549293919290919060ff1685565b6040805195865260208601949094529284019190915260608301521515608082015260a00161041c565b6104386107313660046150ac565b611680565b610527610744366004615296565b61013a60209081526000928352604080842090915290825290205460ff1681565b61041261012f5481565b61041261013b5481565b61014354610461906001600160a01b031681565b610795611844565b60405161041c91906152c6565b6104386107b036600461532a565b6118a7565b6097546001600160a01b0316610461565b6107d96107d43660046153e4565b611abc565b60405161041c9190600061014082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015260a083015160a083015260c083015160c083015260e083015160e083015261010080840151818401525061012080840151818401525092915050565b61088d610860366004615435565b61013460209081526000928352604080842090915290825290208054600182015460029092015490919083565b6040805193845260208401929092529082015260600161041c565b6104126108b6366004615435565b611c76565b6104386108c9366004615463565b611c93565b61041261013c5481565b61041260fb5481565b61041261013d5481565b610438611fb1565b6105277f000000000000000000000000000000000000000000000000000000000000000081565b61014154610461906001600160a01b031681565b6104617f000000000000000000000000000000000000000000000000000000000000000081565b6101365461063890600160801b90046001600160801b031681565b61043861097e366004615435565b611ffa565b610412610991366004615435565b612012565b61041261012e5481565b6104126101305481565b6104386109b83660046154a9565b612027565b61041261212b565b6065546001600160a01b0316610461565b6104126109e43660046150ac565b61215e565b610a166109f73660046150ac565b61012d6020526000908152604090205460ff8082169161010090041682565b60408051921515835290151560208301520161041c565b610461610a3b3660046150ac565b61013e602052600090815260409020546001600160a01b031681565b610412610a653660046150ac565b6101326020526000908152604090205481565b610438610a863660046150ac565b612206565b610a9e610a993660046150ac565b612277565b60405161041c91906154dc565b6107d9610ab9366004615435565b6123b9565b6104127f00000000000000000000000000000000000000000000152d02c7e14af680000081565b610aed612603565b610af68161265d565b50565b610b376040518060400160405280601981526020017f7365744c696d69742875696e743235362c75696e74323536290000000000000081525061271b565b61012e54821080610b4a575061012f5481105b15610b685760405163e55fb50960e01b815260040160405180910390fd5b8161013054610131547f6c52f3e195bdc534883e903e0612c49261a466aacd492501870b0a0ac0b1835584604051610ba291815260200190565b60405180910390a46101305561013155565b61013d54600003610bd85760405163071a45dd60e31b815260040160405180910390fd5b61013b54600003610bfc5760405163071a45dd60e31b815260040160405180910390fd5b60005b81811015610d7b576000838383818110610c1b57610c1b615541565b9050602002016020810190610c3091906150ac565b6001600160a01b038116600090815261012d602052604090205490915060ff16610c6d57604051633aeb927b60e11b815260040160405180910390fd5b61013b54600090815261013a602090815260408083206001600160a01b038516845290915290205460ff1615610ca65750600101610bff565b610135805460005b81811015610cfe576000838281548110610cca57610cca615541565b6000918252602090912001546001600160a01b03169050610ceb85826127b5565b610cf58582612891565b50600101610cae565b5061013d60008154610d0f9061556d565b9091555061013b54600090815261013a602090815260408083206001600160a01b0387168085529252808320805460ff19166001908117909155905196019590917fa699df4aa8f89fc1f5408fe78ae114651f18b25ed1601680e4c70c15177d8b1b91a2505050610bff565b505050565b600054600290610100900460ff16158015610da2575060005460ff8083169116105b610dc75760405162461bcd60e51b8152600401610dbe90615584565b60405180910390fd5b6000805461014380546001600160a01b0319166001600160a01b03861617905561ff001961010060ff851661ffff19909316831717169091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020015b60405180910390a15050565b6000610e438261296e565b90506000610e5082612a14565b6001600160a01b0384166000908152610132602090815260408083205461012d83529281902081518083019092525460ff808216158015808552610100909304909116151593830193909352939450919290610eaa575082155b15610f0c576001600160a01b03851660008181526101326020908152604080832083905551918252600080516020615c18833981519152910160405180910390a2806020015115610f0357610efe85612a4d565b61103d565b610efe85612aa5565b82158015610f1957508051155b8015610f2457508115155b15610f6b576001600160a01b03851660008181526101326020908152604080832083905551918252600080516020615c1883398151915291015b60405180910390a261103d565b81158015610f765750825b8015610f8157508051155b15610fc3576001600160a01b0385166000818152610132602090815260409182902042908190559151918252600080516020615c188339815191529101610f5e565b80518015610fce5750825b1561103d57610fdc85612a4d565b6001600160a01b03851660009081526101326020526040812054900361103d576001600160a01b0385166000818152610132602090815260409182902042908190559151918252600080516020615c18833981519152910160405180910390a25b5050505050565b3360009081526101326020526040812054908190036110755760405162c4e3d160e01b815260040160405180910390fd5b7f000000000000000000000000000000000000000000000000000000000076a7006110a082426155d2565b10156110bf5760405163beb98cab60e01b815260040160405180910390fd5b6110ca600033612c79565b610af633612d8a565b6110f46040518060600160405280602a8152602001615bee602a913961271b565b6001600160a01b038316600090815261013360205260409020600481015460ff1661113257604051630ff2e4a960e31b815260040160405180910390fd5b61113b84611680565b6001810154815460408051868152602081018690526001600160a01b038816917f91e78a55b6df3a0eac1c12a64572a8c0faced385bafba688817f5ce6daa33537910160405180910390a482815560018101829055611198612e87565b50505050565b6111dc6040518060400160405280602081526020017f7365745374616b6564417428616464726573735b5d2c75696e743235365b5d2981525061271b565b8281146111fc5760405163251f56a160e21b815260040160405180910390fd5b60005b8381101561103d574283838381811061121a5761121a615541565b9050602002013511156112405760405163b7d0949760e01b815260040160405180910390fd5b82828281811061125257611252615541565b90506020020135610132600087878581811061127057611270615541565b905060200201602081019061128591906150ac565b6001600160a01b031681526020810191909152604001600020558484828181106112b1576112b1615541565b90506020020160208101906112c691906150ac565b6001600160a01b0316600080516020615c188339815191528484848181106112f0576112f0615541565b9050602002013560405161130691815260200190565b60405180910390a26001016111ff565b6101415460009081906001600160a01b031663a666642b61133685612ebb565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa15801561137a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061139e91906155e9565b90506113ca817f00000000000000000000000000000000000000000000000000000000002819a0615602565b9392505050565b6113d9612603565b6113e36000612f7f565b565b60655433906001600160a01b031681146114535760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b6064820152608401610dbe565b610af681612f7f565b61149260405180604001604052806015815260200174697373756528626f6f6c2c616464726573735b5d2960581b81525061271b565b82156115a75760005b8181101561119857600061012d60008585858181106114bc576114bc615541565b90506020020160208101906114d191906150ac565b6001600160a01b031681526020810191909152604001600020805490915060ff16801561150557508054610100900460ff16155b1561153e5761153984848481811061151f5761151f615541565b905060200201602081019061153491906150ac565b612f98565b61159e565b61156f600185858581811061155557611555615541565b905060200201602081019061156a91906150ac565b612c79565b61159e84848481811061158457611584615541565b905060200201602081019061159991906150ac565b612d8a565b5060010161149b565b60005b81811015611198576115c9600084848481811061155557611555615541565b6115de83838381811061158457611584615541565b6001016115aa565b6116246040518060400160405280601981526020017f7365744d61784c6f6f70734c696d69742875696e74323536290000000000000081525061271b565b610af681613048565b60006116376130e2565b6116418233613128565b90505b919050565b6116776040518060400160405280600d81526020016c6275726e28616464726573732960981b81525061271b565b610af681612aa5565b6001600160a01b038116600090815261013360205260409020600481015460ff166116be57604051630ff2e4a960e31b815260040160405180910390fd5b60006116c983612ebb565b61014154604051638aadf79960e01b81526001600160a01b0380841660048301529293509116908190638aadf79990602401600060405180830381600087803b15801561171557600080fd5b505af1158015611729573d6000803e3d6000fd5b505060405163fa7781ff60e01b81526001600160a01b038581166004830152600093508416915063fa7781ff90602401602060405180830381865afa158015611776573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061179a91906155e9565b6001600160a01b03841660009081526101406020526040812054919250906117c290836155d2565b90508060008190036117d75750505050505050565b6001600160a01b038516600090815261014060205260408120849055600387015415611821576003870154611814670de0b6b3a764000084615602565b61181e9190615637565b90505b80876002016000828254611835919061564b565b90915550505050505050505050565b606061013580548060200260200160405190810160405280929190818152602001828054801561189d57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161187f575b5050505050905090565b600054610100900460ff16158080156118c75750600054600160ff909116105b806118e15750303b1580156118e1575060005460ff166001145b6118fd5760405162461bcd60e51b8152600401610dbe90615584565b6000805460ff191660011790558015611920576000805461ff0019166101001790555b6001600160a01b038b166119475760405163e6c4247b60e01b815260040160405180910390fd5b6001600160a01b038a1661196e5760405163e6c4247b60e01b815260040160405180910390fd5b6001600160a01b0383166119955760405163e6c4247b60e01b815260040160405180910390fd5b6001600160a01b0385166119bc5760405163e6c4247b60e01b815260040160405180910390fd5b6119c6888861330b565b6001600160801b03878116600160801b02908916176101365561013880546001600160a01b03808d166001600160a01b0319928316179092556101398b905561013780548e8416908316179055600061013b55610141805488841690831617905561013f8054878416908316179055610142805492861692909116919091179055611a5086613351565b611a58613389565b611a6182613048565b611a696133b8565b8015611aaf576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050505050505050565b611ac4615044565b6001600160a01b03808716600081815261013460209081526040808320948a1683529381528382206001015492825261013390529190912060030154611b0a91906155d2565b6040820152611b1882613412565b60808201819052600090611b2e9086868a613467565b805160a0840152602081015160c0840152604081015160e08401526060810151610100840152608081015161012084015290506000611b6c88612ebb565b6001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ba9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bcd9190615663565b60ff169050611bdd8160126155d2565b611be890600a61576a565b8360a00151611bf79190615602565b60a08401819052608084015161013654611c2592906001600160801b0380821691600160801b900416613775565b606084018190526040840151611c3b919061564b565b836040018181525050611c638886888660c001518760e001518860600151896040015161382d565b6020850152835250909695505050505050565b6000611c806130e2565b611c8a8383613128565b90505b92915050565b611cb46040518060600160405280602a8152602001615c38602a913961271b565b6001600160a01b038416611cdb576040516383aebebd60e01b815260040160405180910390fd5b61013f546001600160a01b03858116911614801590611d79575061014354604051637aee632d60e01b81526001600160a01b0386811660048301819052921690637aee632d90602401600060405180830381865afa158015611d41573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611d69919081019061581d565b604001516001600160a01b031614155b15611d97576040516383aebebd60e01b815260040160405180910390fd5b6001600160a01b038316600090815261013360205260409020600481015460ff1615611dd657604051630313b28560e01b815260040160405180910390fd5b604051638e8f294b60e01b81526001600160a01b03858116600483015260009190871690638e8f294b90602401602060405180830381865afa158015611e20573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e449190615913565b905080611e6457604051633d21810360e21b815260040160405180910390fd5b60006002830181905584835560018084018590556003840182905560048401805460ff19169091179055611e9786612ebb565b6001600160a01b03808216600090815261013e60205260409020549192501615611ed45760405163dc0d0aab60e01b815260040160405180910390fd5b6001600160a01b03808216600090815261013e6020526040812080549289166001600160a01b03199384168117909155610135805460018101825592527fdf37d27e88e3bd0b85262482997e409a463f5be0ebb19232abf994dd8474090d9091018054909216179055611f45612e87565b61013554611f5290613919565b856001600160a01b0316876001600160a01b03167f1322eaea77217179bf4ef6084dc2f48c897e0d5a6b8365213804360e4d8ba9a28787604051611fa0929190918252602082015260400190565b60405180910390a350505050505050565b611fdf6040518060400160405280600d81526020016c746f67676c655061757365282960981b81525061271b565b60c95460ff1615611ff2576113e361394a565b6113e36133b8565b61200482826127b5565b61200e8282612891565b5050565b600061201d83611680565b611c8a8383613983565b6120656040518060400160405280601c81526020017f757064617465416c7068612875696e743132382c75696e74313238290000000081525061271b565b61206f828261330b565b610136546040516001600160801b03838116825284811692600160801b81048216929116907f9122c3fdea272423a0586803b53902139919baf05be731f04724ef8f363d378d9060200160405180910390a46001600160801b03818116600160801b0290831617610136556101355460005b818110156121225761211a610135828154811061210057612100615541565b6000918252602090912001546001600160a01b0316611680565b6001016120e1565b50610d7b612e87565b60006121597f0000000000000000000000000000000000000000000000000000011b000025fb63ffffffff16565b905090565b6001600160a01b038116600090815261013260205260408120548082036121a757507f000000000000000000000000000000000000000000000000000000000076a70092915050565b428190037f000000000000000000000000000000000000000000000000000000000076a7008110156121fc577f000000000000000000000000000000000000000000000000000000000076a700039392505050565b5060009392505050565b61220e612603565b606580546001600160a01b0383166001600160a01b0319909116811790915561223f6033546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6101358054606091908067ffffffffffffffff81111561229957612299615776565b6040519080825280602002602001820160405280156122e457816020015b60408051606081018252600080825260208083018290529282015282526000199092019101816122b75790505b50925060005b818110156123b157600083828154811061230657612306615541565b60009182526020822001546001600160a01b031691506123268288612012565b6001600160a01b03808416600081815261013460209081526040808320948d168352938152908390205483516060810190945291835292935091810161236b85612ebb565b6001600160a01b03168152602001612383838561564b565b81525087858151811061239857612398615541565b60200260200101819052508360010193505050506122ea565b505050919050565b6123c1615044565b6040516395dd919360e01b81526001600160a01b03838116600483015284916000918316906395dd919390602401602060405180830381865afa15801561240c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061243091906155e9565b90506000826001600160a01b031663182df0f56040518163ffffffff1660e01b8152600401602060405180830381865afa158015612472573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061249691906155e9565b6040516370a0823160e01b81526001600160a01b0387811660048301529192506000918516906370a0823190602401602060405180830381865afa1580156124e2573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061250691906155e9565b90506000670de0b6b3a764000061251d8385615602565b6125279190615637565b6001600160a01b03808a16600081815261013460209081526040808320948d1683529381528382206001015460608c01529181526101339091528190206003015490880152905061257f61257a8861296e565b613412565b6080870181905260009061259590868489613467565b805160a0890152602081015160c0890181905260408083015160e08b018190526060808501516101008d015260808501516101208d01528b0151918b01519394506125e7938d9387938b93919261382d565b602089015287525094979650505050505050565b4390565b4290565b6033546001600160a01b031633146113e35760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610dbe565b6001600160a01b0381166126c15760405162461bcd60e51b815260206004820152602560248201527f696e76616c696420616365737320636f6e74726f6c206d616e61676572206164604482015264647265737360d81b6064820152608401610dbe565b609780546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f66fd58e82f7b31a2a5c30e0888f3093efe4e111b00cd2b0c31fe014601293aa09101610e2c565b6097546040516318c5e8ab60e01b81526000916001600160a01b0316906318c5e8ab9061274e903390869060040161595c565b602060405180830381865afa15801561276b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061278f9190615913565b90508061200e57333083604051634a3fa29360e01b8152600401610dbe93929190615980565b6001600160a01b0381166000908152610133602052604090206004015460ff1615806127fb57506001600160a01b038216600090815261012d602052604090205460ff16155b15612804575050565b61280d81611680565b6128178183613983565b6001600160a01b038083166000908152610134602090815260408083209387168352929052908120805490919061284f90849061564b565b90915550506001600160a01b03908116600090815261013360209081526040808320600290810154610134845282852096909516845294909152902090910155565b6001600160a01b038116600090815261013360205260409020600481015460ff1615806128d857506001600160a01b038316600090815261012d602052604090205460ff16155b156128e257505050565b60006128ee8385613a1a565b6001600160a01b03808516600090815261013460209081526040808320938916835292905220600101546003840154919250829161292c91906155d2565b612936919061564b565b6003909201919091556001600160a01b0391821660009081526101346020908152604080832095909416825293909352912060010155565b6101375461013854610139546040516398e1b31b60e01b81526001600160a01b03928316600482015260248101919091528382166044820152600092839283929116906398e1b31b90606401606060405180830381865afa1580156129d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129fb91906159ac565b92505091508082612a0c91906155d2565b949350505050565b60007f00000000000000000000000000000000000000000000003635c9adc5dea000008210612a4557506001919050565b506000919050565b610135805460005b81811015611198576000838281548110612a7157612a71615541565b6000918252602090912001546001600160a01b03169050612a9285826127b5565b612a9c8582612891565b50600101612a55565b6001600160a01b038116600090815261012d602090815260409182902082518084019093525460ff808216151580855261010090920416151591830191909152612b0257604051633aeb927b60e11b815260040160405180910390fd5b610135805460005b81811015612bdb576000838281548110612b2657612b26615541565b6000918252602090912001546001600160a01b03169050612b4786826127b5565b6001600160a01b03808216600081815261013460209081526040808320948b1683529381528382206001015492825261013390529190912060030154612b8d91906155d2565b6001600160a01b039182166000908152610133602090815260408083206003019390935561013481528282209389168252929092528120600180820183905560029091019190915501612b0a565b50826020015115612bff5761012e60008154612bf69061556d565b90915550612c14565b61012f60008154612c0f9061556d565b909155505b6001600160a01b038416600090815261012d60205260409020805461ffff19169055612c3f84613daa565b6040516001600160a01b038516907fe22de1457cb61fb61b60176bc4235a9abd19466126b46692bc14fc573f09924990600090a250505050565b6001600160a01b038116600090815261012d60205260409020805460ff1615612cb45760405162c4e3d160e01b815260040160405180910390fd5b8054831580156101000261ffff19909216919091176001178255612ceb5761012e60008154612ce2906159da565b90915550612d00565b61012f60008154612cfb906159da565b909155505b6101315461012e541180612d1957506101305461012f54115b15612d375760405163e55fb50960e01b815260040160405180910390fd5b612d4082613e1e565b816001600160a01b03167fdd032f28700d4e4b1719b8fa26918a7d68608b4e36def571ce5fe7a3ecd69f4584604051612d7d911515815260200190565b60405180910390a2505050565b610135805460005b81811015611198576000838281548110612dae57612dae615541565b6000918252602090912001546001600160a01b03169050612dce81611680565b6001600160a01b038082166000908152610133602090815260408083206002908101546101348452828520958b1685529490925282200191909155612e138287613a1a565b6001600160a01b03808416600081815261013460209081526040808320948c1683529381528382206001018590559181526101339091522060030154909150612e5d90829061564b565b6001600160a01b039092166000908152610133602052604090206003019190915550600101612d92565b61013b8054906000612e98836159da565b919050555061012f5461012e54612eaf919061564b565b61013c81905561013d55565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b031603612f1d57507f0000000000000000000000000000000000000000000000000000000000000000919050565b816001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015612f5b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061164191906159f3565b606580546001600160a01b0319169055610af681613e5c565b6001600160a01b038116600090815261012d60205260408120805461ff00191661010017815561012e805491929091612fd0906159da565b9091555061012f8054600090612fe59061556d565b909155506101315461012e5411156130105760405163e55fb50960e01b815260040160405180910390fd5b6040516001600160a01b038316907f5272e69bcef8da96614ac4a5d1e95ca02c35ea627bf7ecf389ec88d8d78b86bb90600090a25050565b60fb5481116130a45760405162461bcd60e51b815260206004820152602260248201527f436f6d7074726f6c6c65723a20496e76616c6964206d61784c6f6f70734c696d6044820152611a5d60f21b6064820152608401610dbe565b60fb80549082905560408051828152602081018490527fc2d09fef144f7c8a86f71ea459f8fc17f675768eb1ae369cbd77fb31d467aafa9101610e2c565b60c95460ff16156113e35760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610dbe565b6000806131358484612012565b6001600160a01b0380861660009081526101346020908152604080832093881683529290522054909150613169908261564b565b6001600160a01b038581166000908152610133602090815260408083206002908101546101348452828520958a16855294909252822090810192909255908190559091506131b685612ebb565b6040516370a0823160e01b815230600482015290915081906001600160a01b038216906370a0823190602401602060405180830381865afa1580156131ff573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061322391906155e9565b8311156132a0576001600160a01b03828116600090815261014060205260408082209190915561014154905163192e7a7b60e01b8152838316600482015291169063192e7a7b90602401600060405180830381600087803b15801561328757600080fd5b505af115801561329b573d6000803e3d6000fd5b505050505b6132b46001600160a01b0382168685613eae565b856001600160a01b0316856001600160a01b03167fc7edf5cfe443c04a10a60ff6084c847114348c55b257a01d62700326219adbba856040516132f991815260200190565b60405180910390a35090949350505050565b806001600160801b0316826001600160801b031610158061333357506001600160801b038216155b1561200e57604051630381eb6d60e61b815260040160405180910390fd5b600054610100900460ff166133785760405162461bcd60e51b8152600401610dbe90615a10565b613380613f00565b610af681613f2f565b600054610100900460ff166133b05760405162461bcd60e51b8152600401610dbe90615a10565b6113e3613f56565b6133c06130e2565b60c9805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586133f53390565b6040516001600160a01b03909116815260200160405180910390a1565b60007f00000000000000000000000000000000000000000000152d02c7e14af680000082111561346357507f00000000000000000000000000000000000000000000152d02c7e14af6800000919050565b5090565b6134996040518060a0016040528060008152602001600081526020016000815260200160008152602001600081525090565b6101375460408051631ac5701b60e11b815290516000926001600160a01b03169163358ae0369160048083019260209291908290030181865afa1580156134e4573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061350891906159f3565b610142546040516341976e0960e01b81526001600160a01b038084166004830152929350600092909116906341976e0990602401602060405180830381865afa158015613559573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061357d91906155e9565b6001600160a01b03851660009081526101336020526040902060010154909150670de0b6b3a76400009081906135b3908a615602565b6135bd9190615637565b6135c79083615602565b6135d19190615637565b60808401526001600160a01b03841660009081526101336020526040902054670de0b6b3a7640000908190613606908a615602565b6136109190615637565b61361a9083615602565b6136249190615637565b60608401526101425460405163fc57d4df60e01b81526001600160a01b038681166004830152600092169063fc57d4df90602401602060405180830381865afa158015613675573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061369991906155e9565b90506000670de0b6b3a76400006136b08884615602565b6136ba9190615637565b90506000670de0b6b3a76400006136d18a85615602565b6136db9190615637565b90508560600151821061371557816000036136f7576000613712565b818660600151896137089190615602565b6137129190615637565b97505b8560800151811061374d578060000361372f57600061374a565b8086608001518a6137409190615602565b61374a9190615637565b98505b613757898961564b565b86525050505060208201939093526040810193909352509092915050565b6000841580613782575083155b1561378f57506000612a0c565b83850361379d575083612a0c565b8385106000816137b6576137b18688613f89565b6137c0565b6137c08787613f89565b905060006137fb6137d086613ff1565b6137d988613ff1565b6137e28561405b565b6137ec9190615a5b565b6137f69190615ae0565b614066565b905082156138175761380d8782614071565b9350505050612a0c565b61382187826140a3565b98975050505050505050565b600080826000036138435750600090508061390d565b60008361384f8b611316565b6138599087615602565b6138639190615637565b90506000613871878961564b565b9050806000036138895760008093509350505061390d565b6127106000808361389a8c87615602565b6138a49190615637565b9150836138b18b87615602565b6138bb9190615637565b90508c156138dd578c6138ce8484615602565b6138d89190615637565b6138e0565b60005b96508b15613902578b6138f38483615602565b6138fd9190615637565b613905565b60005b955050505050505b97509795505050505050565b60fb54811115610af65760fb5460405163792bfb1b60e11b8152600481019190915260248101829052604401610dbe565b6139526140d5565b60c9805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa336133f5565b6001600160a01b0380831660008181526101346020908152604080832094861683529381528382208451606081018652815481526001820154818401526002918201548187018190529484526101339092529382209093015490929183916139eb91906155d2565b6020830151909150670de0b6b3a7640000613a068284615602565b613a109190615637565b9695505050505050565b600080613a2961257a8461296e565b6040516395dd919360e01b81526001600160a01b0385811660048301529192508591600091908316906395dd919390602401602060405180830381865afa158015613a78573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a9c91906155e9565b90506000826001600160a01b031663182df0f56040518163ffffffff1660e01b8152600401602060405180830381865afa158015613ade573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b0291906155e9565b6040516370a0823160e01b81526001600160a01b0388811660048301529192506000918516906370a0823190602401602060405180830381865afa158015613b4e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b7291906155e9565b90506000670de0b6b3a7640000613b898385615602565b613b939190615637565b9050600061013760009054906101000a90046001600160a01b03166001600160a01b031663358ae0366040518163ffffffff1660e01b8152600401602060405180830381865afa158015613beb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c0f91906159f3565b6101425460405163b62cad6960e01b81526001600160a01b03808416600483015292935091169063b62cad6990602401600060405180830381600087803b158015613c5957600080fd5b505af1158015613c6d573d6000803e3d6000fd5b5050610142546040516396e85ced60e01b81526001600160a01b038e8116600483015290911692506396e85ced9150602401600060405180830381600087803b158015613cb957600080fd5b505af1158015613ccd573d6000803e3d6000fd5b505050506000613cdf8887858e613467565b90506000613cec8c612ebb565b6001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015613d29573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d4d9190615663565b60ff169050613d5d8160126155d2565b613d6890600a61576a565b8251613d749190615602565b80835261013654613d9a918b916001600160801b0380821691600160801b900416613775565b9c9b505050505050505050505050565b61013c5415613dc85761013c60008154613dc39061556d565b909155505b61013d5415801590613e02575061013b54600090815261013a602090815260408083206001600160a01b038516845290915290205460ff16155b15610af65761013d60008154613e179061556d565b9091555050565b61013c5415610af65761013b54600090815261013a602090815260408083206001600160a01b03851684529091529020805460ff1916600117905550565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610d7b90849061411e565b600054610100900460ff16613f275760405162461bcd60e51b8152600401610dbe90615a10565b6113e36141f3565b600054610100900460ff16610aed5760405162461bcd60e51b8152600401610dbe90615a10565b600054610100900460ff16613f7d5760405162461bcd60e51b8152600401610dbe90615a10565b60c9805460ff19169055565b6000613f9483613ff1565b613f9d83613ff1565b1215613fc6576040516360c1ae3960e01b81526004810184905260248101839052604401610dbe565b613fcf82613ff1565b6001607f1b613fdd85613ff1565b613fe79190615a5b565b611c8a9190615ae0565b60006001600160ff1b038211156134635760405162461bcd60e51b815260206004820152602860248201527f53616665436173743a2076616c756520646f65736e27742066697420696e2061604482015267371034b73a191a9b60c11b6064820152608401610dbe565b600061164182614223565b600061164182614810565b60008082121561409457604051639603648160e01b815260040160405180910390fd5b6001607f1b82613fdd85613ff1565b6000808212156140c657604051639603648160e01b815260040160405180910390fd5b816001607f1b613fdd85613ff1565b60c95460ff166113e35760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610dbe565b6000614173826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316614f219092919063ffffffff16565b90508051600014806141945750808060200190518101906141949190615913565b610d7b5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610dbe565b600054610100900460ff1661421a5760405162461bcd60e51b8152600401610dbe90615a10565b6113e333612f7f565b60006001607f1b82131561424d57604051633ce23a3d60e11b815260048101839052602401610dbe565b60008213614271576040516330ecaa3d60e21b815260048101839052602401610dbe565b6001607f1b820361428457506000919050565b640733048c5a821361429e576116416101ff607c1b615b0e565b60008060006a01c8464f7616476000000085136142ec576142c3600160841b85615b2a565b93506a01c8464f761647600000006142df6001607f1b87615a5b565b6142e99190615ae0565b94505b6cf1aaddd7742e9000000000000085136143395761430e600160831b85615b2a565b93506cf1aaddd7742e9000000000000061432c6001607f1b87615a5b565b6143369190615ae0565b94505b6615fc21041027af603f1b851361438057614358600160821b85615b2a565b93506615fc21041027af603f1b6143736001607f1b87615a5b565b61437d9190615ae0565b94505b660960aadc109e7b60461b85136143c75761439f600160811b85615b2a565b9350660960aadc109e7b60461b6143ba6001607f1b87615a5b565b6143c49190615ae0565b94505b660454aaa8efe073604a1b851361440e576143e6600160801b85615b2a565b9350660454aaa8efe073604a1b6144016001607f1b87615a5b565b61440b9190615ae0565b94505b6602f16ac6c59de7604c1b85136144555761442d6001607f1b85615b2a565b93506602f16ac6c59de7604c1b6144486001607f1b87615a5b565b6144529190615ae0565b94505b6609b4597e37cb05604b1b851361449c576144746001607e1b85615b2a565b93506609b4597e37cb05604b1b61448f6001607f1b87615a5b565b6144999190615ae0565b94505b6618ebef9eac820b604a1b85136144e3576144bb6001607d1b85615b2a565b93506618ebef9eac820b604a1b6144d66001607f1b87615a5b565b6144e09190615ae0565b94505b6f70f5a893b608861e1f58934f97aea57d8513614536576145086001607c1b85615b2a565b93506f70f5a893b608861e1f58934f97aea57d6145296001607f1b87615a5b565b6145339190615ae0565b94505b6145446001607f1b86615b2a565b92508291506001607f1b6145588380615a5b565b6145629190615ae0565b9050600160801b6145738482615b2a565b61457d9084615a5b565b6145879190615ae0565b6145919085615b69565b93506001607f1b6145a28284615a5b565b6145ac9190615ae0565b9150600160811b6145cd846faaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa615b2a565b6145d79084615a5b565b6145e19190615ae0565b6145eb9085615b69565b93506001607f1b6145fc8284615a5b565b6146069190615ae0565b9150600360801b614627846f99999999999999999999999999999999615b2a565b6146319084615a5b565b61463b9190615ae0565b6146459085615b69565b93506001607f1b6146568284615a5b565b6146609190615ae0565b9150600160821b614681846f92492492492492492492492492492492615b2a565b61468b9084615a5b565b6146959190615ae0565b61469f9085615b69565b93506001607f1b6146b08284615a5b565b6146ba9190615ae0565b9150600560801b6146db846f8e38e38e38e38e38e38e38e38e38e38e615b2a565b6146e59084615a5b565b6146ef9190615ae0565b6146f99085615b69565b93506001607f1b61470a8284615a5b565b6147149190615ae0565b9150600360811b614735846f8ba2e8ba2e8ba2e8ba2e8ba2e8ba2e8b615b2a565b61473f9084615a5b565b6147499190615ae0565b6147539085615b69565b93506001607f1b6147648284615a5b565b61476e9190615ae0565b9150600760801b61478f846f89d89d89d89d89d89d89d89d89d89d89615b2a565b6147999084615a5b565b6147a39190615ae0565b6147ad9085615b69565b93506001607f1b6147be8284615a5b565b6147c89190615ae0565b9150600160831b6147e9846f88888888888888888888888888888888615b2a565b6147f39084615a5b565b6147fd9190615ae0565b6148079085615b69565b95945050505050565b60006148206101ff607c1b615b0e565b82121561482f57506000919050565b8160000361484257506001607f1b919050565b600082131561486757604051631086170d60e01b815260048101839052602401610dbe565b6000806148786001607c1b85615baa565b91508190506001607f1b61488c8280615a5b565b6148969190615ae0565b90506148aa816710e1b3be415a0000615a5b565b6148b49084615b69565b92506001607f1b6148c58383615a5b565b6148cf9190615ae0565b90506148e3816705a0913f6b1e0000615a5b565b6148ed9084615b69565b92506001607f1b6148fe8383615a5b565b6149089190615ae0565b905061491c81670168244fdac78000615a5b565b6149269084615b69565b92506001607f1b6149378383615a5b565b6149419190615ae0565b905061495481664807432bc18000615a5b565b61495e9084615b69565b92506001607f1b61496f8383615a5b565b6149799190615ae0565b905061498c81660c0135dca04000615a5b565b6149969084615b69565b92506001607f1b6149a78383615a5b565b6149b19190615ae0565b90506149c4816601b707b1cdc000615a5b565b6149ce9084615b69565b92506001607f1b6149df8383615a5b565b6149e99190615ae0565b90506149fb816536e0f639b800615a5b565b614a059084615b69565b92506001607f1b614a168383615a5b565b614a209190615ae0565b9050614a3281650618fee9f800615a5b565b614a3c9084615b69565b92506001607f1b614a4d8383615a5b565b614a579190615ae0565b9050614a6881649c197dcc00615a5b565b614a729084615b69565b92506001607f1b614a838383615a5b565b614a8d9190615ae0565b9050614a9e81640e30dce400615a5b565b614aa89084615b69565b92506001607f1b614ab98383615a5b565b614ac39190615ae0565b9050614ad48164012ebd1300615a5b565b614ade9084615b69565b92506001607f1b614aef8383615a5b565b614af99190615ae0565b9050614b09816317499f00615a5b565b614b139084615b69565b92506001607f1b614b248383615a5b565b614b2e9190615ae0565b9050614b3e816301a9d480615a5b565b614b489084615b69565b92506001607f1b614b598383615a5b565b614b639190615ae0565b9050614b7281621c6380615a5b565b614b7c9084615b69565b92506001607f1b614b8d8383615a5b565b614b979190615ae0565b9050614ba6816201c638615a5b565b614bb09084615b69565b92506001607f1b614bc18383615a5b565b614bcb9190615ae0565b9050614bd981611ab8615a5b565b614be39084615b69565b92506001607f1b614bf48383615a5b565b614bfe9190615ae0565b9050614c0c8161017c615a5b565b614c169084615b69565b92506001607f1b614c278383615a5b565b614c319190615ae0565b9050614c3e816014615a5b565b614c489084615b69565b92506001607f1b614c598383615a5b565b614c639190615ae0565b9050614c70816001615a5b565b614c7a9084615b69565b92506001607f1b82614c946721c3677c82b4000086615ae0565b614c9e9190615b69565b614ca89190615b69565b9250614cb384615b0e565b9350600160841b841615614cf9577243cbaf42a000812488fc5c220ad7b97bf6e99e614cec6cf1aaddd7742e56d32fb9f9974485615a5b565b614cf69190615ae0565b92505b600160831b841615614d3e577105d27a9f51c31b7c2f8038212a0574779991614d316e0afe10820813d65dfe6a33c07f738f85615a5b565b614d3b9190615ae0565b92505b600160821b841615614d8357701b4c902e273a58678d6d3bfdb93db96d02614d766f02582ab704279e8efd15e0265855c47a85615a5b565b614d809190615ae0565b92505b600160811b841615614dc8577003b1cc971a9bb5b9867477440d6d157750614dbb6f1152aaa3bf81cb9fdb76eae12d02957185615a5b565b614dc59190615ae0565b92505b600160801b841615614e0d5770015bf0a8b1457695355fb8ac404e7a79e3614e006f2f16ac6c59de6f8d5d6f63c1482a7c8685615a5b565b614e0a9190615ae0565b92505b6001607f1b841615614e51576fd3094c70f034de4b96ff7d5b6f99fcd8614e446f4da2cbf1be5827f9eb3ad1aa9866ebb385615a5b565b614e4e9190615ae0565b92505b6001607e1b841615614e95576fa45af1e1f40c333b3de1db4dd55f29a7614e886f63afbe7ab2082ba1a0ae5e4eb1b479dc85615a5b565b614e929190615ae0565b92505b6001607d1b841615614ed9576f910b022db7ae67ce76b441c27035c6a1614ecc6f70f5a893b608861e1f58934f97aea57d85615a5b565b614ed69190615ae0565b92505b6001607c1b841615614f1a576f88415abbe9a76bead8d00cf112e4d4a8614f106f783eafef1c0a8f3978c7f81824d62ebf85615a5b565b612a0c9190615ae0565b5050919050565b6060612a0c848460008585600080866001600160a01b03168587604051614f489190615bbe565b60006040518083038185875af1925050503d8060008114614f85576040519150601f19603f3d011682016040523d82523d6000602084013e614f8a565b606091505b5091509150614f9b87838387614fa6565b979650505050505050565b6060831561501557825160000361500e576001600160a01b0385163b61500e5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610dbe565b5081612a0c565b612a0c838381511561502a5781518083602001fd5b8060405162461bcd60e51b8152600401610dbe9190615bda565b604051806101400160405280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6001600160a01b0381168114610af657600080fd5b6000602082840312156150be57600080fd5b81356113ca81615097565b600080604083850312156150dc57600080fd5b50508035926020909101359150565b60008083601f8401126150fd57600080fd5b50813567ffffffffffffffff81111561511557600080fd5b6020830191508360208260051b850101111561513057600080fd5b9250929050565b6000806020838503121561514a57600080fd5b823567ffffffffffffffff81111561516157600080fd5b61516d858286016150eb565b90969095509350505050565b60008060006060848603121561518e57600080fd5b833561519981615097565b95602085013595506040909401359392505050565b600080600080604085870312156151c457600080fd5b843567ffffffffffffffff808211156151dc57600080fd5b6151e8888389016150eb565b9096509450602087013591508082111561520157600080fd5b5061520e878288016150eb565b95989497509550505050565b8015158114610af657600080fd5b60008060006040848603121561523d57600080fd5b83356152488161521a565b9250602084013567ffffffffffffffff81111561526457600080fd5b615270868287016150eb565b9497909650939450505050565b60006020828403121561528f57600080fd5b5035919050565b600080604083850312156152a957600080fd5b8235915060208301356152bb81615097565b809150509250929050565b6020808252825182820181905260009190848201906040850190845b818110156153075783516001600160a01b0316835292840192918401916001016152e2565b50909695505050505050565b80356001600160801b038116811461164457600080fd5b6000806000806000806000806000806101408b8d03121561534a57600080fd5b8a3561535581615097565b995060208b013561536581615097565b985060408b0135975061537a60608c01615313565b965061538860808c01615313565b955060a08b013561539881615097565b945060c08b01356153a881615097565b935060e08b01356153b881615097565b92506101008b01356153c981615097565b809250506101208b013590509295989b9194979a5092959850565b600080600080600060a086880312156153fc57600080fd5b853561540781615097565b9450602086013561541781615097565b94979496505050506040830135926060810135926080909101359150565b6000806040838503121561544857600080fd5b823561545381615097565b915060208301356152bb81615097565b6000806000806080858703121561547957600080fd5b843561548481615097565b9350602085013561549481615097565b93969395505050506040820135916060013590565b600080604083850312156154bc57600080fd5b6154c583615313565b91506154d360208401615313565b90509250929050565b602080825282518282018190526000919060409081850190868401855b8281101561553457815180516001600160a01b03908116865287820151168786015285015185850152606090930192908501906001016154f9565b5091979650505050505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60008161557c5761557c615557565b506000190190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b6000828210156155e4576155e4615557565b500390565b6000602082840312156155fb57600080fd5b5051919050565b600081600019048311821515161561561c5761561c615557565b500290565b634e487b7160e01b600052601260045260246000fd5b60008261564657615646615621565b500490565b6000821982111561565e5761565e615557565b500190565b60006020828403121561567557600080fd5b815160ff811681146113ca57600080fd5b600181815b808511156156c15781600019048211156156a7576156a7615557565b808516156156b457918102915b93841c939080029061568b565b509250929050565b6000826156d857506001611c8d565b816156e557506000611c8d565b81600181146156fb576002811461570557615721565b6001915050611c8d565b60ff84111561571657615716615557565b50506001821b611c8d565b5060208310610133831016604e8410600b8410161715615744575081810a611c8d565b61574e8383615686565b806000190482111561576257615762615557565b029392505050565b6000611c8a83836156c9565b634e487b7160e01b600052604160045260246000fd5b60405160a0810167ffffffffffffffff811182821017156157af576157af615776565b60405290565b604051601f8201601f1916810167ffffffffffffffff811182821017156157de576157de615776565b604052919050565b60005b838110156158015781810151838201526020016157e9565b838111156111985750506000910152565b805161164481615097565b6000602080838503121561583057600080fd5b825167ffffffffffffffff8082111561584857600080fd5b9084019060a0828703121561585c57600080fd5b61586461578c565b82518281111561587357600080fd5b8301601f8101881361588457600080fd5b80518381111561589657615896615776565b6158a8601f8201601f191687016157b5565b935080845288868284010111156158be57600080fd5b6158cd818786018885016157e6565b50508181526158dd848401615812565b848201526158ed60408401615812565b604082015260608301516060820152608083015160808201528094505050505092915050565b60006020828403121561592557600080fd5b81516113ca8161521a565b600081518084526159488160208601602086016157e6565b601f01601f19169290920160200192915050565b6001600160a01b0383168152604060208201819052600090612a0c90830184615930565b6001600160a01b0384811682528316602082015260606040820181905260009061480790830184615930565b6000806000606084860312156159c157600080fd5b8351925060208401519150604084015190509250925092565b6000600182016159ec576159ec615557565b5060010190565b600060208284031215615a0557600080fd5b81516113ca81615097565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60006001600160ff1b0381841382841380821686840486111615615a8157615a81615557565b600160ff1b6000871282811687830589121615615aa057615aa0615557565b60008712925087820587128484161615615abc57615abc615557565b87850587128184161615615ad257615ad2615557565b505050929093029392505050565b600082615aef57615aef615621565b600160ff1b821460001984141615615b0957615b09615557565b500590565b6000600160ff1b8201615b2357615b23615557565b5060000390565b60008083128015600160ff1b850184121615615b4857615b48615557565b6001600160ff1b0384018313811615615b6357615b63615557565b50500390565b600080821280156001600160ff1b0384900385131615615b8b57615b8b615557565b600160ff1b8390038412811615615ba457615ba4615557565b50500190565b600082615bb957615bb9615621565b500790565b60008251615bd08184602087016157e6565b9190910192915050565b602081526000611c8a602083018461593056fe7570646174654d756c7469706c6965727328616464726573732c75696e743235362c75696e743235362909d2594e8892daceca055f74be758146a8b8b1167444d0b4ccb96e74168198cc6164644d61726b657428616464726573732c616464726573732c75696e743235362c75696e7432353629a2646970667358221220f73f8d2a2c97164147552d8810882faa3aca58c483e6eefd94dfc63a6813840f64736f6c634300080d0033

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

0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002819a0000000000000000000000000000000000000000000000000000000000076a70000000000000000000000000000000000000000000000003635c9adc5dea0000000000000000000000000000000000000000000000000152d02c7e14af68000000000000000000000000000000000000000000000000000000000000000000000

-----Decoded View---------------
Arg [0] : _wrappedNativeToken (address): 0x0000000000000000000000000000000000000000
Arg [1] : _nativeMarket (address): 0x0000000000000000000000000000000000000000
Arg [2] : _blocksPerYear (uint256): 2628000
Arg [3] : _stakingPeriod (uint256): 7776000
Arg [4] : _minimumStakedXVS (uint256): 1000000000000000000000
Arg [5] : _maximumXVSCap (uint256): 100000000000000000000000
Arg [6] : _timeBased (bool): False

-----Encoded View---------------
7 Constructor Arguments found :
Arg [0] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [2] : 00000000000000000000000000000000000000000000000000000000002819a0
Arg [3] : 000000000000000000000000000000000000000000000000000000000076a700
Arg [4] : 00000000000000000000000000000000000000000000003635c9adc5dea00000
Arg [5] : 00000000000000000000000000000000000000000000152d02c7e14af6800000
Arg [6] : 0000000000000000000000000000000000000000000000000000000000000000


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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