ETH Price: $2,287.70 (+0.48%)

Contract

0x0b9A7EA2FCA868C93640Dd77cF44df335095F501
 
Transaction Hash
Method
Block
From
To
Redeem168273942023-03-14 16:31:11543 days ago1678811471IN
0x0b9A7EA2...35095F501
0 ETH0.0049137737.95619486
Redeem168238742023-03-14 4:40:23544 days ago1678768823IN
0x0b9A7EA2...35095F501
0 ETH0.0023967618.51366651
Redeem168035302023-03-11 8:02:59546 days ago1678521779IN
0x0b9A7EA2...35095F501
0 ETH0.03807973294.1451714
Redeem168002342023-03-10 20:55:59547 days ago1678481759IN
0x0b9A7EA2...35095F501
0 ETH0.0054772546.76017694
Redeem167817352023-03-08 6:23:47550 days ago1678256627IN
0x0b9A7EA2...35095F501
0 ETH0.0027678721.38228826
Redeem167732402023-03-07 1:43:35551 days ago1678153415IN
0x0b9A7EA2...35095F501
0 ETH0.0033829930.11522146
Redeem167722122023-03-06 22:16:11551 days ago1678140971IN
0x0b9A7EA2...35095F501
0 ETH0.0039207334.90217443
Redeem167515652023-03-04 0:35:59554 days ago1677890159IN
0x0b9A7EA2...35095F501
0 ETH0.0032997425.49106969
Redeem167445852023-03-03 1:00:59555 days ago1677805259IN
0x0b9A7EA2...35095F501
0 ETH0.0031565623.51730953
Mint167297442023-02-28 22:53:35557 days ago1677624815IN
0x0b9A7EA2...35095F501
0 ETH0.0030448923.57624388
Redeem167277992023-02-28 16:18:47557 days ago1677601127IN
0x0b9A7EA2...35095F501
0 ETH0.0040644731.40163806
Redeem167276772023-02-28 15:54:23557 days ago1677599663IN
0x0b9A7EA2...35095F501
0 ETH0.0036537528.22583859
Redeem167270972023-02-28 13:57:11557 days ago1677592631IN
0x0b9A7EA2...35095F501
0 ETH0.0030984423.93600058
Redeem167269502023-02-28 13:27:35557 days ago1677590855IN
0x0b9A7EA2...35095F501
0 ETH0.0034125626.3650844
Redeem167268852023-02-28 13:14:23557 days ago1677590063IN
0x0b9A7EA2...35095F501
0 ETH0.0035787327.64634096
Redeem167267532023-02-28 12:47:47557 days ago1677588467IN
0x0b9A7EA2...35095F501
0 ETH0.0029339522.6694765
Redeem167266642023-02-28 12:29:47557 days ago1677587387IN
0x0b9A7EA2...35095F501
0 ETH0.0026703420.62883757
Redeem167265062023-02-28 11:57:35557 days ago1677585455IN
0x0b9A7EA2...35095F501
0 ETH0.0024972419.29165676
Redeem167258172023-02-28 9:38:11557 days ago1677577091IN
0x0b9A7EA2...35095F501
0 ETH0.0027452121.20722391
Redeem167257152023-02-28 9:17:35557 days ago1677575855IN
0x0b9A7EA2...35095F501
0 ETH0.0022632917.48432026
Redeem167254302023-02-28 8:20:23557 days ago1677572423IN
0x0b9A7EA2...35095F501
0 ETH0.002428118.75925951
Redeem167246962023-02-28 5:51:35558 days ago1677563495IN
0x0b9A7EA2...35095F501
0 ETH0.0020632115.93865655
Redeem167246622023-02-28 5:44:35558 days ago1677563075IN
0x0b9A7EA2...35095F501
0 ETH0.0022253617.19131511
Redeem167245222023-02-28 5:16:11558 days ago1677561371IN
0x0b9A7EA2...35095F501
0 ETH0.0023507218.15972748
Redeem167241532023-02-28 4:00:47558 days ago1677556847IN
0x0b9A7EA2...35095F501
0 ETH0.0028525422.03639477
View all transactions

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
PriceBoundPSM

Compiler Version
v0.8.10+commit.fc410830

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 36 : PriceBoundPSM.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.4;

import {PegStabilityModule, Decimal, SafeERC20, SafeCast, IERC20, IPCVDeposit, Constants} from "./PegStabilityModule.sol";
import {IPriceBound} from "./IPriceBound.sol";

/// @notice contract to create a price bound DAI PSM
/// This contract will allow swaps when the price of DAI is between 98 cents and 1.02 by default
/// These defaults are changeable by the admin and governance by calling floor and ceiling setters
/// setOracleFloor and setOracleCeiling
contract PriceBoundPSM is PegStabilityModule, IPriceBound {
    using Decimal for Decimal.D256;
    using SafeERC20 for IERC20;
    using SafeCast for *;

    /// @notice the default minimum acceptable oracle price floor is 98 cents
    uint256 public override floor;

    /// @notice the default maximum acceptable oracle price ceiling is $1.02
    uint256 public override ceiling;

    /// @notice constructor
    /// @param _floor minimum acceptable oracle price
    /// @param _ceiling maximum  acceptable oracle price
    /// @param _params PSM construction params
    constructor(
        uint256 _floor,
        uint256 _ceiling,
        OracleParams memory _params,
        uint256 _mintFeeBasisPoints,
        uint256 _redeemFeeBasisPoints,
        uint256 _reservesThreshold,
        uint256 _feiLimitPerSecond,
        uint256 _mintingBufferCap,
        IERC20 _underlyingToken,
        IPCVDeposit _surplusTarget
    )
        PegStabilityModule(
            _params,
            _mintFeeBasisPoints,
            _redeemFeeBasisPoints,
            _reservesThreshold,
            _feiLimitPerSecond,
            _mintingBufferCap,
            _underlyingToken,
            _surplusTarget
        )
    {
        _setCeilingBasisPoints(_ceiling);
        _setFloorBasisPoints(_floor);
    }

    /// @notice sets the floor price in BP
    function setOracleFloorBasisPoints(uint256 newFloorBasisPoints)
        external
        override
        onlyGovernorOrAdmin
    {
        _setFloorBasisPoints(newFloorBasisPoints);
    }

    /// @notice sets the ceiling price in BP
    function setOracleCeilingBasisPoints(uint256 newCeilingBasisPoints)
        external
        override
        onlyGovernorOrAdmin
    {
        _setCeilingBasisPoints(newCeilingBasisPoints);
    }

    function isPriceValid() external view override returns (bool) {
        return _validPrice(readOracle());
    }

    /// @notice Allocates a portion of escrowed PCV to a target PCV deposit
    function _allocate(uint256 amount) internal override {
        _transfer(address(surplusTarget), amount);

        emit AllocateSurplus(msg.sender, amount);
    }

    /// @notice helper function to set the ceiling in basis points
    function _setCeilingBasisPoints(uint256 newCeilingBasisPoints) internal {
        require(
            newCeilingBasisPoints != 0,
            "PegStabilityModule: invalid ceiling"
        );
        require(
            Decimal
                .ratio(
                    newCeilingBasisPoints,
                    Constants.BASIS_POINTS_GRANULARITY
                )
                .greaterThan(
                    Decimal.ratio(floor, Constants.BASIS_POINTS_GRANULARITY)
                ),
            "PegStabilityModule: ceiling must be greater than floor"
        );
        uint256 oldCeiling = ceiling;
        ceiling = newCeilingBasisPoints;

        emit OracleCeilingUpdate(oldCeiling, ceiling);
    }

    /// @notice helper function to set the floor in basis points
    function _setFloorBasisPoints(uint256 newFloorBasisPoints) internal {
        require(newFloorBasisPoints != 0, "PegStabilityModule: invalid floor");
        require(
            Decimal
                .ratio(newFloorBasisPoints, Constants.BASIS_POINTS_GRANULARITY)
                .lessThan(
                    Decimal.ratio(ceiling, Constants.BASIS_POINTS_GRANULARITY)
                ),
            "PegStabilityModule: floor must be less than ceiling"
        );
        uint256 oldFloor = floor;
        floor = newFloorBasisPoints;

        emit OracleFloorUpdate(oldFloor, floor);
    }

    /// @notice helper function to determine if price is within a valid range
    function _validPrice(Decimal.D256 memory price)
        internal
        view
        returns (bool valid)
    {
        valid =
            price.greaterThan(
                Decimal.ratio(floor, Constants.BASIS_POINTS_GRANULARITY)
            ) &&
            price.lessThan(
                Decimal.ratio(ceiling, Constants.BASIS_POINTS_GRANULARITY)
            );
    }

    /// @notice reverts if the price is greater than or equal to the ceiling or less than or equal to the floor
    function _validatePriceRange(Decimal.D256 memory price)
        internal
        view
        override
    {
        require(_validPrice(price), "PegStabilityModule: price out of bounds");
    }
}

File 2 of 36 : PegStabilityModule.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.4;

import "./../pcv/PCVDeposit.sol";
import "./../volt/minter/RateLimitedMinter.sol";
import "./IPegStabilityModule.sol";
import "./../refs/OracleRef.sol";
import "../Constants.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

contract PegStabilityModule is
    IPegStabilityModule,
    RateLimitedMinter,
    OracleRef,
    PCVDeposit,
    ReentrancyGuard
{
    using Decimal for Decimal.D256;
    using SafeCast for *;
    using SafeERC20 for IERC20;

    /// @notice the fee in basis points for selling asset into FEI
    uint256 public override mintFeeBasisPoints;

    /// @notice the fee in basis points for buying the asset for FEI
    uint256 public override redeemFeeBasisPoints;

    /// @notice the amount of reserves to be held for redemptions
    uint256 public override reservesThreshold;

    /// @notice the PCV deposit target
    IPCVDeposit public override surplusTarget;

    /// @notice the token this PSM will exchange for FEI
    /// This token will be set to WETH9 if the bonding curve accepts eth
    IERC20 public immutable override underlyingToken;

    /// @notice the max mint and redeem fee in basis points
    /// Governance can change this fee
    uint256 public override MAX_FEE = 300;

    /// @notice boolean switch that indicates whether redemptions are paused
    bool public redeemPaused;

    /// @notice event that is emitted when redemptions are paused
    event RedemptionsPaused(address account);

    /// @notice event that is emitted when redemptions are unpaused
    event RedemptionsUnpaused(address account);

    /// @notice boolean switch that indicates whether minting is paused
    bool public mintPaused;

    /// @notice event that is emitted when minting is paused
    event MintingPaused(address account);

    /// @notice event that is emitted when minting is unpaused
    event MintingUnpaused(address account);

    /// @notice struct for passing constructor parameters related to OracleRef
    struct OracleParams {
        address coreAddress;
        address oracleAddress;
        address backupOracle;
        int256 decimalsNormalizer;
        bool doInvert;
    }

    /// @notice constructor
    /// @param params PSM constructor parameter struct
    constructor(
        OracleParams memory params,
        uint256 _mintFeeBasisPoints,
        uint256 _redeemFeeBasisPoints,
        uint256 _reservesThreshold,
        uint256 _feiLimitPerSecond,
        uint256 _mintingBufferCap,
        IERC20 _underlyingToken,
        IPCVDeposit _surplusTarget
    )
        OracleRef(
            params.coreAddress,
            params.oracleAddress,
            params.backupOracle,
            params.decimalsNormalizer,
            params.doInvert
        )
        /// rate limited minter passes false as the last param as there can be no partial mints
        RateLimitedMinter(_feiLimitPerSecond, _mintingBufferCap, false)
    {
        underlyingToken = _underlyingToken;

        _setReservesThreshold(_reservesThreshold);
        _setMintFee(_mintFeeBasisPoints);
        _setRedeemFee(_redeemFeeBasisPoints);
        _setSurplusTarget(_surplusTarget);
        _setContractAdminRole(keccak256("PSM_ADMIN_ROLE"));
    }

    /// @notice modifier that allows execution when redemptions are not paused
    modifier whileRedemptionsNotPaused() {
        require(!redeemPaused, "PegStabilityModule: Redeem paused");
        _;
    }

    /// @notice modifier that allows execution when minting is not paused
    modifier whileMintingNotPaused() {
        require(!mintPaused, "PegStabilityModule: Minting paused");
        _;
    }

    /// @notice set secondary pausable methods to paused
    function pauseRedeem() external onlyGovernorOrGuardianOrAdmin {
        redeemPaused = true;
        emit RedemptionsPaused(msg.sender);
    }

    /// @notice set secondary pausable methods to unpaused
    function unpauseRedeem() external onlyGovernorOrGuardianOrAdmin {
        redeemPaused = false;
        emit RedemptionsUnpaused(msg.sender);
    }

    /// @notice set secondary pausable methods to paused
    function pauseMint() external onlyGovernorOrGuardianOrAdmin {
        mintPaused = true;
        emit MintingPaused(msg.sender);
    }

    /// @notice set secondary pausable methods to unpaused
    function unpauseMint() external onlyGovernorOrGuardianOrAdmin {
        mintPaused = false;
        emit MintingUnpaused(msg.sender);
    }

    /// @notice withdraw assets from PSM to an external address
    function withdraw(address to, uint256 amount)
        external
        virtual
        override
        onlyPCVController
    {
        _withdrawERC20(address(underlyingToken), to, amount);
    }

    /// @notice set the mint fee vs oracle price in basis point terms
    function setMintFee(uint256 newMintFeeBasisPoints)
        external
        override
        onlyGovernorOrAdmin
    {
        _setMintFee(newMintFeeBasisPoints);
    }

    /// @notice set the redemption fee vs oracle price in basis point terms
    function setRedeemFee(uint256 newRedeemFeeBasisPoints)
        external
        override
        onlyGovernorOrAdmin
    {
        _setRedeemFee(newRedeemFeeBasisPoints);
    }

    /// @notice set the ideal amount of reserves for the contract to hold for redemptions
    function setReservesThreshold(uint256 newReservesThreshold)
        external
        override
        onlyGovernorOrAdmin
    {
        _setReservesThreshold(newReservesThreshold);
    }

    /// @notice set the target for sending surplus reserves
    function setSurplusTarget(IPCVDeposit newTarget)
        external
        override
        onlyGovernorOrAdmin
    {
        _setSurplusTarget(newTarget);
    }

    /// @notice set the mint fee vs oracle price in basis point terms
    function _setMintFee(uint256 newMintFeeBasisPoints) internal {
        require(
            newMintFeeBasisPoints <= MAX_FEE,
            "PegStabilityModule: Mint fee exceeds max fee"
        );
        uint256 _oldMintFee = mintFeeBasisPoints;
        mintFeeBasisPoints = newMintFeeBasisPoints;

        emit MintFeeUpdate(_oldMintFee, newMintFeeBasisPoints);
    }

    /// @notice internal helper function to set the redemption fee
    function _setRedeemFee(uint256 newRedeemFeeBasisPoints) internal {
        require(
            newRedeemFeeBasisPoints <= MAX_FEE,
            "PegStabilityModule: Redeem fee exceeds max fee"
        );
        uint256 _oldRedeemFee = redeemFeeBasisPoints;
        redeemFeeBasisPoints = newRedeemFeeBasisPoints;

        emit RedeemFeeUpdate(_oldRedeemFee, newRedeemFeeBasisPoints);
    }

    /// @notice helper function to set reserves threshold
    function _setReservesThreshold(uint256 newReservesThreshold) internal {
        require(
            newReservesThreshold > 0,
            "PegStabilityModule: Invalid new reserves threshold"
        );
        uint256 oldReservesThreshold = reservesThreshold;
        reservesThreshold = newReservesThreshold;

        emit ReservesThresholdUpdate(
            oldReservesThreshold,
            newReservesThreshold
        );
    }

    /// @notice helper function to set the surplus target
    function _setSurplusTarget(IPCVDeposit newSurplusTarget) internal {
        require(
            address(newSurplusTarget) != address(0),
            "PegStabilityModule: Invalid new surplus target"
        );
        IPCVDeposit oldTarget = surplusTarget;
        surplusTarget = newSurplusTarget;

        emit SurplusTargetUpdate(oldTarget, newSurplusTarget);
    }

    // ----------- Public State Changing API -----------

    /// @notice send any surplus reserves to the PCV allocation
    function allocateSurplus() external override {
        int256 currentSurplus = reservesSurplus();
        require(
            currentSurplus > 0,
            "PegStabilityModule: No surplus to allocate"
        );

        _allocate(currentSurplus.toUint256());
    }

    /// @notice function to receive ERC20 tokens from external contracts
    function deposit() external override {
        int256 currentSurplus = reservesSurplus();
        if (currentSurplus > 0) {
            _allocate(currentSurplus.toUint256());
        }
    }

    /// @notice internal helper method to redeem fei in exchange for an external asset
    function _redeem(
        address to,
        uint256 amountFeiIn,
        uint256 minAmountOut
    ) internal virtual returns (uint256 amountOut) {
        updateOracle();

        amountOut = _getRedeemAmountOut(amountFeiIn);
        require(
            amountOut >= minAmountOut,
            "PegStabilityModule: Redeem not enough out"
        );

        IERC20(volt()).safeTransferFrom(msg.sender, address(this), amountFeiIn);

        _transfer(to, amountOut);

        emit Redeem(to, amountFeiIn, amountOut);
    }

    /// @notice internal helper method to mint fei in exchange for an external asset
    function _mint(
        address to,
        uint256 amountIn,
        uint256 minAmountOut
    ) internal virtual returns (uint256 amountFeiOut) {
        updateOracle();

        amountFeiOut = _getMintAmountOut(amountIn);
        require(
            amountFeiOut >= minAmountOut,
            "PegStabilityModule: Mint not enough out"
        );

        _transferFrom(msg.sender, address(this), amountIn);

        uint256 amountFeiToTransfer = Math.min(
            volt().balanceOf(address(this)),
            amountFeiOut
        );
        uint256 amountFeiToMint = amountFeiOut - amountFeiToTransfer;

        if (amountFeiToTransfer != 0) {
            IERC20(volt()).safeTransfer(to, amountFeiToTransfer);
        }

        if (amountFeiToMint != 0) {
            _mintVolt(to, amountFeiToMint);
        }

        emit Mint(to, amountIn, amountFeiOut);
    }

    /// @notice function to redeem FEI for an underlying asset
    /// We do not burn Fei; this allows the contract's balance of Fei to be used before the buffer is used
    /// In practice, this helps prevent artificial cycling of mint-burn cycles and prevents a griefing vector.
    function redeem(
        address to,
        uint256 amountFeiIn,
        uint256 minAmountOut
    )
        external
        virtual
        override
        nonReentrant
        whenNotPaused
        whileRedemptionsNotPaused
        returns (uint256 amountOut)
    {
        amountOut = _redeem(to, amountFeiIn, minAmountOut);
    }

    /// @notice function to buy FEI for an underlying asset
    /// We first transfer any contract-owned fei, then mint the remaining if necessary
    function mint(
        address to,
        uint256 amountIn,
        uint256 minAmountOut
    )
        external
        virtual
        override
        nonReentrant
        whenNotPaused
        whileMintingNotPaused
        returns (uint256 amountFeiOut)
    {
        amountFeiOut = _mint(to, amountIn, minAmountOut);
    }

    // ----------- Public View-Only API ----------

    /// @notice calculate the amount of FEI out for a given `amountIn` of underlying
    /// First get oracle price of token
    /// Then figure out how many dollars that amount in is worth by multiplying price * amount.
    /// ensure decimals are normalized if on underlying they are not 18
    function getMintAmountOut(uint256 amountIn)
        public
        view
        override
        returns (uint256 amountFeiOut)
    {
        amountFeiOut = _getMintAmountOut(amountIn);
    }

    /// @notice calculate the amount of underlying out for a given `amountFeiIn` of FEI
    /// First get oracle price of token
    /// Then figure out how many dollars that amount in is worth by multiplying price * amount.
    /// ensure decimals are normalized if on underlying they are not 18
    function getRedeemAmountOut(uint256 amountFeiIn)
        public
        view
        override
        returns (uint256 amountTokenOut)
    {
        amountTokenOut = _getRedeemAmountOut(amountFeiIn);
    }

    /// @notice the maximum mint amount out
    function getMaxMintAmountOut() external view override returns (uint256) {
        return volt().balanceOf(address(this)) + buffer();
    }

    /// @notice a flag for whether the current balance is above (true) or below (false) the reservesThreshold
    function hasSurplus() external view override returns (bool) {
        return balance() > reservesThreshold;
    }

    /// @notice an integer representing the positive surplus or negative deficit of contract balance vs reservesThreshold
    function reservesSurplus() public view override returns (int256) {
        return balance().toInt256() - reservesThreshold.toInt256();
    }

    /// @notice function from PCVDeposit that must be overriden
    function balance() public view virtual override returns (uint256) {
        return underlyingToken.balanceOf(address(this));
    }

    /// @notice returns address of token this contracts balance is reported in
    function balanceReportedIn() public view override returns (address) {
        return address(underlyingToken);
    }

    /// @notice override default behavior of not checking fei balance
    function resistantBalanceAndVolt()
        public
        view
        override
        returns (uint256, uint256)
    {
        return (balance(), voltBalance());
    }

    // ----------- Internal Methods -----------

    /// @notice helper function to get mint amount out based on current market prices
    /// @dev will revert if price is outside of bounds and bounded PSM is being used
    function _getMintAmountOut(uint256 amountIn)
        internal
        view
        virtual
        returns (uint256 amountFeiOut)
    {
        Decimal.D256 memory price = readOracle();
        _validatePriceRange(price);

        Decimal.D256 memory adjustedAmountIn = price.mul(amountIn);

        amountFeiOut = adjustedAmountIn
            .mul(Constants.BASIS_POINTS_GRANULARITY - mintFeeBasisPoints)
            .div(Constants.BASIS_POINTS_GRANULARITY)
            .asUint256();
    }

    /// @notice helper function to get redeem amount out based on current market prices
    /// @dev will revert if price is outside of bounds and bounded PSM is being used
    function _getRedeemAmountOut(uint256 amountFeiIn)
        internal
        view
        virtual
        returns (uint256 amountTokenOut)
    {
        Decimal.D256 memory price = readOracle();
        _validatePriceRange(price);

        /// get amount of dollars being provided
        Decimal.D256 memory adjustedAmountIn = Decimal.from(
            (amountFeiIn *
                (Constants.BASIS_POINTS_GRANULARITY - redeemFeeBasisPoints)) /
                Constants.BASIS_POINTS_GRANULARITY
        );

        /// now turn the dollars into the underlying token amounts
        /// dollars / price = how much token to pay out
        amountTokenOut = adjustedAmountIn.div(price).asUint256();
    }

    /// @notice Allocates a portion of escrowed PCV to a target PCV deposit
    function _allocate(uint256 amount) internal virtual {
        _transfer(address(surplusTarget), amount);

        surplusTarget.deposit();

        emit AllocateSurplus(msg.sender, amount);
    }

    /// @notice transfer ERC20 token
    function _transfer(address to, uint256 amount) internal {
        SafeERC20.safeTransfer(underlyingToken, to, amount);
    }

    /// @notice transfer assets from user to this contract
    function _transferFrom(
        address from,
        address to,
        uint256 amount
    ) internal {
        SafeERC20.safeTransferFrom(underlyingToken, from, to, amount);
    }

    /// @notice mint amount of FEI to the specified user on a rate limit
    function _mintVolt(address to, uint256 amount)
        internal
        override(CoreRef, RateLimitedMinter)
    {
        super._mintVolt(to, amount);
    }

    // ----------- Hooks -----------

    /// @notice overriden function in the bounded PSM
    function _validatePriceRange(Decimal.D256 memory price)
        internal
        view
        virtual
    {}
}

