ETH Price: $3,315.81 (+1.28%)
Gas: 4.09 Gwei
 

Overview

Max Total Supply

1,221.394792003623335347 ez-aCRV

Holders

9

Market

Onchain Market Cap

$0.00

Circulating Supply Market Cap

-

Other Info

Token Contract (WITH 18 Decimals)

Filtered by Token Holder
Armor.fi: MultiSig
Balance
30 ez-aCRV

Value
$0.00
0x1f28ed9d4792a567dad779235c2b766ab84d8e33
Loading...
Loading
Loading...
Loading
Loading...
Loading

Click here to update the token information / general information
# Exchange Pair Price  24H Volume % Volume

Contract Source Code Verified (Exact Match)

Contract Name:
RcaShieldAave

Compiler Version
v0.8.11+commit.d7f03943

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 13 : RcaShieldAave.sol
/// SPDX-License-Identifier: UNLICENSED

pragma solidity ^0.8.11;

import "../RcaShieldNormalized.sol";
import "../../external/Aave.sol";

contract RcaShieldAave is RcaShieldNormalized {
    using SafeERC20 for IERC20Metadata;

    IIncentivesController public immutable incentivesController;

    constructor(
        string memory _name,
        string memory _symbol,
        address _uToken,
        uint256 _uTokenDecimals,
        address _governance,
        address _controller,
        IIncentivesController _incentivesController
    ) RcaShieldNormalized(_name, _symbol, _uToken, _uTokenDecimals, _governance, _controller) {
        incentivesController = _incentivesController;
    }

    function getReward() external {
        address[] memory assets = new address[](1);
        assets[0] = address(uToken);
        uint256 amount = incentivesController.getRewardsBalance(assets, address(this));
        incentivesController.claimRewards(assets, amount, address(this));
    }

    function purchase(
        address _token,
        uint256 _amount, // token amount to buy
        uint256 _tokenPrice,
        bytes32[] calldata _tokenPriceProof,
        uint256 _underlyingPrice,
        bytes32[] calldata _underlyinPriceProof
    ) external {
        require(_token != address(uToken), "cannot buy underlying token");
        controller.verifyPrice(_token, _tokenPrice, _tokenPriceProof);
        controller.verifyPrice(address(uToken), _underlyingPrice, _underlyinPriceProof);
        uint256 underlyingAmount = (_amount * _tokenPrice) / _underlyingPrice;
        if (discount > 0) {
            underlyingAmount -= (underlyingAmount * discount) / DENOMINATOR;
        }

        IERC20Metadata token = IERC20Metadata(_token);
        // normalize token amount to transfer to the user so that it can handle different decimals
        _amount = (_amount * 10**token.decimals()) / BUFFER;

        token.safeTransfer(msg.sender, _amount);
        uToken.safeTransferFrom(msg.sender, address(this), _normalizedUAmount(underlyingAmount));
    }

    function _afterMint(uint256 _uAmount) internal override {
        // no-op since we get aToken
    }

    function _afterRedeem(uint256 _uAmount) internal override {
        // no-op since we get aToken
    }
}

File 2 of 13 : RcaShieldNormalized.sol
/// SPDX-License-Identifier: UNLICENSED

pragma solidity ^0.8.11;

import "./RcaShieldBase.sol";

contract RcaShieldNormalized is RcaShieldBase {
    using SafeERC20 for IERC20Metadata;

    uint256 immutable BUFFER_UTOKEN;

    constructor(
        string memory _name,
        string memory _symbol,
        address _uToken,
        uint256 _uTokenDecimals,
        address _governor,
        address _controller
    ) RcaShieldBase(_name, _symbol, _uToken, _governor, _controller) {
        BUFFER_UTOKEN = 10**_uTokenDecimals;
    }

    function mintTo(
        address _user,
        address _referrer,
        uint256 _uAmount,
        uint256 _expiry,
        uint8 _v,
        bytes32 _r,
        bytes32 _s,
        uint256 _newCumLiqForClaims,
        bytes32[] calldata _liqForClaimsProof
    ) external override {
        // Call controller to check capacity limits, add to capacity limits, emit events, check for new "for sale".
        controller.mint(_user, _uAmount, _expiry, _v, _r, _s, _newCumLiqForClaims, _liqForClaimsProof);

        // Only update fees after potential contract update.
        _update();

        uint256 rcaAmount = _rcaValue(_uAmount, amtForSale);

        // handles decimals diff of underlying tokens
        _uAmount = _normalizedUAmount(_uAmount);
        uToken.safeTransferFrom(msg.sender, address(this), _uAmount);

        _mint(_user, rcaAmount);

        _afterMint(_uAmount);

        emit Mint(msg.sender, _user, _referrer, _uAmount, rcaAmount, block.timestamp);
    }

    function redeemFinalize(
        address _to,
        bytes calldata _routerData,
        uint256 _newCumLiqForClaims,
        bytes32[] calldata _liqForClaimsProof,
        uint256 _newPercentReserved,
        bytes32[] calldata _percentReservedProof
    ) external override {
        // Removed address user = msg.sender because of stack too deep.

        WithdrawRequest memory request = withdrawRequests[msg.sender];
        delete withdrawRequests[msg.sender];

        // endTime > 0 ensures request exists.
        require(request.endTime > 0 && uint32(block.timestamp) > request.endTime, "Withdrawal not yet allowed.");

        bool isRouterVerified = controller.redeemFinalize(msg.sender, _to, _newCumLiqForClaims, _liqForClaimsProof, _newPercentReserved, _percentReservedProof);

        _update();

        pendingWithdrawal -= uint256(request.rcaAmount);

        // handles decimals diff of underlying tokens
        uint256 uAmount = _uValue(request.rcaAmount, amtForSale, percentReserved);
        if (uAmount > request.uAmount) uAmount = request.uAmount;

        uint256 transferAmount = _normalizedUAmount(uAmount);
        uToken.safeTransfer(_to, transferAmount);

        // The cool part about doing it this way rather than having user send RCAs to router contract,
        // then it exchanging and returning Ether is that it's more gas efficient and no approvals are needed.
        if (isRouterVerified) IRouter(_to).routeTo(msg.sender, transferAmount, _routerData);

        emit RedeemFinalize(msg.sender, _to, transferAmount, uint256(request.rcaAmount), block.timestamp);
    }

    function purchaseU(
        address _user,
        uint256 _uAmount,
        uint256 _uEthPrice,
        bytes32[] calldata _priceProof,
        uint256 _newCumLiqForClaims,
        bytes32[] calldata _liqForClaimsProof
    ) external payable override {
        // If user submits incorrect price, tx will fail here.
        controller.purchase(_user, address(uToken), _uEthPrice, _priceProof, _newCumLiqForClaims, _liqForClaimsProof);

        _update();

        uint256 price = _uEthPrice - ((_uEthPrice * discount) / DENOMINATOR);
        // divide by 1 ether because price also has 18 decimals.
        uint256 ethAmount = (price * _uAmount) / 1 ether;
        require(msg.value == ethAmount, "Incorrect Ether sent.");

        // If amount is bigger than for sale, tx will fail here.
        amtForSale -= _uAmount;

        // handles decimals diff of underlying tokens
        _uAmount = _normalizedUAmount(_uAmount);
        uToken.safeTransfer(_user, _uAmount);
        treasury.transfer(msg.value);

        emit PurchaseU(_user, _uAmount, ethAmount, _uEthPrice, block.timestamp);
    }

    /**
     * @notice Normalizes underlying token amount by taking consideration of its
     * decimals.
     * @param _uAmount Utoken amount in 18 decimals
     */
    function _normalizedUAmount(uint256 _uAmount) internal view returns (uint256 amount) {
        amount = (_uAmount * BUFFER_UTOKEN) / BUFFER;
    }

    function _uBalance() internal view virtual override returns (uint256) {
        return (uToken.balanceOf(address(this)) * BUFFER) / BUFFER_UTOKEN;
    }

    function _afterMint(uint256) internal virtual override {
        // no-op
    }

    function _afterRedeem(uint256) internal virtual override {
        // no-op
    }
}

File 3 of 13 : Aave.sol
// SPDX-License-Identifier: agpl-3.0
pragma solidity ^0.8.11;

interface ILendingPool {
    /**
     * @dev Emitted on deposit()
     * @param reserve The address of the underlying asset of the reserve
     * @param user The address initiating the deposit
     * @param onBehalfOf The beneficiary of the deposit, receiving the aTokens
     * @param amount The amount deposited
     * @param referral The referral code used
     **/
    event Deposit(
        address indexed reserve,
        address user,
        address indexed onBehalfOf,
        uint256 amount,
        uint16 indexed referral
    );

    /**
     * @dev Emitted on withdraw()
     * @param reserve The address of the underlyng asset being withdrawn
     * @param user The address initiating the withdrawal, owner of aTokens
     * @param to Address that will receive the underlying
     * @param amount The amount to be withdrawn
     **/
    event Withdraw(address indexed reserve, address indexed user, address indexed to, uint256 amount);

    /**
     * @dev Emitted on borrow() and flashLoan() when debt needs to be opened
     * @param reserve The address of the underlying asset being borrowed
     * @param user The address of the user initiating the borrow(), receiving the funds on borrow() or just
     * initiator of the transaction on flashLoan()
     * @param onBehalfOf The address that will be getting the debt
     * @param amount The amount borrowed out
     * @param borrowRateMode The rate mode: 1 for Stable, 2 for Variable
     * @param borrowRate The numeric rate at which the user has borrowed
     * @param referral The referral code used
     **/
    event Borrow(
        address indexed reserve,
        address user,
        address indexed onBehalfOf,
        uint256 amount,
        uint256 borrowRateMode,
        uint256 borrowRate,
        uint16 indexed referral
    );

    /**
     * @dev Emitted on repay()
     * @param reserve The address of the underlying asset of the reserve
     * @param user The beneficiary of the repayment, getting his debt reduced
     * @param repayer The address of the user initiating the repay(), providing the funds
     * @param amount The amount repaid
     **/
    event Repay(address indexed reserve, address indexed user, address indexed repayer, uint256 amount);

    /**
     * @dev Emitted on swapBorrowRateMode()
     * @param reserve The address of the underlying asset of the reserve
     * @param user The address of the user swapping his rate mode
     * @param rateMode The rate mode that the user wants to swap to
     **/
    event Swap(address indexed reserve, address indexed user, uint256 rateMode);

    /**
     * @dev Emitted on setUserUseReserveAsCollateral()
     * @param reserve The address of the underlying asset of the reserve
     * @param user The address of the user enabling the usage as collateral
     **/
    event ReserveUsedAsCollateralEnabled(address indexed reserve, address indexed user);

    /**
     * @dev Emitted on setUserUseReserveAsCollateral()
     * @param reserve The address of the underlying asset of the reserve
     * @param user The address of the user enabling the usage as collateral
     **/
    event ReserveUsedAsCollateralDisabled(address indexed reserve, address indexed user);

    /**
     * @dev Emitted on rebalanceStableBorrowRate()
     * @param reserve The address of the underlying asset of the reserve
     * @param user The address of the user for which the rebalance has been executed
     **/
    event RebalanceStableBorrowRate(address indexed reserve, address indexed user);

    /**
     * @dev Emitted on flashLoan()
     * @param target The address of the flash loan receiver contract
     * @param initiator The address initiating the flash loan
     * @param asset The address of the asset being flash borrowed
     * @param amount The amount flash borrowed
     * @param premium The fee flash borrowed
     * @param referralCode The referral code used
     **/
    event FlashLoan(
        address indexed target,
        address indexed initiator,
        address indexed asset,
        uint256 amount,
        uint256 premium,
        uint16 referralCode
    );

    /**
     * @dev Emitted when the pause is triggered.
     */
    event Paused();

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

    /**
     * @dev Emitted when a borrower is liquidated. This event is emitted by the LendingPool via
     * LendingPoolCollateral manager using a DELEGATECALL
     * This allows to have the events in the generated ABI for LendingPool.
     * @param collateralAsset The address of the underlying asset used as collateral,
     * to receive as result of the liquidation
     * @param debtAsset The address of the underlying borrowed asset to be repaid with the liquidation
     * @param user The address of the borrower getting liquidated
     * @param debtToCover The debt amount of borrowed `asset` the liquidator wants to cover
     * @param liquidatedCollateralAmount The amount of collateral received by the liiquidator
     * @param liquidator The address of the liquidator
     * @param receiveAToken `true` if the liquidators wants to receive the collateral aTokens, `false` if he wants
     * to receive the underlying collateral asset directly
     **/
    event LiquidationCall(
        address indexed collateralAsset,
        address indexed debtAsset,
        address indexed user,
        uint256 debtToCover,
        uint256 liquidatedCollateralAmount,
        address liquidator,
        bool receiveAToken
    );

    /**
     * @dev Emitted when the state of a reserve is updated. NOTE: This event is actually declared
     * in the ReserveLogic library and emitted in the updateInterestRates() function. Since the function is internal,
     * the event will actually be fired by the LendingPool contract. The event is therefore replicated here so it
     * gets added to the LendingPool ABI
     * @param reserve The address of the underlying asset of the reserve
     * @param liquidityRate The new liquidity rate
     * @param stableBorrowRate The new stable borrow rate
     * @param variableBorrowRate The new variable borrow rate
     * @param liquidityIndex The new liquidity index
     * @param variableBorrowIndex The new variable borrow index
     **/
    event ReserveDataUpdated(
        address indexed reserve,
        uint256 liquidityRate,
        uint256 stableBorrowRate,
        uint256 variableBorrowRate,
        uint256 liquidityIndex,
        uint256 variableBorrowIndex
    );

    /**
     * @dev Deposits an `amount` of underlying asset into the reserve, receiving in return overlying aTokens.
     * - E.g. User deposits 100 USDC and gets in return 100 aUSDC
     * @param asset The address of the underlying asset to deposit
     * @param amount The amount to be deposited
     * @param onBehalfOf The address that will receive the aTokens, same as msg.sender if the user
     *   wants to receive them on his own wallet, or a different address if the beneficiary of aTokens
     *   is a different wallet
     * @param referralCode Code used to register the integrator originating the operation, for potential rewards.
     *   0 if the action is executed directly by the user, without any middle-man
     **/
    function deposit(
        address asset,
        uint256 amount,
        address onBehalfOf,
        uint16 referralCode
    ) external;

    /**
     * @dev Withdraws an `amount` of underlying asset from the reserve, burning the equivalent aTokens owned
     * E.g. User has 100 aUSDC, calls withdraw() and receives 100 USDC, burning the 100 aUSDC
     * @param asset The address of the underlying asset to withdraw
     * @param amount The underlying amount to be withdrawn
     *   - Send the value type(uint256).max in order to withdraw the whole aToken balance
     * @param to Address that will receive the underlying, same as msg.sender if the user
     *   wants to receive it on his own wallet, or a different address if the beneficiary is a
     *   different wallet
     * @return The final amount withdrawn
     **/
    function withdraw(
        address asset,
        uint256 amount,
        address to
    ) external returns (uint256);