File 3 of 36 : IPriceBound.sol
pragma solidity ^0.8.4;

interface IPriceBound {
    // ----------- Events -----------

    /// @notice event emitted when minimum floor price is updated
    event OracleFloorUpdate(uint256 oldFloor, uint256 newFloor);

    /// @notice event emitted when maximum ceiling price is updated
    event OracleCeilingUpdate(uint256 oldCeiling, uint256 newCeiling);

    // ----------- Governor or admin only state changing api -----------

    /// @notice sets the floor price in BP
    function setOracleFloorBasisPoints(uint256 newFloor) external;

    /// @notice sets the ceiling price in BP
    function setOracleCeilingBasisPoints(uint256 newCeiling) external;

    // ----------- Getters -----------

    /// @notice get the floor price in basis points
    function floor() external view returns (uint256);

    /// @notice get the ceiling price in basis points
    function ceiling() external view returns (uint256);

    /// @notice return wether the current oracle price is valid or not
    function isPriceValid() external view returns (bool);
}

File 4 of 36 : PCVDeposit.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.4;

import "../refs/CoreRef.sol";
import "./IPCVDeposit.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

/// @title abstract contract for withdrawing ERC-20 tokens using a PCV Controller
/// @author Fei Protocol
abstract contract PCVDeposit is IPCVDeposit, CoreRef {
    using SafeERC20 for IERC20;

    /// @notice withdraw ERC20 from the contract
    /// @param token address of the ERC20 to send
    /// @param to address destination of the ERC20
    /// @param amount quantity of ERC20 to send
    function withdrawERC20(
        address token,
        address to,
        uint256 amount
    ) public virtual override onlyPCVController {
        _withdrawERC20(token, to, amount);
    }

    function _withdrawERC20(
        address token,
        address to,
        uint256 amount
    ) internal {
        IERC20(token).safeTransfer(to, amount);
        emit WithdrawERC20(msg.sender, token, to, amount);
    }

    /// @notice withdraw ETH from the contract
    /// @param to address to send ETH
    /// @param amountOut amount of ETH to send
    function withdrawETH(address payable to, uint256 amountOut)
        external
        virtual
        override
        onlyPCVController
    {
        Address.sendValue(to, amountOut);
        emit WithdrawETH(msg.sender, to, amountOut);
    }

    function balance() public view virtual override returns (uint256);

    function resistantBalanceAndVolt()
        public
        view
        virtual
        override
        returns (uint256, uint256)
    {
        return (balance(), 0);
    }
}

File 5 of 36 : RateLimitedMinter.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.4;

import "../../utils/RateLimited.sol";

/// @title abstract contract for putting a rate limit on how fast a contract can mint FEI
/// @author Fei Protocol
abstract contract RateLimitedMinter is RateLimited {
    uint256 private constant MAX_FEI_LIMIT_PER_SECOND = 10_000e18; // 10000 volt/s or ~860m volt/day

    constructor(
        uint256 _feiLimitPerSecond,
        uint256 _mintingBufferCap,
        bool _doPartialMint
    )
        RateLimited(
            MAX_FEI_LIMIT_PER_SECOND,
            _feiLimitPerSecond,
            _mintingBufferCap,
            _doPartialMint
        )
    {}

    /// @notice override the FEI minting behavior to enforce a rate limit
    function _mintVolt(address to, uint256 amount) internal virtual override {
        uint256 mintAmount = _depleteBuffer(amount);
        super._mintVolt(to, mintAmount);
    }
}

File 6 of 36 : IPegStabilityModule.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.4;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "../pcv/IPCVDeposit.sol";

/**
 * @title Fei Peg Stability Module
 * @author Fei Protocol
 * @notice  The Fei PSM is a contract which holds a reserve of assets in order to exchange FEI at $1 of underlying assets with a fee.
 * `mint()` - buy FEI for $1 of underlying tokens
 * `redeem()` - sell FEI back for $1 of the same
 *
 * The contract has a reservesThreshold() of underlying meant to stand ready for redemptions. Any surplus reserves can be sent into the PCV using `allocateSurplus()`
 *
 * The contract is a
 * PCVDeposit - to track reserves
 * OracleRef - to determine price of underlying, and
 * RateLimitedMinter - to stop infinite mints and related issues (but this is in the implementation due to inheritance-linearization difficulties)
 *
 * Inspired by MakerDAO PSM, code written without reference
 */
interface IPegStabilityModule {
    // ----------- Public State Changing API -----------

    /// @notice mint `amountFeiOut` FEI to address `to` for `amountIn` underlying tokens
    /// @dev see getMintAmountOut() to pre-calculate amount out
    function mint(
        address to,
        uint256 amountIn,
        uint256 minAmountOut
    ) external returns (uint256 amountFeiOut);

    /// @notice redeem `amountFeiIn` FEI for `amountOut` underlying tokens and send to address `to`
    /// @dev see getRedeemAmountOut() to pre-calculate amount out
    function redeem(
        address to,
        uint256 amountFeiIn,
        uint256 minAmountOut
    ) external returns (uint256 amountOut);

    /// @notice send any surplus reserves to the PCV allocation
    function allocateSurplus() external;

    // ----------- Governor or Admin Only State Changing API -----------

    /// @notice set the mint fee vs oracle price in basis point terms
    function setMintFee(uint256 newMintFeeBasisPoints) external;

    /// @notice set the redemption fee vs oracle price in basis point terms
    function setRedeemFee(uint256 newRedeemFeeBasisPoints) external;

    /// @notice set the ideal amount of reserves for the contract to hold for redemptions
    function setReservesThreshold(uint256 newReservesThreshold) external;

    /// @notice set the target for sending surplus reserves
    function setSurplusTarget(IPCVDeposit newTarget) external;

    // ----------- Getters -----------

    /// @notice calculate the amount of FEI out for a given `amountIn` of underlying
    function getMintAmountOut(uint256 amountIn)
        external
        view
        returns (uint256 amountFeiOut);

    /// @notice calculate the amount of underlying out for a given `amountFeiIn` of FEI
    function getRedeemAmountOut(uint256 amountFeiIn)
        external
        view
        returns (uint256 amountOut);

    /// @notice the maximum mint amount out
    function getMaxMintAmountOut() external view returns (uint256);

    /// @notice a flag for whether the current balance is above (true) or below and equal (false) to the reservesThreshold
    function hasSurplus() external view returns (bool);

    /// @notice an integer representing the positive surplus or negative deficit of contract balance vs reservesThreshold
    function reservesSurplus() external view returns (int256);

    /// @notice the ideal amount of reserves for the contract to hold for redemptions
    function reservesThreshold() external view returns (uint256);

    /// @notice the mint fee vs oracle price in basis point terms
    function mintFeeBasisPoints() external view returns (uint256);

    /// @notice the redemption fee vs oracle price in basis point terms
    function redeemFeeBasisPoints() external view returns (uint256);

    /// @notice the underlying token exchanged for FEI
    function underlyingToken() external view returns (IERC20);

    /// @notice the PCV deposit target to send surplus reserves
    function surplusTarget() external view returns (IPCVDeposit);

    /// @notice the max mint and redeem fee in basis points
    function MAX_FEE() external view returns (uint256);

    // ----------- Events -----------

    /// @notice event emitted when excess PCV is allocated
    event AllocateSurplus(address indexed caller, uint256 amount);

    /// @notice event emitted when a new max fee is set
    event MaxFeeUpdate(uint256 oldMaxFee, uint256 newMaxFee);

    /// @notice event emitted when a new mint fee is set
    event MintFeeUpdate(uint256 oldMintFee, uint256 newMintFee);

    /// @notice event emitted when a new redeem fee is set
    event RedeemFeeUpdate(uint256 oldRedeemFee, uint256 newRedeemFee);

    /// @notice event emitted when reservesThreshold is updated
    event ReservesThresholdUpdate(
        uint256 oldReservesThreshold,
        uint256 newReservesThreshold
    );

    /// @notice event emitted when surplus target is updated
    event SurplusTargetUpdate(IPCVDeposit oldTarget, IPCVDeposit newTarget);

    /// @notice event emitted upon a redemption
    event Redeem(address to, uint256 amountFeiIn, uint256 amountAssetOut);

    /// @notice event emitted when fei gets minted
    event Mint(address to, uint256 amountIn, uint256 amountFeiOut);
}

File 7 of 36 : OracleRef.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.4;

import "./IOracleRef.sol";
import "./CoreRef.sol";
import "@openzeppelin/contracts/utils/math/SafeCast.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";

/// @title Reference to an Oracle
/// @author Fei Protocol
/// @notice defines some utilities around interacting with the referenced oracle
abstract contract OracleRef is IOracleRef, CoreRef {
    using Decimal for Decimal.D256;
    using SafeCast for int256;

    /// @notice the oracle reference by the contract
    IOracle public override oracle;

    /// @notice the backup oracle reference by the contract
    IOracle public override backupOracle;

    /// @notice number of decimals to scale oracle price by, i.e. multiplying by 10^(decimalsNormalizer)
    int256 public override decimalsNormalizer;

    bool public override doInvert;

    /// @notice OracleRef constructor
    /// @param _core Fei Core to reference
    /// @param _oracle oracle to reference
    /// @param _backupOracle backup oracle to reference
    /// @param _decimalsNormalizer number of decimals to normalize the oracle feed if necessary
    /// @param _doInvert invert the oracle price if this flag is on
    constructor(
        address _core,
        address _oracle,
        address _backupOracle,
        int256 _decimalsNormalizer,
        bool _doInvert
    ) CoreRef(_core) {
        _setOracle(_oracle);
        if (_backupOracle != address(0) && _backupOracle != _oracle) {
            _setBackupOracle(_backupOracle);
        }
        _setDoInvert(_doInvert);
        _setDecimalsNormalizer(_decimalsNormalizer);
    }

    /// @notice sets the referenced oracle
    /// @param newOracle the new oracle to reference
    function setOracle(address newOracle) external override onlyGovernor {
        _setOracle(newOracle);
    }

    /// @notice sets the flag for whether to invert or not
    /// @param newDoInvert the new flag for whether to invert
    function setDoInvert(bool newDoInvert) external override onlyGovernor {
        _setDoInvert(newDoInvert);
    }

    /// @notice sets the new decimalsNormalizer
    /// @param newDecimalsNormalizer the new decimalsNormalizer
    function setDecimalsNormalizer(int256 newDecimalsNormalizer)
        external
        override
        onlyGovernor
    {
        _setDecimalsNormalizer(newDecimalsNormalizer);
    }

    /// @notice sets the referenced backup oracle
    /// @param newBackupOracle the new backup oracle to reference
    function setBackupOracle(address newBackupOracle)
        external
        override
        onlyGovernorOrAdmin
    {
        _setBackupOracle(newBackupOracle);
    }

    /// @notice invert a peg price
    /// @param price the peg price to invert
    /// @return the inverted peg as a Decimal
    /// @dev the inverted peg would be X per FEI
    function invert(Decimal.D256 memory price)
        public
        pure
        override
        returns (Decimal.D256 memory)
    {
        return Decimal.one().div(price);
    }

    /// @notice updates the referenced oracle
    function updateOracle() public override {
        oracle.update();
    }

    /// @notice the peg price of the referenced oracle
    /// @return the peg as a Decimal
    /// @dev the peg is defined as FEI per X with X being ETH, dollars, etc
    function readOracle() public view override returns (Decimal.D256 memory) {
        (Decimal.D256 memory _peg, bool valid) = oracle.read();
        if (!valid && address(backupOracle) != address(0)) {
            (_peg, valid) = backupOracle.read();
        }
        require(valid, "OracleRef: oracle invalid");

        // Invert the oracle price if necessary
        if (doInvert) {
            _peg = invert(_peg);
        }

        // Scale the oracle price by token decimals delta if necessary
        uint256 scalingFactor;
        if (decimalsNormalizer < 0) {
            scalingFactor = 10**(-1 * decimalsNormalizer).toUint256();
            _peg = _peg.div(scalingFactor);
        } else {
            scalingFactor = 10**decimalsNormalizer.toUint256();
            _peg = _peg.mul(scalingFactor);
        }

        return _peg;
    }

    function _setOracle(address newOracle) internal {
        require(newOracle != address(0), "OracleRef: zero address");
        address oldOracle = address(oracle);
        oracle = IOracle(newOracle);
        emit OracleUpdate(oldOracle, newOracle);
    }

    // Supports zero address if no backup
    function _setBackupOracle(address newBackupOracle) internal {
        address oldBackupOracle = address(backupOracle);
        backupOracle = IOracle(newBackupOracle);
        emit BackupOracleUpdate(oldBackupOracle, newBackupOracle);
    }

    function _setDoInvert(bool newDoInvert) internal {
        bool oldDoInvert = doInvert;
        doInvert = newDoInvert;

        if (oldDoInvert != newDoInvert) {
            _setDecimalsNormalizer(-1 * decimalsNormalizer);
        }

        emit InvertUpdate(oldDoInvert, newDoInvert);
    }

    function _setDecimalsNormalizer(int256 newDecimalsNormalizer) internal {
        int256 oldDecimalsNormalizer = decimalsNormalizer;
        decimalsNormalizer = newDecimalsNormalizer;
        emit DecimalsNormalizerUpdate(
            oldDecimalsNormalizer,
            newDecimalsNormalizer
        );
    }

    function _setDecimalsNormalizerFromToken(address token) internal {
        int256 feiDecimals = 18;
        int256 _decimalsNormalizer = feiDecimals -
            int256(uint256(IERC20Metadata(token).decimals()));

        if (doInvert) {
            _decimalsNormalizer = -1 * _decimalsNormalizer;
        }

        _setDecimalsNormalizer(_decimalsNormalizer);
    }
}