    /**
     * @dev Allows users to borrow a specific `amount` of the reserve underlying asset, provided that the borrower
     * already deposited enough collateral, or he was given enough allowance by a credit delegator on the
     * corresponding debt token (StableDebtToken or VariableDebtToken)
     * - E.g. User borrows 100 USDC passing as `onBehalfOf` his own address, receiving the 100 USDC in his wallet
     *   and 100 stable/variable debt tokens, depending on the `interestRateMode`
     * @param asset The address of the underlying asset to borrow
     * @param amount The amount to be borrowed
     * @param interestRateMode The interest rate mode at which the user wants to borrow: 1 for Stable, 2 for Variable
     * @param referralCode Code used to register the integrator originating the operation, for potential rewards.
     *   0 if the action is executed directly by the user, without any middle-man
     * @param onBehalfOf Address of the user who will receive the debt. Should be the address of the borrower itself
     * calling the function if he wants to borrow against his own collateral, or the address of the credit delegator
     * if he has been given credit delegation allowance
     **/
    function borrow(
        address asset,
        uint256 amount,
        uint256 interestRateMode,
        uint16 referralCode,
        address onBehalfOf
    ) external;

    /**
     * @notice Repays a borrowed `amount` on a specific reserve, burning the equivalent debt tokens owned
     * - E.g. User repays 100 USDC, burning 100 variable/stable debt tokens of the `onBehalfOf` address
     * @param asset The address of the borrowed underlying asset previously borrowed
     * @param amount The amount to repay
     * - Send the value type(uint256).max in order to repay the whole debt for `asset` on the specific `debtMode`
     * @param rateMode The interest rate mode at of the debt the user wants to repay: 1 for Stable, 2 for Variable
     * @param onBehalfOf Address of the user who will get his debt reduced/removed. Should be the address of the
     * user calling the function if he wants to reduce/remove his own debt, or the address of any other
     * other borrower whose debt should be removed
     * @return The final amount repaid
     **/
    function repay(
        address asset,
        uint256 amount,
        uint256 rateMode,
        address onBehalfOf
    ) external returns (uint256);

    /**
     * @dev Allows a borrower to swap his debt between stable and variable mode, or viceversa
     * @param asset The address of the underlying asset borrowed
     * @param rateMode The rate mode that the user wants to swap to
     **/
    function swapBorrowRateMode(address asset, uint256 rateMode) external;

    /**
     * @dev Rebalances the stable interest rate of a user to the current stable rate defined on the reserve.
     * - Users can be rebalanced if the following conditions are satisfied:
     *     1. Usage ratio is above 95%
     *     2. the current deposit APY is below REBALANCE_UP_THRESHOLD * maxVariableBorrowRate,
     *        which means that too much has been
     *        borrowed at a stable rate and depositors are not earning enough
     * @param asset The address of the underlying asset borrowed
     * @param user The address of the user to be rebalanced
     **/
    function rebalanceStableBorrowRate(address asset, address user) external;

    /**
     * @dev Allows depositors to enable/disable a specific deposited asset as collateral
     * @param asset The address of the underlying asset deposited
     * @param useAsCollateral `true` if the user wants to use the deposit as collateral, `false` otherwise
     **/
    function setUserUseReserveAsCollateral(address asset, bool useAsCollateral) external;

    /**
     * @dev Function to liquidate a non-healthy position collateral-wise, with Health Factor below 1
     * - The caller (liquidator) covers `debtToCover` amount of debt of the user getting liquidated, and receives
     *   a proportionally amount of the `collateralAsset` plus a bonus to cover market risk
     * @param collateralAsset The address of the underlying asset used as collateral,
     * to receive as result of the liquidation
     * @param debtAsset The address of the underlying borrowed asset to be repaid with the liquidation
     * @param user The address of the borrower getting liquidated
     * @param debtToCover The debt amount of borrowed `asset` the liquidator wants to cover
     * @param receiveAToken `true` if the liquidators wants to receive the collateral aTokens, `false` if he wants
     * to receive the underlying collateral asset directly
     **/
    function liquidationCall(
        address collateralAsset,
        address debtAsset,
        address user,
        uint256 debtToCover,
        bool receiveAToken
    ) external;

    /**
     * @dev Allows smartcontracts to access the liquidity of the pool within one transaction,
     * as long as the amount taken plus a fee is returned.
     * IMPORTANT There are security concerns for developers of flashloan receiver contracts
     *  that must be kept into consideration.
     * For further details please visit https://developers.aave.com
     * @param receiverAddress The address of the contract receiving the funds,
     * implementing the IFlashLoanReceiver interface
     * @param assets The addresses of the assets being flash-borrowed
     * @param amounts The amounts amounts being flash-borrowed
     * @param modes Types of the debt to open if the flash loan is not returned:
     *   0 -> Don't open any debt, just revert if funds can't be transferred from the receiver
     *   1 -> Open debt at stable rate for the value of the amount flash-borrowed to the `onBehalfOf` address
     *   2 -> Open debt at variable rate for the value of the amount flash-borrowed to the `onBehalfOf` address
     * @param onBehalfOf The address  that will receive the debt in the case of using on `modes` 1 or 2
     * @param params Variadic packed params to pass to the receiver as extra information
     * @param referralCode Code used to register the integrator originating the operation, for potential rewards.
     *   0 if the action is executed directly by the user, without any middle-man
     **/
    function flashLoan(
        address receiverAddress,
        address[] calldata assets,
        uint256[] calldata amounts,
        uint256[] calldata modes,
        address onBehalfOf,
        bytes calldata params,
        uint16 referralCode
    ) external;

    /**
     * @dev Returns the user account data across all the reserves
     * @param user The address of the user
     * @return totalCollateralETH the total collateral in ETH of the user
     * @return totalDebtETH the total debt in ETH of the user
     * @return availableBorrowsETH the borrowing power left of the user
     * @return currentLiquidationThreshold the liquidation threshold of the user
     * @return ltv the loan to value of the user
     * @return healthFactor the current health factor of the user
     **/
    function getUserAccountData(address user)
        external
        view
        returns (
            uint256 totalCollateralETH,
            uint256 totalDebtETH,
            uint256 availableBorrowsETH,
            uint256 currentLiquidationThreshold,
            uint256 ltv,
            uint256 healthFactor
        );

    function initReserve(
        address reserve,
        address aTokenAddress,
        address stableDebtAddress,
        address variableDebtAddress,
        address interestRateStrategyAddress
    ) external;

    function setReserveInterestRateStrategyAddress(address reserve, address rateStrategyAddress) external;

    function setConfiguration(address reserve, uint256 configuration) external;

    /**
     * @dev Returns the normalized income normalized income of the reserve
     * @param asset The address of the underlying asset of the reserve
     * @return The reserve's normalized income
     */
    function getReserveNormalizedIncome(address asset) external view returns (uint256);

    /**
     * @dev Returns the normalized variable debt per unit of asset
     * @param asset The address of the underlying asset of the reserve
     * @return The reserve normalized variable debt
     */
    function getReserveNormalizedVariableDebt(address asset) external view returns (uint256);

    function finalizeTransfer(
        address asset,
        address from,
        address to,
        uint256 amount,
        uint256 balanceFromAfter,
        uint256 balanceToBefore
    ) external;

    function getReservesList() external view returns (address[] memory);

    function setPause(bool val) external;

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

interface IIncentivesController {
    event RewardsAccrued(address indexed user, uint256 amount);

    event RewardsClaimed(address indexed user, address indexed to, address indexed claimer, uint256 amount);

    event ClaimerSet(address indexed user, address indexed claimer);

    /**
     * @dev Whitelists an address to claim the rewards on behalf of another address
     * @param user The address of the user
     * @param claimer The address of the claimer
     */
    function setClaimer(address user, address claimer) external;

    /**
     * @dev Returns the whitelisted claimer for a certain address (0x0 if not set)
     * @param user The address of the user
     * @return The claimer address
     */
    function getClaimer(address user) external view returns (address);

    /**
     * @dev Configure assets for a certain rewards emission
     * @param assets The assets to incentivize
     * @param emissionsPerSecond The emission for each asset
     */
    function configureAssets(address[] calldata assets, uint256[] calldata emissionsPerSecond) external;

    /**
     * @dev Called by the corresponding asset on any update that affects the rewards distribution
     * @param asset The address of the user
     * @param userBalance The balance of the user of the asset in the lending pool
     * @param totalSupply The total supply of the asset in the lending pool
     **/
    function handleAction(
        address asset,
        uint256 userBalance,
        uint256 totalSupply
    ) external;

    /**
     * @dev Returns the total of rewards of an user, already accrued + not yet accrued
     * @param user The address of the user
     * @return The rewards
     **/
    function getRewardsBalance(address[] calldata assets, address user) external view returns (uint256);

    /**
     * @dev Claims reward for an user, on all the assets of the lending pool, accumulating the pending rewards
     * @param amount Amount of rewards to claim
     * @param to Address that will be receiving the rewards
     * @return Rewards claimed
     **/
    function claimRewards(
        address[] calldata assets,
        uint256 amount,
        address to
    ) external returns (uint256);

    /**
     * @dev Claims reward for an user on behalf, on all the assets of the lending pool,
     * accumulating the pending rewards. The caller must be whitelisted via "allowClaimOnBehalf"
     * function by the RewardsAdmin role manager
     * @param amount Amount of rewards to claim
     * @param user Address to check and claim rewards
     * @param to Address that will be receiving the rewards
     * @return Rewards claimed
     **/
    function claimRewardsOnBehalf(
        address[] calldata assets,
        uint256 amount,
        address user,
        address to
    ) external returns (uint256);

    /**
     * @dev returns the unclaimed rewards of the user
     * @param user the address of the user
     * @return the unclaimed user rewards
     */
    function getUserUnclaimedRewards(address user) external view returns (uint256);

    /**
     * @dev for backward compatibility with previous implementation of the Incentives controller
     */
    function REWARD_TOKEN() external view returns (address);
}

File 4 of 13 : RcaShieldBase.sol
/// SPDX-License-Identifier: UNLICENSED

/**
 * By using this contract and/or any other launched by the Ease protocol, you agree to Ease's
 * Terms and Conditions, Privacy Policy, and Terms of Coverage.
 * https://ease.org/about-ease-defi/terms-and-conditions-disclaimer/
 * https://ease.org/about-ease-defi/privacy-policy/
 * https://ease.org/learn-crypto-defi/get-defi-cover-at-ease/ease-defi-cover/terms-of-ease-coverage/
 */

/**

                               ................                            
                          ..',,;;::::::::ccccc:;,'..                       
                      ..',;;;;::::::::::::cccccllllc;..                    
                    .';;;;;;;,'..............',:clllolc,.                  
                  .,;;;;;,..                    .';cooool;.                
                .';;;;;'.           .....          .,coodoc.               
               .,;;;;'.       ..',;:::cccc:;,'.      .;odddl'              
              .,;;;;.       .,:cccclllllllllool:'      ,odddl'             
             .,:;:;.      .;ccccc:;,''''',;cooooo:.     ,odddc.            
             ';:::'     .,ccclc,..         .':odddc.    .cdddo,            
            .;:::,.     ,cccc;.              .:oddd:.    ,dddd:.           
            '::::'     .ccll:.                .ldddo'    'odddc.           
            ,::c:.     ,lllc'    .';;;::::::::codddd;    ,dxxxc.           
           .,ccc:.    .;lllc.    ,oooooddddddddddddd;    :dxxd:            
            ,cccc.     ;llll'    .;:ccccccccccccccc;.   'oxxxo'            
            'cccc,     'loooc.                         'lxxxd;             
            .:lll:.    .;ooooc.                      .;oxxxd:.             
             ,llll;.    .;ooddo:'.                ..:oxxxxo;.              
             .:llol,.     'coddddl:;''.........,;codxxxxd:.                
              .:lool;.     .':odddddddddoooodddxxxxxxdl;.                  
               .:ooooc'       .';codddddddxxxxxxdol:,.                     
                .;ldddoc'.        ...'',,;;;,,''..                         
                  .:oddddl:'.                          .,;:'.              
                    .:odddddoc;,...              ..',:ldxxxx;              
                      .,:odddddddoolcc::::::::cllodxxxxxxxd:.              
                         .';clddxxxxxxxxxxxxxxxxxxxxxxoc;'.                
                             ..',;:ccllooooooollc:;,'..                    
                                        ......                             
                                                                      
**/

pragma solidity 0.8.11;
import "../general/Governable.sol";
import "../interfaces/IRouter.sol";
import "../interfaces/IRcaController.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

/**
 * @title RCA Vault
 * @notice Main contract for reciprocally-covered assets. Mints, redeems, and sells.
 * Each underlying token (not protocol) has its own RCA vault. This contract
 * doubles as the vault and the RCA token.
 * @dev This contract assumes uToken decimals of 18.
 * @author Ease -- Robert M.C. Forster, Romke Jonker, Taek Lee, Chiranjibi Poudyal, Dominik Prediger
 **/
abstract contract RcaShieldBase is ERC20, Governable {
    using SafeERC20 for IERC20Metadata;

    uint256 constant YEAR_SECS = 31536000;
    uint256 constant DENOMINATOR = 10000;
    uint256 constant BUFFER = 1e18;

    /// @notice Controller of RCA contract that takes care of actions.
    IRcaController public controller;
    /// @notice Underlying token that is protected by the shield.
    IERC20Metadata public immutable uToken;

    /// @notice Percent to pay per year. 1000 == 10%.
    uint256 public apr;
    /// @notice Current sale discount to sell tokens cheaper.
    uint256 public discount;
    /// @notice Treasury for all funds that accepts payments.
    address payable public treasury;
    /// @notice Percent of the contract that is currently paused and cannot be withdrawn.
    /// Set > 0 when a hack has happened and DAO has not submitted for sales.
    /// Withdrawals during this time will lose this percent. 1000 == 10%.
    uint256 public percentReserved;

    /**
     * @notice Cumulative total amount that has been liquidated lol.
     * @dev Used to make sure we don't run into a situation where liq amount isn't updated,
     * a new hack occurs and current liq is added to, then current liq is updated while
     * DAO votes on the new total liq. In this case we can subtract that interim addition.
     */
    uint256 public cumLiqForClaims;
    /// @notice Amount of tokens currently up for sale.
    uint256 public amtForSale;

    /**
     * @notice Amount of RCA tokens pending withdrawal.
     * @dev When doing value calculations this is required because RCAs are burned immediately
     * upon request, but underlying tokens only leave the contract once the withdrawal is finalized.
     */
    uint256 public pendingWithdrawal;
    /// @notice withdrawal variable for withdrawal delays.
    uint256 public withdrawalDelay;
    /// @notice Requests by users for withdrawals.
    mapping(address => WithdrawRequest) public withdrawRequests;

    /**
     * @notice Last time the contract has been updated.
     * @dev Used to calculate APR if fees are implemented.
     */
    uint256 lastUpdate;

    struct WithdrawRequest {
        uint112 uAmount;
        uint112 rcaAmount;
        uint32 endTime;
    }

    /// @notice Notification of the mint of new tokens.
    event Mint(
        address indexed sender,
        address indexed to,
        address indexed referrer,
        uint256 uAmount,
        uint256 rcaAmount,
        uint256 timestamp
    );
    /// @notice Notification of an initial redeem request.
    event RedeemRequest(address indexed user, uint256 uAmount, uint256 rcaAmount, uint256 endTime, uint256 timestamp);
    /// @notice Notification of a redeem finalization after withdrawal delay.
    event RedeemFinalize(
        address indexed user,
        address indexed to,
        uint256 uAmount,
        uint256 rcaAmount,
        uint256 timestamp
    );
    /// @notice Notification of a purchase of the underlying token.
    event PurchaseU(address indexed to, uint256 uAmount, uint256 ethAmount, uint256 price, uint256 timestamp);
    /// @notice Notification of a purchase of an RCA token.
    event PurchaseRca(
        address indexed to,
        uint256 uAmount,
        uint256 rcaAmount,
        uint256 ethAmount,
        uint256 price,
        uint256 timestamp
    );

    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //////////////////////////////////////////////// modifiers //////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////

    /**
     * @notice Restrict set functions to only controller for many variables.
     */
    modifier onlyController() {
        require(msg.sender == address(controller), "Function must only be called by controller.");
        _;
    }

    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //////////////////////////////////////////////// constructor ////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////

    /**
     * @notice Construct shield and RCA ERC20 token.
     * @param _name Name of the RCA token.
     * @param _symbol Symbol of the RCA token.
     * @param _uToken Address of the underlying token.
     * @param _governor Address of the governor (owner) of the shield.
     * @param _controller Address of the controller that maintains the shield.
     */
    constructor(
        string memory _name,
        string memory _symbol,
        address _uToken,
        address _governor,
        address _controller
    ) ERC20(_name, _symbol) {
        initializeGovernable(_governor);
        uToken = IERC20Metadata(_uToken);
        controller = IRcaController(_controller);
    }

    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //////////////////////////////////////////////// initialize /////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////

    /**
     * @notice Controller calls to initiate which sets current contract variables. All %s are 1000 == 10%.
     * @param _apr Fees for using the RCA ecosystem.
     * @param _discount Discount for purchases while tokens are being liquidated.
     * @param _treasury Address of the treasury to which Ether from fees and liquidation will be sent.
     * @param _withdrawalDelay Delay of withdrawals from the shield in seconds.
     */
    function initialize(
        uint256 _apr,
        uint256 _discount,
        address payable _treasury,
        uint256 _withdrawalDelay
    ) external onlyController {
        require(treasury == address(0), "Contract has already been initialized.");
        apr = _apr;
        discount = _discount;
        treasury = _treasury;
        withdrawalDelay = _withdrawalDelay;
        lastUpdate = block.timestamp;
    }

    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ///////////////////////////////////////////////// external //////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////

    /**
     * @notice Mint tokens to an address. Not automatically to msg.sender so we can more easily zap assets.
     * @param _user The user to mint tokens to.
     * @param _referrer The address that referred this user.
     * @param _uAmount Amount of underlying tokens desired to use for mint.
     * @param _expiry Time (Unix timestamp) that this request expires.
     * @param _v The recovery byte of the signature.
     * @param _r Half of the ECDSA signature pair.
     * @param _s Half of the ECDSA signature pair.
     * @param _newCumLiqForClaims New total cumulative liquidated if there is one.
     * @param _liqForClaimsProof Merkle proof to verify cumulative liquidated.
     */
    function mintTo(
        address _user,
        address _referrer,
        uint256 _uAmount,
        uint256 _expiry,
        uint8 _v,
        bytes32 _r,
        bytes32 _s,
        uint256 _newCumLiqForClaims,
        bytes32[] calldata _liqForClaimsProof
    ) external virtual {
        // Call controller to check capacity limits, add to capacity limits, emit events, check for new "for sale".
        controller.mint(_user, _uAmount, _expiry, _v, _r, _s, _newCumLiqForClaims, _liqForClaimsProof);

        // Only update fees after potential contract update.
        _update();

        uint256 rcaAmount = _rcaValue(_uAmount, amtForSale);

        uToken.safeTransferFrom(msg.sender, address(this), _uAmount);

        _mint(_user, rcaAmount);

        _afterMint(_uAmount);

        emit Mint(msg.sender, _user, _referrer, _uAmount, rcaAmount, block.timestamp);
    }

    /**
     * @notice Request redemption of RCAs back to the underlying token.
     * Has a withdrawal delay so it's 2 parts (request and finalize).
     * @param _rcaAmount The amount of tokens (in RCAs) to be redeemed.
     * @param _newCumLiqForClaims New cumulative liquidated if this must be updated.
     * @param _liqForClaimsProof Merkle proof to verify the new cumulative liquidated.
     * @param _newPercentReserved New percent of funds in shield that are reserved.
     * @param _percentReservedProof Merkle proof for the new percent reserved.
     */
    function redeemRequest(
        uint256 _rcaAmount,
        uint256 _newCumLiqForClaims,
        bytes32[] calldata _liqForClaimsProof,
        uint256 _newPercentReserved,
        bytes32[] calldata _percentReservedProof
    ) external {
        controller.redeemRequest(
            msg.sender,
            _newCumLiqForClaims,
            _liqForClaimsProof,
            _newPercentReserved,
            _percentReservedProof
        );

        _update();

        uint256 uAmount = _uValue(_rcaAmount, amtForSale, percentReserved);
        _burn(msg.sender, _rcaAmount);

        _afterRedeem(uAmount);

        pendingWithdrawal += _rcaAmount;

        WithdrawRequest memory curRequest = withdrawRequests[msg.sender];
        uint112 newUAmount = uint112(uAmount) + curRequest.uAmount;
        uint112 newRcaAmount = uint112(_rcaAmount) + curRequest.rcaAmount;
        uint32 endTime = uint32(block.timestamp) + uint32(withdrawalDelay);
        withdrawRequests[msg.sender] = WithdrawRequest(newUAmount, newRcaAmount, endTime);

        emit RedeemRequest(msg.sender, uint256(uAmount), _rcaAmount, uint256(endTime), block.timestamp);
    }

    /**
     * @notice Used to exchange RCA tokens back to the underlying token. Will have a 1-2 day delay upon withdrawal.
     * This can mint to a router contract that can exchange the asset for Ether and send to the user.
     * @param _to The destination of the tokens.
     * @param _newCumLiqForClaims New cumulative liquidated if this must be updated.
     * @param _liqForClaimsProof Merkle proof to verify new cumulative liquidation.
     * @param _liqForClaimsProof Merkle proof to verify the new cumulative liquidated.
     * @param _newPercentReserved New percent of funds in shield that are reserved.
     * @param _percentReservedProof Merkle proof for the new percent reserved.
     */
    function redeemFinalize(
        address _to,
        bytes calldata _routerData,
        uint256 _newCumLiqForClaims,
        bytes32[] calldata _liqForClaimsProof,
        uint256 _newPercentReserved,
        bytes32[] calldata _percentReservedProof
    ) external virtual {
        address user = msg.sender;

        WithdrawRequest memory request = withdrawRequests[user];
        delete withdrawRequests[user];

        // endTime > 0 ensures request exists.
        require(request.endTime > 0 && uint32(block.timestamp) > request.endTime, "Withdrawal not yet allowed.");

        bool isRouterVerified = controller.redeemFinalize(
            user,
            _to,
            _newCumLiqForClaims,
            _liqForClaimsProof,
            _newPercentReserved,
            _percentReservedProof
        );

        _update();

        // We're going to calculate uAmount a second time here then send the lesser of the two.
        // If we only calculate once, users can either get their full uAmount after a hack if percentReserved
        // hasn't been sent in, or users can earn yield after requesting redeem (with the same consequence).
        uint256 uAmount = _uValue(request.rcaAmount, amtForSale, percentReserved);
        if (request.uAmount < uAmount) uAmount = uint256(request.uAmount);

        pendingWithdrawal -= uint256(request.rcaAmount);

        uToken.safeTransfer(_to, uAmount);

        // The cool part about doing it this way rather than having user send RCAs to router contract,
        // then it exchanging and returning Ether is that it's more gas efficient and no approvals are needed.
        // (and no nonsense with the withdrawal delay making routers wonky)
        if (isRouterVerified) IRouter(_to).routeTo(user, uAmount, _routerData);

        emit RedeemFinalize(user, _to, uAmount, uint256(request.rcaAmount), block.timestamp);
    }

    /**
     * @notice Purchase underlying tokens directly. This will be preferred by bots.
     * @param _user The user to purchase tokens for.
     * @param _uAmount Amount of underlying tokens to purchase.
     * @param _uEthPrice Price of the underlying token in Ether per token.
     * @param _priceProof Merkle proof for the price.
     * @param _newCumLiqForClaims New cumulative amount for liquidation.
     * @param _liqForClaimsProof Merkle proof for new liquidation amounts.
     */
    function purchaseU(
        address _user,
        uint256 _uAmount,
        uint256 _uEthPrice,
        bytes32[] calldata _priceProof,
        uint256 _newCumLiqForClaims,
        bytes32[] calldata _liqForClaimsProof
    ) external payable virtual {
        // If user submits incorrect price, tx will fail here.
        controller.purchase(_user, address(uToken), _uEthPrice, _priceProof, _newCumLiqForClaims, _liqForClaimsProof);

        _update();

        uint256 price = _uEthPrice - ((_uEthPrice * discount) / DENOMINATOR);
        // divide by 1 ether because price also has 18 decimals.
        uint256 ethAmount = (price * _uAmount) / 1 ether;
        require(msg.value == ethAmount, "Incorrect Ether sent.");

        // If amount is bigger than for sale, tx will fail here.
        amtForSale -= _uAmount;

        uToken.safeTransfer(_user, _uAmount);
        treasury.transfer(msg.value);

        emit PurchaseU(_user, _uAmount, ethAmount, _uEthPrice, block.timestamp);
    }

    /**
     * @notice purchaseRca allows a user to purchase the RCA directly with Ether through liquidation.
     * @param _user The user to make the purchase for.
     * @param _uAmount The amount of underlying tokens to purchase.
     * @param _uEthPrice The underlying token price in Ether per token.
     * @param _priceProof Merkle proof to verify this price.
     * @param _newCumLiqForClaims Old cumulative amount for sale.
     * @param _liqForClaimsProof Merkle proof of the for sale amounts.
     */
    function purchaseRca(
        address _user,
        uint256 _uAmount,
        uint256 _uEthPrice,
        bytes32[] calldata _priceProof,
        uint256 _newCumLiqForClaims,
        bytes32[] calldata _liqForClaimsProof
    ) external payable {
        // If user submits incorrect price, tx will fail here.
        controller.purchase(_user, address(uToken), _uEthPrice, _priceProof, _newCumLiqForClaims, _liqForClaimsProof);

        _update();

        uint256 price = _uEthPrice - ((_uEthPrice * discount) / DENOMINATOR);
        // divide by 1 ether because price also has 18 decimals.
        uint256 ethAmount = (price * _uAmount) / 1 ether;
        require(msg.value == ethAmount, "Incorrect Ether sent.");

        // If amount is too big than for sale, tx will fail here.
        uint256 rcaAmount = _rcaValue(_uAmount, amtForSale);
        amtForSale -= _uAmount;

        _mint(_user, rcaAmount);
        treasury.transfer(msg.value);

        emit PurchaseRca(_user, _uAmount, rcaAmount, _uEthPrice, ethAmount, block.timestamp);
    }

    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////// view ////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////

    /**
     * @dev External version of RCA value is needed so that frontend can properly
     * calculate values in cases where the contract has not been recently updated.
     * @param _rcaAmount Amount of RCA tokens (18 decimal) to find the underlying token value of.
     * @param _cumLiqForClaims New cumulative liquidated if this must be updated.
     * @param _percentReserved Percent of tokens that are reserved after a hack payout.
     */
    function uValue(
        uint256 _rcaAmount,
        uint256 _cumLiqForClaims,
        uint256 _percentReserved
    ) external view returns (uint256 uAmount) {
        uint256 extraForSale = getExtraForSale(_cumLiqForClaims);
        uAmount = _uValue(_rcaAmount, amtForSale + extraForSale, _percentReserved);
    }

    /**
     * @dev External version of RCA value is needed so that frontend can properly
     * calculate values in cases where the contract has not been recently updated.
     * @param _uAmount Amount of underlying tokens (18 decimal).
     * @param _cumLiqForClaims New cumulative liquidated if this must be updated.
     */
    function rcaValue(uint256 _uAmount, uint256 _cumLiqForClaims) external view returns (uint256 rcaAmount) {
        uint256 extraForSale = getExtraForSale(_cumLiqForClaims);
        rcaAmount = _rcaValue(_uAmount, amtForSale + extraForSale);
    }

    /**
     * @notice Convert RCA value to underlying tokens. This is internal because new
     * for sale amounts will already have been retrieved and updated.
     * @param _rcaAmount The amount of RCAs to find the underlying value of.
     * @param _totalForSale Used by external value calls cause updates aren't made on those.
     * @param _percentReserved Percent of funds reserved if a hack is being examined.
     */
    function _uValue(
        uint256 _rcaAmount,
        uint256 _totalForSale,
        uint256 _percentReserved
    ) internal view returns (uint256 uAmount) {
        uint256 balance = _uBalance();

        if (totalSupply() == 0) return _rcaAmount;
        else if (balance < _totalForSale) return 0;

        uAmount = ((balance - _totalForSale) * _rcaAmount) / (totalSupply() + pendingWithdrawal);

        if (_percentReserved > 0) uAmount -= ((uAmount * _percentReserved) / DENOMINATOR);
    }

    /**
     * @notice Find the RCA value of an amount of underlying tokens.
     * @param _uAmount Amount of underlying tokens to find RCA value of.
     * @param _totalForSale Used by external value calls cause updates aren't made on those.
     */
    function _rcaValue(uint256 _uAmount, uint256 _totalForSale) internal view returns (uint256 rcaAmount) {
        uint256 balance = _uBalance();

        // Interesting edgecase in which 1 person is in vault, they request redeem, 
        // underlying continue to gain value, then withdraw their original value.
        // Vault is then un-useable because below we're dividing 0 by > 0.
        if (balance == 0 || totalSupply() == 0 || balance < _totalForSale) return _uAmount;

        rcaAmount = ((totalSupply() + pendingWithdrawal) * _uAmount) / (balance - _totalForSale);
    }

    /**
     * @notice For frontend calls. Doesn't need to verify info because it's not changing state.
     */
    function getExtraForSale(uint256 _newCumLiqForClaims) public view returns (uint256 extraForSale) {
        // Check for liquidation, then percent paused, then APR
        uint256 extraLiqForClaims = _newCumLiqForClaims - cumLiqForClaims;
        uint256 extraFees = _getInterimFees(controller.apr(), uint256(controller.getAprUpdate()));
        extraForSale = extraFees + extraLiqForClaims;
        return extraForSale;
    }

    /**
     * @notice Get the amount that should be added to "amtForSale" based on actions within the time since last update.
     * @dev If values have changed within the interim period,
     * this function averages them to find new owed amounts for fees.
     * @param _newApr new APR.
     * @param _aprUpdate start time for new APR.
     */
    function _getInterimFees(uint256 _newApr, uint256 _aprUpdate) internal view returns (uint256 fees) {
        // Get all variables that are currently in this contract's state.
        uint256 balance = _uBalance();
        uint256 aprAvg = apr * BUFFER;
        uint256 totalTimeElapsed = block.timestamp - lastUpdate;

        // Find average APR throughout period if it has been updated.
        if (_aprUpdate > lastUpdate) {
            uint256 aprPrev = apr * (_aprUpdate - lastUpdate);
            uint256 aprCur = _newApr * (block.timestamp - _aprUpdate);
            aprAvg = ((aprPrev + aprCur) * BUFFER) / totalTimeElapsed;
        }

        // Will probably never occur, but just in case.
        if (balance < amtForSale) return 0;

        // Calculate fees based on average active amount.
        uint256 activeInclReserved = balance - amtForSale;
        fees = (activeInclReserved * aprAvg * totalTimeElapsed) / YEAR_SECS / DENOMINATOR / BUFFER;
    }

    /**
     * @notice Grabs full underlying balance to make frontend fetching much easier.
     */
    function uBalance() external view returns (uint256) {
        return _uBalance();
    }

    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //////////////////////////////////////////////// internal ///////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////

    /**
     * @notice Update the amtForSale if there's an active fee.
     */
    function _update() internal {
        if (apr > 0) {
            uint256 balance = _uBalance();

            // If liquidation for claims is set incorrectly this could occur and break the contract.
            if (balance < amtForSale) return;

            uint256 secsElapsed = block.timestamp - lastUpdate;
            uint256 active = balance - amtForSale;
            uint256 activeExclReserved = active - ((active * percentReserved) / DENOMINATOR);

            amtForSale += (activeExclReserved * secsElapsed * apr) / YEAR_SECS / DENOMINATOR;
        }

        lastUpdate = block.timestamp;
    }

    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ///////////////////////////////////////////////// virtual ///////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////

    /// @notice Check balance of underlying token.
    function _uBalance() internal view virtual returns (uint256);

    /// @notice Logic to run after a mint, such as if we need to stake the underlying token.
    function _afterMint(uint256 _uAmount) internal virtual;

    /// @notice Logic to run after a redeem, such as unstaking.
    function _afterRedeem(uint256 _uAmount) internal virtual;

    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////// onlyController //////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////

    /**
     * @notice Update function to be called by controller. This is only called when a controller has made
     * an APR update since the last shield update was made, so it must do extra calculations to determine
     * what the exact costs throughout the period were according to when system updates were made.
     */
    function controllerUpdate(uint256 _newApr, uint256 _aprUpdate) external onlyController {
        uint256 extraFees = _getInterimFees(_newApr, _aprUpdate);

        amtForSale += extraFees;
        lastUpdate = block.timestamp;
    }

    /**
     * @notice Add a for sale amount to this shield vault.
     * @param _newCumLiqForClaims New cumulative total for sale.
     **/
    function setLiqForClaims(uint256 _newCumLiqForClaims) external onlyController {
        if (_newCumLiqForClaims > cumLiqForClaims) {
            amtForSale += _newCumLiqForClaims - cumLiqForClaims;
        } else {
            uint256 subtrahend = cumLiqForClaims - _newCumLiqForClaims;
            amtForSale = amtForSale > subtrahend ? amtForSale - subtrahend : 0;
        }

        require(_uBalance() >= amtForSale, "amtForSale is too high.");

        cumLiqForClaims = _newCumLiqForClaims;
    }

    /**
     * @notice Change the treasury address to which funds will be sent.
     * @param _newTreasury New treasury address.
     **/
    function setTreasury(address _newTreasury) external onlyController {
        treasury = payable(_newTreasury);
    }

    /**
     * @notice Change the percent reserved on this vault. 1000 == 10%.
     * @param _newPercentReserved New percent reserved.
     **/
    function setPercentReserved(uint256 _newPercentReserved) external onlyController {
        // Protection to not have too much reserved from any single vault.
        if (_newPercentReserved > 3300) {
            percentReserved = 3300;
        } else {
            percentReserved = _newPercentReserved;
        }
    }

    /**
     * @notice Change the withdrawal delay of withdrawing underlying tokens from vault. In seconds.
     * @param _newWithdrawalDelay New withdrawal delay.
     **/
    function setWithdrawalDelay(uint256 _newWithdrawalDelay) external onlyController {
        withdrawalDelay = _newWithdrawalDelay;
    }

    /**
     * @notice Change the discount that users get for purchasing from us. 1000 == 10%.
     * @param _newDiscount New discount.
     **/
    function setDiscount(uint256 _newDiscount) external onlyController {
        discount = _newDiscount;
    }

    /**
     * @notice Change the treasury address to which funds will be sent.
     * @param _newApr New APR. 1000 == 10%.
     **/
    function setApr(uint256 _newApr) external onlyController {
        apr = _newApr;
    }

    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////// onlyGov //////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////

    /**
     * @notice Update Controller to a new address. Very rare case for this to be used.
     * @param _newController Address of the new Controller contract.
     */
    function setController(address _newController) external onlyGov {
        controller = IRcaController(_newController);
    }

    /**
     * @notice Needed for Nexus to prove this contract lost funds. We'll likely have reinsurance
     * at least at the beginning to ensure we don't have too much risk in certain protocols.
     * @param _coverAddress Address that we need to send 0 eth to to confirm we had a loss.
     */
    function proofOfLoss(address payable _coverAddress) external onlyGov {
        _coverAddress.transfer(0);
    }
}

File 5 of 13 : Governable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;

/**
 * @title Governable
 * @dev Pretty default ownable but with variable names changed to better convey owner.
 */
contract Governable {
    address payable private _governor;
    address payable private _pendingGovernor;

    event OwnershipTransferred(address indexed previousGovernor, address indexed newGovernor);
    event PendingOwnershipTransfer(address indexed from, address indexed to);

    /**
     * @dev The Ownable constructor sets the original `owner` of the contract to the sender
     * account.
     */
    function initializeGovernable(address _newGovernor) internal {
        require(_governor == address(0), "already initialized");
        _governor = payable(_newGovernor);
        emit OwnershipTransferred(address(0), _newGovernor);
    }

    /**
     * @return the address of the owner.
     */
    function governor() public view returns (address payable) {
        return _governor;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyGov() {
        require(isGov(), "msg.sender is not owner");
        _;
    }

    /**
     * @return true if `msg.sender` is the owner of the contract.
     */
    function isGov() public view returns (bool) {
        return msg.sender == _governor;
    }

    /**
     * @dev Allows the current owner to transfer control of the contract to a newOwner.
     * @param newGovernor The address to transfer ownership to.
     */
    function transferOwnership(address payable newGovernor) public onlyGov {
        _pendingGovernor = newGovernor;
        emit PendingOwnershipTransfer(_governor, newGovernor);
    }

    function receiveOwnership() public {
        require(msg.sender == _pendingGovernor, "Only pending governor can call this function");
        _transferOwnership(_pendingGovernor);
        _pendingGovernor = payable(address(0));
    }

    /**
     * @dev Transfers control of the contract to a newOwner.
     * @param newGovernor The address to transfer ownership to.
     */
    function _transferOwnership(address payable newGovernor) internal {
        require(newGovernor != address(0));
        emit OwnershipTransferred(_governor, newGovernor);
        _governor = newGovernor;
    }

    uint256[50] private __gap;
}

File 6 of 13 : IRouter.sol
/// SPDX-License-Identifier: UNLICENSED

pragma solidity ^0.8.11;

interface IRouter {
    function routeTo(
        address user,
        uint256 uAmount,
        bytes calldata data
    ) external;
}

File 7 of 13 : IRcaController.sol
/// SPDX-License-Identifier: UNLICENSED

pragma solidity ^0.8.11;

interface IRcaController {
    function mint(
        address user,
        uint256 uAmount,
        uint256 expiry,
        uint8 v,
        bytes32 r,
        bytes32 s,
        uint256 _newCumLiq,
        bytes32[] calldata cumLiqProof
    ) external;

    function redeemRequest(
        address user,
        uint256 _newCumLiq,
        bytes32[] calldata cumLiqProof,
        uint256 _newPercentReserved,
        bytes32[] calldata _percentReservedProof
    ) external;

    function redeemFinalize(
        address user,
        address _to,
        uint256 _newCumLiq,
        bytes32[] calldata cumLiqProof,
        uint256 _newPercentReserved,
        bytes32[] calldata _percentReservedProof
    ) external returns (bool);

    function purchase(
        address user,
        address uToken,
        uint256 uEthPrice,
        bytes32[] calldata priceProof,
        uint256 _newCumLiq,
        bytes32[] calldata cumLiqProof
    ) external;

    function verifyLiq(
        address shield,
        uint256 _newCumLiq,
        bytes32[] memory cumLiqProof
    ) external view;

    function verifyPrice(
        address shield,
        uint256 _value,
        bytes32[] memory _proof
    ) external view;

    function apr() external view returns (uint256);

    function getAprUpdate() external view returns (uint32);

    function systemUpdates()
        external
        view
        returns (
            uint32,
            uint32,
            uint32,
            uint32,
            uint32,
            uint32
        );
}

File 8 of 13 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (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 `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 amount) external returns (bool);

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

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

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

    /**
     * @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 9 of 13 : ERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/ERC20.sol)

pragma solidity ^0.8.0;

import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";

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

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

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * The default value of {decimals} is 18. To select a different value for
     * {decimals} you should overload it.
     *
     * All two of these values are immutable: they can only be set once during
     * construction.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

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

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

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

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

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

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

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

    /**
     * @dev See {IERC20-approve}.
     *
     * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
     * `transferFrom`. This is semantically equivalent to an infinite approval.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * NOTE: Does not update the allowance if the current allowance
     * is the maximum `uint256`.
     *
     * Requirements:
     *
     * - `from` and `to` cannot be the zero address.
     * - `from` must have a balance of at least `amount`.
     * - the caller must have allowance for ``from``'s tokens of at least
     * `amount`.
     */
    function transferFrom(
        address from,
        address to,
        uint256 amount
    ) public virtual override returns (bool) {
        address spender = _msgSender();
        _spendAllowance(from, spender, amount);
        _transfer(from, to, amount);
        return true;
    }

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

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

        return true;
    }

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

        _beforeTokenTransfer(from, to, amount);

        uint256 fromBalance = _balances[from];
        require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
        unchecked {
            _balances[from] = fromBalance - amount;
        }
        _balances[to] += amount;

        emit Transfer(from, to, amount);

        _afterTokenTransfer(from, to, amount);
    }

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

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

        _totalSupply += amount;
        _balances[account] += amount;
        emit Transfer(address(0), account, amount);

        _afterTokenTransfer(address(0), account, amount);
    }

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

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

        uint256 accountBalance = _balances[account];
        require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
        unchecked {
            _balances[account] = accountBalance - amount;
        }
        _totalSupply -= amount;

        emit Transfer(account, address(0), amount);

        _afterTokenTransfer(account, address(0), amount);
    }

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

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

    /**
     * @dev Spend `amount` form the allowance of `owner` toward `spender`.
     *
     * Does not update the allowance amount in case of infinite allowance.
     * Revert if not enough allowance is available.
     *
     * Might emit an {Approval} event.
     */
    function _spendAllowance(
        address owner,
        address spender,
        uint256 amount
    ) internal virtual {
        uint256 currentAllowance = allowance(owner, spender);
        if (currentAllowance != type(uint256).max) {
            require(currentAllowance >= amount, "ERC20: insufficient allowance");
            unchecked {
                _approve(owner, spender, currentAllowance - amount);
            }
        }
    }

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

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

File 10 of 13 : 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 13 : 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 12 of 13 : 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 13 of 13 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @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
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://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);
            }
        }
    }
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"address","name":"_uToken","type":"address"},{"internalType":"uint256","name":"_uTokenDecimals","type":"uint256"},{"internalType":"address","name":"_governance","type":"address"},{"internalType":"address","name":"_controller","type":"address"},{"internalType":"contract IIncentivesController","name":"_incentivesController","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"address","name":"referrer","type":"address"},{"indexed":false,"internalType":"uint256","name":"uAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rcaAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousGovernor","type":"address"},{"indexed":true,"internalType":"address","name":"newGovernor","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"PendingOwnershipTransfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"uAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rcaAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"ethAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"PurchaseRca","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"uAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"ethAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"PurchaseU","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"uAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rcaAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"RedeemFinalize","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"uAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rcaAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"endTime","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"RedeemRequest","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"amtForSale","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"apr","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"controller","outputs":[{"internalType":"contract IRcaController","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newApr","type":"uint256"},{"internalType":"uint256","name":"_aprUpdate","type":"uint256"}],"name":"controllerUpdate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"cumLiqForClaims","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"discount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newCumLiqForClaims","type":"uint256"}],"name":"getExtraForSale","outputs":[{"internalType":"uint256","name":"extraForSale","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"governor","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"incentivesController","outputs":[{"internalType":"contract IIncentivesController","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_apr","type":"uint256"},{"internalType":"uint256","name":"_discount","type":"uint256"},{"internalType":"address payable","name":"_treasury","type":"address"},{"internalType":"uint256","name":"_withdrawalDelay","type":"uint256"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"isGov","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"address","name":"_referrer","type":"address"},{"internalType":"uint256","name":"_uAmount","type":"uint256"},{"internalType":"uint256","name":"_expiry","type":"uint256"},{"internalType":"uint8","name":"_v","type":"uint8"},{"internalType":"bytes32","name":"_r","type":"bytes32"},{"internalType":"bytes32","name":"_s","type":"bytes32"},{"internalType":"uint256","name":"_newCumLiqForClaims","type":"uint256"},{"internalType":"bytes32[]","name":"_liqForClaimsProof","type":"bytes32[]"}],"name":"mintTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingWithdrawal","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"percentReserved","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address payable","name":"_coverAddress","type":"address"}],"name":"proofOfLoss","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_tokenPrice","type":"uint256"},{"internalType":"bytes32[]","name":"_tokenPriceProof","type":"bytes32[]"},{"internalType":"uint256","name":"_underlyingPrice","type":"uint256"},{"internalType":"bytes32[]","name":"_underlyinPriceProof","type":"bytes32[]"}],"name":"purchase","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_uAmount","type":"uint256"},{"internalType":"uint256","name":"_uEthPrice","type":"uint256"},{"internalType":"bytes32[]","name":"_priceProof","type":"bytes32[]"},{"internalType":"uint256","name":"_newCumLiqForClaims","type":"uint256"},{"internalType":"bytes32[]","name":"_liqForClaimsProof","type":"bytes32[]"}],"name":"purchaseRca","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_uAmount","type":"uint256"},{"internalType":"uint256","name":"_uEthPrice","type":"uint256"},{"internalType":"bytes32[]","name":"_priceProof","type":"bytes32[]"},{"internalType":"uint256","name":"_newCumLiqForClaims","type":"uint256"},{"internalType":"bytes32[]","name":"_liqForClaimsProof","type":"bytes32[]"}],"name":"purchaseU","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_uAmount","type":"uint256"},{"internalType":"uint256","name":"_cumLiqForClaims","type":"uint256"}],"name":"rcaValue","outputs":[{"internalType":"uint256","name":"rcaAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"receiveOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"bytes","name":"_routerData","type":"bytes"},{"internalType":"uint256","name":"_newCumLiqForClaims","type":"uint256"},{"internalType":"bytes32[]","name":"_liqForClaimsProof","type":"bytes32[]"},{"internalType":"uint256","name":"_newPercentReserved","type":"uint256"},{"internalType":"bytes32[]","name":"_percentReservedProof","type":"bytes32[]"}],"name":"redeemFinalize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_rcaAmount","type":"uint256"},{"internalType":"uint256","name":"_newCumLiqForClaims","type":"uint256"},{"internalType":"bytes32[]","name":"_liqForClaimsProof","type":"bytes32[]"},{"internalType":"uint256","name":"_newPercentReserved","type":"uint256"},{"internalType":"bytes32[]","name":"_percentReservedProof","type":"bytes32[]"}],"name":"redeemRequest","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newApr","type":"uint256"}],"name":"setApr","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newController","type":"address"}],"name":"setController","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newDiscount","type":"uint256"}],"name":"setDiscount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newCumLiqForClaims","type":"uint256"}],"name":"setLiqForClaims","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newPercentReserved","type":"uint256"}],"name":"setPercentReserved","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newTreasury","type":"address"}],"name":"setTreasury","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newWithdrawalDelay","type":"uint256"}],"name":"setWithdrawalDelay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"newGovernor","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"treasury","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"uBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"uToken","outputs":[{"internalType":"contract IERC20Metadata","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_rcaAmount","type":"uint256"},{"internalType":"uint256","name":"_cumLiqForClaims","type":"uint256"},{"internalType":"uint256","name":"_percentReserved","type":"uint256"}],"name":"uValue","outputs":[{"internalType":"uint256","name":"uAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"withdrawRequests","outputs":[{"internalType":"uint112","name":"uAmount","type":"uint112"},{"internalType":"uint112","name":"rcaAmount","type":"uint112"},{"internalType":"uint32","name":"endTime","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdrawalDelay","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]

60e06040523480156200001157600080fd5b5060405162003cf338038062003cf3833981016040819052620000349162000313565b8686868686868585858484848481600390805190602001906200005992919062000187565b5080516200006f90600490602084019062000187565b5050506200008382620000dd60201b60201c565b6001600160a01b03928316608052603980546001600160a01b031916919093161790915550620000b99150849050600a620004f3565b60a0525050506001600160a01b0390931660c0525062000545975050505050505050565b6005546001600160a01b0316156200013b5760405162461bcd60e51b815260206004820152601360248201527f616c726561647920696e697469616c697a656400000000000000000000000000604482015260640160405180910390fd5b600580546001600160a01b0319166001600160a01b0383169081179091556040516000907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a350565b828054620001959062000508565b90600052602060002090601f016020900481019282620001b9576000855562000204565b82601f10620001d457805160ff191683800117855562000204565b8280016001018555821562000204579182015b8281111562000204578251825591602001919060010190620001e7565b506200021292915062000216565b5090565b5b8082111562000212576000815560010162000217565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126200025557600080fd5b81516001600160401b03808211156200027257620002726200022d565b604051601f8301601f19908116603f011681019082821181831017156200029d576200029d6200022d565b81604052838152602092508683858801011115620002ba57600080fd5b600091505b83821015620002de5785820183015181830184015290820190620002bf565b83821115620002f05760008385830101525b9695505050505050565b6001600160a01b03811681146200031057600080fd5b50565b600080600080600080600060e0888a0312156200032f57600080fd5b87516001600160401b03808211156200034757600080fd5b620003558b838c0162000243565b985060208a01519150808211156200036c57600080fd5b506200037b8a828b0162000243565b96505060408801516200038e81620002fa565b606089015160808a01519196509450620003a881620002fa565b60a0890151909350620003bb81620002fa565b60c0890151909250620003ce81620002fa565b8091505092959891949750929550565b634e487b7160e01b600052601160045260246000fd5b600181815b8085111562000435578160001904821115620004195762000419620003de565b808516156200042757918102915b93841c9390800290620003f9565b509250929050565b6000826200044e57506001620004ed565b816200045d57506000620004ed565b81600181146200047657600281146200048157620004a1565b6001915050620004ed565b60ff841115620004955762000495620003de565b50506001821b620004ed565b5060208310610133831016604e8410600b8410161715620004c6575081810a620004ed565b620004d28383620003f4565b8060001904821115620004e957620004e9620003de565b0290505b92915050565b60006200050183836200043d565b9392505050565b600181811c908216806200051d57607f821691505b602082108114156200053f57634e487b7160e01b600052602260045260246000fd5b50919050565b60805160a05160c051613723620005d0600039600081816106f301528181610b790152610c0b01526000818161268d0152612a030152600081816104f101528181610b1f01528181610e5a015281816110390152818161170301528181611a5101528181611b8001528181611c4101528181611d4f01528181611eb60152612a3701526137236000f3fe6080604052600436106102935760003560e01c80637e2888221161015a578063cf9640b4116100c1578063ea1fd2df1161007a578063ea1fd2df14610837578063f0f4426014610857578063f2d348c214610877578063f2fde38b14610897578063f77c4791146108b7578063fc6b3204146108d757600080fd5b8063cf9640b41461075e578063d2c13da51461077e578063d786b6691461079e578063dabd2719146107be578063dc0e91eb146107de578063dd62ed3e146107f157600080fd5b8063a7ab696111610113578063a7ab6961146106ab578063a9059cbb146106c1578063af1df255146106e1578063b5432b3114610715578063c646d14314610735578063cadc98fa1461074857600080fd5b80637e2888221461060a5780638fbd1a6c1461062057806390c0a28b1461064057806392eefe9b1461065657806395d89b4114610676578063a457c2d71461068b57600080fd5b806358f43751116101fe5780636be2ca5f116101b75780636be2ca5f1461054957806370a082311461055f57806375e309ba1461059557806375f9fcb5146105b55780637712f541146105d55780637c976cc6146105ea57600080fd5b806358f437511461047f57806359cee29c1461049f57806361d027b3146104bf57806363315637146104df57806366a0b015146105135780636b6f4a9d1461053357600080fd5b8063313ce56711610250578063313ce5671461037b57806339509351146103975780633b3ae2bb146103b75780633d18b912146103d757806352df49ec146103ec57806357ded9c91461046957600080fd5b806306fdde0314610298578063095ea7b3146102c35780630c340a24146102f357806318160ddd146103255780631c74a3011461034457806323b872dd1461035b575b600080fd5b3480156102a457600080fd5b506102ad6108f7565b6040516102ba9190612cb8565b60405180910390f35b3480156102cf57600080fd5b506102e36102de366004612d00565b610989565b60405190151581526020016102ba565b3480156102ff57600080fd5b506005546001600160a01b03165b6040516001600160a01b0390911681526020016102ba565b34801561033157600080fd5b506002545b6040519081526020016102ba565b34801561035057600080fd5b506103596109a3565b005b34801561036757600080fd5b506102e3610376366004612d2c565b610a3e565b34801561038757600080fd5b50604051601281526020016102ba565b3480156103a357600080fd5b506102e36103b2366004612d00565b610a64565b3480156103c357600080fd5b506103596103d2366004612d6d565b610aa3565b3480156103e357600080fd5b50610359610afb565b3480156103f857600080fd5b5061043d610407366004612d8f565b6042602052600090815260409020546001600160701b0380821691600160701b810490911690600160e01b900463ffffffff1683565b604080516001600160701b03948516815293909216602084015263ffffffff16908201526060016102ba565b34801561047557600080fd5b50610336603a5481565b34801561048b57600080fd5b5061035961049a366004612df8565b610c8c565b3480156104ab57600080fd5b506103596104ba366004612ee8565b610f68565b3480156104cb57600080fd5b50603c5461030d906001600160a01b031681565b3480156104eb57600080fd5b5061030d7f000000000000000000000000000000000000000000000000000000000000000081565b34801561051f57600080fd5b5061035961052e366004612f10565b610f97565b34801561053f57600080fd5b50610336603b5481565b34801561055557600080fd5b50610336603f5481565b34801561056b57600080fd5b5061033661057a366004612d8f565b6001600160a01b031660009081526020819052604090205490565b3480156105a157600080fd5b506103366105b0366004612d6d565b6110ca565b3480156105c157600080fd5b506103596105d0366004612fc0565b6110f7565b3480156105e157600080fd5b50610336611371565b3480156105f657600080fd5b50610359610605366004612ee8565b611380565b34801561061657600080fd5b5061033660405481565b34801561062c57600080fd5b5061033661063b366004612ee8565b6113c6565b34801561064c57600080fd5b50610336603d5481565b34801561066257600080fd5b50610359610671366004612d8f565b6114e3565b34801561068257600080fd5b506102ad61152f565b34801561069757600080fd5b506102e36106a6366004612d00565b61153e565b3480156106b757600080fd5b5061033660415481565b3480156106cd57600080fd5b506102e36106dc366004612d00565b6115db565b3480156106ed57600080fd5b5061030d7f000000000000000000000000000000000000000000000000000000000000000081565b34801561072157600080fd5b50610359610730366004612ee8565b6115e9565b61035961074336600461304d565b6116d9565b34801561075457600080fd5b50610336603e5481565b34801561076a57600080fd5b506103596107793660046130ec565b6118d4565b34801561078a57600080fd5b50610359610799366004612ee8565b61199a565b3480156107aa57600080fd5b506103366107b936600461312b565b6119c9565b3480156107ca57600080fd5b506103596107d9366004612ee8565b6119f8565b6103596107ec36600461304d565b611a27565b3480156107fd57600080fd5b5061033661080c366004613157565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b34801561084357600080fd5b5061035961085236600461304d565b611c3f565b34801561086357600080fd5b50610359610872366004612d8f565b611eea565b34801561088357600080fd5b50610359610892366004612d8f565b611f36565b3480156108a357600080fd5b506103596108b2366004612d8f565b611f97565b3480156108c357600080fd5b5060395461030d906001600160a01b031681565b3480156108e357600080fd5b506005546001600160a01b031633146102e3565b60606003805461090690613190565b80601f016020809104026020016040519081016040528092919081815260200182805461093290613190565b801561097f5780601f106109545761010080835404028352916020019161097f565b820191906000526020600020905b81548152906001019060200180831161096257829003601f168201915b5050505050905090565b600033610997818585612013565b60019150505b92915050565b6006546001600160a01b03163314610a175760405162461bcd60e51b815260206004820152602c60248201527f4f6e6c792070656e64696e6720676f7665726e6f722063616e2063616c6c207460448201526b3434b990333ab731ba34b7b760a11b60648201526084015b60405180910390fd5b600654610a2c906001600160a01b0316612137565b600680546001600160a01b0319169055565b600033610a4c8582856121a6565b610a57858585612238565b60019150505b9392505050565b3360008181526001602090815260408083206001600160a01b03871684529091528120549091906109979082908690610a9e9087906131e1565b612013565b6039546001600160a01b03163314610acd5760405162461bcd60e51b8152600401610a0e906131f9565b6000610ad98383612406565b905080603f6000828254610aed91906131e1565b909155505042604355505050565b604080516001808252818301909252600091602080830190803683370190505090507f000000000000000000000000000000000000000000000000000000000000000081600081518110610b5157610b51613244565b6001600160a01b0392831660209182029290920101526040516345accf9360e11b81526000917f00000000000000000000000000000000000000000000000000000000000000001690638b599f2690610bb0908590309060040161329e565b602060405180830381865afa158015610bcd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bf191906132c8565b604051633111e7b360e01b81529091506001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690633111e7b390610c44908590859030906004016132e1565b6020604051808303816000875af1158015610c63573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c8791906132c8565b505050565b336000818152604260208181526040808420815160608101835281546001600160701b038082168352600160701b8204168286015263ffffffff600160e01b909104811693820193845296865293909252929055905190911615801590610d025750806040015163ffffffff164263ffffffff16115b610d4e5760405162461bcd60e51b815260206004820152601b60248201527f5769746864726177616c206e6f742079657420616c6c6f7765642e00000000006044820152606401610a0e565b603954604051631870665d60e21b81526000916001600160a01b0316906361c1997490610d8d9033908f908d908d908d908d908d908d9060040161334a565b6020604051808303816000875af1158015610dac573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dd091906133a6565b9050610dda612524565b81602001516001600160701b031660406000828254610df991906133c8565b925050819055506000610e1e83602001516001600160701b0316603f54603d546125e8565b83519091506001600160701b0316811115610e40575081516001600160701b03165b6000610e4b8261267d565b9050610e816001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168e836126bc565b8215610eec578c6001600160a01b0316637dabc75733838f8f6040518563ffffffff1660e01b8152600401610eb994939291906133df565b600060405180830381600087803b158015610ed357600080fd5b505af1158015610ee7573d6000803e3d6000fd5b505050505b8c6001600160a01b0316336001600160a01b03167f8e1e77f1fc31b0a9951d3ec7d02f21f3ec4f2248a09a6f4e37587303d0e961338387602001516001600160701b031642604051610f51939291909283526020830191909152604082015260600190565b60405180910390a350505050505050505050505050565b6039546001600160a01b03163314610f925760405162461bcd60e51b8152600401610a0e906131f9565b603a55565b60395460405163f894849f60e01b81526001600160a01b039091169063f894849f90610fd7908d908c908c908c908c908c908c908c908c90600401613427565b600060405180830381600087803b158015610ff157600080fd5b505af1158015611005573d6000803e3d6000fd5b50505050611011612524565b600061101f89603f5461271f565b905061102a8961267d565b98506110616001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001633308c612786565b61106b8b826127be565b604080518a815260208101839052428183015290516001600160a01b038c811692908e169133917feca801b067fae3d181506c21fb55d44a644d16cdb863595643131a7e105b5f01919081900360600190a45050505050505050505050565b6000806110d6836113c6565b90506110ef8482603f546110ea91906131e1565b61271f565b949350505050565b6039546040516351374ca560e01b81526001600160a01b03909116906351374ca5906111339033908a908a908a908a908a908a90600401613481565b600060405180830381600087803b15801561114d57600080fd5b505af1158015611161573d6000803e3d6000fd5b5050505061116d612524565b600061117e88603f54603d546125e8565b905061118a338961289d565b876040600082825461119c91906131e1565b9091555050336000908152604260209081526040808320815160608101835290546001600160701b03808216808452600160701b830490911694830194909452600160e01b900463ffffffff169181019190915291906111fc90846134d0565b9050600082602001518b61121091906134d0565b905060006041544261122291906134fb565b90506040518060600160405280846001600160701b03168152602001836001600160701b031681526020018263ffffffff1681525060426000336001600160a01b03166001600160a01b0316815260200190815260200160002060008201518160000160006101000a8154816001600160701b0302191690836001600160701b03160217905550602082015181600001600e6101000a8154816001600160701b0302191690836001600160701b03160217905550604082015181600001601c6101000a81548163ffffffff021916908363ffffffff160217905550905050336001600160a01b03167f0a5bed7081b3a25d92b911ed554f54dcff8d81e50faef20051436b4627625a8e868e8463ffffffff164260405161135b949392919093845260208401929092526040830152606082015260800190565b60405180910390a2505050505050505050505050565b600061137b6129eb565b905090565b6039546001600160a01b031633146113aa5760405162461bcd60e51b8152600401610a0e906131f9565b610ce48111156113bd57610ce4603d5550565b603d8190555b50565b600080603e54836113d791906133c8565b905060006114d7603960009054906101000a90046001600160a01b03166001600160a01b03166357ded9c96040518163ffffffff1660e01b8152600401602060405180830381865afa158015611431573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061145591906132c8565b603960009054906101000a90046001600160a01b03166001600160a01b031663e914ff6c6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156114a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114cc919061351a565b63ffffffff16612406565b90506110ef82826131e1565b6005546001600160a01b0316331461150d5760405162461bcd60e51b8152600401610a0e90613540565b603980546001600160a01b0319166001600160a01b0392909216919091179055565b60606004805461090690613190565b3360008181526001602090815260408083206001600160a01b0387168452909152812054909190838110156115c35760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610a0e565b6115d08286868403612013565b506001949350505050565b600033610997818585612238565b6039546001600160a01b031633146116135760405162461bcd60e51b8152600401610a0e906131f9565b603e5481111561164657603e5461162a90826133c8565b603f600082825461163b91906131e1565b9091555061167b9050565b600081603e5461165691906133c8565b905080603f5411611668576000611676565b80603f5461167691906133c8565b603f55505b603f546116866129eb565b10156116d45760405162461bcd60e51b815260206004820152601760248201527f616d74466f7253616c6520697320746f6f20686967682e0000000000000000006044820152606401610a0e565b603e55565b603954604051637bdbfa3160e11b81526001600160a01b039091169063f7b7f46290611737908b907f0000000000000000000000000000000000000000000000000000000000000000908b908b908b908b908b908b9060040161334a565b600060405180830381600087803b15801561175157600080fd5b505af1158015611765573d6000803e3d6000fd5b50505050611771612524565b6000612710603b54886117849190613577565b61178e9190613596565b61179890886133c8565b90506000670de0b6b3a76400006117af8a84613577565b6117b99190613596565b90508034146118025760405162461bcd60e51b815260206004820152601560248201527424b731b7b93932b1ba1022ba3432b91039b2b73a1760591b6044820152606401610a0e565b60006118108a603f5461271f565b905089603f600082825461182491906133c8565b9091555061183490508b826127be565b603c546040516001600160a01b03909116903480156108fc02916000818181858888f1935050505015801561186d573d6000803e3d6000fd5b50604080518b8152602081018390529081018a9052606081018390524260808201526001600160a01b038c16907f21945b242aeffcd052dd8b7c890383b76d0cc7d1249deeec70ac21cd42afe73e9060a00160405180910390a25050505050505050505050565b6039546001600160a01b031633146118fe5760405162461bcd60e51b8152600401610a0e906131f9565b603c546001600160a01b0316156119665760405162461bcd60e51b815260206004820152602660248201527f436f6e74726163742068617320616c7265616479206265656e20696e697469616044820152653634bd32b21760d11b6064820152608401610a0e565b603a93909355603b91909155603c80546001600160a01b0319166001600160a01b0390921691909117905560415542604355565b6039546001600160a01b031633146119c45760405162461bcd60e51b8152600401610a0e906131f9565b604155565b6000806119d5846113c6565b90506119ef8582603f546119e991906131e1565b856125e8565b95945050505050565b6039546001600160a01b03163314611a225760405162461bcd60e51b8152600401610a0e906131f9565b603b55565b603954604051637bdbfa3160e11b81526001600160a01b039091169063f7b7f46290611a85908b907f0000000000000000000000000000000000000000000000000000000000000000908b908b908b908b908b908b9060040161334a565b600060405180830381600087803b158015611a9f57600080fd5b505af1158015611ab3573d6000803e3d6000fd5b50505050611abf612524565b6000612710603b5488611ad29190613577565b611adc9190613596565b611ae690886133c8565b90506000670de0b6b3a7640000611afd8a84613577565b611b079190613596565b9050803414611b505760405162461bcd60e51b815260206004820152601560248201527424b731b7b93932b1ba1022ba3432b91039b2b73a1760591b6044820152606401610a0e565b88603f6000828254611b6291906133c8565b90915550611b7190508961267d565b9850611ba76001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168b8b6126bc565b603c546040516001600160a01b03909116903480156108fc02916000818181858888f19350505050158015611be0573d6000803e3d6000fd5b50604080518a8152602081018390529081018990524260608201526001600160a01b038b16907fbb2ac200a6c3b8388dbcb5138a75011982b1d73b8ac94027392b22b64ef0fb4c9060800160405180910390a250505050505050505050565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316886001600160a01b03161415611cc15760405162461bcd60e51b815260206004820152601b60248201527f63616e6e6f742062757920756e6465726c79696e6720746f6b656e00000000006044820152606401610a0e565b60395460405163644e0b0760e11b81526001600160a01b039091169063c89c160e90611cf7908b908a908a908a906004016135b8565b60006040518083038186803b158015611d0f57600080fd5b505afa158015611d23573d6000803e3d6000fd5b505060395460405163644e0b0760e11b81526001600160a01b03909116925063c89c160e9150611d7d907f0000000000000000000000000000000000000000000000000000000000000000908790879087906004016135b8565b60006040518083038186803b158015611d9557600080fd5b505afa158015611da9573d6000803e3d6000fd5b505050506000838789611dbc9190613577565b611dc69190613596565b603b5490915015611df957612710603b5482611de29190613577565b611dec9190613596565b611df690826133c8565b90505b6000899050670de0b6b3a7640000816001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611e45573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e6991906135ea565b611e7490600a6136eb565b611e7e908b613577565b611e889190613596565b9850611e9e6001600160a01b038216338b6126bc565b611ede3330611eac8561267d565b6001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016929190612786565b50505050505050505050565b6039546001600160a01b03163314611f145760405162461bcd60e51b8152600401610a0e906131f9565b603c80546001600160a01b0319166001600160a01b0392909216919091179055565b6005546001600160a01b03163314611f605760405162461bcd60e51b8152600401610a0e90613540565b6040516001600160a01b038216906108fc9060009081818181818888f19350505050158015611f93573d6000803e3d6000fd5b5050565b6005546001600160a01b03163314611fc15760405162461bcd60e51b8152600401610a0e90613540565b600680546001600160a01b0319166001600160a01b03838116918217909255600554604051919216907f23e1f881d1e797ea57a7247e53536f0bfc37c42e6645b3bdc4b1c9a0e0d8a13390600090a350565b6001600160a01b0383166120755760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610a0e565b6001600160a01b0382166120d65760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610a0e565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b03811661214a57600080fd5b6005546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600580546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b03838116600090815260016020908152604080832093861683529290522054600019811461223257818110156122255760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610a0e565b6122328484848403612013565b50505050565b6001600160a01b03831661229c5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610a0e565b6001600160a01b0382166122fe5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610a0e565b6001600160a01b038316600090815260208190526040902054818110156123765760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610a0e565b6001600160a01b038085166000908152602081905260408082208585039055918516815290812080548492906123ad9084906131e1565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516123f991815260200190565b60405180910390a3612232565b6000806124116129eb565b90506000670de0b6b3a7640000603a5461242b9190613577565b905060006043544261243d91906133c8565b90506043548511156124ad5760006043548661245991906133c8565b603a546124669190613577565b9050600061247487426133c8565b61247e9089613577565b905082670de0b6b3a764000061249483856131e1565b61249e9190613577565b6124a89190613596565b935050505b603f548310156124c3576000935050505061099d565b6000603f54846124d391906133c8565b9050670de0b6b3a76400006127106301e13380846124f18786613577565b6124fb9190613577565b6125059190613596565b61250f9190613596565b6125199190613596565b979650505050505050565b603a54156125e25760006125366129eb565b9050603f548110156125455750565b60006043544261255591906133c8565b90506000603f548361256791906133c8565b90506000612710603d548361257c9190613577565b6125869190613596565b61259090836133c8565b90506127106301e13380603a5485846125a99190613577565b6125b39190613577565b6125bd9190613596565b6125c79190613596565b603f60008282546125d891906131e1565b9091555050505050505b42604355565b6000806125f36129eb565b90506125fe60025490565b61260b5784915050610a5d565b8381101561261d576000915050610a5d565b60405460025461262d91906131e1565b8561263886846133c8565b6126429190613577565b61264c9190613596565b91508215612675576127106126618484613577565b61266b9190613596565b6119ef90836133c8565b509392505050565b6000670de0b6b3a76400006126b27f000000000000000000000000000000000000000000000000000000000000000084613577565b61099d9190613596565b6040516001600160a01b038316602482015260448101829052610c8790849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612ab6565b60008061272a6129eb565b90508015806127395750600254155b8061274357508281105b15612751578391505061099d565b61275b83826133c8565b8460405461276860025490565b61277291906131e1565b61277c9190613577565b6110ef9190613596565b6040516001600160a01b03808516602483015283166044820152606481018290526122329085906323b872dd60e01b906084016126e8565b6001600160a01b0382166128145760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610a0e565b806002600082825461282691906131e1565b90915550506001600160a01b038216600090815260208190526040812080548392906128539084906131e1565b90915550506040518181526001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b6001600160a01b0382166128fd5760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b6064820152608401610a0e565b6001600160a01b038216600090815260208190526040902054818110156129715760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b6064820152608401610a0e565b6001600160a01b03831660009081526020819052604081208383039055600280548492906129a09084906133c8565b90915550506040518281526000906001600160a01b038516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a3505050565b6040516370a0823160e01b81523060048201526000907f000000000000000000000000000000000000000000000000000000000000000090670de0b6b3a7640000906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906370a0823190602401602060405180830381865afa158015612a7e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612aa291906132c8565b612aac9190613577565b61137b9190613596565b6000612b0b826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612b889092919063ffffffff16565b805190915015610c875780806020019051810190612b2991906133a6565b610c875760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610a0e565b60606110ef8484600085856001600160a01b0385163b612bea5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610a0e565b600080866001600160a01b03168587604051612c0691906136fa565b60006040518083038185875af1925050503d8060008114612c43576040519150601f19603f3d011682016040523d82523d6000602084013e612c48565b606091505b509150915061251982828660608315612c62575081610a5d565b825115612c725782518084602001fd5b8160405162461bcd60e51b8152600401610a0e9190612cb8565b60005b83811015612ca7578181015183820152602001612c8f565b838111156122325750506000910152565b6020815260008251806020840152612cd7816040850160208701612c8c565b601f01601f19169190910160400192915050565b6001600160a01b03811681146113c357600080fd5b60008060408385031215612d1357600080fd5b8235612d1e81612ceb565b946020939093013593505050565b600080600060608486031215612d4157600080fd5b8335612d4c81612ceb565b92506020840135612d5c81612ceb565b929592945050506040919091013590565b60008060408385031215612d8057600080fd5b50508035926020909101359150565b600060208284031215612da157600080fd5b8135610a5d81612ceb565b60008083601f840112612dbe57600080fd5b50813567ffffffffffffffff811115612dd657600080fd5b6020830191508360208260051b8501011115612df157600080fd5b9250929050565b600080600080600080600080600060c08a8c031215612e1657600080fd5b8935612e2181612ceb565b985060208a013567ffffffffffffffff80821115612e3e57600080fd5b818c0191508c601f830112612e5257600080fd5b813581811115612e6157600080fd5b8d6020828501011115612e7357600080fd5b602083019a508099505060408c0135975060608c0135915080821115612e9857600080fd5b612ea48d838e01612dac565b909750955060808c0135945060a08c0135915080821115612ec457600080fd5b50612ed18c828d01612dac565b915080935050809150509295985092959850929598565b600060208284031215612efa57600080fd5b5035919050565b60ff811681146113c357600080fd5b6000806000806000806000806000806101208b8d031215612f3057600080fd5b8a35612f3b81612ceb565b995060208b0135612f4b81612ceb565b985060408b0135975060608b0135965060808b0135612f6981612f01565b955060a08b0135945060c08b0135935060e08b013592506101008b013567ffffffffffffffff811115612f9b57600080fd5b612fa78d828e01612dac565b915080935050809150509295989b9194979a5092959850565b600080600080600080600060a0888a031215612fdb57600080fd5b8735965060208801359550604088013567ffffffffffffffff8082111561300157600080fd5b61300d8b838c01612dac565b909750955060608a0135945060808a013591508082111561302d57600080fd5b5061303a8a828b01612dac565b989b979a50959850939692959293505050565b60008060008060008060008060c0898b03121561306957600080fd5b883561307481612ceb565b97506020890135965060408901359550606089013567ffffffffffffffff8082111561309f57600080fd5b6130ab8c838d01612dac565b909750955060808b0135945060a08b01359150808211156130cb57600080fd5b506130d88b828c01612dac565b999c989b5096995094979396929594505050565b6000806000806080858703121561310257600080fd5b8435935060208501359250604085013561311b81612ceb565b9396929550929360600135925050565b60008060006060848603121561314057600080fd5b505081359360208301359350604090920135919050565b6000806040838503121561316a57600080fd5b823561317581612ceb565b9150602083013561318581612ceb565b809150509250929050565b600181811c908216806131a457607f821691505b602082108114156131c557634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b600082198211156131f4576131f46131cb565b500190565b6020808252602b908201527f46756e6374696f6e206d757374206f6e6c792062652063616c6c65642062792060408201526a31b7b73a3937b63632b91760a91b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b600081518084526020808501945080840160005b838110156132935781516001600160a01b03168752958201959082019060010161326e565b509495945050505050565b6040815260006132b1604083018561325a565b905060018060a01b03831660208301529392505050565b6000602082840312156132da57600080fd5b5051919050565b6060815260006132f4606083018661325a565b6020830194909452506001600160a01b0391909116604090910152919050565b81835260006001600160fb1b0383111561332d57600080fd5b8260051b8083602087013760009401602001938452509192915050565b6001600160a01b038981168252881660208201526040810187905260c06060820181905260009061337e9083018789613314565b85608084015282810360a0840152613397818587613314565b9b9a5050505050505050505050565b6000602082840312156133b857600080fd5b81518015158114610a5d57600080fd5b6000828210156133da576133da6131cb565b500390565b6001600160a01b0385168152602081018490526060604082018190528101829052818360808301376000818301608090810191909152601f909201601f191601019392505050565b600061010060018060a01b038c1683528a602084015289604084015260ff891660608401528760808401528660a08401528560c08401528060e08401526134718184018587613314565b9c9b505050505050505050505050565b60018060a01b038816815286602082015260a0604082015260006134a960a083018789613314565b85606084015282810360808401526134c2818587613314565b9a9950505050505050505050565b60006001600160701b038083168185168083038211156134f2576134f26131cb565b01949350505050565b600063ffffffff8083168185168083038211156134f2576134f26131cb565b60006020828403121561352c57600080fd5b815163ffffffff81168114610a5d57600080fd5b60208082526017908201527f6d73672e73656e646572206973206e6f74206f776e6572000000000000000000604082015260600190565b6000816000190483118215151615613591576135916131cb565b500290565b6000826135b357634e487b7160e01b600052601260045260246000fd5b500490565b60018060a01b03851681528360208201526060604082015260006135e0606083018486613314565b9695505050505050565b6000602082840312156135fc57600080fd5b8151610a5d81612f01565b600181815b80851115613642578160001904821115613628576136286131cb565b8085161561363557918102915b93841c939080029061360c565b509250929050565b6000826136595750600161099d565b816136665750600061099d565b816001811461367c5760028114613686576136a2565b600191505061099d565b60ff841115613697576136976131cb565b50506001821b61099d565b5060208310610133831016604e8410600b84101617156136c5575081810a61099d565b6136cf8383613607565b80600019048211156136e3576136e36131cb565b029392505050565b6000610a5d60ff84168361364a565b6000825161370c818460208701612c8c565b919091019291505056fea164736f6c634300080b000a00000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000001200000000000000000000000008dae6cb04688c62d939ed9b68d32bc62e49970b100000000000000000000000000000000000000000000000000000000000000120000000000000000000000005afedef13bd7b3e363db724420d773caa8b88763000000000000000000000000ea5edef1a7106d9e2024240299df3d00c7d94767000000000000000000000000d784927ff2f95ba542bfc824c8a8a98f3495f6b5000000000000000000000000000000000000000000000000000000000000000f614352562045617365205661756c7400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007657a2d6143525600000000000000000000000000000000000000000000000000

Deployed Bytecode

0x6080604052600436106102935760003560e01c80637e2888221161015a578063cf9640b4116100c1578063ea1fd2df1161007a578063ea1fd2df14610837578063f0f4426014610857578063f2d348c214610877578063f2fde38b14610897578063f77c4791146108b7578063fc6b3204146108d757600080fd5b8063cf9640b41461075e578063d2c13da51461077e578063d786b6691461079e578063dabd2719146107be578063dc0e91eb146107de578063dd62ed3e146107f157600080fd5b8063a7ab696111610113578063a7ab6961146106ab578063a9059cbb146106c1578063af1df255146106e1578063b5432b3114610715578063c646d14314610735578063cadc98fa1461074857600080fd5b80637e2888221461060a5780638fbd1a6c1461062057806390c0a28b1461064057806392eefe9b1461065657806395d89b4114610676578063a457c2d71461068b57600080fd5b806358f43751116101fe5780636be2ca5f116101b75780636be2ca5f1461054957806370a082311461055f57806375e309ba1461059557806375f9fcb5146105b55780637712f541146105d55780637c976cc6146105ea57600080fd5b806358f437511461047f57806359cee29c1461049f57806361d027b3146104bf57806363315637146104df57806366a0b015146105135780636b6f4a9d1461053357600080fd5b8063313ce56711610250578063313ce5671461037b57806339509351146103975780633b3ae2bb146103b75780633d18b912146103d757806352df49ec146103ec57806357ded9c91461046957600080fd5b806306fdde0314610298578063095ea7b3146102c35780630c340a24146102f357806318160ddd146103255780631c74a3011461034457806323b872dd1461035b575b600080fd5b3480156102a457600080fd5b506102ad6108f7565b6040516102ba9190612cb8565b60405180910390f35b3480156102cf57600080fd5b506102e36102de366004612d00565b610989565b60405190151581526020016102ba565b3480156102ff57600080fd5b506005546001600160a01b03165b6040516001600160a01b0390911681526020016102ba565b34801561033157600080fd5b506002545b6040519081526020016102ba565b34801561035057600080fd5b506103596109a3565b005b34801561036757600080fd5b506102e3610376366004612d2c565b610a3e565b34801561038757600080fd5b50604051601281526020016102ba565b3480156103a357600080fd5b506102e36103b2366004612d00565b610a64565b3480156103c357600080fd5b506103596103d2366004612d6d565b610aa3565b3480156103e357600080fd5b50610359610afb565b3480156103f857600080fd5b5061043d610407366004612d8f565b6042602052600090815260409020546001600160701b0380821691600160701b810490911690600160e01b900463ffffffff1683565b604080516001600160701b03948516815293909216602084015263ffffffff16908201526060016102ba565b34801561047557600080fd5b50610336603a5481565b34801561048b57600080fd5b5061035961049a366004612df8565b610c8c565b3480156104ab57600080fd5b506103596104ba366004612ee8565b610f68565b3480156104cb57600080fd5b50603c5461030d906001600160a01b031681565b3480156104eb57600080fd5b5061030d7f0000000000000000000000008dae6cb04688c62d939ed9b68d32bc62e49970b181565b34801561051f57600080fd5b5061035961052e366004612f10565b610f97565b34801561053f57600080fd5b50610336603b5481565b34801561055557600080fd5b50610336603f5481565b34801561056b57600080fd5b5061033661057a366004612d8f565b6001600160a01b031660009081526020819052604090205490565b3480156105a157600080fd5b506103366105b0366004612d6d565b6110ca565b3480156105c157600080fd5b506103596105d0366004612fc0565b6110f7565b3480156105e157600080fd5b50610336611371565b3480156105f657600080fd5b50610359610605366004612ee8565b611380565b34801561061657600080fd5b5061033660405481565b34801561062c57600080fd5b5061033661063b366004612ee8565b6113c6565b34801561064c57600080fd5b50610336603d5481565b34801561066257600080fd5b50610359610671366004612d8f565b6114e3565b34801561068257600080fd5b506102ad61152f565b34801561069757600080fd5b506102e36106a6366004612d00565b61153e565b3480156106b757600080fd5b5061033660415481565b3480156106cd57600080fd5b506102e36106dc366004612d00565b6115db565b3480156106ed57600080fd5b5061030d7f000000000000000000000000d784927ff2f95ba542bfc824c8a8a98f3495f6b581565b34801561072157600080fd5b50610359610730366004612ee8565b6115e9565b61035961074336600461304d565b6116d9565b34801561075457600080fd5b50610336603e5481565b34801561076a57600080fd5b506103596107793660046130ec565b6118d4565b34801561078a57600080fd5b50610359610799366004612ee8565b61199a565b3480156107aa57600080fd5b506103366107b936600461312b565b6119c9565b3480156107ca57600080fd5b506103596107d9366004612ee8565b6119f8565b6103596107ec36600461304d565b611a27565b3480156107fd57600080fd5b5061033661080c366004613157565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b34801561084357600080fd5b5061035961085236600461304d565b611c3f565b34801561086357600080fd5b50610359610872366004612d8f565b611eea565b34801561088357600080fd5b50610359610892366004612d8f565b611f36565b3480156108a357600080fd5b506103596108b2366004612d8f565b611f97565b3480156108c357600080fd5b5060395461030d906001600160a01b031681565b3480156108e357600080fd5b506005546001600160a01b031633146102e3565b60606003805461090690613190565b80601f016020809104026020016040519081016040528092919081815260200182805461093290613190565b801561097f5780601f106109545761010080835404028352916020019161097f565b820191906000526020600020905b81548152906001019060200180831161096257829003601f168201915b5050505050905090565b600033610997818585612013565b60019150505b92915050565b6006546001600160a01b03163314610a175760405162461bcd60e51b815260206004820152602c60248201527f4f6e6c792070656e64696e6720676f7665726e6f722063616e2063616c6c207460448201526b3434b990333ab731ba34b7b760a11b60648201526084015b60405180910390fd5b600654610a2c906001600160a01b0316612137565b600680546001600160a01b0319169055565b600033610a4c8582856121a6565b610a57858585612238565b60019150505b9392505050565b3360008181526001602090815260408083206001600160a01b03871684529091528120549091906109979082908690610a9e9087906131e1565b612013565b6039546001600160a01b03163314610acd5760405162461bcd60e51b8152600401610a0e906131f9565b6000610ad98383612406565b905080603f6000828254610aed91906131e1565b909155505042604355505050565b604080516001808252818301909252600091602080830190803683370190505090507f0000000000000000000000008dae6cb04688c62d939ed9b68d32bc62e49970b181600081518110610b5157610b51613244565b6001600160a01b0392831660209182029290920101526040516345accf9360e11b81526000917f000000000000000000000000d784927ff2f95ba542bfc824c8a8a98f3495f6b51690638b599f2690610bb0908590309060040161329e565b602060405180830381865afa158015610bcd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bf191906132c8565b604051633111e7b360e01b81529091506001600160a01b037f000000000000000000000000d784927ff2f95ba542bfc824c8a8a98f3495f6b51690633111e7b390610c44908590859030906004016132e1565b6020604051808303816000875af1158015610c63573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c8791906132c8565b505050565b336000818152604260208181526040808420815160608101835281546001600160701b038082168352600160701b8204168286015263ffffffff600160e01b909104811693820193845296865293909252929055905190911615801590610d025750806040015163ffffffff164263ffffffff16115b610d4e5760405162461bcd60e51b815260206004820152601b60248201527f5769746864726177616c206e6f742079657420616c6c6f7765642e00000000006044820152606401610a0e565b603954604051631870665d60e21b81526000916001600160a01b0316906361c1997490610d8d9033908f908d908d908d908d908d908d9060040161334a565b6020604051808303816000875af1158015610dac573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dd091906133a6565b9050610dda612524565b81602001516001600160701b031660406000828254610df991906133c8565b925050819055506000610e1e83602001516001600160701b0316603f54603d546125e8565b83519091506001600160701b0316811115610e40575081516001600160701b03165b6000610e4b8261267d565b9050610e816001600160a01b037f0000000000000000000000008dae6cb04688c62d939ed9b68d32bc62e49970b1168e836126bc565b8215610eec578c6001600160a01b0316637dabc75733838f8f6040518563ffffffff1660e01b8152600401610eb994939291906133df565b600060405180830381600087803b158015610ed357600080fd5b505af1158015610ee7573d6000803e3d6000fd5b505050505b8c6001600160a01b0316336001600160a01b03167f8e1e77f1fc31b0a9951d3ec7d02f21f3ec4f2248a09a6f4e37587303d0e961338387602001516001600160701b031642604051610f51939291909283526020830191909152604082015260600190565b60405180910390a350505050505050505050505050565b6039546001600160a01b03163314610f925760405162461bcd60e51b8152600401610a0e906131f9565b603a55565b60395460405163f894849f60e01b81526001600160a01b039091169063f894849f90610fd7908d908c908c908c908c908c908c908c908c90600401613427565b600060405180830381600087803b158015610ff157600080fd5b505af1158015611005573d6000803e3d6000fd5b50505050611011612524565b600061101f89603f5461271f565b905061102a8961267d565b98506110616001600160a01b037f0000000000000000000000008dae6cb04688c62d939ed9b68d32bc62e49970b11633308c612786565b61106b8b826127be565b604080518a815260208101839052428183015290516001600160a01b038c811692908e169133917feca801b067fae3d181506c21fb55d44a644d16cdb863595643131a7e105b5f01919081900360600190a45050505050505050505050565b6000806110d6836113c6565b90506110ef8482603f546110ea91906131e1565b61271f565b949350505050565b6039546040516351374ca560e01b81526001600160a01b03909116906351374ca5906111339033908a908a908a908a908a908a90600401613481565b600060405180830381600087803b15801561114d57600080fd5b505af1158015611161573d6000803e3d6000fd5b5050505061116d612524565b600061117e88603f54603d546125e8565b905061118a338961289d565b876040600082825461119c91906131e1565b9091555050336000908152604260209081526040808320815160608101835290546001600160701b03808216808452600160701b830490911694830194909452600160e01b900463ffffffff169181019190915291906111fc90846134d0565b9050600082602001518b61121091906134d0565b905060006041544261122291906134fb565b90506040518060600160405280846001600160701b03168152602001836001600160701b031681526020018263ffffffff1681525060426000336001600160a01b03166001600160a01b0316815260200190815260200160002060008201518160000160006101000a8154816001600160701b0302191690836001600160701b03160217905550602082015181600001600e6101000a8154816001600160701b0302191690836001600160701b03160217905550604082015181600001601c6101000a81548163ffffffff021916908363ffffffff160217905550905050336001600160a01b03167f0a5bed7081b3a25d92b911ed554f54dcff8d81e50faef20051436b4627625a8e868e8463ffffffff164260405161135b949392919093845260208401929092526040830152606082015260800190565b60405180910390a2505050505050505050505050565b600061137b6129eb565b905090565b6039546001600160a01b031633146113aa5760405162461bcd60e51b8152600401610a0e906131f9565b610ce48111156113bd57610ce4603d5550565b603d8190555b50565b600080603e54836113d791906133c8565b905060006114d7603960009054906101000a90046001600160a01b03166001600160a01b03166357ded9c96040518163ffffffff1660e01b8152600401602060405180830381865afa158015611431573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061145591906132c8565b603960009054906101000a90046001600160a01b03166001600160a01b031663e914ff6c6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156114a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114cc919061351a565b63ffffffff16612406565b90506110ef82826131e1565b6005546001600160a01b0316331461150d5760405162461bcd60e51b8152600401610a0e90613540565b603980546001600160a01b0319166001600160a01b0392909216919091179055565b60606004805461090690613190565b3360008181526001602090815260408083206001600160a01b0387168452909152812054909190838110156115c35760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610a0e565b6115d08286868403612013565b506001949350505050565b600033610997818585612238565b6039546001600160a01b031633146116135760405162461bcd60e51b8152600401610a0e906131f9565b603e5481111561164657603e5461162a90826133c8565b603f600082825461163b91906131e1565b9091555061167b9050565b600081603e5461165691906133c8565b905080603f5411611668576000611676565b80603f5461167691906133c8565b603f55505b603f546116866129eb565b10156116d45760405162461bcd60e51b815260206004820152601760248201527f616d74466f7253616c6520697320746f6f20686967682e0000000000000000006044820152606401610a0e565b603e55565b603954604051637bdbfa3160e11b81526001600160a01b039091169063f7b7f46290611737908b907f0000000000000000000000008dae6cb04688c62d939ed9b68d32bc62e49970b1908b908b908b908b908b908b9060040161334a565b600060405180830381600087803b15801561175157600080fd5b505af1158015611765573d6000803e3d6000fd5b50505050611771612524565b6000612710603b54886117849190613577565b61178e9190613596565b61179890886133c8565b90506000670de0b6b3a76400006117af8a84613577565b6117b99190613596565b90508034146118025760405162461bcd60e51b815260206004820152601560248201527424b731b7b93932b1ba1022ba3432b91039b2b73a1760591b6044820152606401610a0e565b60006118108a603f5461271f565b905089603f600082825461182491906133c8565b9091555061183490508b826127be565b603c546040516001600160a01b03909116903480156108fc02916000818181858888f1935050505015801561186d573d6000803e3d6000fd5b50604080518b8152602081018390529081018a9052606081018390524260808201526001600160a01b038c16907f21945b242aeffcd052dd8b7c890383b76d0cc7d1249deeec70ac21cd42afe73e9060a00160405180910390a25050505050505050505050565b6039546001600160a01b031633146118fe5760405162461bcd60e51b8152600401610a0e906131f9565b603c546001600160a01b0316156119665760405162461bcd60e51b815260206004820152602660248201527f436f6e74726163742068617320616c7265616479206265656e20696e697469616044820152653634bd32b21760d11b6064820152608401610a0e565b603a93909355603b91909155603c80546001600160a01b0319166001600160a01b0390921691909117905560415542604355565b6039546001600160a01b031633146119c45760405162461bcd60e51b8152600401610a0e906131f9565b604155565b6000806119d5846113c6565b90506119ef8582603f546119e991906131e1565b856125e8565b95945050505050565b6039546001600160a01b03163314611a225760405162461bcd60e51b8152600401610a0e906131f9565b603b55565b603954604051637bdbfa3160e11b81526001600160a01b039091169063f7b7f46290611a85908b907f0000000000000000000000008dae6cb04688c62d939ed9b68d32bc62e49970b1908b908b908b908b908b908b9060040161334a565b600060405180830381600087803b158015611a9f57600080fd5b505af1158015611ab3573d6000803e3d6000fd5b50505050611abf612524565b6000612710603b5488611ad29190613577565b611adc9190613596565b611ae690886133c8565b90506000670de0b6b3a7640000611afd8a84613577565b611b079190613596565b9050803414611b505760405162461bcd60e51b815260206004820152601560248201527424b731b7b93932b1ba1022ba3432b91039b2b73a1760591b6044820152606401610a0e565b88603f6000828254611b6291906133c8565b90915550611b7190508961267d565b9850611ba76001600160a01b037f0000000000000000000000008dae6cb04688c62d939ed9b68d32bc62e49970b1168b8b6126bc565b603c546040516001600160a01b03909116903480156108fc02916000818181858888f19350505050158015611be0573d6000803e3d6000fd5b50604080518a8152602081018390529081018990524260608201526001600160a01b038b16907fbb2ac200a6c3b8388dbcb5138a75011982b1d73b8ac94027392b22b64ef0fb4c9060800160405180910390a250505050505050505050565b7f0000000000000000000000008dae6cb04688c62d939ed9b68d32bc62e49970b16001600160a01b0316886001600160a01b03161415611cc15760405162461bcd60e51b815260206004820152601b60248201527f63616e6e6f742062757920756e6465726c79696e6720746f6b656e00000000006044820152606401610a0e565b60395460405163644e0b0760e11b81526001600160a01b039091169063c89c160e90611cf7908b908a908a908a906004016135b8565b60006040518083038186803b158015611d0f57600080fd5b505afa158015611d23573d6000803e3d6000fd5b505060395460405163644e0b0760e11b81526001600160a01b03909116925063c89c160e9150611d7d907f0000000000000000000000008dae6cb04688c62d939ed9b68d32bc62e49970b1908790879087906004016135b8565b60006040518083038186803b158015611d9557600080fd5b505afa158015611da9573d6000803e3d6000fd5b505050506000838789611dbc9190613577565b611dc69190613596565b603b5490915015611df957612710603b5482611de29190613577565b611dec9190613596565b611df690826133c8565b90505b6000899050670de0b6b3a7640000816001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611e45573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e6991906135ea565b611e7490600a6136eb565b611e7e908b613577565b611e889190613596565b9850611e9e6001600160a01b038216338b6126bc565b611ede3330611eac8561267d565b6001600160a01b037f0000000000000000000000008dae6cb04688c62d939ed9b68d32bc62e49970b116929190612786565b50505050505050505050565b6039546001600160a01b03163314611f145760405162461bcd60e51b8152600401610a0e906131f9565b603c80546001600160a01b0319166001600160a01b0392909216919091179055565b6005546001600160a01b03163314611f605760405162461bcd60e51b8152600401610a0e90613540565b6040516001600160a01b038216906108fc9060009081818181818888f19350505050158015611f93573d6000803e3d6000fd5b5050565b6005546001600160a01b03163314611fc15760405162461bcd60e51b8152600401610a0e90613540565b600680546001600160a01b0319166001600160a01b03838116918217909255600554604051919216907f23e1f881d1e797ea57a7247e53536f0bfc37c42e6645b3bdc4b1c9a0e0d8a13390600090a350565b6001600160a01b0383166120755760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610a0e565b6001600160a01b0382166120d65760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610a0e565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b03811661214a57600080fd5b6005546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600580546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b03838116600090815260016020908152604080832093861683529290522054600019811461223257818110156122255760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610a0e565b6122328484848403612013565b50505050565b6001600160a01b03831661229c5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610a0e565b6001600160a01b0382166122fe5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610a0e565b6001600160a01b038316600090815260208190526040902054818110156123765760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610a0e565b6001600160a01b038085166000908152602081905260408082208585039055918516815290812080548492906123ad9084906131e1565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516123f991815260200190565b60405180910390a3612232565b6000806124116129eb565b90506000670de0b6b3a7640000603a5461242b9190613577565b905060006043544261243d91906133c8565b90506043548511156124ad5760006043548661245991906133c8565b603a546124669190613577565b9050600061247487426133c8565b61247e9089613577565b905082670de0b6b3a764000061249483856131e1565b61249e9190613577565b6124a89190613596565b935050505b603f548310156124c3576000935050505061099d565b6000603f54846124d391906133c8565b9050670de0b6b3a76400006127106301e13380846124f18786613577565b6124fb9190613577565b6125059190613596565b61250f9190613596565b6125199190613596565b979650505050505050565b603a54156125e25760006125366129eb565b9050603f548110156125455750565b60006043544261255591906133c8565b90506000603f548361256791906133c8565b90506000612710603d548361257c9190613577565b6125869190613596565b61259090836133c8565b90506127106301e13380603a5485846125a99190613577565b6125b39190613577565b6125bd9190613596565b6125c79190613596565b603f60008282546125d891906131e1565b9091555050505050505b42604355565b6000806125f36129eb565b90506125fe60025490565b61260b5784915050610a5d565b8381101561261d576000915050610a5d565b60405460025461262d91906131e1565b8561263886846133c8565b6126429190613577565b61264c9190613596565b91508215612675576127106126618484613577565b61266b9190613596565b6119ef90836133c8565b509392505050565b6000670de0b6b3a76400006126b27f0000000000000000000000000000000000000000000000000de0b6b3a764000084613577565b61099d9190613596565b6040516001600160a01b038316602482015260448101829052610c8790849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612ab6565b60008061272a6129eb565b90508015806127395750600254155b8061274357508281105b15612751578391505061099d565b61275b83826133c8565b8460405461276860025490565b61277291906131e1565b61277c9190613577565b6110ef9190613596565b6040516001600160a01b03808516602483015283166044820152606481018290526122329085906323b872dd60e01b906084016126e8565b6001600160a01b0382166128145760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610a0e565b806002600082825461282691906131e1565b90915550506001600160a01b038216600090815260208190526040812080548392906128539084906131e1565b90915550506040518181526001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b6001600160a01b0382166128fd5760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b6064820152608401610a0e565b6001600160a01b038216600090815260208190526040902054818110156129715760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b6064820152608401610a0e565b6001600160a01b03831660009081526020819052604081208383039055600280548492906129a09084906133c8565b90915550506040518281526000906001600160a01b038516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a3505050565b6040516370a0823160e01b81523060048201526000907f0000000000000000000000000000000000000000000000000de0b6b3a764000090670de0b6b3a7640000906001600160a01b037f0000000000000000000000008dae6cb04688c62d939ed9b68d32bc62e49970b116906370a0823190602401602060405180830381865afa158015612a7e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612aa291906132c8565b612aac9190613577565b61137b9190613596565b6000612b0b826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612b889092919063ffffffff16565b805190915015610c875780806020019051810190612b2991906133a6565b610c875760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610a0e565b60606110ef8484600085856001600160a01b0385163b612bea5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610a0e565b600080866001600160a01b03168587604051612c0691906136fa565b60006040518083038185875af1925050503d8060008114612c43576040519150601f19603f3d011682016040523d82523d6000602084013e612c48565b606091505b509150915061251982828660608315612c62575081610a5d565b825115612c725782518084602001fd5b8160405162461bcd60e51b8152600401610a0e9190612cb8565b60005b83811015612ca7578181015183820152602001612c8f565b838111156122325750506000910152565b6020815260008251806020840152612cd7816040850160208701612c8c565b601f01601f19169190910160400192915050565b6001600160a01b03811681146113c357600080fd5b60008060408385031215612d1357600080fd5b8235612d1e81612ceb565b946020939093013593505050565b600080600060608486031215612d4157600080fd5b8335612d4c81612ceb565b92506020840135612d5c81612ceb565b929592945050506040919091013590565b60008060408385031215612d8057600080fd5b50508035926020909101359150565b600060208284031215612da157600080fd5b8135610a5d81612ceb565b60008083601f840112612dbe57600080fd5b50813567ffffffffffffffff811115612dd657600080fd5b6020830191508360208260051b8501011115612df157600080fd5b9250929050565b600080600080600080600080600060c08a8c031215612e1657600080fd5b8935612e2181612ceb565b985060208a013567ffffffffffffffff80821115612e3e57600080fd5b818c0191508c601f830112612e5257600080fd5b813581811115612e6157600080fd5b8d6020828501011115612e7357600080fd5b602083019a508099505060408c0135975060608c0135915080821115612e9857600080fd5b612ea48d838e01612dac565b909750955060808c0135945060a08c0135915080821115612ec457600080fd5b50612ed18c828d01612dac565b915080935050809150509295985092959850929598565b600060208284031215612efa57600080fd5b5035919050565b60ff811681146113c357600080fd5b6000806000806000806000806000806101208b8d031215612f3057600080fd5b8a35612f3b81612ceb565b995060208b0135612f4b81612ceb565b985060408b0135975060608b0135965060808b0135612f6981612f01565b955060a08b0135945060c08b0135935060e08b013592506101008b013567ffffffffffffffff811115612f9b57600080fd5b612fa78d828e01612dac565b915080935050809150509295989b9194979a5092959850565b600080600080600080600060a0888a031215612fdb57600080fd5b8735965060208801359550604088013567ffffffffffffffff8082111561300157600080fd5b61300d8b838c01612dac565b909750955060608a0135945060808a013591508082111561302d57600080fd5b5061303a8a828b01612dac565b989b979a50959850939692959293505050565b60008060008060008060008060c0898b03121561306957600080fd5b883561307481612ceb565b97506020890135965060408901359550606089013567ffffffffffffffff8082111561309f57600080fd5b6130ab8c838d01612dac565b909750955060808b0135945060a08b01359150808211156130cb57600080fd5b506130d88b828c01612dac565b999c989b5096995094979396929594505050565b6000806000806080858703121561310257600080fd5b8435935060208501359250604085013561311b81612ceb565b9396929550929360600135925050565b60008060006060848603121561314057600080fd5b505081359360208301359350604090920135919050565b6000806040838503121561316a57600080fd5b823561317581612ceb565b9150602083013561318581612ceb565b809150509250929050565b600181811c908216806131a457607f821691505b602082108114156131c557634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b600082198211156131f4576131f46131cb565b500190565b6020808252602b908201527f46756e6374696f6e206d757374206f6e6c792062652063616c6c65642062792060408201526a31b7b73a3937b63632b91760a91b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b600081518084526020808501945080840160005b838110156132935781516001600160a01b03168752958201959082019060010161326e565b509495945050505050565b6040815260006132b1604083018561325a565b905060018060a01b03831660208301529392505050565b6000602082840312156132da57600080fd5b5051919050565b6060815260006132f4606083018661325a565b6020830194909452506001600160a01b0391909116604090910152919050565b81835260006001600160fb1b0383111561332d57600080fd5b8260051b8083602087013760009401602001938452509192915050565b6001600160a01b038981168252881660208201526040810187905260c06060820181905260009061337e9083018789613314565b85608084015282810360a0840152613397818587613314565b9b9a5050505050505050505050565b6000602082840312156133b857600080fd5b81518015158114610a5d57600080fd5b6000828210156133da576133da6131cb565b500390565b6001600160a01b0385168152602081018490526060604082018190528101829052818360808301376000818301608090810191909152601f909201601f191601019392505050565b600061010060018060a01b038c1683528a602084015289604084015260ff891660608401528760808401528660a08401528560c08401528060e08401526134718184018587613314565b9c9b505050505050505050505050565b60018060a01b038816815286602082015260a0604082015260006134a960a083018789613314565b85606084015282810360808401526134c2818587613314565b9a9950505050505050505050565b60006001600160701b038083168185168083038211156134f2576134f26131cb565b01949350505050565b600063ffffffff8083168185168083038211156134f2576134f26131cb565b60006020828403121561352c57600080fd5b815163ffffffff81168114610a5d57600080fd5b60208082526017908201527f6d73672e73656e646572206973206e6f74206f776e6572000000000000000000604082015260600190565b6000816000190483118215151615613591576135916131cb565b500290565b6000826135b357634e487b7160e01b600052601260045260246000fd5b500490565b60018060a01b03851681528360208201526060604082015260006135e0606083018486613314565b9695505050505050565b6000602082840312156135fc57600080fd5b8151610a5d81612f01565b600181815b80851115613642578160001904821115613628576136286131cb565b8085161561363557918102915b93841c939080029061360c565b509250929050565b6000826136595750600161099d565b816136665750600061099d565b816001811461367c5760028114613686576136a2565b600191505061099d565b60ff841115613697576136976131cb565b50506001821b61099d565b5060208310610133831016604e8410600b84101617156136c5575081810a61099d565b6136cf8383613607565b80600019048211156136e3576136e36131cb565b029392505050565b6000610a5d60ff84168361364a565b6000825161370c818460208701612c8c565b919091019291505056fea164736f6c634300080b000a

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

00000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000001200000000000000000000000008dae6cb04688c62d939ed9b68d32bc62e49970b100000000000000000000000000000000000000000000000000000000000000120000000000000000000000005afedef13bd7b3e363db724420d773caa8b88763000000000000000000000000ea5edef1a7106d9e2024240299df3d00c7d94767000000000000000000000000d784927ff2f95ba542bfc824c8a8a98f3495f6b5000000000000000000000000000000000000000000000000000000000000000f614352562045617365205661756c7400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007657a2d6143525600000000000000000000000000000000000000000000000000

-----Decoded View---------------
Arg [0] : _name (string): aCRV Ease Vault
Arg [1] : _symbol (string): ez-aCRV
Arg [2] : _uToken (address): 0x8dAE6Cb04688C62d939ed9B68d32Bc62e49970b1
Arg [3] : _uTokenDecimals (uint256): 18
Arg [4] : _governance (address): 0x5AFeDEF13Bd7B3e363db724420D773cAa8B88763
Arg [5] : _controller (address): 0xEA5edEF1A7106D9e2024240299DF3D00C7D94767
Arg [6] : _incentivesController (address): 0xd784927Ff2f95ba542BfC824c8a8a98F3495f6b5

-----Encoded View---------------
11 Constructor Arguments found :
Arg [0] : 00000000000000000000000000000000000000000000000000000000000000e0
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000120
Arg [2] : 0000000000000000000000008dae6cb04688c62d939ed9b68d32bc62e49970b1
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000012
Arg [4] : 0000000000000000000000005afedef13bd7b3e363db724420d773caa8b88763
Arg [5] : 000000000000000000000000ea5edef1a7106d9e2024240299df3d00c7d94767
Arg [6] : 000000000000000000000000d784927ff2f95ba542bfc824c8a8a98f3495f6b5
Arg [7] : 000000000000000000000000000000000000000000000000000000000000000f
Arg [8] : 614352562045617365205661756c740000000000000000000000000000000000
Arg [9] : 0000000000000000000000000000000000000000000000000000000000000007
Arg [10] : 657a2d6143525600000000000000000000000000000000000000000000000000


Loading...
Loading
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

A token is a representation of an on-chain or off-chain asset. The token page shows information such as price, total supply, holders, transfers and social links. Learn more about this page in our Knowledge Base.