File 8 of 36 : Constants.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;

import {IWETH} from "@uniswap/v2-periphery/contracts/interfaces/IWETH.sol";

library Constants {
    /// @notice the denominator for basis points granularity (10,000)
    uint256 public constant BASIS_POINTS_GRANULARITY = 10_000;

    /// @notice the denominator for basis points granularity (10,000) expressed as an int data type
    int256 public constant BP_INT = int256(BASIS_POINTS_GRANULARITY);

    uint256 public constant ONE_YEAR = 365.25 days;

    int256 public constant ONE_YEAR_INT = int256(ONE_YEAR);

    /// @notice WETH9 address
    IWETH public constant WETH =
        IWETH(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);

    /// @notice USD stand-in address
    address public constant USD = 0x1111111111111111111111111111111111111111;

    /// @notice Wei per ETH, i.e. 10**18
    uint256 public constant ETH_GRANULARITY = 1e18;

    /// @notice number of decimals in ETH, 18
    uint256 public constant ETH_DECIMALS = 18;
}

File 9 of 36 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;

        _;

        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }
}

File 10 of 36 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../../../utils/Address.sol";

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

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

    function safeTransferFrom(
        IERC20 token,
        address from,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

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

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

    function safeDecreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    }

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

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

File 11 of 36 : CoreRef.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.4;

import "./ICoreRef.sol";
import "@openzeppelin/contracts/security/Pausable.sol";

/// @title A Reference to Core
/// @author Fei Protocol
/// @notice defines some modifiers and utilities around interacting with Core
abstract contract CoreRef is ICoreRef, Pausable {
    ICore private immutable _core;
    IVolt private immutable _volt;
    IERC20 private immutable _vcon;

    /// @notice a role used with a subset of governor permissions for this contract only
    bytes32 public override CONTRACT_ADMIN_ROLE;

    constructor(address coreAddress) {
        _core = ICore(coreAddress);

        _volt = ICore(coreAddress).volt();
        _vcon = ICore(coreAddress).vcon();

        _setContractAdminRole(ICore(coreAddress).GOVERN_ROLE());
    }

    function _initialize() internal {} // no-op for backward compatibility

    modifier ifMinterSelf() {
        if (_core.isMinter(address(this))) {
            _;
        }
    }

    modifier onlyMinter() {
        require(_core.isMinter(msg.sender), "CoreRef: Caller is not a minter");
        _;
    }

    modifier onlyBurner() {
        require(_core.isBurner(msg.sender), "CoreRef: Caller is not a burner");
        _;
    }

    modifier onlyPCVController() {
        require(
            _core.isPCVController(msg.sender),
            "CoreRef: Caller is not a PCV controller"
        );
        _;
    }

    modifier onlyGovernorOrAdmin() {
        require(
            _core.isGovernor(msg.sender) || isContractAdmin(msg.sender),
            "CoreRef: Caller is not a governor or contract admin"
        );
        _;
    }

    modifier onlyGovernor() {
        require(
            _core.isGovernor(msg.sender),
            "CoreRef: Caller is not a governor"
        );
        _;
    }

    modifier onlyGuardianOrGovernor() {
        require(
            _core.isGovernor(msg.sender) || _core.isGuardian(msg.sender),
            "CoreRef: Caller is not a guardian or governor"
        );
        _;
    }

    modifier onlyGovernorOrGuardianOrAdmin() {
        require(
            _core.isGovernor(msg.sender) ||
                _core.isGuardian(msg.sender) ||
                isContractAdmin(msg.sender),
            "CoreRef: Caller is not governor or guardian or admin"
        );
        _;
    }

    // Named onlyTribeRole to prevent collision with OZ onlyRole modifier
    modifier onlyTribeRole(bytes32 role) {
        require(_core.hasRole(role, msg.sender), "UNAUTHORIZED");
        _;
    }

    // Modifiers to allow any combination of roles
    modifier hasAnyOfTwoRoles(bytes32 role1, bytes32 role2) {
        require(
            _core.hasRole(role1, msg.sender) ||
                _core.hasRole(role2, msg.sender),
            "UNAUTHORIZED"
        );
        _;
    }

    modifier hasAnyOfThreeRoles(
        bytes32 role1,
        bytes32 role2,
        bytes32 role3
    ) {
        require(
            _core.hasRole(role1, msg.sender) ||
                _core.hasRole(role2, msg.sender) ||
                _core.hasRole(role3, msg.sender),
            "UNAUTHORIZED"
        );
        _;
    }

    modifier hasAnyOfFourRoles(
        bytes32 role1,
        bytes32 role2,
        bytes32 role3,
        bytes32 role4
    ) {
        require(
            _core.hasRole(role1, msg.sender) ||
                _core.hasRole(role2, msg.sender) ||
                _core.hasRole(role3, msg.sender) ||
                _core.hasRole(role4, msg.sender),
            "UNAUTHORIZED"
        );
        _;
    }

    modifier hasAnyOfFiveRoles(
        bytes32 role1,
        bytes32 role2,
        bytes32 role3,
        bytes32 role4,
        bytes32 role5
    ) {
        require(
            _core.hasRole(role1, msg.sender) ||
                _core.hasRole(role2, msg.sender) ||
                _core.hasRole(role3, msg.sender) ||
                _core.hasRole(role4, msg.sender) ||
                _core.hasRole(role5, msg.sender),
            "UNAUTHORIZED"
        );
        _;
    }

    modifier onlyVolt() {
        require(msg.sender == address(_volt), "CoreRef: Caller is not VOLT");
        _;
    }

    /// @notice sets a new admin role for this contract
    function setContractAdminRole(bytes32 newContractAdminRole)
        external
        override
        onlyGovernor
    {
        _setContractAdminRole(newContractAdminRole);
    }

    /// @notice returns whether a given address has the admin role for this contract
    function isContractAdmin(address _admin)
        public
        view
        override
        returns (bool)
    {
        return _core.hasRole(CONTRACT_ADMIN_ROLE, _admin);
    }

    /// @notice set pausable methods to paused
    function pause() public override onlyGuardianOrGovernor {
        _pause();
    }

    /// @notice set pausable methods to unpaused
    function unpause() public override onlyGuardianOrGovernor {
        _unpause();
    }

    /// @notice address of the Core contract referenced
    /// @return ICore implementation address
    function core() public view override returns (ICore) {
        return _core;
    }

    /// @notice address of the Fei contract referenced by Core
    /// @return IFei implementation address
    function volt() public view override returns (IVolt) {
        return _volt;
    }

    /// @notice address of the Tribe contract referenced by Core
    /// @return IERC20 implementation address
    function vcon() public view override returns (IERC20) {
        return _vcon;
    }

    /// @notice volt balance of contract
    /// @return volt amount held
    function voltBalance() public view override returns (uint256) {
        return _volt.balanceOf(address(this));
    }

    /// @notice vcon balance of contract
    /// @return vcon amount held
    function vconBalance() public view override returns (uint256) {
        return _vcon.balanceOf(address(this));
    }

    function _burnVoltHeld() internal {
        _volt.burn(voltBalance());
    }

    function _mintVolt(address to, uint256 amount) internal virtual {
        if (amount != 0) {
            _volt.mint(to, amount);
        }
    }

    function _setContractAdminRole(bytes32 newContractAdminRole) internal {
        bytes32 oldContractAdminRole = CONTRACT_ADMIN_ROLE;
        CONTRACT_ADMIN_ROLE = newContractAdminRole;
        emit ContractAdminRoleUpdate(
            oldContractAdminRole,
            newContractAdminRole
        );
    }
}

File 12 of 36 : IPCVDeposit.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.4;

import "./IPCVDepositBalances.sol";

/// @title a PCV Deposit interface
/// @author Fei Protocol
interface IPCVDeposit is IPCVDepositBalances {
    // ----------- Events -----------
    event Deposit(address indexed _from, uint256 _amount);

    event Withdrawal(
        address indexed _caller,
        address indexed _to,
        uint256 _amount
    );

    event WithdrawERC20(
        address indexed _caller,
        address indexed _token,
        address indexed _to,
        uint256 _amount
    );

    event WithdrawETH(
        address indexed _caller,
        address indexed _to,
        uint256 _amount
    );

    // ----------- State changing api -----------

    function deposit() external;

    // ----------- PCV Controller only state changing api -----------

    function withdraw(address to, uint256 amount) external;

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

    function withdrawETH(address payable to, uint256 amount) external;
}

File 13 of 36 : ICoreRef.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.4;

import "../core/ICore.sol";

/// @title CoreRef interface
/// @author Fei Protocol
interface ICoreRef {
    // ----------- Events -----------

    event CoreUpdate(address indexed oldCore, address indexed newCore);

    event ContractAdminRoleUpdate(
        bytes32 indexed oldContractAdminRole,
        bytes32 indexed newContractAdminRole
    );

    // ----------- Governor only state changing api -----------

    function setContractAdminRole(bytes32 newContractAdminRole) external;

    // ----------- Governor or Guardian only state changing api -----------

    function pause() external;

    function unpause() external;

    // ----------- Getters -----------

    function core() external view returns (ICore);

    function volt() external view returns (IVolt);

    function vcon() external view returns (IERC20);

    function voltBalance() external view returns (uint256);

    function vconBalance() external view returns (uint256);

    function CONTRACT_ADMIN_ROLE() external view returns (bytes32);

    function isContractAdmin(address admin) external view returns (bool);
}

File 14 of 36 : Pausable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/Pausable.sol)

pragma solidity ^0.8.0;

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

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

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

    bool private _paused;

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

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

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

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        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());
    }
}

File 15 of 36 : ICore.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.4;

import {IPermissions} from "./IPermissions.sol";
import {IVolt, IERC20} from "../volt/IVolt.sol";

/// @title Core Interface
/// @author Fei Protocol
interface ICore is IPermissions {
    // ----------- Events -----------
    event VoltUpdate(IERC20 indexed _volt);
    event VconUpdate(IERC20 indexed _vcon);

    // ----------- Getters -----------

    function volt() external view returns (IVolt);

    function vcon() external view returns (IERC20);
}

File 16 of 36 : IPermissions.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.4;

import "@openzeppelin/contracts/access/AccessControl.sol";
import "./IPermissionsRead.sol";

/// @title Permissions interface
/// @author Fei Protocol
interface IPermissions is IAccessControl, IPermissionsRead {
    // ----------- Governor only state changing api -----------

    function createRole(bytes32 role, bytes32 adminRole) external;

    function grantMinter(address minter) external;

    function grantBurner(address burner) external;

    function grantPCVController(address pcvController) external;

    function grantGovernor(address governor) external;

    function grantGuardian(address guardian) external;

    function revokeMinter(address minter) external;

    function revokeBurner(address burner) external;

    function revokePCVController(address pcvController) external;

    function revokeGovernor(address governor) external;

    function revokeGuardian(address guardian) external;

    // ----------- Revoker only state changing api -----------

    function revokeOverride(bytes32 role, address account) external;

    // ----------- Getters -----------

    function GUARDIAN_ROLE() external view returns (bytes32);

    function GOVERN_ROLE() external view returns (bytes32);

    function BURNER_ROLE() external view returns (bytes32);

    function MINTER_ROLE() external view returns (bytes32);

    function PCV_CONTROLLER_ROLE() external view returns (bytes32);
}

File 17 of 36 : IVolt.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.4;

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

/// @title FEI stablecoin interface
/// @author Fei Protocol
interface IVolt is IERC20 {
    // ----------- Events -----------

    event Minting(
        address indexed _to,
        address indexed _minter,
        uint256 _amount
    );

    event Burning(
        address indexed _to,
        address indexed _burner,
        uint256 _amount
    );

    event IncentiveContractUpdate(
        address indexed _incentivized,
        address indexed _incentiveContract
    );

    // ----------- State changing api -----------

    function burn(uint256 amount) external;

    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    // ----------- Minter only state changing api -----------

    function mint(address account, uint256 amount) external;
}

File 18 of 36 : AccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/AccessControl.sol)

pragma solidity ^0.8.0;

import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms. This is a lightweight version that doesn't allow enumerating role
 * members except through off-chain means by accessing the contract event logs. Some
 * applications may benefit from on-chain enumerability, for those cases see
 * {AccessControlEnumerable}.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it.
 */
abstract contract AccessControl is Context, IAccessControl, ERC165 {
    struct RoleData {
        mapping(address => bool) members;
        bytes32 adminRole;
    }

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with a standardized message including the required role.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     *
     * _Available since v4.1._
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role, _msgSender());
        _;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) public view override returns (bool) {
        return _roles[role].members[account];
    }

    /**
     * @dev Revert with a standard message if `account` is missing `role`.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     */
    function _checkRole(bytes32 role, address account) internal view {
        if (!hasRole(role, account)) {
            revert(
                string(
                    abi.encodePacked(
                        "AccessControl: account ",
                        Strings.toHexString(uint160(account), 20),
                        " is missing role ",
                        Strings.toHexString(uint256(role), 32)
                    )
                )
            );
        }
    }

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) public view override returns (bytes32) {
        return _roles[role].adminRole;
    }

    /**
     * @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) public virtual override onlyRole(getRoleAdmin(role)) {
        _grantRole(role, account);
    }

    /**
     * @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) public virtual override onlyRole(getRoleAdmin(role)) {
        _revokeRole(role, account);
    }

    /**
     * @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 revoked `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) public virtual override {
        require(account == _msgSender(), "AccessControl: can only renounce roles for self");

        _revokeRole(role, account);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event. Note that unlike {grantRole}, this function doesn't perform any
     * checks on the calling account.
     *
     * [WARNING]
     * ====
     * This function should only be called from the constructor when setting
     * up the initial roles for the system.
     *
     * Using this function in any other way is effectively circumventing the admin
     * system imposed by {AccessControl}.
     * ====
     *
     * NOTE: This function is deprecated in favor of {_grantRole}.
     */
    function _setupRole(bytes32 role, address account) internal virtual {
        _grantRole(role, account);
    }

    /**
     * @dev Sets `adminRole` as ``role``'s admin role.
     *
     * Emits a {RoleAdminChanged} event.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
        bytes32 previousAdminRole = getRoleAdmin(role);
        _roles[role].adminRole = adminRole;
        emit RoleAdminChanged(role, previousAdminRole, adminRole);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * Internal function without access restriction.
     */
    function _grantRole(bytes32 role, address account) internal virtual {
        if (!hasRole(role, account)) {
            _roles[role].members[account] = true;
            emit RoleGranted(role, account, _msgSender());
        }
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * Internal function without access restriction.
     */
    function _revokeRole(bytes32 role, address account) internal virtual {
        if (hasRole(role, account)) {
            _roles[role].members[account] = false;
            emit RoleRevoked(role, account, _msgSender());
        }
    }
}

File 19 of 36 : IPermissionsRead.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.4;

/// @title Permissions Read interface
/// @author Fei Protocol
interface IPermissionsRead {
    // ----------- Getters -----------

    function isBurner(address _address) external view returns (bool);

    function isMinter(address _address) external view returns (bool);

    function isGovernor(address _address) external view returns (bool);

    function isGuardian(address _address) external view returns (bool);

    function isPCVController(address _address) external view returns (bool);
}

File 20 of 36 : 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 21 of 36 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

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

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

File 22 of 36 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }

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

File 23 of 36 : ERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)

pragma solidity ^0.8.0;

import "./IERC165.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}

File 24 of 36 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

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

File 25 of 36 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

File 26 of 36 : IPCVDepositBalances.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.4;

/// @title a PCV Deposit interface for only balance getters
/// @author Fei Protocol
interface IPCVDepositBalances {
    // ----------- Getters -----------

    /// @notice gets the effective balance of "balanceReportedIn" token if the deposit were fully withdrawn
    function balance() external view returns (uint256);

    /// @notice gets the token address in which this deposit returns its balance
    function balanceReportedIn() external view returns (address);

    /// @notice gets the resistant token balance and protocol owned fei of this deposit
    function resistantBalanceAndVolt() external view returns (uint256, uint256);
}

File 27 of 36 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)

pragma solidity ^0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 0;
    }

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

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

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

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

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

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

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(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) {
        require(isContract(target), "Address: delegate call to non-contract");

        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason 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 {
            // 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

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 28 of 36 : RateLimited.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.4;

import "../refs/CoreRef.sol";
import "@openzeppelin/contracts/utils/math/Math.sol";

/// @title abstract contract for putting a rate limit on how fast a contract can perform an action e.g. Minting
/// @author Fei Protocol
abstract contract RateLimited is CoreRef {
    /// @notice maximum rate limit per second governance can set for this contract
    uint256 public immutable MAX_RATE_LIMIT_PER_SECOND;

    /// @notice the rate per second for this contract
    uint256 public rateLimitPerSecond;

    /// @notice the last time the buffer was used by the contract
    uint256 public lastBufferUsedTime;

    /// @notice the cap of the buffer that can be used at once
    uint256 public bufferCap;

    /// @notice a flag for whether to allow partial actions to complete if the buffer is less than amount
    bool public doPartialAction;

    /// @notice the buffer at the timestamp of lastBufferUsedTime
    uint256 public bufferStored;

    event BufferUsed(uint256 amountUsed, uint256 bufferRemaining);
    event BufferCapUpdate(uint256 oldBufferCap, uint256 newBufferCap);
    event RateLimitPerSecondUpdate(
        uint256 oldRateLimitPerSecond,
        uint256 newRateLimitPerSecond
    );

    constructor(
        uint256 _maxRateLimitPerSecond,
        uint256 _rateLimitPerSecond,
        uint256 _bufferCap,
        bool _doPartialAction
    ) {
        lastBufferUsedTime = block.timestamp;

        _setBufferCap(_bufferCap);
        bufferStored = _bufferCap;

        require(
            _rateLimitPerSecond <= _maxRateLimitPerSecond,
            "RateLimited: rateLimitPerSecond too high"
        );
        _setRateLimitPerSecond(_rateLimitPerSecond);

        MAX_RATE_LIMIT_PER_SECOND = _maxRateLimitPerSecond;
        doPartialAction = _doPartialAction;
    }

    /// @notice set the rate limit per second
    function setRateLimitPerSecond(uint256 newRateLimitPerSecond)
        external
        virtual
        onlyGovernorOrAdmin
    {
        require(
            newRateLimitPerSecond <= MAX_RATE_LIMIT_PER_SECOND,
            "RateLimited: rateLimitPerSecond too high"
        );
        _updateBufferStored();

        _setRateLimitPerSecond(newRateLimitPerSecond);
    }

    /// @notice set the buffer cap
    function setBufferCap(uint256 newBufferCap)
        external
        virtual
        onlyGovernorOrAdmin
    {
        _setBufferCap(newBufferCap);
    }

    /// @notice the amount of action used before hitting limit
    /// @dev replenishes at rateLimitPerSecond per second up to bufferCap
    function buffer() public view returns (uint256) {
        uint256 elapsed = block.timestamp - lastBufferUsedTime;
        return
            Math.min(bufferStored + (rateLimitPerSecond * elapsed), bufferCap);
    }

    /** 
        @notice the method that enforces the rate limit. Decreases buffer by "amount". 
        If buffer is <= amount either
        1. Does a partial mint by the amount remaining in the buffer or
        2. Reverts
        Depending on whether doPartialAction is true or false
    */
    function _depleteBuffer(uint256 amount) internal virtual returns (uint256) {
        uint256 newBuffer = buffer();

        uint256 usedAmount = amount;
        if (doPartialAction && usedAmount > newBuffer) {
            usedAmount = newBuffer;
        }

        require(newBuffer != 0, "RateLimited: no rate limit buffer");
        require(usedAmount <= newBuffer, "RateLimited: rate limit hit");

        bufferStored = newBuffer - usedAmount;

        lastBufferUsedTime = block.timestamp;

        emit BufferUsed(usedAmount, bufferStored);

        return usedAmount;
    }

    /// @notice function to replenish buffer
    /// @param amount to increase buffer by if under buffer cap
    function _replenishBuffer(uint256 amount) internal {
        uint256 newBuffer = buffer();

        uint256 _bufferCap = bufferCap; /// gas opti, save an SLOAD

        /// cannot replenish any further if already at buffer cap
        if (newBuffer == _bufferCap) {
            return;
        }

        lastBufferUsedTime = block.timestamp;

        /// ensure that bufferStored cannot be gt buffer cap
        bufferStored = Math.min(newBuffer + amount, _bufferCap);
    }

    function _setRateLimitPerSecond(uint256 newRateLimitPerSecond) internal {
        uint256 oldRateLimitPerSecond = rateLimitPerSecond;
        rateLimitPerSecond = newRateLimitPerSecond;

        emit RateLimitPerSecondUpdate(
            oldRateLimitPerSecond,
            newRateLimitPerSecond
        );
    }

    function _setBufferCap(uint256 newBufferCap) internal {
        _updateBufferStored();

        uint256 oldBufferCap = bufferCap;
        bufferCap = newBufferCap;

        emit BufferCapUpdate(oldBufferCap, newBufferCap);
    }

    function _resetBuffer() internal {
        bufferStored = bufferCap;
    }

    function _updateBufferStored() internal {
        bufferStored = buffer();
        lastBufferUsedTime = block.timestamp;
    }
}

File 29 of 36 : Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/math/Math.sol)

pragma solidity ^0.8.0;

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

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

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a / b + (a % b == 0 ? 0 : 1);
    }
}

File 30 of 36 : IOracleRef.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.4;

import "../oracle/IOracle.sol";

/// @title OracleRef interface
/// @author Fei Protocol
interface IOracleRef {
    // ----------- Events -----------

    event OracleUpdate(address indexed oldOracle, address indexed newOracle);

    event InvertUpdate(bool oldDoInvert, bool newDoInvert);

    event DecimalsNormalizerUpdate(
        int256 oldDecimalsNormalizer,
        int256 newDecimalsNormalizer
    );

    event BackupOracleUpdate(
        address indexed oldBackupOracle,
        address indexed newBackupOracle
    );

    // ----------- State changing API -----------

    function updateOracle() external;

    // ----------- Governor only state changing API -----------

    function setOracle(address newOracle) external;

    function setBackupOracle(address newBackupOracle) external;

    function setDecimalsNormalizer(int256 newDecimalsNormalizer) external;

    function setDoInvert(bool newDoInvert) external;

    // ----------- Getters -----------

    function oracle() external view returns (IOracle);

    function backupOracle() external view returns (IOracle);

    function doInvert() external view returns (bool);

    function decimalsNormalizer() external view returns (int256);

    function readOracle() external view returns (Decimal.D256 memory);

    function invert(Decimal.D256 calldata price)
        external
        pure
        returns (Decimal.D256 memory);
}

File 31 of 36 : SafeCast.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/math/SafeCast.sol)

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 SafeCast {
    /**
     * @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
     */
    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 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
     */
    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 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
     */
    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 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
     */
    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 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
     */
    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 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
     */
    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.
     */
    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.
     */
    function toUint256(int256 value) internal pure returns (uint256) {
        require(value >= 0, "SafeCast: value must be positive");
        return uint256(value);
    }

    /**
     * @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) {
        require(value >= type(int128).min && value <= type(int128).max, "SafeCast: value doesn't fit in 128 bits");
        return int128(value);
    }

    /**
     * @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) {
        require(value >= type(int64).min && value <= type(int64).max, "SafeCast: value doesn't fit in 64 bits");
        return int64(value);
    }

    /**
     * @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) {
        require(value >= type(int32).min && value <= type(int32).max, "SafeCast: value doesn't fit in 32 bits");
        return int32(value);
    }

    /**
     * @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) {
        require(value >= type(int16).min && value <= type(int16).max, "SafeCast: value doesn't fit in 16 bits");
        return int16(value);
    }

    /**
     * @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) {
        require(value >= type(int8).min && value <= type(int8).max, "SafeCast: value doesn't fit in 8 bits");
        return int8(value);
    }

    /**
     * @dev Converts an unsigned uint256 into a signed int256.
     *
     * Requirements:
     *
     * - input must be less than or equal to maxInt256.
     */
    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 32 of 36 : IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";

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

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

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

File 33 of 36 : IOracle.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.4;

import "../external/Decimal.sol";

/// @title generic oracle interface for Fei Protocol
/// @author Fei Protocol
interface IOracle {
    // ----------- Events -----------

    event Update(uint256 _peg);

    // ----------- State changing API -----------

    function update() external;

    // ----------- Getters -----------

    function read() external view returns (Decimal.D256 memory, bool);

    function isOutdated() external view returns (bool);
}

File 34 of 36 : Decimal.sol
/*
    Copyright 2019 dYdX Trading Inc.
    Copyright 2020 Empty Set Squad <[email protected]>
    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.
*/

pragma solidity ^0.8.4;

import "@openzeppelin/contracts/utils/math/SafeMath.sol";

/**
 * @title Decimal
 * @author dYdX
 *
 * Library that defines a fixed-point number with 18 decimal places.
 */
library Decimal {
    using SafeMath for uint256;

    // ============ Constants ============

    uint256 private constant BASE = 10**18;

    // ============ Structs ============

    struct D256 {
        uint256 value;
    }

    // ============ Static Functions ============

    function zero() internal pure returns (D256 memory) {
        return D256({value: 0});
    }

    function one() internal pure returns (D256 memory) {
        return D256({value: BASE});
    }

    function from(uint256 a) internal pure returns (D256 memory) {
        return D256({value: a.mul(BASE)});
    }

    function ratio(uint256 a, uint256 b) internal pure returns (D256 memory) {
        return D256({value: getPartial(a, BASE, b)});
    }

    // ============ Self Functions ============

    function add(D256 memory self, uint256 b)
        internal
        pure
        returns (D256 memory)
    {
        return D256({value: self.value.add(b.mul(BASE))});
    }

    function sub(D256 memory self, uint256 b)
        internal
        pure
        returns (D256 memory)
    {
        return D256({value: self.value.sub(b.mul(BASE))});
    }

    function sub(
        D256 memory self,
        uint256 b,
        string memory reason
    ) internal pure returns (D256 memory) {
        return D256({value: self.value.sub(b.mul(BASE), reason)});
    }

    function mul(D256 memory self, uint256 b)
        internal
        pure
        returns (D256 memory)
    {
        return D256({value: self.value.mul(b)});
    }

    function div(D256 memory self, uint256 b)
        internal
        pure
        returns (D256 memory)
    {
        return D256({value: self.value.div(b)});
    }

    function pow(D256 memory self, uint256 b)
        internal
        pure
        returns (D256 memory)
    {
        if (b == 0) {
            return from(1);
        }

        D256 memory temp = D256({value: self.value});
        for (uint256 i = 1; i < b; i++) {
            temp = mul(temp, self);
        }

        return temp;
    }

    function add(D256 memory self, D256 memory b)
        internal
        pure
        returns (D256 memory)
    {
        return D256({value: self.value.add(b.value)});
    }

    function sub(D256 memory self, D256 memory b)
        internal
        pure
        returns (D256 memory)
    {
        return D256({value: self.value.sub(b.value)});
    }

    function sub(
        D256 memory self,
        D256 memory b,
        string memory reason
    ) internal pure returns (D256 memory) {
        return D256({value: self.value.sub(b.value, reason)});
    }

    function mul(D256 memory self, D256 memory b)
        internal
        pure
        returns (D256 memory)
    {
        return D256({value: getPartial(self.value, b.value, BASE)});
    }

    function div(D256 memory self, D256 memory b)
        internal
        pure
        returns (D256 memory)
    {
        return D256({value: getPartial(self.value, BASE, b.value)});
    }

    function equals(D256 memory self, D256 memory b)
        internal
        pure
        returns (bool)
    {
        return self.value == b.value;
    }

    function greaterThan(D256 memory self, D256 memory b)
        internal
        pure
        returns (bool)
    {
        return compareTo(self, b) == 2;
    }

    function lessThan(D256 memory self, D256 memory b)
        internal
        pure
        returns (bool)
    {
        return compareTo(self, b) == 0;
    }

    function greaterThanOrEqualTo(D256 memory self, D256 memory b)
        internal
        pure
        returns (bool)
    {
        return compareTo(self, b) > 0;
    }

    function lessThanOrEqualTo(D256 memory self, D256 memory b)
        internal
        pure
        returns (bool)
    {
        return compareTo(self, b) < 2;
    }

    function isZero(D256 memory self) internal pure returns (bool) {
        return self.value == 0;
    }

    function asUint256(D256 memory self) internal pure returns (uint256) {
        return self.value.div(BASE);
    }

    // ============ Core Methods ============

    function getPartial(
        uint256 target,
        uint256 numerator,
        uint256 denominator
    ) private pure returns (uint256) {
        return target.mul(numerator).div(denominator);
    }

    function compareTo(D256 memory a, D256 memory b)
        private
        pure
        returns (uint256)
    {
        if (a.value == b.value) {
            return 1;
        }
        return a.value > b.value ? 2 : 0;
    }
}

File 35 of 36 : SafeMath.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/math/SafeMath.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

File 36 of 36 : IWETH.sol
pragma solidity >=0.5.0;

interface IWETH {
    function deposit() external payable;
    function transfer(address to, uint value) external returns (bool);
    function withdraw(uint) external;
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"uint256","name":"_floor","type":"uint256"},{"internalType":"uint256","name":"_ceiling","type":"uint256"},{"components":[{"internalType":"address","name":"coreAddress","type":"address"},{"internalType":"address","name":"oracleAddress","type":"address"},{"internalType":"address","name":"backupOracle","type":"address"},{"internalType":"int256","name":"decimalsNormalizer","type":"int256"},{"internalType":"bool","name":"doInvert","type":"bool"}],"internalType":"struct PegStabilityModule.OracleParams","name":"_params","type":"tuple"},{"internalType":"uint256","name":"_mintFeeBasisPoints","type":"uint256"},{"internalType":"uint256","name":"_redeemFeeBasisPoints","type":"uint256"},{"internalType":"uint256","name":"_reservesThreshold","type":"uint256"},{"internalType":"uint256","name":"_feiLimitPerSecond","type":"uint256"},{"internalType":"uint256","name":"_mintingBufferCap","type":"uint256"},{"internalType":"contract IERC20","name":"_underlyingToken","type":"address"},{"internalType":"contract IPCVDeposit","name":"_surplusTarget","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"AllocateSurplus","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldBackupOracle","type":"address"},{"indexed":true,"internalType":"address","name":"newBackupOracle","type":"address"}],"name":"BackupOracleUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldBufferCap","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newBufferCap","type":"uint256"}],"name":"BufferCapUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amountUsed","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"bufferRemaining","type":"uint256"}],"name":"BufferUsed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"oldContractAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newContractAdminRole","type":"bytes32"}],"name":"ContractAdminRoleUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldCore","type":"address"},{"indexed":true,"internalType":"address","name":"newCore","type":"address"}],"name":"CoreUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"int256","name":"oldDecimalsNormalizer","type":"int256"},{"indexed":false,"internalType":"int256","name":"newDecimalsNormalizer","type":"int256"}],"name":"DecimalsNormalizerUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_from","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"oldDoInvert","type":"bool"},{"indexed":false,"internalType":"bool","name":"newDoInvert","type":"bool"}],"name":"InvertUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldMaxFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newMaxFee","type":"uint256"}],"name":"MaxFeeUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountIn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountFeiOut","type":"uint256"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldMintFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newMintFee","type":"uint256"}],"name":"MintFeeUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"MintingPaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"MintingUnpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldCeiling","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newCeiling","type":"uint256"}],"name":"OracleCeilingUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldFloor","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newFloor","type":"uint256"}],"name":"OracleFloorUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldOracle","type":"address"},{"indexed":true,"internalType":"address","name":"newOracle","type":"address"}],"name":"OracleUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldRateLimitPerSecond","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newRateLimitPerSecond","type":"uint256"}],"name":"RateLimitPerSecondUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountFeiIn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountAssetOut","type":"uint256"}],"name":"Redeem","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldRedeemFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newRedeemFee","type":"uint256"}],"name":"RedeemFeeUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"RedemptionsPaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"RedemptionsUnpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldReservesThreshold","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newReservesThreshold","type":"uint256"}],"name":"ReservesThresholdUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IPCVDeposit","name":"oldTarget","type":"address"},{"indexed":false,"internalType":"contract IPCVDeposit","name":"newTarget","type":"address"}],"name":"SurplusTargetUpdate","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":"_caller","type":"address"},{"indexed":true,"internalType":"address","name":"_token","type":"address"},{"indexed":true,"internalType":"address","name":"_to","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"WithdrawERC20","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_caller","type":"address"},{"indexed":true,"internalType":"address","name":"_to","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"WithdrawETH","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_caller","type":"address"},{"indexed":true,"internalType":"address","name":"_to","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"Withdrawal","type":"event"},{"inputs":[],"name":"CONTRACT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_FEE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_RATE_LIMIT_PER_SECOND","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"allocateSurplus","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"backupOracle","outputs":[{"internalType":"contract IOracle","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"balance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"balanceReportedIn","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"buffer","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bufferCap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bufferStored","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ceiling","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"core","outputs":[{"internalType":"contract ICore","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimalsNormalizer","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"doInvert","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"doPartialAction","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"floor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMaxMintAmountOut","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"}],"name":"getMintAmountOut","outputs":[{"internalType":"uint256","name":"amountFeiOut","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountFeiIn","type":"uint256"}],"name":"getRedeemAmountOut","outputs":[{"internalType":"uint256","name":"amountTokenOut","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"hasSurplus","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"value","type":"uint256"}],"internalType":"struct Decimal.D256","name":"price","type":"tuple"}],"name":"invert","outputs":[{"components":[{"internalType":"uint256","name":"value","type":"uint256"}],"internalType":"struct Decimal.D256","name":"","type":"tuple"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"_admin","type":"address"}],"name":"isContractAdmin","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isPriceValid","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastBufferUsedTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"minAmountOut","type":"uint256"}],"name":"mint","outputs":[{"internalType":"uint256","name":"amountFeiOut","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"mintFeeBasisPoints","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"mintPaused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"oracle","outputs":[{"internalType":"contract IOracle","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pauseMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pauseRedeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rateLimitPerSecond","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"readOracle","outputs":[{"components":[{"internalType":"uint256","name":"value","type":"uint256"}],"internalType":"struct Decimal.D256","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amountFeiIn","type":"uint256"},{"internalType":"uint256","name":"minAmountOut","type":"uint256"}],"name":"redeem","outputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"redeemFeeBasisPoints","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"redeemPaused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"reservesSurplus","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"reservesThreshold","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"resistantBalanceAndVolt","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newBackupOracle","type":"address"}],"name":"setBackupOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newBufferCap","type":"uint256"}],"name":"setBufferCap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"newContractAdminRole","type":"bytes32"}],"name":"setContractAdminRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"int256","name":"newDecimalsNormalizer","type":"int256"}],"name":"setDecimalsNormalizer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"newDoInvert","type":"bool"}],"name":"setDoInvert","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newMintFeeBasisPoints","type":"uint256"}],"name":"setMintFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOracle","type":"address"}],"name":"setOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newCeilingBasisPoints","type":"uint256"}],"name":"setOracleCeilingBasisPoints","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newFloorBasisPoints","type":"uint256"}],"name":"setOracleFloorBasisPoints","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newRateLimitPerSecond","type":"uint256"}],"name":"setRateLimitPerSecond","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newRedeemFeeBasisPoints","type":"uint256"}],"name":"setRedeemFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newReservesThreshold","type":"uint256"}],"name":"setReservesThreshold","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IPCVDeposit","name":"newTarget","type":"address"}],"name":"setSurplusTarget","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"surplusTarget","outputs":[{"internalType":"contract IPCVDeposit","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"underlyingToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpauseMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpauseRedeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"updateOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"vcon","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vconBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"volt","outputs":[{"internalType":"contract IVolt","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"voltBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdrawERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"to","type":"address"},{"internalType":"uint256","name":"amountOut","type":"uint256"}],"name":"withdrawETH","outputs":[],"stateMutability":"nonpayable","type":"function"}]

61012060405261012c6010553480156200001857600080fd5b5060405162005303380380620053038339810160408190526200003b9162000d3a565b87878787878787878760000151886020015189604001518a606001518b608001518888600069021e19e0c9bab24000008383838b60008060006101000a81548160ff021916908315150217905550806001600160a01b03166080816001600160a01b031681525050806001600160a01b03166317607ad96040518163ffffffff1660e01b8152600401602060405180830381865afa158015620000e2573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000108919062000e60565b6001600160a01b031660a0816001600160a01b031681525050806001600160a01b031663315d2f5b6040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000160573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000186919062000e60565b6001600160a01b031660c0816001600160a01b0316815250506200020e816001600160a01b03166338b7f4466040518163ffffffff1660e01b8152600401602060405180830381865afa158015620001e2573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000208919062000e80565b620003b3565b50426003556200021e82620003ec565b6006829055838311156200028a5760405162461bcd60e51b815260206004820152602860248201527f526174654c696d697465643a20726174654c696d69745065725365636f6e64206044820152670e8dede40d0d2ced60c31b60648201526084015b60405180910390fd5b62000295836200043c565b60e09390935250506005805460ff191691151591909117905550620002be91508590506200047b565b6001600160a01b03831615801590620002e95750836001600160a01b0316836001600160a01b031614155b15620002fa57620002fa8362000525565b620003058162000577565b6200031082620005eb565b50506001600b555050506001600160a01b0382166101005262000333856200062a565b6200033e87620006c5565b62000349866200076d565b620003548162000817565b6200037f7f1749ca1ca3564d20da6efea465c2a5ae869a9e4b006da7035e688beb14d704e0620003b3565b50505050505050506200039889620008d060201b60201c565b620003a38a62000a2a565b5050505050505050505062000fbb565b6001805490829055604051829082907f29ddd278ef9169e35aa84e424b39048b89af9c0b50f85497e40f97dff6946cf590600090a35050565b620003f662000b82565b600480549082905560408051828152602081018490527f52d0e582769dcd1e242b38b9a795ef4699f2eca0f23b1d8f94368efb27bcd5ff91015b60405180910390a15050565b600280549082905560408051828152602081018490527fc1d6758c9eb8ba949914722321f508e4cd1e14d3ff96773ef5950336d8a2c63a910162000430565b6001600160a01b038116620004d35760405162461bcd60e51b815260206004820152601760248201527f4f7261636c655265663a207a65726f2061646472657373000000000000000000604482015260640162000281565b600780546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f93450534569bdbb3109b44eef77c9b236897f4caa4f201be10252d6462a5693790600090a35050565b600880546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f492cc1f8400b642b4e56de46ed10d314a49bf3e0594c43e2e5947c1e1733645b90600090a35050565b600a805482151560ff198216811790925560ff169081151514620005b157620005b1600954600019620005ab919062000eb0565b620005eb565b60408051821515815283151560208201527f16b9ae7ca814a6dfd3357b20f33bcc7c194676988d5da46846628da394df8ab3910162000430565b600980549082905560408051828152602081018490527fc45ec9015c033bb1ee553a67346dd851062dddce070a6dddb7616e5d7595bcc2910162000430565b60008111620006865760405162461bcd60e51b81526020600482015260326024820152600080516020620052e38339815191526044820152711c995cd95c9d995cc81d1a1c995cda1bdb1960721b606482015260840162000281565b600e80549082905560408051828152602081018490527f11f873e0db7952f2f3eab9ad99121a8661e39c5cb67d33d51665f9f3e75d799e910162000430565b6010548111156200072e5760405162461bcd60e51b815260206004820152602c60248201527f50656753746162696c6974794d6f64756c653a204d696e74206665652065786360448201526b65656473206d61782066656560a01b606482015260840162000281565b600c80549082905560408051828152602081018490527f06255fba5f99bcc77a5d27ee1222dd110e196ad4cfba488e1fceccbec8dedc68910162000430565b601054811115620007d85760405162461bcd60e51b815260206004820152602e60248201527f50656753746162696c6974794d6f64756c653a2052656465656d20666565206560448201526d786365656473206d61782066656560901b606482015260840162000281565b600d80549082905560408051828152602081018490527f288d91cad90f9c412f12c0869aa634660d8403c9590aa55fd5035212c6f98c95910162000430565b6001600160a01b038116620008755760405162461bcd60e51b815260206004820152602e6024820152600080516020620052e383398151915260448201526d1cdd5c9c1b1d5cc81d185c99d95d60921b606482015260840162000281565b600f80546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f70dc5d19a845312f7e3a89f1894fe84155cbd0a1f8434ebf02d9de842d982325910162000430565b806200092b5760405162461bcd60e51b815260206004820152602360248201527f50656753746162696c6974794d6f64756c653a20696e76616c6964206365696c604482015262696e6760e81b606482015260840162000281565b620009776200094a60125461271062000b9560201b620025601760201c565b620009638361271062000b9560201b620025601760201c565b62000bd560201b620025961790919060201c565b620009eb5760405162461bcd60e51b815260206004820152603660248201527f50656753746162696c6974794d6f64756c653a206365696c696e67206d75737460448201527f2062652067726561746572207468616e20666c6f6f7200000000000000000000606482015260840162000281565b601380549082905560408051828152602081018490527f15ddf2d8b0f5def2d9096715ee6dbe8646cd0a5c0225c781525b943244e1a7a3910162000430565b8062000a835760405162461bcd60e51b815260206004820152602160248201527f50656753746162696c6974794d6f64756c653a20696e76616c696420666c6f6f6044820152603960f91b606482015260840162000281565b62000acf62000aa260135461271062000b9560201b620025601760201c565b62000abb8361271062000b9560201b620025601760201c565b62000bed60201b620025ac1790919060201c565b62000b435760405162461bcd60e51b815260206004820152603360248201527f50656753746162696c6974794d6f64756c653a20666c6f6f72206d757374206260448201527f65206c657373207468616e206365696c696e6700000000000000000000000000606482015260840162000281565b601280549082905560408051828152602081018490527fa91829da8506bd47a58affb492ad10b559a97ce6fefc606c084df3d22f83dd90910162000430565b62000b8c62000c03565b60065542600355565b604080516020810190915260008152604051806020016040528062000bca85670de0b6b3a76400008662000c5560201b60201c565b905290505b92915050565b600062000be3838362000c92565b6002149392505050565b600062000bfb838362000c92565b159392505050565b6000806003544262000c16919062000f41565b905062000c4f8160025462000c2c919062000f5b565b60065462000c3b919062000f7d565b60045462000cc860201b620025c01760201c565b91505090565b600062000c8a8262000c76858762000ce260201b620025d81790919060201c565b62000cf060201b620025e41790919060201c565b949350505050565b80518251600091141562000ca95750600162000bcf565b815183511162000cbb57600062000cbe565b60025b60ff169392505050565b600081831062000cd9578162000cdb565b825b9392505050565b600062000cdb828462000f5b565b600062000cdb828462000f98565b6001600160a01b038116811462000d1457600080fd5b50565b805162000d248162000cfe565b919050565b8051801515811462000d2457600080fd5b6000806000806000806000806000808a8c036101c081121562000d5c57600080fd5b8b519a5060208c0151995060a0603f198201121562000d7a57600080fd5b5060405160a081016001600160401b038111828210171562000dac57634e487b7160e01b600052604160045260246000fd5b806040525062000dbf60408d0162000d17565b815262000dcf60608d0162000d17565b602082015262000de260808d0162000d17565b604082015260a08c0151606082015262000dff60c08d0162000d29565b60808201528098505060e08b015196506101008b015195506101208b015194506101408b015193506101608b0151925062000e3e6101808c0162000d17565b915062000e4f6101a08c0162000d17565b90509295989b9194979a5092959850565b60006020828403121562000e7357600080fd5b815162000cdb8162000cfe565b60006020828403121562000e9357600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b60006001600160ff1b038184138284138082168684048611161562000ed95762000ed962000e9a565b600160ff1b600087128281168783058912161562000efb5762000efb62000e9a565b6000871292508782058712848416161562000f1a5762000f1a62000e9a565b8785058712818416161562000f335762000f3362000e9a565b505050929093029392505050565b60008282101562000f565762000f5662000e9a565b500390565b600081600019048311821515161562000f785762000f7862000e9a565b500290565b6000821982111562000f935762000f9362000e9a565b500190565b60008262000fb657634e487b7160e01b600052601260045260246000fd5b500490565b60805160a05160c05160e051610100516141bd620011266000396000818161044f015281816104df01528181611d5d015281816124420152818161362101526136f20152600081816107330152611a1b01526000818161053c01526110660152600081816104a501528181611b370152818161248401528181612840015281816128f201528181612a5201526139560152600081816107fd015281816108710152818161093b01528181610aef01528181610b7d01528181610c7101528181610e1201528181610ece01528181610f5c015281816112d10152818161135f0152818161140d015281816114c1015281816115ce0152818161167b0152818161179401528181611841015281816118cf0152818161197b01528181611bdf01528181611c6d01528181611da901528181611e6501528181611f2101528181611faf015281816120d501528181612191015281816122f2015281816123ae01526124d801526141bd6000f3fe608060405234801561001057600080fd5b50600436106103f15760003560e01c8063753ed1bd11610215578063bc063e1a11610125578063d6f124f0116100b8578063f2f4eb2611610087578063f2f4eb26146107fb578063f3fef3a314610821578063fa9ee68b14610834578063fc81a12a1461083c578063ff2ca34c1461084f57600080fd5b8063d6f124f0146107c5578063e3d91a89146107cd578063edaafe20146107e0578063eddd0d9c146107e857600080fd5b8063d01b3de0116100f4578063d01b3de01461078f578063d0e30db014610797578063d2808cbd1461079f578063d3488442146107b257600080fd5b8063bc063e1a1461075e578063bf8c8e9e14610767578063cd85cdb51461077a578063cf63fc631461078257600080fd5b806393c61130116101a8578063b235d46811610177578063b235d46814610706578063b69ef8a814610713578063b7ad9f121461071b578063b91628951461072e578063ba82051b1461075557600080fd5b806393c61130146106e55780639635f75f146106ee578063ab1d1e74146106f6578063af3345d1146106fe57600080fd5b8063836efd31116101e4578063836efd31146106ae5780638456cb59146106c15780638f9e7f32146106c957806390e3ea5c146106dc57600080fd5b8063753ed1bd1461066d5780637adbf973146106765780637dc0d1d0146106895780637e4831d31461069c57600080fd5b80633611956c11610310578063538b40f2116102a35780635d841af5116102725780635d841af5146106235780635e3b96ef1461063657806367a33d7d146106495780636e791c831461065157806373ab1ddd1461066457600080fd5b8063538b40f2146105df5780635936b637146105fc5780635c975abb1461060f5780635c9ffc6e1461061a57600080fd5b806340695363116102df57806340695363146105a757806342501e01146105b057806344004cc1146105b95780634782f779146105cc57600080fd5b80633611956c146105685780633872cdb1146105805780633be8261b146105885780633f4ba83a1461059f57600080fd5b80631a8bd2da116103885780632b83cccd116103575780632b83cccd146105145780632ee2820b14610527578063315d2f5b1461053a57806332ec84d21461056057600080fd5b80631a8bd2da146104c95780631da03312146104d15780632495a599146104da578063254984011461050157600080fd5b80630c68f63b116103c45780630c68f63b1461044d5780630fa8d64514610487578063156e29f61461049057806317607ad9146104a357600080fd5b806303bd9edd146103f6578063077e5fe31461040b57806309debcec146104315780630ae7a8ed14610444575b600080fd5b610409610404366004613b17565b61085c565b005b61041e610419366004613b17565b610915565b6040519081526020015b60405180910390f35b61040961043f366004613b17565b610926565b61041e60045481565b7f00000000000000000000000000000000000000000000000000000000000000005b6040516001600160a01b039091168152602001610428565b61041e60065481565b61041e61049e366004613b45565b6109e2565b7f000000000000000000000000000000000000000000000000000000000000000061046f565b610409610ada565b61041e60015481565b61046f7f000000000000000000000000000000000000000000000000000000000000000081565b61040961050f366004613b7a565b610c5c565b61041e610522366004613b45565b610d18565b610409610535366004613b17565b610dfd565b7f000000000000000000000000000000000000000000000000000000000000000061046f565b610409610eb9565b610570611037565b6040519015158152602001610428565b61041e61104e565b6105906110da565b60405190518152602001610428565b6104096112bc565b61041e60125481565b61041e60025481565b6104096105c7366004613b97565b6113f8565b6104096105da366004613bd8565b6114ac565b6105e761159e565b60408051928352602083019190915201610428565b61040961060a366004613c12565b6115b9565b60005460ff16610570565b61041e600e5481565b610409610631366004613b17565b611666565b600f5461046f906001600160a01b031681565b61041e611722565b61059061065f366004613c2f565b611749565b61041e60095481565b61041e60135481565b610409610684366004613b7a565b61177f565b60075461046f906001600160a01b031681565b60115461057090610100900460ff1681565b60085461046f906001600160a01b031681565b61040961182c565b6104096106d7366004613b17565b611966565b61041e600c5481565b61041e60035481565b610409611aab565b61041e611b2b565b610409611bca565b6011546105709060ff1681565b61041e611d45565b610409610729366004613b17565b611d94565b61041e7f000000000000000000000000000000000000000000000000000000000000000081565b61041e600d5481565b61041e60105481565b610409610775366004613b7a565b611e50565b610409611f0c565b6005546105709060ff1681565b61057061208c565b61040961209f565b6104096107ad366004613b17565b6120c0565b6104096107c0366004613b17565b61217c565b610409612229565b61041e6107db366004613b17565b612293565b61041e61229e565b6104096107f6366004613b17565b6122dd565b7f000000000000000000000000000000000000000000000000000000000000000061046f565b61040961082f366004613bd8565b612399565b61041e61246c565b61057061084a366004613b7a565b6124bb565b600a546105709060ff1681565b604051631c86b03760e31b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063e43581b890602401602060405180830381865afa1580156108c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108e49190613c7f565b6109095760405162461bcd60e51b815260040161090090613c9c565b60405180910390fd5b610912816125f0565b50565b600061092082612636565b92915050565b604051631c86b03760e31b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063e43581b890602401602060405180830381865afa15801561098a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109ae9190613c7f565b806109bd57506109bd336124bb565b6109d95760405162461bcd60e51b815260040161090090613cdd565b61091281612699565b60006002600b541415610a375760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610900565b6002600b5560005460ff1615610a5f5760405162461bcd60e51b815260040161090090613d30565b601154610100900460ff1615610ac25760405162461bcd60e51b815260206004820152602260248201527f50656753746162696c6974794d6f64756c653a204d696e74696e672070617573604482015261195960f21b6064820152608401610900565b610acd8484846127b9565b6001600b55949350505050565b604051631c86b03760e31b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063e43581b890602401602060405180830381865afa158015610b3e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b629190613c7f565b80610bf05750604051630c68ba2160e01b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690630c68ba2190602401602060405180830381865afa158015610bcc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bf09190613c7f565b80610bff5750610bff336124bb565b610c1b5760405162461bcd60e51b815260040161090090613d5a565b6011805461ff00191690556040513381527fd772a9007742ba57886abe6ba82f5094ce4eaa4c1564be00395e5eb5cbc1298d906020015b60405180910390a1565b604051631c86b03760e31b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063e43581b890602401602060405180830381865afa158015610cc0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ce49190613c7f565b80610cf35750610cf3336124bb565b610d0f5760405162461bcd60e51b815260040161090090613cdd565b6109128161297c565b60006002600b541415610d6d5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610900565b6002600b5560005460ff1615610d955760405162461bcd60e51b815260040161090090613d30565b60115460ff1615610df25760405162461bcd60e51b815260206004820152602160248201527f50656753746162696c6974794d6f64756c653a2052656465656d2070617573656044820152601960fa1b6064820152608401610900565b610acd8484846129ce565b604051631c86b03760e31b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063e43581b890602401602060405180830381865afa158015610e61573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e859190613c7f565b80610e945750610e94336124bb565b610eb05760405162461bcd60e51b815260040161090090613cdd565b61091281612ad6565b604051631c86b03760e31b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063e43581b890602401602060405180830381865afa158015610f1d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f419190613c7f565b80610fcf5750604051630c68ba2160e01b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690630c68ba2190602401602060405180830381865afa158015610fab573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fcf9190613c7f565b80610fde5750610fde336124bb565b610ffa5760405162461bcd60e51b815260040161090090613d5a565b6011805460ff191660011790556040513381527f7dbbd5642e73390b48a9065df0cff2dcd86b417c0148e685cc921737630c848c90602001610c52565b60006110496110446110da565b612b7f565b905090565b6040516370a0823160e01b81523060048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a08231906024015b602060405180830381865afa1580156110b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110499190613dae565b604080516020810190915260008152600754604080516315f789a960e21b8152815160009384936001600160a01b03909116926357de26a492600480830193928290030181865afa158015611133573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111579190613dc7565b915091508015801561117357506008546001600160a01b031615155b156111e957600854604080516315f789a960e21b815281516001600160a01b03909316926357de26a4926004808401939192918290030181865afa1580156111bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111e39190613dc7565b90925090505b806112365760405162461bcd60e51b815260206004820152601960248201527f4f7261636c655265663a206f7261636c6520696e76616c6964000000000000006044820152606401610900565b600a5460ff161561124d5761124a82611749565b91505b600080600954121561128f5761127160095460001961126c9190613e54565b612bb8565b61127c90600a613fbd565b90506112888382612c0e565b92506112b4565b61129a600954612bb8565b6112a590600a613fbd565b90506112b18382612c36565b92505b509092915050565b604051631c86b03760e31b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063e43581b890602401602060405180830381865afa158015611320573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113449190613c7f565b806113d25750604051630c68ba2160e01b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690630c68ba2190602401602060405180830381865afa1580156113ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113d29190613c7f565b6113ee5760405162461bcd60e51b815260040161090090613fc9565b6113f6612c5e565b565b6040516330c34a1f60e11b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690636186943e90602401602060405180830381865afa15801561145c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114809190613c7f565b61149c5760405162461bcd60e51b815260040161090090614016565b6114a7838383612cec565b505050565b6040516330c34a1f60e11b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690636186943e90602401602060405180830381865afa158015611510573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115349190613c7f565b6115505760405162461bcd60e51b815260040161090090614016565b61155a8282612d5c565b6040518181526001600160a01b0383169033907f6b1f4ce962fec27598edceab6195c77516c3df32025eaf0c38d0d4009ac3bd489060200160405180910390a35050565b6000806115a9611d45565b6115b161246c565b915091509091565b604051631c86b03760e31b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063e43581b890602401602060405180830381865afa15801561161d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116419190613c7f565b61165d5760405162461bcd60e51b815260040161090090613c9c565b61091281612e75565b604051631c86b03760e31b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063e43581b890602401602060405180830381865afa1580156116ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116ee9190613c7f565b806116fd57506116fd336124bb565b6117195760405162461bcd60e51b815260040161090090613cdd565b61091281612ee3565b600061172f600e54612f8a565b61173f61173a611d45565b612f8a565b611049919061405d565b6040805160208082018352600080835283518083018552528251908101909252670de0b6b3a76400008252906109209083612ff4565b604051631c86b03760e31b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063e43581b890602401602060405180830381865afa1580156117e3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118079190613c7f565b6118235760405162461bcd60e51b815260040161090090613c9c565b61091281613029565b604051631c86b03760e31b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063e43581b890602401602060405180830381865afa158015611890573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118b49190613c7f565b806119425750604051630c68ba2160e01b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690630c68ba2190602401602060405180830381865afa15801561191e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119429190613c7f565b61195e5760405162461bcd60e51b815260040161090090613fc9565b6113f66130d1565b604051631c86b03760e31b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063e43581b890602401602060405180830381865afa1580156119ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119ee9190613c7f565b806119fd57506119fd336124bb565b611a195760405162461bcd60e51b815260040161090090613cdd565b7f0000000000000000000000000000000000000000000000000000000000000000811115611a9a5760405162461bcd60e51b815260206004820152602860248201527f526174654c696d697465643a20726174654c696d69745065725365636f6e64206044820152670e8dede40d0d2ced60c31b6064820152608401610900565b611aa2613129565b6109128161313a565b6000611ab5611722565b905060008113611b1a5760405162461bcd60e51b815260206004820152602a60248201527f50656753746162696c6974794d6f64756c653a204e6f20737572706c757320746044820152696f20616c6c6f6361746560b01b6064820152608401610900565b610912611b2682612bb8565b613178565b6000611b3561229e565b7f00000000000000000000000000000000000000000000000000000000000000006040516370a0823160e01b81523060048201526001600160a01b0391909116906370a0823190602401602060405180830381865afa158015611b9c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bc09190613dae565b611049919061409c565b604051631c86b03760e31b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063e43581b890602401602060405180830381865afa158015611c2e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c529190613c7f565b80611ce05750604051630c68ba2160e01b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690630c68ba2190602401602060405180830381865afa158015611cbc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ce09190613c7f565b80611cef5750611cef336124bb565b611d0b5760405162461bcd60e51b815260040161090090613d5a565b6011805460ff191690556040513381527f52199c9a84e8137486458d9d5d47455ac6a123b345ff11204badf27318dafdf190602001610c52565b6040516370a0823160e01b81523060048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401611099565b604051631c86b03760e31b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063e43581b890602401602060405180830381865afa158015611df8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e1c9190613c7f565b80611e2b5750611e2b336124bb565b611e475760405162461bcd60e51b815260040161090090613cdd565b610912816131c6565b604051631c86b03760e31b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063e43581b890602401602060405180830381865afa158015611eb4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ed89190613c7f565b80611ee75750611ee7336124bb565b611f035760405162461bcd60e51b815260040161090090613cdd565b610912816132eb565b604051631c86b03760e31b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063e43581b890602401602060405180830381865afa158015611f70573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f949190613c7f565b806120225750604051630c68ba2160e01b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690630c68ba2190602401602060405180830381865afa158015611ffe573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120229190613c7f565b806120315750612031336124bb565b61204d5760405162461bcd60e51b815260040161090090613d5a565b6011805461ff0019166101001790556040513381527f35365f539a67058ad0735a24a50fe45b0ee05207919e9f4a2f60d855f55e0c0e90602001610c52565b6000600e54612099611d45565b11905090565b60006120a9611722565b9050600081131561091257610912611b2682612bb8565b604051631c86b03760e31b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063e43581b890602401602060405180830381865afa158015612124573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121489190613c7f565b806121575750612157336124bb565b6121735760405162461bcd60e51b815260040161090090613cdd565b610912816133b2565b604051631c86b03760e31b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063e43581b890602401602060405180830381865afa1580156121e0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122049190613c7f565b6122205760405162461bcd60e51b815260040161090090613c9c565b610912816133f8565b600760009054906101000a90046001600160a01b03166001600160a01b031663a2e620456040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561227957600080fd5b505af115801561228d573d6000803e3d6000fd5b50505050565b600061092082613431565b600080600354426122af91906140b4565b90506122d7816002546122c291906140cb565b6006546122cf919061409c565b6004546125c0565b91505090565b604051631c86b03760e31b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063e43581b890602401602060405180830381865afa158015612341573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123659190613c7f565b806123745750612374336124bb565b6123905760405162461bcd60e51b815260040161090090613cdd565b6109128161347e565b6040516330c34a1f60e11b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690636186943e90602401602060405180830381865afa1580156123fd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124219190613c7f565b61243d5760405162461bcd60e51b815260040161090090614016565b6124687f00000000000000000000000000000000000000000000000000000000000000008383612cec565b5050565b6040516370a0823160e01b81523060048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401611099565b600154604051632474521560e21b81526000916001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016916391d148549161251f9186906004019182526001600160a01b0316602082015260400190565b602060405180830381865afa15801561253c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109209190613c7f565b604080516020810190915260008152604051806020016040528061258d85670de0b6b3a764000086613523565b90529392505050565b60006125a28383613539565b6002149392505050565b60006125b88383613539565b159392505050565b60008183106125cf57816125d1565b825b9392505050565b60006125d182846140cb565b60006125d182846140ea565b600980549082905560408051828152602081018490527fc45ec9015c033bb1ee553a67346dd851062dddce070a6dddb7616e5d7595bcc291015b60405180910390a15050565b6000806126416110da565b905061264c8161356b565b600061267d612710600d5461271061266491906140b4565b61266e90876140cb565b61267891906140ea565b6135d0565b905061269161268c8284612ff4565b613605565b949350505050565b806126f05760405162461bcd60e51b815260206004820152602160248201527f50656753746162696c6974794d6f64756c653a20696e76616c696420666c6f6f6044820152603960f91b6064820152608401610900565b612713612701601354612710612560565b61270d83612710612560565b906125ac565b61277b5760405162461bcd60e51b815260206004820152603360248201527f50656753746162696c6974794d6f64756c653a20666c6f6f72206d757374206260448201527265206c657373207468616e206365696c696e6760681b6064820152608401610900565b601280549082905560408051828152602081018490527fa91829da8506bd47a58affb492ad10b559a97ce6fefc606c084df3d22f83dd90910161262a565b60006127c3612229565b6127cc83613431565b90508181101561282e5760405162461bcd60e51b815260206004820152602760248201527f50656753746162696c6974794d6f64756c653a204d696e74206e6f7420656e6f6044820152661d59da081bdd5d60ca1b6064820152608401610900565b61283933308561361c565b60006128cf7f00000000000000000000000000000000000000000000000000000000000000006040516370a0823160e01b81523060048201526001600160a01b0391909116906370a0823190602401602060405180830381865afa1580156128a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128c99190613dae565b836125c0565b905060006128dd82846140b4565b90508115612919576129196001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168784613648565b80156129295761292986826136ab565b604080516001600160a01b0388168152602081018790529081018490527f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f9060600160405180910390a150509392505050565b600880546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f492cc1f8400b642b4e56de46ed10d314a49bf3e0594c43e2e5947c1e1733645b90600090a35050565b60006129d8612229565b6129e183612636565b905081811015612a455760405162461bcd60e51b815260206004820152602960248201527f50656753746162696c6974794d6f64756c653a2052656465656d206e6f7420656044820152681b9bdd59da081bdd5d60ba1b6064820152608401610900565b612a7a6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163330866136b5565b612a8484826136ed565b604080516001600160a01b0386168152602081018590529081018290527fe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929906060015b60405180910390a19392505050565b60008111612b415760405162461bcd60e51b815260206004820152603260248201527f50656753746162696c6974794d6f64756c653a20496e76616c6964206e6577206044820152711c995cd95c9d995cc81d1a1c995cda1bdb1960721b6064820152608401610900565b600e80549082905560408051828152602081018490527f11f873e0db7952f2f3eab9ad99121a8661e39c5cb67d33d51665f9f3e75d799e910161262a565b6000612b99612b92601254612710612560565b8390612596565b80156109205750610920612bb1601354612710612560565b83906125ac565b600080821215612c0a5760405162461bcd60e51b815260206004820181905260248201527f53616665436173743a2076616c7565206d75737420626520706f7369746976656044820152606401610900565b5090565b60408051602081019091526000815260408051602081019091528351819061258d90856125e4565b60408051602081019091526000815260408051602081019091528351819061258d90856125d8565b60005460ff16612ca75760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610900565b6000805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b039091168152602001610c52565b612d006001600160a01b0384168383613648565b816001600160a01b0316836001600160a01b0316336001600160a01b03167f08c1fcaf583c2b413bb27833685230422583405ae651b6d53e2053bf75bd074084604051612d4f91815260200190565b60405180910390a4505050565b80471015612dac5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610900565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114612df9576040519150601f19603f3d011682016040523d82523d6000602084013e612dfe565b606091505b50509050806114a75760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610900565b600a805482151560ff198216811790925560ff169081151514612eaa57612eaa600954600019612ea59190613e54565b6125f0565b60408051821515815283151560208201527f16b9ae7ca814a6dfd3357b20f33bcc7c194676988d5da46846628da394df8ab3910161262a565b601054811115612f4c5760405162461bcd60e51b815260206004820152602e60248201527f50656753746162696c6974794d6f64756c653a2052656465656d20666565206560448201526d786365656473206d61782066656560901b6064820152608401610900565b600d80549082905560408051828152602081018490527f288d91cad90f9c412f12c0869aa634660d8403c9590aa55fd5035212c6f98c95910161262a565b60006001600160ff1b03821115612c0a5760405162461bcd60e51b815260206004820152602860248201527f53616665436173743a2076616c756520646f65736e27742066697420696e2061604482015267371034b73a191a9b60c11b6064820152608401610900565b604080516020810190915260008152604051806020016040528061258d8560000151670de0b6b3a76400008660000151613523565b6001600160a01b03811661307f5760405162461bcd60e51b815260206004820152601760248201527f4f7261636c655265663a207a65726f20616464726573730000000000000000006044820152606401610900565b600780546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f93450534569bdbb3109b44eef77c9b236897f4caa4f201be10252d6462a5693790600090a35050565b60005460ff16156130f45760405162461bcd60e51b815260040161090090613d30565b6000805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612cd43390565b61313161229e565b60065542600355565b600280549082905560408051828152602081018490527fc1d6758c9eb8ba949914722321f508e4cd1e14d3ff96773ef5950336d8a2c63a910161262a565b600f5461318e906001600160a01b0316826136ed565b60405181815233907f26b1c64768593a5154cde08c3114534f1c582b6cb597bd6c0c29587f48c2004f9060200160405180910390a250565b8061321f5760405162461bcd60e51b815260206004820152602360248201527f50656753746162696c6974794d6f64756c653a20696e76616c6964206365696c604482015262696e6760e81b6064820152608401610900565b613242613230601254612710612560565b61323c83612710612560565b90612596565b6132ad5760405162461bcd60e51b815260206004820152603660248201527f50656753746162696c6974794d6f64756c653a206365696c696e67206d7573746044820152751031329033b932b0ba32b9103a3430b710333637b7b960511b6064820152608401610900565b601380549082905560408051828152602081018490527f15ddf2d8b0f5def2d9096715ee6dbe8646cd0a5c0225c781525b943244e1a7a3910161262a565b6001600160a01b0381166133585760405162461bcd60e51b815260206004820152602e60248201527f50656753746162696c6974794d6f64756c653a20496e76616c6964206e65772060448201526d1cdd5c9c1b1d5cc81d185c99d95d60921b6064820152608401610900565b600f80546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f70dc5d19a845312f7e3a89f1894fe84155cbd0a1f8434ebf02d9de842d982325910161262a565b6133ba613129565b600480549082905560408051828152602081018490527f52d0e582769dcd1e242b38b9a795ef4699f2eca0f23b1d8f94368efb27bcd5ff910161262a565b6001805490829055604051829082907f29ddd278ef9169e35aa84e424b39048b89af9c0b50f85497e40f97dff6946cf590600090a35050565b60008061343c6110da565b90506134478161356b565b60006134538285612c36565b905061269161268c612710613478600c5461271061347191906140b4565b8590612c36565b90612c0e565b6010548111156134e55760405162461bcd60e51b815260206004820152602c60248201527f50656753746162696c6974794d6f64756c653a204d696e74206665652065786360448201526b65656473206d61782066656560a01b6064820152608401610900565b600c80549082905560408051828152602081018490527f06255fba5f99bcc77a5d27ee1222dd110e196ad4cfba488e1fceccbec8dedc68910161262a565b60006126918261353386866125d8565b906125e4565b80518251600091141561354e57506001610920565b815183511161355e576000613561565b60025b60ff169392505050565b61357481612b7f565b6109125760405162461bcd60e51b815260206004820152602760248201527f50656753746162696c6974794d6f64756c653a207072696365206f7574206f6660448201526620626f756e647360c81b6064820152608401610900565b6040805160208101909152600081526040805160208101909152806135fd84670de0b6b3a76400006125d8565b905292915050565b805160009061092090670de0b6b3a76400006125e4565b6114a77f00000000000000000000000000000000000000000000000000000000000000008484846136b5565b6040516001600160a01b0383166024820152604481018290526114a790849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613718565b61246882826137ea565b6040516001600160a01b038085166024830152831660448201526064810182905261228d9085906323b872dd60e01b90608401613674565b6124687f00000000000000000000000000000000000000000000000000000000000000008383613648565b600061376d826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166138019092919063ffffffff16565b8051909150156114a7578080602001905181019061378b9190613c7f565b6114a75760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610900565b60006137f582613810565b90506114a7838261392a565b606061269184846000856139b6565b60008061381b61229e565b600554909150839060ff16801561383157508181115b156138395750805b816138905760405162461bcd60e51b815260206004820152602160248201527f526174654c696d697465643a206e6f2072617465206c696d69742062756666656044820152603960f91b6064820152608401610900565b818111156138e05760405162461bcd60e51b815260206004820152601b60248201527f526174654c696d697465643a2072617465206c696d69742068697400000000006044820152606401610900565b6138ea81836140b4565b6006819055426003556040805183815260208101929092527fc89b99870f6dd9f35bdd8bada9a4e2a6ba2862d2b5be9eaf54f6b8a6987368fe9101612ac7565b8015612468576040516340c10f1960e01b81526001600160a01b038381166004830152602482018390527f000000000000000000000000000000000000000000000000000000000000000016906340c10f1990604401600060405180830381600087803b15801561399a57600080fd5b505af11580156139ae573d6000803e3d6000fd5b505050505050565b606082471015613a175760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610900565b843b613a655760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610900565b600080866001600160a01b03168587604051613a819190614138565b60006040518083038185875af1925050503d8060008114613abe576040519150601f19603f3d011682016040523d82523d6000602084013e613ac3565b606091505b5091509150613ad3828286613ade565b979650505050505050565b60608315613aed5750816125d1565b825115613afd5782518084602001fd5b8160405162461bcd60e51b81526004016109009190614154565b600060208284031215613b2957600080fd5b5035919050565b6001600160a01b038116811461091257600080fd5b600080600060608486031215613b5a57600080fd5b8335613b6581613b30565b95602085013595506040909401359392505050565b600060208284031215613b8c57600080fd5b81356125d181613b30565b600080600060608486031215613bac57600080fd5b8335613bb781613b30565b92506020840135613bc781613b30565b929592945050506040919091013590565b60008060408385031215613beb57600080fd5b8235613bf681613b30565b946020939093013593505050565b801515811461091257600080fd5b600060208284031215613c2457600080fd5b81356125d181613c04565b600060208284031215613c4157600080fd5b6040516020810181811067ffffffffffffffff82111715613c7257634e487b7160e01b600052604160045260246000fd5b6040529135825250919050565b600060208284031215613c9157600080fd5b81516125d181613c04565b60208082526021908201527f436f72655265663a2043616c6c6572206973206e6f74206120676f7665726e6f6040820152603960f91b606082015260800190565b60208082526033908201527f436f72655265663a2043616c6c6572206973206e6f74206120676f7665726e6f604082015272391037b91031b7b73a3930b1ba1030b236b4b760691b606082015260800190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b60208082526034908201527f436f72655265663a2043616c6c6572206973206e6f7420676f7665726e6f722060408201527337b91033bab0b93234b0b71037b91030b236b4b760611b606082015260800190565b600060208284031215613dc057600080fd5b5051919050565b6000808284036040811215613ddb57600080fd5b6020811215613de957600080fd5b506040516020810181811067ffffffffffffffff82111715613e1b57634e487b7160e01b600052604160045260246000fd5b604052835181526020840151909250613e3381613c04565b809150509250929050565b634e487b7160e01b600052601160045260246000fd5b60006001600160ff1b0381841382841380821686840486111615613e7a57613e7a613e3e565b600160ff1b6000871282811687830589121615613e9957613e99613e3e565b60008712925087820587128484161615613eb557613eb5613e3e565b87850587128184161615613ecb57613ecb613e3e565b505050929093029392505050565b600181815b80851115613f14578160001904821115613efa57613efa613e3e565b80851615613f0757918102915b93841c9390800290613ede565b509250929050565b600082613f2b57506001610920565b81613f3857506000610920565b8160018114613f4e5760028114613f5857613f74565b6001915050610920565b60ff841115613f6957613f69613e3e565b50506001821b610920565b5060208310610133831016604e8410600b8410161715613f97575081810a610920565b613fa18383613ed9565b8060001904821115613fb557613fb5613e3e565b029392505050565b60006125d18383613f1c565b6020808252602d908201527f436f72655265663a2043616c6c6572206973206e6f742061206775617264696160408201526c371037b91033b7bb32b93737b960991b606082015260800190565b60208082526027908201527f436f72655265663a2043616c6c6572206973206e6f7420612050435620636f6e6040820152663a3937b63632b960c91b606082015260800190565b60008083128015600160ff1b85018412161561407b5761407b613e3e565b6001600160ff1b038401831381161561409657614096613e3e565b50500390565b600082198211156140af576140af613e3e565b500190565b6000828210156140c6576140c6613e3e565b500390565b60008160001904831182151516156140e5576140e5613e3e565b500290565b60008261410757634e487b7160e01b600052601260045260246000fd5b500490565b60005b8381101561412757818101518382015260200161410f565b8381111561228d5750506000910152565b6000825161414a81846020870161410c565b9190910192915050565b602081526000825180602084015261417381604085016020870161410c565b601f01601f1916919091016040019291505056fea2646970667358221220d6fe5f8c946bd1baf6f5aeca46e7c22c691d50d1815e41adec54ea705b77792964736f6c634300080a003350656753746162696c6974794d6f64756c653a20496e76616c6964206e657720000000000000000000000000000000000000000000000000001ff973cafa8000000000000000000000000000000000000000000000000000002386f26fc10000000000000000000000000000ec7ad284f7ad256b64c6e69b84eb0f48f42e819600000000000000000000000084dc71500d504163a87756db6368cc8bb654592f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000001e0000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000021e19e0c9bab2400000000000000000000000000000000000000000000000084595161401484a000000000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000febdf448c8484834bb399d930d7e1bdc773e23ba

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106103f15760003560e01c8063753ed1bd11610215578063bc063e1a11610125578063d6f124f0116100b8578063f2f4eb2611610087578063f2f4eb26146107fb578063f3fef3a314610821578063fa9ee68b14610834578063fc81a12a1461083c578063ff2ca34c1461084f57600080fd5b8063d6f124f0146107c5578063e3d91a89146107cd578063edaafe20146107e0578063eddd0d9c146107e857600080fd5b8063d01b3de0116100f4578063d01b3de01461078f578063d0e30db014610797578063d2808cbd1461079f578063d3488442146107b257600080fd5b8063bc063e1a1461075e578063bf8c8e9e14610767578063cd85cdb51461077a578063cf63fc631461078257600080fd5b806393c61130116101a8578063b235d46811610177578063b235d46814610706578063b69ef8a814610713578063b7ad9f121461071b578063b91628951461072e578063ba82051b1461075557600080fd5b806393c61130146106e55780639635f75f146106ee578063ab1d1e74146106f6578063af3345d1146106fe57600080fd5b8063836efd31116101e4578063836efd31146106ae5780638456cb59146106c15780638f9e7f32146106c957806390e3ea5c146106dc57600080fd5b8063753ed1bd1461066d5780637adbf973146106765780637dc0d1d0146106895780637e4831d31461069c57600080fd5b80633611956c11610310578063538b40f2116102a35780635d841af5116102725780635d841af5146106235780635e3b96ef1461063657806367a33d7d146106495780636e791c831461065157806373ab1ddd1461066457600080fd5b8063538b40f2146105df5780635936b637146105fc5780635c975abb1461060f5780635c9ffc6e1461061a57600080fd5b806340695363116102df57806340695363146105a757806342501e01146105b057806344004cc1146105b95780634782f779146105cc57600080fd5b80633611956c146105685780633872cdb1146105805780633be8261b146105885780633f4ba83a1461059f57600080fd5b80631a8bd2da116103885780632b83cccd116103575780632b83cccd146105145780632ee2820b14610527578063315d2f5b1461053a57806332ec84d21461056057600080fd5b80631a8bd2da146104c95780631da03312146104d15780632495a599146104da578063254984011461050157600080fd5b80630c68f63b116103c45780630c68f63b1461044d5780630fa8d64514610487578063156e29f61461049057806317607ad9146104a357600080fd5b806303bd9edd146103f6578063077e5fe31461040b57806309debcec146104315780630ae7a8ed14610444575b600080fd5b610409610404366004613b17565b61085c565b005b61041e610419366004613b17565b610915565b6040519081526020015b60405180910390f35b61040961043f366004613b17565b610926565b61041e60045481565b7f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb485b6040516001600160a01b039091168152602001610428565b61041e60065481565b61041e61049e366004613b45565b6109e2565b7f000000000000000000000000559ebc30b0e58a45cc9ff573f77ef1e5eb1b3e1861046f565b610409610ada565b61041e60015481565b61046f7f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4881565b61040961050f366004613b7a565b610c5c565b61041e610522366004613b45565b610d18565b610409610535366004613b17565b610dfd565b7f000000000000000000000000000000000000000000000000000000000000000061046f565b610409610eb9565b610570611037565b6040519015158152602001610428565b61041e61104e565b6105906110da565b60405190518152602001610428565b6104096112bc565b61041e60125481565b61041e60025481565b6104096105c7366004613b97565b6113f8565b6104096105da366004613bd8565b6114ac565b6105e761159e565b60408051928352602083019190915201610428565b61040961060a366004613c12565b6115b9565b60005460ff16610570565b61041e600e5481565b610409610631366004613b17565b611666565b600f5461046f906001600160a01b031681565b61041e611722565b61059061065f366004613c2f565b611749565b61041e60095481565b61041e60135481565b610409610684366004613b7a565b61177f565b60075461046f906001600160a01b031681565b60115461057090610100900460ff1681565b60085461046f906001600160a01b031681565b61040961182c565b6104096106d7366004613b17565b611966565b61041e600c5481565b61041e60035481565b610409611aab565b61041e611b2b565b610409611bca565b6011546105709060ff1681565b61041e611d45565b610409610729366004613b17565b611d94565b61041e7f00000000000000000000000000000000000000000000021e19e0c9bab240000081565b61041e600d5481565b61041e60105481565b610409610775366004613b7a565b611e50565b610409611f0c565b6005546105709060ff1681565b61057061208c565b61040961209f565b6104096107ad366004613b17565b6120c0565b6104096107c0366004613b17565b61217c565b610409612229565b61041e6107db366004613b17565b612293565b61041e61229e565b6104096107f6366004613b17565b6122dd565b7f000000000000000000000000ec7ad284f7ad256b64c6e69b84eb0f48f42e819661046f565b61040961082f366004613bd8565b612399565b61041e61246c565b61057061084a366004613b7a565b6124bb565b600a546105709060ff1681565b604051631c86b03760e31b81523360048201527f000000000000000000000000ec7ad284f7ad256b64c6e69b84eb0f48f42e81966001600160a01b03169063e43581b890602401602060405180830381865afa1580156108c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108e49190613c7f565b6109095760405162461bcd60e51b815260040161090090613c9c565b60405180910390fd5b610912816125f0565b50565b600061092082612636565b92915050565b604051631c86b03760e31b81523360048201527f000000000000000000000000ec7ad284f7ad256b64c6e69b84eb0f48f42e81966001600160a01b03169063e43581b890602401602060405180830381865afa15801561098a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109ae9190613c7f565b806109bd57506109bd336124bb565b6109d95760405162461bcd60e51b815260040161090090613cdd565b61091281612699565b60006002600b541415610a375760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610900565b6002600b5560005460ff1615610a5f5760405162461bcd60e51b815260040161090090613d30565b601154610100900460ff1615610ac25760405162461bcd60e51b815260206004820152602260248201527f50656753746162696c6974794d6f64756c653a204d696e74696e672070617573604482015261195960f21b6064820152608401610900565b610acd8484846127b9565b6001600b55949350505050565b604051631c86b03760e31b81523360048201527f000000000000000000000000ec7ad284f7ad256b64c6e69b84eb0f48f42e81966001600160a01b03169063e43581b890602401602060405180830381865afa158015610b3e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b629190613c7f565b80610bf05750604051630c68ba2160e01b81523360048201527f000000000000000000000000ec7ad284f7ad256b64c6e69b84eb0f48f42e81966001600160a01b031690630c68ba2190602401602060405180830381865afa158015610bcc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bf09190613c7f565b80610bff5750610bff336124bb565b610c1b5760405162461bcd60e51b815260040161090090613d5a565b6011805461ff00191690556040513381527fd772a9007742ba57886abe6ba82f5094ce4eaa4c1564be00395e5eb5cbc1298d906020015b60405180910390a1565b604051631c86b03760e31b81523360048201527f000000000000000000000000ec7ad284f7ad256b64c6e69b84eb0f48f42e81966001600160a01b03169063e43581b890602401602060405180830381865afa158015610cc0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ce49190613c7f565b80610cf35750610cf3336124bb565b610d0f5760405162461bcd60e51b815260040161090090613cdd565b6109128161297c565b60006002600b541415610d6d5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610900565b6002600b5560005460ff1615610d955760405162461bcd60e51b815260040161090090613d30565b60115460ff1615610df25760405162461bcd60e51b815260206004820152602160248201527f50656753746162696c6974794d6f64756c653a2052656465656d2070617573656044820152601960fa1b6064820152608401610900565b610acd8484846129ce565b604051631c86b03760e31b81523360048201527f000000000000000000000000ec7ad284f7ad256b64c6e69b84eb0f48f42e81966001600160a01b03169063e43581b890602401602060405180830381865afa158015610e61573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e859190613c7f565b80610e945750610e94336124bb565b610eb05760405162461bcd60e51b815260040161090090613cdd565b61091281612ad6565b604051631c86b03760e31b81523360048201527f000000000000000000000000ec7ad284f7ad256b64c6e69b84eb0f48f42e81966001600160a01b03169063e43581b890602401602060405180830381865afa158015610f1d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f419190613c7f565b80610fcf5750604051630c68ba2160e01b81523360048201527f000000000000000000000000ec7ad284f7ad256b64c6e69b84eb0f48f42e81966001600160a01b031690630c68ba2190602401602060405180830381865afa158015610fab573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fcf9190613c7f565b80610fde5750610fde336124bb565b610ffa5760405162461bcd60e51b815260040161090090613d5a565b6011805460ff191660011790556040513381527f7dbbd5642e73390b48a9065df0cff2dcd86b417c0148e685cc921737630c848c90602001610c52565b60006110496110446110da565b612b7f565b905090565b6040516370a0823160e01b81523060048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a08231906024015b602060405180830381865afa1580156110b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110499190613dae565b604080516020810190915260008152600754604080516315f789a960e21b8152815160009384936001600160a01b03909116926357de26a492600480830193928290030181865afa158015611133573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111579190613dc7565b915091508015801561117357506008546001600160a01b031615155b156111e957600854604080516315f789a960e21b815281516001600160a01b03909316926357de26a4926004808401939192918290030181865afa1580156111bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111e39190613dc7565b90925090505b806112365760405162461bcd60e51b815260206004820152601960248201527f4f7261636c655265663a206f7261636c6520696e76616c6964000000000000006044820152606401610900565b600a5460ff161561124d5761124a82611749565b91505b600080600954121561128f5761127160095460001961126c9190613e54565b612bb8565b61127c90600a613fbd565b90506112888382612c0e565b92506112b4565b61129a600954612bb8565b6112a590600a613fbd565b90506112b18382612c36565b92505b509092915050565b604051631c86b03760e31b81523360048201527f000000000000000000000000ec7ad284f7ad256b64c6e69b84eb0f48f42e81966001600160a01b03169063e43581b890602401602060405180830381865afa158015611320573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113449190613c7f565b806113d25750604051630c68ba2160e01b81523360048201527f000000000000000000000000ec7ad284f7ad256b64c6e69b84eb0f48f42e81966001600160a01b031690630c68ba2190602401602060405180830381865afa1580156113ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113d29190613c7f565b6113ee5760405162461bcd60e51b815260040161090090613fc9565b6113f6612c5e565b565b6040516330c34a1f60e11b81523360048201527f000000000000000000000000ec7ad284f7ad256b64c6e69b84eb0f48f42e81966001600160a01b031690636186943e90602401602060405180830381865afa15801561145c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114809190613c7f565b61149c5760405162461bcd60e51b815260040161090090614016565b6114a7838383612cec565b505050565b6040516330c34a1f60e11b81523360048201527f000000000000000000000000ec7ad284f7ad256b64c6e69b84eb0f48f42e81966001600160a01b031690636186943e90602401602060405180830381865afa158015611510573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115349190613c7f565b6115505760405162461bcd60e51b815260040161090090614016565b61155a8282612d5c565b6040518181526001600160a01b0383169033907f6b1f4ce962fec27598edceab6195c77516c3df32025eaf0c38d0d4009ac3bd489060200160405180910390a35050565b6000806115a9611d45565b6115b161246c565b915091509091565b604051631c86b03760e31b81523360048201527f000000000000000000000000ec7ad284f7ad256b64c6e69b84eb0f48f42e81966001600160a01b03169063e43581b890602401602060405180830381865afa15801561161d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116419190613c7f565b61165d5760405162461bcd60e51b815260040161090090613c9c565b61091281612e75565b604051631c86b03760e31b81523360048201527f000000000000000000000000ec7ad284f7ad256b64c6e69b84eb0f48f42e81966001600160a01b03169063e43581b890602401602060405180830381865afa1580156116ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116ee9190613c7f565b806116fd57506116fd336124bb565b6117195760405162461bcd60e51b815260040161090090613cdd565b61091281612ee3565b600061172f600e54612f8a565b61173f61173a611d45565b612f8a565b611049919061405d565b6040805160208082018352600080835283518083018552528251908101909252670de0b6b3a76400008252906109209083612ff4565b604051631c86b03760e31b81523360048201527f000000000000000000000000ec7ad284f7ad256b64c6e69b84eb0f48f42e81966001600160a01b03169063e43581b890602401602060405180830381865afa1580156117e3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118079190613c7f565b6118235760405162461bcd60e51b815260040161090090613c9c565b61091281613029565b604051631c86b03760e31b81523360048201527f000000000000000000000000ec7ad284f7ad256b64c6e69b84eb0f48f42e81966001600160a01b03169063e43581b890602401602060405180830381865afa158015611890573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118b49190613c7f565b806119425750604051630c68ba2160e01b81523360048201527f000000000000000000000000ec7ad284f7ad256b64c6e69b84eb0f48f42e81966001600160a01b031690630c68ba2190602401602060405180830381865afa15801561191e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119429190613c7f565b61195e5760405162461bcd60e51b815260040161090090613fc9565b6113f66130d1565b604051631c86b03760e31b81523360048201527f000000000000000000000000ec7ad284f7ad256b64c6e69b84eb0f48f42e81966001600160a01b03169063e43581b890602401602060405180830381865afa1580156119ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119ee9190613c7f565b806119fd57506119fd336124bb565b611a195760405162461bcd60e51b815260040161090090613cdd565b7f00000000000000000000000000000000000000000000021e19e0c9bab2400000811115611a9a5760405162461bcd60e51b815260206004820152602860248201527f526174654c696d697465643a20726174654c696d69745065725365636f6e64206044820152670e8dede40d0d2ced60c31b6064820152608401610900565b611aa2613129565b6109128161313a565b6000611ab5611722565b905060008113611b1a5760405162461bcd60e51b815260206004820152602a60248201527f50656753746162696c6974794d6f64756c653a204e6f20737572706c757320746044820152696f20616c6c6f6361746560b01b6064820152608401610900565b610912611b2682612bb8565b613178565b6000611b3561229e565b7f000000000000000000000000559ebc30b0e58a45cc9ff573f77ef1e5eb1b3e186040516370a0823160e01b81523060048201526001600160a01b0391909116906370a0823190602401602060405180830381865afa158015611b9c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bc09190613dae565b611049919061409c565b604051631c86b03760e31b81523360048201527f000000000000000000000000ec7ad284f7ad256b64c6e69b84eb0f48f42e81966001600160a01b03169063e43581b890602401602060405180830381865afa158015611c2e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c529190613c7f565b80611ce05750604051630c68ba2160e01b81523360048201527f000000000000000000000000ec7ad284f7ad256b64c6e69b84eb0f48f42e81966001600160a01b031690630c68ba2190602401602060405180830381865afa158015611cbc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ce09190613c7f565b80611cef5750611cef336124bb565b611d0b5760405162461bcd60e51b815260040161090090613d5a565b6011805460ff191690556040513381527f52199c9a84e8137486458d9d5d47455ac6a123b345ff11204badf27318dafdf190602001610c52565b6040516370a0823160e01b81523060048201526000907f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb486001600160a01b0316906370a0823190602401611099565b604051631c86b03760e31b81523360048201527f000000000000000000000000ec7ad284f7ad256b64c6e69b84eb0f48f42e81966001600160a01b03169063e43581b890602401602060405180830381865afa158015611df8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e1c9190613c7f565b80611e2b5750611e2b336124bb565b611e475760405162461bcd60e51b815260040161090090613cdd565b610912816131c6565b604051631c86b03760e31b81523360048201527f000000000000000000000000ec7ad284f7ad256b64c6e69b84eb0f48f42e81966001600160a01b03169063e43581b890602401602060405180830381865afa158015611eb4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ed89190613c7f565b80611ee75750611ee7336124bb565b611f035760405162461bcd60e51b815260040161090090613cdd565b610912816132eb565b604051631c86b03760e31b81523360048201527f000000000000000000000000ec7ad284f7ad256b64c6e69b84eb0f48f42e81966001600160a01b03169063e43581b890602401602060405180830381865afa158015611f70573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f949190613c7f565b806120225750604051630c68ba2160e01b81523360048201527f000000000000000000000000ec7ad284f7ad256b64c6e69b84eb0f48f42e81966001600160a01b031690630c68ba2190602401602060405180830381865afa158015611ffe573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120229190613c7f565b806120315750612031336124bb565b61204d5760405162461bcd60e51b815260040161090090613d5a565b6011805461ff0019166101001790556040513381527f35365f539a67058ad0735a24a50fe45b0ee05207919e9f4a2f60d855f55e0c0e90602001610c52565b6000600e54612099611d45565b11905090565b60006120a9611722565b9050600081131561091257610912611b2682612bb8565b604051631c86b03760e31b81523360048201527f000000000000000000000000ec7ad284f7ad256b64c6e69b84eb0f48f42e81966001600160a01b03169063e43581b890602401602060405180830381865afa158015612124573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121489190613c7f565b806121575750612157336124bb565b6121735760405162461bcd60e51b815260040161090090613cdd565b610912816133b2565b604051631c86b03760e31b81523360048201527f000000000000000000000000ec7ad284f7ad256b64c6e69b84eb0f48f42e81966001600160a01b03169063e43581b890602401602060405180830381865afa1580156121e0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122049190613c7f565b6122205760405162461bcd60e51b815260040161090090613c9c565b610912816133f8565b600760009054906101000a90046001600160a01b03166001600160a01b031663a2e620456040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561227957600080fd5b505af115801561228d573d6000803e3d6000fd5b50505050565b600061092082613431565b600080600354426122af91906140b4565b90506122d7816002546122c291906140cb565b6006546122cf919061409c565b6004546125c0565b91505090565b604051631c86b03760e31b81523360048201527f000000000000000000000000ec7ad284f7ad256b64c6e69b84eb0f48f42e81966001600160a01b03169063e43581b890602401602060405180830381865afa158015612341573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123659190613c7f565b806123745750612374336124bb565b6123905760405162461bcd60e51b815260040161090090613cdd565b6109128161347e565b6040516330c34a1f60e11b81523360048201527f000000000000000000000000ec7ad284f7ad256b64c6e69b84eb0f48f42e81966001600160a01b031690636186943e90602401602060405180830381865afa1580156123fd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124219190613c7f565b61243d5760405162461bcd60e51b815260040161090090614016565b6124687f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb488383612cec565b5050565b6040516370a0823160e01b81523060048201526000907f000000000000000000000000559ebc30b0e58a45cc9ff573f77ef1e5eb1b3e186001600160a01b0316906370a0823190602401611099565b600154604051632474521560e21b81526000916001600160a01b037f000000000000000000000000ec7ad284f7ad256b64c6e69b84eb0f48f42e819616916391d148549161251f9186906004019182526001600160a01b0316602082015260400190565b602060405180830381865afa15801561253c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109209190613c7f565b604080516020810190915260008152604051806020016040528061258d85670de0b6b3a764000086613523565b90529392505050565b60006125a28383613539565b6002149392505050565b60006125b88383613539565b159392505050565b60008183106125cf57816125d1565b825b9392505050565b60006125d182846140cb565b60006125d182846140ea565b600980549082905560408051828152602081018490527fc45ec9015c033bb1ee553a67346dd851062dddce070a6dddb7616e5d7595bcc291015b60405180910390a15050565b6000806126416110da565b905061264c8161356b565b600061267d612710600d5461271061266491906140b4565b61266e90876140cb565b61267891906140ea565b6135d0565b905061269161268c8284612ff4565b613605565b949350505050565b806126f05760405162461bcd60e51b815260206004820152602160248201527f50656753746162696c6974794d6f64756c653a20696e76616c696420666c6f6f6044820152603960f91b6064820152608401610900565b612713612701601354612710612560565b61270d83612710612560565b906125ac565b61277b5760405162461bcd60e51b815260206004820152603360248201527f50656753746162696c6974794d6f64756c653a20666c6f6f72206d757374206260448201527265206c657373207468616e206365696c696e6760681b6064820152608401610900565b601280549082905560408051828152602081018490527fa91829da8506bd47a58affb492ad10b559a97ce6fefc606c084df3d22f83dd90910161262a565b60006127c3612229565b6127cc83613431565b90508181101561282e5760405162461bcd60e51b815260206004820152602760248201527f50656753746162696c6974794d6f64756c653a204d696e74206e6f7420656e6f6044820152661d59da081bdd5d60ca1b6064820152608401610900565b61283933308561361c565b60006128cf7f000000000000000000000000559ebc30b0e58a45cc9ff573f77ef1e5eb1b3e186040516370a0823160e01b81523060048201526001600160a01b0391909116906370a0823190602401602060405180830381865afa1580156128a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128c99190613dae565b836125c0565b905060006128dd82846140b4565b90508115612919576129196001600160a01b037f000000000000000000000000559ebc30b0e58a45cc9ff573f77ef1e5eb1b3e18168784613648565b80156129295761292986826136ab565b604080516001600160a01b0388168152602081018790529081018490527f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f9060600160405180910390a150509392505050565b600880546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f492cc1f8400b642b4e56de46ed10d314a49bf3e0594c43e2e5947c1e1733645b90600090a35050565b60006129d8612229565b6129e183612636565b905081811015612a455760405162461bcd60e51b815260206004820152602960248201527f50656753746162696c6974794d6f64756c653a2052656465656d206e6f7420656044820152681b9bdd59da081bdd5d60ba1b6064820152608401610900565b612a7a6001600160a01b037f000000000000000000000000559ebc30b0e58a45cc9ff573f77ef1e5eb1b3e18163330866136b5565b612a8484826136ed565b604080516001600160a01b0386168152602081018590529081018290527fe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929906060015b60405180910390a19392505050565b60008111612b415760405162461bcd60e51b815260206004820152603260248201527f50656753746162696c6974794d6f64756c653a20496e76616c6964206e6577206044820152711c995cd95c9d995cc81d1a1c995cda1bdb1960721b6064820152608401610900565b600e80549082905560408051828152602081018490527f11f873e0db7952f2f3eab9ad99121a8661e39c5cb67d33d51665f9f3e75d799e910161262a565b6000612b99612b92601254612710612560565b8390612596565b80156109205750610920612bb1601354612710612560565b83906125ac565b600080821215612c0a5760405162461bcd60e51b815260206004820181905260248201527f53616665436173743a2076616c7565206d75737420626520706f7369746976656044820152606401610900565b5090565b60408051602081019091526000815260408051602081019091528351819061258d90856125e4565b60408051602081019091526000815260408051602081019091528351819061258d90856125d8565b60005460ff16612ca75760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610900565b6000805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b039091168152602001610c52565b612d006001600160a01b0384168383613648565b816001600160a01b0316836001600160a01b0316336001600160a01b03167f08c1fcaf583c2b413bb27833685230422583405ae651b6d53e2053bf75bd074084604051612d4f91815260200190565b60405180910390a4505050565b80471015612dac5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610900565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114612df9576040519150601f19603f3d011682016040523d82523d6000602084013e612dfe565b606091505b50509050806114a75760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610900565b600a805482151560ff198216811790925560ff169081151514612eaa57612eaa600954600019612ea59190613e54565b6125f0565b60408051821515815283151560208201527f16b9ae7ca814a6dfd3357b20f33bcc7c194676988d5da46846628da394df8ab3910161262a565b601054811115612f4c5760405162461bcd60e51b815260206004820152602e60248201527f50656753746162696c6974794d6f64756c653a2052656465656d20666565206560448201526d786365656473206d61782066656560901b6064820152608401610900565b600d80549082905560408051828152602081018490527f288d91cad90f9c412f12c0869aa634660d8403c9590aa55fd5035212c6f98c95910161262a565b60006001600160ff1b03821115612c0a5760405162461bcd60e51b815260206004820152602860248201527f53616665436173743a2076616c756520646f65736e27742066697420696e2061604482015267371034b73a191a9b60c11b6064820152608401610900565b604080516020810190915260008152604051806020016040528061258d8560000151670de0b6b3a76400008660000151613523565b6001600160a01b03811661307f5760405162461bcd60e51b815260206004820152601760248201527f4f7261636c655265663a207a65726f20616464726573730000000000000000006044820152606401610900565b600780546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f93450534569bdbb3109b44eef77c9b236897f4caa4f201be10252d6462a5693790600090a35050565b60005460ff16156130f45760405162461bcd60e51b815260040161090090613d30565b6000805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612cd43390565b61313161229e565b60065542600355565b600280549082905560408051828152602081018490527fc1d6758c9eb8ba949914722321f508e4cd1e14d3ff96773ef5950336d8a2c63a910161262a565b600f5461318e906001600160a01b0316826136ed565b60405181815233907f26b1c64768593a5154cde08c3114534f1c582b6cb597bd6c0c29587f48c2004f9060200160405180910390a250565b8061321f5760405162461bcd60e51b815260206004820152602360248201527f50656753746162696c6974794d6f64756c653a20696e76616c6964206365696c604482015262696e6760e81b6064820152608401610900565b613242613230601254612710612560565b61323c83612710612560565b90612596565b6132ad5760405162461bcd60e51b815260206004820152603660248201527f50656753746162696c6974794d6f64756c653a206365696c696e67206d7573746044820152751031329033b932b0ba32b9103a3430b710333637b7b960511b6064820152608401610900565b601380549082905560408051828152602081018490527f15ddf2d8b0f5def2d9096715ee6dbe8646cd0a5c0225c781525b943244e1a7a3910161262a565b6001600160a01b0381166133585760405162461bcd60e51b815260206004820152602e60248201527f50656753746162696c6974794d6f64756c653a20496e76616c6964206e65772060448201526d1cdd5c9c1b1d5cc81d185c99d95d60921b6064820152608401610900565b600f80546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f70dc5d19a845312f7e3a89f1894fe84155cbd0a1f8434ebf02d9de842d982325910161262a565b6133ba613129565b600480549082905560408051828152602081018490527f52d0e582769dcd1e242b38b9a795ef4699f2eca0f23b1d8f94368efb27bcd5ff910161262a565b6001805490829055604051829082907f29ddd278ef9169e35aa84e424b39048b89af9c0b50f85497e40f97dff6946cf590600090a35050565b60008061343c6110da565b90506134478161356b565b60006134538285612c36565b905061269161268c612710613478600c5461271061347191906140b4565b8590612c36565b90612c0e565b6010548111156134e55760405162461bcd60e51b815260206004820152602c60248201527f50656753746162696c6974794d6f64756c653a204d696e74206665652065786360448201526b65656473206d61782066656560a01b6064820152608401610900565b600c80549082905560408051828152602081018490527f06255fba5f99bcc77a5d27ee1222dd110e196ad4cfba488e1fceccbec8dedc68910161262a565b60006126918261353386866125d8565b906125e4565b80518251600091141561354e57506001610920565b815183511161355e576000613561565b60025b60ff169392505050565b61357481612b7f565b6109125760405162461bcd60e51b815260206004820152602760248201527f50656753746162696c6974794d6f64756c653a207072696365206f7574206f6660448201526620626f756e647360c81b6064820152608401610900565b6040805160208101909152600081526040805160208101909152806135fd84670de0b6b3a76400006125d8565b905292915050565b805160009061092090670de0b6b3a76400006125e4565b6114a77f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb488484846136b5565b6040516001600160a01b0383166024820152604481018290526114a790849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613718565b61246882826137ea565b6040516001600160a01b038085166024830152831660448201526064810182905261228d9085906323b872dd60e01b90608401613674565b6124687f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb488383613648565b600061376d826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166138019092919063ffffffff16565b8051909150156114a7578080602001905181019061378b9190613c7f565b6114a75760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610900565b60006137f582613810565b90506114a7838261392a565b606061269184846000856139b6565b60008061381b61229e565b600554909150839060ff16801561383157508181115b156138395750805b816138905760405162461bcd60e51b815260206004820152602160248201527f526174654c696d697465643a206e6f2072617465206c696d69742062756666656044820152603960f91b6064820152608401610900565b818111156138e05760405162461bcd60e51b815260206004820152601b60248201527f526174654c696d697465643a2072617465206c696d69742068697400000000006044820152606401610900565b6138ea81836140b4565b6006819055426003556040805183815260208101929092527fc89b99870f6dd9f35bdd8bada9a4e2a6ba2862d2b5be9eaf54f6b8a6987368fe9101612ac7565b8015612468576040516340c10f1960e01b81526001600160a01b038381166004830152602482018390527f000000000000000000000000559ebc30b0e58a45cc9ff573f77ef1e5eb1b3e1816906340c10f1990604401600060405180830381600087803b15801561399a57600080fd5b505af11580156139ae573d6000803e3d6000fd5b505050505050565b606082471015613a175760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610900565b843b613a655760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610900565b600080866001600160a01b03168587604051613a819190614138565b60006040518083038185875af1925050503d8060008114613abe576040519150601f19603f3d011682016040523d82523d6000602084013e613ac3565b606091505b5091509150613ad3828286613ade565b979650505050505050565b60608315613aed5750816125d1565b825115613afd5782518084602001fd5b8160405162461bcd60e51b81526004016109009190614154565b600060208284031215613b2957600080fd5b5035919050565b6001600160a01b038116811461091257600080fd5b600080600060608486031215613b5a57600080fd5b8335613b6581613b30565b95602085013595506040909401359392505050565b600060208284031215613b8c57600080fd5b81356125d181613b30565b600080600060608486031215613bac57600080fd5b8335613bb781613b30565b92506020840135613bc781613b30565b929592945050506040919091013590565b60008060408385031215613beb57600080fd5b8235613bf681613b30565b946020939093013593505050565b801515811461091257600080fd5b600060208284031215613c2457600080fd5b81356125d181613c04565b600060208284031215613c4157600080fd5b6040516020810181811067ffffffffffffffff82111715613c7257634e487b7160e01b600052604160045260246000fd5b6040529135825250919050565b600060208284031215613c9157600080fd5b81516125d181613c04565b60208082526021908201527f436f72655265663a2043616c6c6572206973206e6f74206120676f7665726e6f6040820152603960f91b606082015260800190565b60208082526033908201527f436f72655265663a2043616c6c6572206973206e6f74206120676f7665726e6f604082015272391037b91031b7b73a3930b1ba1030b236b4b760691b606082015260800190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b60208082526034908201527f436f72655265663a2043616c6c6572206973206e6f7420676f7665726e6f722060408201527337b91033bab0b93234b0b71037b91030b236b4b760611b606082015260800190565b600060208284031215613dc057600080fd5b5051919050565b6000808284036040811215613ddb57600080fd5b6020811215613de957600080fd5b506040516020810181811067ffffffffffffffff82111715613e1b57634e487b7160e01b600052604160045260246000fd5b604052835181526020840151909250613e3381613c04565b809150509250929050565b634e487b7160e01b600052601160045260246000fd5b60006001600160ff1b0381841382841380821686840486111615613e7a57613e7a613e3e565b600160ff1b6000871282811687830589121615613e9957613e99613e3e565b60008712925087820587128484161615613eb557613eb5613e3e565b87850587128184161615613ecb57613ecb613e3e565b505050929093029392505050565b600181815b80851115613f14578160001904821115613efa57613efa613e3e565b80851615613f0757918102915b93841c9390800290613ede565b509250929050565b600082613f2b57506001610920565b81613f3857506000610920565b8160018114613f4e5760028114613f5857613f74565b6001915050610920565b60ff841115613f6957613f69613e3e565b50506001821b610920565b5060208310610133831016604e8410600b8410161715613f97575081810a610920565b613fa18383613ed9565b8060001904821115613fb557613fb5613e3e565b029392505050565b60006125d18383613f1c565b6020808252602d908201527f436f72655265663a2043616c6c6572206973206e6f742061206775617264696160408201526c371037b91033b7bb32b93737b960991b606082015260800190565b60208082526027908201527f436f72655265663a2043616c6c6572206973206e6f7420612050435620636f6e6040820152663a3937b63632b960c91b606082015260800190565b60008083128015600160ff1b85018412161561407b5761407b613e3e565b6001600160ff1b038401831381161561409657614096613e3e565b50500390565b600082198211156140af576140af613e3e565b500190565b6000828210156140c6576140c6613e3e565b500390565b60008160001904831182151516156140e5576140e5613e3e565b500290565b60008261410757634e487b7160e01b600052601260045260246000fd5b500490565b60005b8381101561412757818101518382015260200161410f565b8381111561228d5750506000910152565b6000825161414a81846020870161410c565b9190910192915050565b602081526000825180602084015261417381604085016020870161410c565b601f01601f1916919091016040019291505056fea2646970667358221220d6fe5f8c946bd1baf6f5aeca46e7c22c691d50d1815e41adec54ea705b77792964736f6c634300080a0033

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

000000000000000000000000000000000000000000000000001ff973cafa8000000000000000000000000000000000000000000000000000002386f26fc10000000000000000000000000000ec7ad284f7ad256b64c6e69b84eb0f48f42e819600000000000000000000000084dc71500d504163a87756db6368cc8bb654592f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000001e0000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000021e19e0c9bab2400000000000000000000000000000000000000000000000084595161401484a000000000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000febdf448c8484834bb399d930d7e1bdc773e23ba

-----Decoded View---------------
Arg [0] : _floor (uint256): 9000000000000000
Arg [1] : _ceiling (uint256): 10000000000000000
Arg [2] : _params (tuple): System.Collections.Generic.List`1[Nethereum.ABI.FunctionEncoding.ParameterOutput]
Arg [3] : _mintFeeBasisPoints (uint256): 30
Arg [4] : _redeemFeeBasisPoints (uint256): 0
Arg [5] : _reservesThreshold (uint256): 115792089237316195423570985008687907853269984665640564039457584007913129639935
Arg [6] : _feiLimitPerSecond (uint256): 10000000000000000000000
Arg [7] : _mintingBufferCap (uint256): 10000000000000000000000000
Arg [8] : _underlyingToken (address): 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
Arg [9] : _surplusTarget (address): 0xFeBDf448C8484834bb399d930d7E1bdC773E23bA

-----Encoded View---------------
14 Constructor Arguments found :
Arg [0] : 000000000000000000000000000000000000000000000000001ff973cafa8000
Arg [1] : 000000000000000000000000000000000000000000000000002386f26fc10000
Arg [2] : 000000000000000000000000ec7ad284f7ad256b64c6e69b84eb0f48f42e8196
Arg [3] : 00000000000000000000000084dc71500d504163a87756db6368cc8bb654592f
Arg [4] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [5] : 000000000000000000000000000000000000000000000000000000000000000c
Arg [6] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [7] : 000000000000000000000000000000000000000000000000000000000000001e
Arg [8] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [9] : ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
Arg [10] : 00000000000000000000000000000000000000000000021e19e0c9bab2400000
Arg [11] : 000000000000000000000000000000000000000000084595161401484a000000
Arg [12] : 000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48
Arg [13] : 000000000000000000000000febdf448c8484834bb399d930d7e1bdc773e23ba


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.