ETH Price: $2,433.07 (-2.24%)

Contract

0xdB5fD0678eED82246b599da6BC36B56157E4beD8
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Redeem To Yield ...188697032023-12-26 11:54:35286 days ago1703591675IN
0xdB5fD067...157E4beD8
0 ETH0.0033110218.48123166
Exit Amm Given L...188696482023-12-26 11:43:23286 days ago1703591003IN
0xdB5fD067...157E4beD8
0 ETH0.0065412118.3249418
Exit Amm Given L...188696422023-12-26 11:42:11286 days ago1703590931IN
0xdB5fD067...157E4beD8
0 ETH0.0159369517.46517912
Exit Amm Given L...188694312023-12-26 10:59:47286 days ago1703588387IN
0xdB5fD067...157E4beD8
0 ETH0.0063181517.36962828
Exit Amm Given L...165681702023-02-06 7:11:35609 days ago1675667495IN
0xdB5fD067...157E4beD8
0 ETH0.0061011917.20908997
Exit Amm Given L...165681582023-02-06 7:09:11609 days ago1675667351IN
0xdB5fD067...157E4beD8
0 ETH0.006419518.71220047
Exit Amm Given L...165681372023-02-06 7:04:59609 days ago1675667099IN
0xdB5fD067...157E4beD8
0 ETH0.0059572316.71099942
Deposit And Fix162499652022-12-23 20:58:23654 days ago1671829103IN
0xdB5fD067...157E4beD8
0 ETH0.0052358616.40201139
Exit Amm Given L...159360332022-11-10 0:26:47697 days ago1668040007IN
0xdB5fD067...157E4beD8
0 ETH0.0181352750.86962908
Deposit And Fix157315052022-10-12 10:42:23726 days ago1665571343IN
0xdB5fD067...157E4beD8
0 ETH0.0060089218.81860146
Exit Amm Given L...156968822022-10-07 14:40:47731 days ago1665153647IN
0xdB5fD067...157E4beD8
0 ETH0.0050603711.95959166
Deposit And Fix156968722022-10-07 14:38:47731 days ago1665153527IN
0xdB5fD067...157E4beD8
0 ETH0.0040478112.67798877
Exit Amm Given L...156967012022-10-07 14:04:23731 days ago1665151463IN
0xdB5fD067...157E4beD8
0 ETH0.0024251813.93511077
Deposit And Fix156966192022-10-07 13:47:47731 days ago1665150467IN
0xdB5fD067...157E4beD8
0 ETH0.002904929.50538187
Exit Amm Given L...156666082022-10-03 9:03:35735 days ago1664787815IN
0xdB5fD067...157E4beD8
0 ETH0.001477878.49277817
Exit Amm Given L...156553752022-10-01 19:25:47737 days ago1664652347IN
0xdB5fD067...157E4beD8
0 ETH0.001678798.69352443
Exit Amm Given L...156023352022-09-24 9:30:47744 days ago1664011847IN
0xdB5fD067...157E4beD8
0 ETH0.000975075.42165164
Deposit And Fix155956212022-09-23 11:02:47745 days ago1663930967IN
0xdB5fD067...157E4beD8
0 ETH0.002809727.94372955
Exit Amm Given L...155823292022-09-21 14:25:23747 days ago1663770323IN
0xdB5fD067...157E4beD8
0 ETH0.0047732511.54222005
Deposit And Fix155823202022-09-21 14:23:35747 days ago1663770215IN
0xdB5fD067...157E4beD8
0 ETH0.0034059210.66659492
Exit Amm Given L...155814092022-09-21 11:18:59747 days ago1663759139IN
0xdB5fD067...157E4beD8
0 ETH0.002011574.86420932
Deposit And Fix155814022022-09-21 11:17:35747 days ago1663759055IN
0xdB5fD067...157E4beD8
0 ETH0.001528925.00288244
Deposit And Fix155768312022-09-20 19:40:23748 days ago1663702823IN
0xdB5fD067...157E4beD8
0 ETH0.0044217814.46881884
Exit Amm Given L...155768182022-09-20 19:37:47748 days ago1663702667IN
0xdB5fD067...157E4beD8
0 ETH0.0066072715.34524632
Deposit And Fix155767702022-09-20 19:28:11748 days ago1663702091IN
0xdB5fD067...157E4beD8
0 ETH0.0056865217.81001221
View all transactions

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To
150456562022-06-29 15:29:25831 days ago1656516565
0xdB5fD067...157E4beD8
0.00001 ETH
147872572022-05-16 16:17:32875 days ago1652717852
0xdB5fD067...157E4beD8
0.001 ETH
142067482022-02-14 21:46:45966 days ago1644875205
0xdB5fD067...157E4beD8
0.1 ETH
142067242022-02-14 21:43:18966 days ago1644874998
0xdB5fD067...157E4beD8
0.1 ETH
141968152022-02-13 8:46:27967 days ago1644741987
0xdB5fD067...157E4beD8
0.07 ETH
141967362022-02-13 8:27:34967 days ago1644740854
0xdB5fD067...157E4beD8
0.07 ETH
141696442022-02-09 4:10:31971 days ago1644379831
0xdB5fD067...157E4beD8
30 ETH
141391882022-02-04 11:17:15976 days ago1643973435
0xdB5fD067...157E4beD8
0.25 ETH
141391652022-02-04 11:13:01976 days ago1643973181
0xdB5fD067...157E4beD8
0.5 ETH
140332392022-01-19 2:10:55992 days ago1642558255
0xdB5fD067...157E4beD8
50 ETH
140318272022-01-18 20:55:36993 days ago1642539336
0xdB5fD067...157E4beD8
36 ETH
140309472022-01-18 17:41:35993 days ago1642527695
0xdB5fD067...157E4beD8
32.2 ETH
139092612021-12-30 21:56:531012 days ago1640901413
0xdB5fD067...157E4beD8
0.13 ETH
138956442021-12-28 19:32:101014 days ago1640719930
0xdB5fD067...157E4beD8
0.05 ETH
138620392021-12-23 14:42:131019 days ago1640270533
0xdB5fD067...157E4beD8
0.01 ETH
138215112021-12-17 8:10:241025 days ago1639728624
0xdB5fD067...157E4beD8
0.1 ETH
138167602021-12-16 14:40:021026 days ago1639665602
0xdB5fD067...157E4beD8
5 ETH
138132692021-12-16 1:32:021026 days ago1639618322
0xdB5fD067...157E4beD8
0.20069918 ETH
138125892021-12-15 23:03:551027 days ago1639609435
0xdB5fD067...157E4beD8
0.3 ETH
138122992021-12-15 21:59:521027 days ago1639605592
0xdB5fD067...157E4beD8
0.01 ETH
138104062021-12-15 14:57:361027 days ago1639580256
0xdB5fD067...157E4beD8
0.1 ETH
138103362021-12-15 14:40:491027 days ago1639579249
0xdB5fD067...157E4beD8
0.2 ETH
138093302021-12-15 11:02:371027 days ago1639566157
0xdB5fD067...157E4beD8
400 ETH
138067052021-12-15 1:05:241027 days ago1639530324
0xdB5fD067...157E4beD8
125 ETH
138038752021-12-14 14:39:061028 days ago1639492746
0xdB5fD067...157E4beD8
0.1 ETH
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
TempusController

Compiler Version
v0.8.10+commit.fc410830

Optimization Enabled:
Yes with 100000 runs

Other Settings:
default evmVersion
File 1 of 16 : TempusController.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.10;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";

import "./amm/interfaces/ITempusAMM.sol";
import "./amm/interfaces/IVault.sol";
import "./ITempusPool.sol";
import "./math/Fixed256xVar.sol";
import "./utils/AMMBalancesHelper.sol";
import "./utils/UntrustedERC20.sol";
import "./utils/Ownable.sol";
import "./utils/Versioned.sol";

/// @dev TempusController singleton with a transferrable ownership and re-entrancy guards
///      Owner is automatically set to the deployer of this contract
contract TempusController is ReentrancyGuard, Ownable, Versioned {
    using Fixed256xVar for uint256;
    using SafeERC20 for IERC20;
    using UntrustedERC20 for IERC20;
    using AMMBalancesHelper for uint256[];

    /// Registry for valid pools and AMM's to avoid fake address injection
    mapping(address => bool) private registry;

    /// @dev Event emitted on a successful BT/YBT deposit.
    /// @param pool The Tempus Pool to which assets were deposited
    /// @param depositor Address of the user who deposited Yield Bearing Tokens to mint
    ///                  Tempus Principal Share (TPS) and Tempus Yield Shares
    /// @param recipient Address of the recipient who will receive TPS and TYS tokens
    /// @param yieldTokenAmount Amount of yield tokens received from underlying pool
    /// @param backingTokenValue Value of @param yieldTokenAmount expressed in backing tokens
    /// @param shareAmounts Number of Tempus Principal Shares (TPS) and Tempus Yield Shares (TYS) granted to `recipient`
    /// @param interestRate Interest Rate of the underlying pool from Yield Bearing Tokens to the underlying asset
    /// @param fee The fee which was deducted (in terms of yield bearing tokens)
    event Deposited(
        address indexed pool,
        address indexed depositor,
        address indexed recipient,
        uint256 yieldTokenAmount,
        uint256 backingTokenValue,
        uint256 shareAmounts,
        uint256 interestRate,
        uint256 fee
    );

    /// @dev Event emitted on a successful BT/YBT redemption.
    /// @param pool The Tempus Pool from which Tempus Shares were redeemed
    /// @param redeemer Address of the user whose Shares (Principals and Yields) are redeemed
    /// @param recipient Address of user that received Yield Bearing Tokens
    /// @param principalShareAmount Number of Tempus Principal Shares (TPS) to redeem into the Yield Bearing Token (YBT)
    /// @param yieldShareAmount Number of Tempus Yield Shares (TYS) to redeem into the Yield Bearing Token (YBT)
    /// @param yieldTokenAmount Number of Yield bearing tokens redeemed from the pool
    /// @param backingTokenValue Value of @param yieldTokenAmount expressed in backing tokens
    /// @param interestRate Interest Rate of the underlying pool from Yield Bearing Tokens to the underlying asset
    /// @param fee The fee which was deducted (in terms of yield bearing tokens)
    /// @param isEarlyRedeem True in case of early redemption, otherwise false
    event Redeemed(
        address indexed pool,
        address indexed redeemer,
        address indexed recipient,
        uint256 principalShareAmount,
        uint256 yieldShareAmount,
        uint256 yieldTokenAmount,
        uint256 backingTokenValue,
        uint256 interestRate,
        uint256 fee,
        bool isEarlyRedeem
    );

    constructor() Versioned(1, 0, 0) {}

    /// @dev Registers a POOL or an AMM as valid or invalid to use with this Controller
    /// @param authorizedContract Contract which will be allowed to be used inside this Controller
    /// @param isValid If true, contract is valid to be used, if false, it's not allowed anymore
    function register(address authorizedContract, bool isValid) public onlyOwner {
        registry[authorizedContract] = isValid;
    }

    /// @dev Validates that the provided contract is registered to be used with this Controller
    /// @param authorizedContract Contract address to check
    function requireRegistered(address authorizedContract) private view {
        require(registry[authorizedContract], "Unauthorized contract address");
    }

    /// @dev Atomically deposits YBT/BT to TempusPool and provides liquidity
    ///      to the corresponding Tempus AMM with the issued TYS & TPS
    /// @param tempusAMM Tempus AMM to use to swap TYS for TPS
    /// @param tokenAmount Amount of YBT/BT to be deposited
    /// @param isBackingToken specifies whether the deposited asset is the Backing Token or Yield Bearing Token
    function depositAndProvideLiquidity(
        ITempusAMM tempusAMM,
        uint256 tokenAmount,
        bool isBackingToken
    ) external payable nonReentrant {
        requireRegistered(address(tempusAMM));
        _depositAndProvideLiquidity(tempusAMM, tokenAmount, isBackingToken);
    }

    /// @dev Adds liquidity to tempusAMM with ratio of shares that is equal to ratio in AMM
    /// @param tempusAMM Tempus AMM to provide liquidity to
    /// @param sharesAmount Amount of shares to be used to provide liquidity, one of the sahres will be partially used
    /// @notice If sharesAmount is 100 and amm balances ratio is 1 principal : 10 yields 90 principal will be "unused"
    ///         So, liquidity will be provided with 10 principals and 100 yields
    /// @notice msg.sender needs to approve Controller for both Principals and Yields for @param sharesAmount
    function provideLiquidity(ITempusAMM tempusAMM, uint256 sharesAmount) external nonReentrant {
        requireRegistered(address(tempusAMM));
        (
            IVault vault,
            bytes32 poolId,
            IERC20[] memory ammTokens,
            uint256[] memory ammBalances
        ) = _getAMMDetailsAndEnsureInitialized(tempusAMM);

        _provideLiquidity(msg.sender, vault, poolId, ammTokens, ammBalances, sharesAmount, msg.sender);
    }

    /// @dev Atomically deposits YBT/BT to TempusPool and swaps TYS for TPS to get fixed yield
    ///      See https://docs.balancer.fi/developers/guides/single-swaps#swap-overview
    /// @param tempusAMM Tempus AMM to use to swap TYS for TPS
    /// @param tokenAmount Amount of YBT/BT to be deposited in underlying YBT/BT decimal precision
    /// @param isBackingToken specifies whether the deposited asset is the Backing Token or Yield Bearing Token
    /// @param minTYSRate Minimum exchange rate of TYS (denominated in TPS) to receive in exchange for TPS
    /// @param deadline A timestamp by which the transaction must be completed, otherwise it would revert
    function depositAndFix(
        ITempusAMM tempusAMM,
        uint256 tokenAmount,
        bool isBackingToken,
        uint256 minTYSRate,
        uint256 deadline
    ) external payable nonReentrant {
        requireRegistered(address(tempusAMM));
        _depositAndFix(tempusAMM, tokenAmount, isBackingToken, minTYSRate, deadline);
    }

    /// @dev Deposits Yield Bearing Tokens to a Tempus Pool.
    /// @param targetPool The Tempus Pool to which tokens will be deposited
    /// @param yieldTokenAmount amount of Yield Bearing Tokens to be deposited
    ///                         in YBT Contract precision which can be 18 or 8 decimals
    /// @param recipient Address which will receive Tempus Principal Shares (TPS) and Tempus Yield Shares (TYS)
    function depositYieldBearing(
        ITempusPool targetPool,
        uint256 yieldTokenAmount,
        address recipient
    ) external nonReentrant {
        require(recipient != address(0), "recipient can not be 0x0");
        requireRegistered(address(targetPool));
        _depositYieldBearing(targetPool, yieldTokenAmount, recipient);
    }

    /// @dev Deposits Backing Tokens into the underlying protocol and
    ///      then deposited the minted Yield Bearing Tokens to the Tempus Pool.
    /// @param targetPool The Tempus Pool to which tokens will be deposited
    /// @param backingTokenAmount amount of Backing Tokens to be deposited into the underlying protocol
    /// @param recipient Address which will receive Tempus Principal Shares (TPS) and Tempus Yield Shares (TYS)
    function depositBacking(
        ITempusPool targetPool,
        uint256 backingTokenAmount,
        address recipient
    ) external payable nonReentrant {
        require(recipient != address(0), "recipient can not be 0x0");
        requireRegistered(address(targetPool));
        _depositBacking(targetPool, backingTokenAmount, recipient);
    }

    /// @dev Redeem TPS+TYS held by msg.sender into Yield Bearing Tokens
    /// @notice `msg.sender` will receive yield bearing tokens
    /// @notice Before maturity, `principalAmount` must equal to `yieldAmount`
    /// @param targetPool The Tempus Pool from which to redeem Tempus Shares
    /// @param principalAmount Amount of Tempus Principals to redeem in PrincipalShare decimal precision
    /// @param yieldAmount Amount of Tempus Yields to redeem in YieldShare decimal precision
    /// @param recipient Address of user that will receive yield bearing tokens
    function redeemToYieldBearing(
        ITempusPool targetPool,
        uint256 principalAmount,
        uint256 yieldAmount,
        address recipient
    ) external nonReentrant {
        require(recipient != address(0), "recipient can not be 0x0");
        requireRegistered(address(targetPool));
        _redeemToYieldBearing(targetPool, msg.sender, principalAmount, yieldAmount, recipient);
    }

    /// @dev Redeem TPS+TYS held by msg.sender into Backing Tokens
    /// @notice `recipient` will receive the backing tokens
    /// @notice Before maturity, `principalAmount` must equal to `yieldAmount`
    /// @param targetPool The Tempus Pool from which to redeem Tempus Shares
    /// @param principalAmount Amount of Tempus Principals to redeem in PrincipalShare decimal precision
    /// @param yieldAmount Amount of Tempus Yields to redeem in YieldShare decimal precision
    /// @param recipient Address of user that will receive yield bearing tokens
    function redeemToBacking(
        ITempusPool targetPool,
        uint256 principalAmount,
        uint256 yieldAmount,
        address recipient
    ) external nonReentrant {
        require(recipient != address(0), "recipient can not be 0x0");
        requireRegistered(address(targetPool));
        _redeemToBacking(targetPool, msg.sender, principalAmount, yieldAmount, recipient);
    }

    /// @dev Withdraws liquidity from TempusAMM
    /// @notice `msg.sender` needs to approve controller for @param lpTokensAmount of LP tokens
    /// @notice Transfers LP tokens to controller and exiting tempusAmm with `msg.sender` as recipient
    /// @param tempusAMM Tempus AMM instance
    /// @param lpTokensAmount Amount of LP tokens to be withdrawn
    /// @param principalAmountOutMin Minimal amount of TPS to be withdrawn
    /// @param yieldAmountOutMin Minimal amount of TYS to be withdrawn
    /// @param toInternalBalances Withdrawing liquidity to internal balances
    function exitTempusAMM(
        ITempusAMM tempusAMM,
        uint256 lpTokensAmount,
        uint256 principalAmountOutMin,
        uint256 yieldAmountOutMin,
        bool toInternalBalances
    ) external nonReentrant {
        requireRegistered(address(tempusAMM));
        _exitTempusAMM(tempusAMM, lpTokensAmount, principalAmountOutMin, yieldAmountOutMin, toInternalBalances);
    }

    /// @dev Withdraws liquidity from TempusAMM and redeems Shares to Yield Bearing or Backing Tokens
    ///      Checks user's balance of principal shares and yield shares
    ///      and exits AMM with exact amounts needed for redemption.
    /// @notice `msg.sender` needs to approve controller for whole balance of LP token
    /// @notice Transfers users' LP tokens to controller, then exits tempusAMM with `msg.sender` as recipient.
    ///         After exit transfers remainder of LP tokens back to user
    /// @notice Can fail if there is not enough user balance
    /// @notice Only available before maturity since exiting AMM with exact amounts is disallowed after maturity
    /// @param tempusAMM TempusAMM instance to withdraw liquidity from
    /// @param principals Amount of Principals to redeem
    /// @param yields Amount of Yields to redeem
    /// @param principalsStaked Amount of staked principals (in TempusAMM) to redeem
    /// @param yieldsStaked Amount of staked yields (in TempusAMM) to redeem
    /// @param maxLpTokensToRedeem Maximum amount of LP tokens to spend for staked shares redemption
    /// @param toBackingToken If true redeems to backing token, otherwise redeems to yield bearing
    function exitAmmGivenAmountsOutAndEarlyRedeem(
        ITempusAMM tempusAMM,
        uint256 principals,
        uint256 yields,
        uint256 principalsStaked,
        uint256 yieldsStaked,
        uint256 maxLpTokensToRedeem,
        bool toBackingToken
    ) external nonReentrant {
        requireRegistered(address(tempusAMM));
        _exitAmmGivenAmountsOutAndEarlyRedeem(
            tempusAMM,
            principals,
            yields,
            principalsStaked,
            yieldsStaked,
            maxLpTokensToRedeem,
            toBackingToken
        );
    }

    /// @dev Withdraws ALL liquidity from TempusAMM and redeems Shares to Yield Bearing or Backing Tokens
    /// @notice `msg.sender` needs to approve controller for whole balance of LP token
    /// @notice Can fail if there is not enough user balance
    /// @param tempusAMM TempusAMM instance to withdraw liquidity from
    /// @param lpTokens Number of Lp tokens to redeem
    /// @param principals Number of Principals to redeem
    /// @param yields Number of Yields to redeem
    /// @param minPrincipalsStaked Minimum amount of staked principals to redeem for `lpTokens`
    /// @param minYieldsStaked Minimum amount of staked yields to redeem for `lpTokens`
    /// @param maxLeftoverShares Maximum amount of Principals or Yields to be left in case of early exit
    /// @param yieldsRate Base exchange rate of TYS (denominated in TPS)
    /// @param maxSlippage Maximum allowed change in the exchange rate from the base @param yieldsRate (1e18 precision)
    /// @param toBackingToken If true redeems to backing token, otherwise redeems to yield bearing
    /// @param deadline A timestamp by which, if a swap is necessary, the transaction must be completed,
    ///    otherwise it would revert
    function exitAmmGivenLpAndRedeem(
        ITempusAMM tempusAMM,
        uint256 lpTokens,
        uint256 principals,
        uint256 yields,
        uint256 minPrincipalsStaked,
        uint256 minYieldsStaked,
        uint256 maxLeftoverShares,
        uint256 yieldsRate,
        uint256 maxSlippage,
        bool toBackingToken,
        uint256 deadline
    ) external nonReentrant {
        requireRegistered(address(tempusAMM));
        if (lpTokens > 0) {
            // if there is LP balance, transfer to controller
            require(tempusAMM.transferFrom(msg.sender, address(this), lpTokens), "LP token transfer failed");

            // exit amm and sent shares to controller
            uint256[] memory minAmountsOutFromLP = getAMMOrderedAmounts(
                tempusAMM,
                minPrincipalsStaked,
                minYieldsStaked
            );
            _exitTempusAMMGivenLP(tempusAMM, address(this), address(this), lpTokens, minAmountsOutFromLP, false);
        }

        _redeemWithEqualShares(
            tempusAMM,
            principals,
            yields,
            maxLeftoverShares,
            yieldsRate,
            maxSlippage,
            deadline,
            toBackingToken
        );
    }

    function swap(
        ITempusAMM tempusAMM,
        uint256 swapAmount,
        IERC20 tokenIn,
        IERC20 tokenOut,
        uint256 minReturn,
        uint256 deadline
    ) private {
        require(swapAmount > 0, "Invalid swap amount.");
        tokenIn.safeIncreaseAllowance(address(tempusAMM.getVault()), swapAmount);

        (IVault vault, bytes32 poolId, , ) = _getAMMDetailsAndEnsureInitialized(tempusAMM);

        IVault.SingleSwap memory singleSwap = IVault.SingleSwap({
            poolId: poolId,
            kind: IVault.SwapKind.GIVEN_IN,
            assetIn: tokenIn,
            assetOut: tokenOut,
            amount: swapAmount,
            userData: ""
        });

        IVault.FundManagement memory fundManagement = IVault.FundManagement({
            sender: address(this),
            fromInternalBalance: false,
            recipient: payable(address(this)),
            toInternalBalance: false
        });
        vault.swap(singleSwap, fundManagement, minReturn, deadline);
    }

    function _depositAndProvideLiquidity(
        ITempusAMM tempusAMM,
        uint256 tokenAmount,
        bool isBackingToken
    ) private {
        (
            IVault vault,
            bytes32 poolId,
            IERC20[] memory ammTokens,
            uint256[] memory ammBalances
        ) = _getAMMDetailsAndEnsureInitialized(tempusAMM);

        uint256 mintedShares = _deposit(tempusAMM.tempusPool(), tokenAmount, isBackingToken);

        uint256[] memory sharesUsed = _provideLiquidity(
            address(this),
            vault,
            poolId,
            ammTokens,
            ammBalances,
            mintedShares,
            msg.sender
        );

        // Send remaining Shares to user
        if (mintedShares > sharesUsed[0]) {
            ammTokens[0].safeTransfer(msg.sender, mintedShares - sharesUsed[0]);
        }
        if (mintedShares > sharesUsed[1]) {
            ammTokens[1].safeTransfer(msg.sender, mintedShares - sharesUsed[1]);
        }
    }

    function _provideLiquidity(
        address sender,
        IVault vault,
        bytes32 poolId,
        IERC20[] memory ammTokens,
        uint256[] memory ammBalances,
        uint256 sharesAmount,
        address recipient
    ) private returns (uint256[] memory) {
        uint256[] memory ammLiquidityProvisionAmounts = ammBalances.getLiquidityProvisionSharesAmounts(sharesAmount);

        if (sender != address(this)) {
            ammTokens[0].safeTransferFrom(sender, address(this), ammLiquidityProvisionAmounts[0]);
            ammTokens[1].safeTransferFrom(sender, address(this), ammLiquidityProvisionAmounts[1]);
        }

        ammTokens[0].safeIncreaseAllowance(address(vault), ammLiquidityProvisionAmounts[0]);
        ammTokens[1].safeIncreaseAllowance(address(vault), ammLiquidityProvisionAmounts[1]);

        IVault.JoinPoolRequest memory request = IVault.JoinPoolRequest({
            assets: ammTokens,
            maxAmountsIn: ammLiquidityProvisionAmounts,
            userData: abi.encode(uint8(ITempusAMM.JoinKind.EXACT_TOKENS_IN_FOR_BPT_OUT), ammLiquidityProvisionAmounts),
            fromInternalBalance: false
        });

        // Provide TPS/TYS liquidity to TempusAMM
        vault.joinPool(poolId, address(this), recipient, request);

        return ammLiquidityProvisionAmounts;
    }

    function _depositAndFix(
        ITempusAMM tempusAMM,
        uint256 tokenAmount,
        bool isBackingToken,
        uint256 minTYSRate,
        uint256 deadline
    ) private {
        ITempusPool targetPool = tempusAMM.tempusPool();
        IERC20 principalShares = IERC20(address(targetPool.principalShare()));
        IERC20 yieldShares = IERC20(address(targetPool.yieldShare()));

        uint256 swapAmount = _deposit(targetPool, tokenAmount, isBackingToken);

        yieldShares.safeIncreaseAllowance(address(tempusAMM.getVault()), swapAmount);
        uint256 minReturn = swapAmount.mulfV(minTYSRate, targetPool.backingTokenONE());
        swap(tempusAMM, swapAmount, yieldShares, principalShares, minReturn, deadline);

        // At this point all TYS must be swapped for TPS
        uint256 principalsBalance = principalShares.balanceOf(address(this));
        assert(principalsBalance > 0);

        principalShares.safeTransfer(msg.sender, principalsBalance);
    }

    function _deposit(
        ITempusPool targetPool,
        uint256 tokenAmount,
        bool isBackingToken
    ) private returns (uint256 mintedShares) {
        mintedShares = isBackingToken
            ? _depositBacking(targetPool, tokenAmount, address(this))
            : _depositYieldBearing(targetPool, tokenAmount, address(this));
    }

    function _depositYieldBearing(
        ITempusPool targetPool,
        uint256 yieldTokenAmount,
        address recipient
    ) private returns (uint256) {
        require(yieldTokenAmount > 0, "yieldTokenAmount is 0");

        IERC20 yieldBearingToken = IERC20(targetPool.yieldBearingToken());

        // Transfer funds from msg.sender to targetPool
        uint transferredYBT = yieldBearingToken.untrustedTransferFrom(
            msg.sender,
            address(targetPool),
            yieldTokenAmount
        );

        (uint mintedShares, uint depositedBT, uint fee, uint rate) = targetPool.onDepositYieldBearing(
            transferredYBT,
            recipient
        );

        emit Deposited(
            address(targetPool),
            msg.sender,
            recipient,
            transferredYBT,
            depositedBT,
            mintedShares,
            rate,
            fee
        );

        return mintedShares;
    }

    function _depositBacking(
        ITempusPool targetPool,
        uint256 backingTokenAmount,
        address recipient
    ) private returns (uint256) {
        require(backingTokenAmount > 0, "backingTokenAmount is 0");

        IERC20 backingToken = IERC20(targetPool.backingToken());

        // In case the underlying pool expects deposits in Ether (e.g. Lido),
        // it uses `backingToken = address(0)`.  Since we disallow 0-value deposits,
        // and `msg.value == backingTokenAmount`, this check here can be used to
        // distinguish between the two pool types.
        if (msg.value == 0) {
            // NOTE: We need to have this check here to avoid calling transfer on address(0),
            //       because that always succeeds.
            require(address(backingToken) != address(0), "Pool requires ETH deposits");

            backingTokenAmount = backingToken.untrustedTransferFrom(
                msg.sender,
                address(targetPool),
                backingTokenAmount
            );
        } else {
            require(address(backingToken) == address(0), "given TempusPool's Backing Token is not ETH");
            require(msg.value == backingTokenAmount, "ETH value does not match provided amount");
        }

        (uint256 mintedShares, uint256 depositedYBT, uint256 fee, uint256 interestRate) = targetPool.onDepositBacking{
            value: msg.value
        }(backingTokenAmount, recipient);

        emit Deposited(
            address(targetPool),
            msg.sender,
            recipient,
            depositedYBT,
            backingTokenAmount,
            mintedShares,
            interestRate,
            fee
        );

        return mintedShares;
    }

    function _redeemToYieldBearing(
        ITempusPool targetPool,
        address sender,
        uint256 principals,
        uint256 yields,
        address recipient
    ) private {
        require((principals > 0) || (yields > 0), "principalAmount and yieldAmount cannot both be 0");

        (uint redeemedYBT, uint fee, uint interestRate) = targetPool.redeem(sender, principals, yields, recipient);

        uint redeemedBT = targetPool.numAssetsPerYieldToken(redeemedYBT, targetPool.currentInterestRate());
        bool earlyRedeem = !targetPool.matured();
        emit Redeemed(
            address(targetPool),
            sender,
            recipient,
            principals,
            yields,
            redeemedYBT,
            redeemedBT,
            fee,
            interestRate,
            earlyRedeem
        );
    }

    function _redeemToBacking(
        ITempusPool targetPool,
        address sender,
        uint256 principals,
        uint256 yields,
        address recipient
    ) private {
        require((principals > 0) || (yields > 0), "principalAmount and yieldAmount cannot both be 0");

        (uint redeemedYBT, uint redeemedBT, uint fee, uint rate) = targetPool.redeemToBacking(
            sender,
            principals,
            yields,
            recipient
        );

        bool earlyRedeem = !targetPool.matured();
        emit Redeemed(
            address(targetPool),
            sender,
            recipient,
            principals,
            yields,
            redeemedYBT,
            redeemedBT,
            fee,
            rate,
            earlyRedeem
        );
    }

    function _exitTempusAMM(
        ITempusAMM tempusAMM,
        uint256 lpTokensAmount,
        uint256 principalAmountOutMin,
        uint256 yieldAmountOutMin,
        bool toInternalBalances
    ) private {
        require(tempusAMM.transferFrom(msg.sender, address(this), lpTokensAmount), "LP token transfer failed");

        uint256[] memory amounts = getAMMOrderedAmounts(tempusAMM, principalAmountOutMin, yieldAmountOutMin);
        _exitTempusAMMGivenLP(tempusAMM, address(this), msg.sender, lpTokensAmount, amounts, toInternalBalances);
    }

    function _exitTempusAMMGivenLP(
        ITempusAMM tempusAMM,
        address sender,
        address recipient,
        uint256 lpTokensAmount,
        uint256[] memory minAmountsOut,
        bool toInternalBalances
    ) private {
        require(lpTokensAmount > 0, "LP token amount is 0");

        (IVault vault, bytes32 poolId, IERC20[] memory ammTokens, ) = _getAMMDetailsAndEnsureInitialized(tempusAMM);

        IVault.ExitPoolRequest memory request = IVault.ExitPoolRequest({
            assets: ammTokens,
            minAmountsOut: minAmountsOut,
            userData: abi.encode(uint8(ITempusAMM.ExitKind.EXACT_BPT_IN_FOR_TOKENS_OUT), lpTokensAmount),
            toInternalBalance: toInternalBalances
        });
        vault.exitPool(poolId, sender, payable(recipient), request);
    }

    function _exitTempusAMMGivenAmountsOut(
        ITempusAMM tempusAMM,
        address sender,
        address recipient,
        uint256[] memory amountsOut,
        uint256 lpTokensAmountInMax,
        bool toInternalBalances
    ) private {
        (IVault vault, bytes32 poolId, IERC20[] memory ammTokens, ) = _getAMMDetailsAndEnsureInitialized(tempusAMM);

        IVault.ExitPoolRequest memory request = IVault.ExitPoolRequest({
            assets: ammTokens,
            minAmountsOut: amountsOut,
            userData: abi.encode(
                uint8(ITempusAMM.ExitKind.BPT_IN_FOR_EXACT_TOKENS_OUT),
                amountsOut,
                lpTokensAmountInMax
            ),
            toInternalBalance: toInternalBalances
        });
        vault.exitPool(poolId, sender, payable(recipient), request);
    }

    function _exitAmmGivenAmountsOutAndEarlyRedeem(
        ITempusAMM tempusAMM,
        uint256 principals,
        uint256 yields,
        uint256 principalsStaked,
        uint256 yieldsStaked,
        uint256 maxLpTokensToRedeem,
        bool toBackingToken
    ) private {
        ITempusPool tempusPool = tempusAMM.tempusPool();
        require(!tempusPool.matured(), "Pool already finalized");
        principals += principalsStaked;
        yields += yieldsStaked;
        require(principals == yields, "Needs equal amounts of shares before maturity");

        // transfer LP tokens to controller
        require(tempusAMM.transferFrom(msg.sender, address(this), maxLpTokensToRedeem), "LP token transfer failed");

        uint256[] memory amounts = getAMMOrderedAmounts(tempusAMM, principalsStaked, yieldsStaked);
        _exitTempusAMMGivenAmountsOut(tempusAMM, address(this), msg.sender, amounts, maxLpTokensToRedeem, false);

        // transfer remainder of LP tokens back to user
        uint256 lpTokenBalance = tempusAMM.balanceOf(address(this));
        require(tempusAMM.transferFrom(address(this), msg.sender, lpTokenBalance), "LP token transfer failed");

        if (toBackingToken) {
            _redeemToBacking(tempusPool, msg.sender, principals, yields, msg.sender);
        } else {
            _redeemToYieldBearing(tempusPool, msg.sender, principals, yields, msg.sender);
        }
    }

    function _redeemWithEqualShares(
        ITempusAMM tempusAMM,
        uint256 principals,
        uint256 yields,
        uint256 maxLeftoverShares,
        uint256 yieldsRate,
        uint256 maxSlippage,
        uint256 deadline,
        bool toBackingToken
    ) private {
        ITempusPool tempusPool = tempusAMM.tempusPool();

        IERC20 principalShare = IERC20(address(tempusPool.principalShare()));
        IERC20 yieldShare = IERC20(address(tempusPool.yieldShare()));
        require(principalShare.transferFrom(msg.sender, address(this), principals), "Principals transfer failed");
        require(yieldShare.transferFrom(msg.sender, address(this), yields), "Yields transfer failed");
        require(yieldsRate > 0, "yieldsRate must be greater than 0");
        require(maxSlippage <= 1e18, "maxSlippage can not be greater than 1e18");

        principals = principalShare.balanceOf(address(this));
        yields = yieldShare.balanceOf(address(this));

        if (!tempusPool.matured()) {
            if (((yields > principals) ? (yields - principals) : (principals - yields)) >= maxLeftoverShares) {
                (uint256 swapAmount, bool yieldsIn) = tempusAMM.getSwapAmountToEndWithEqualShares(
                    principals,
                    yields,
                    maxLeftoverShares
                );
                uint256 minReturn = yieldsIn
                    ? swapAmount.mulfV(yieldsRate, tempusPool.backingTokenONE())
                    : swapAmount.divfV(yieldsRate, tempusPool.backingTokenONE());

                minReturn = minReturn.mulfV(1e18 - maxSlippage, 1e18);

                swap(
                    tempusAMM,
                    swapAmount,
                    yieldsIn ? yieldShare : principalShare,
                    yieldsIn ? principalShare : yieldShare,
                    minReturn,
                    deadline
                );

                principals = principalShare.balanceOf(address(this));
                yields = yieldShare.balanceOf(address(this));
            }
            (yields, principals) = (principals <= yields) ? (principals, principals) : (yields, yields);
        }

        if (toBackingToken) {
            _redeemToBacking(tempusPool, address(this), principals, yields, msg.sender);
        } else {
            _redeemToYieldBearing(tempusPool, address(this), principals, yields, msg.sender);
        }
    }

    function _getAMMDetailsAndEnsureInitialized(ITempusAMM tempusAMM)
        private
        view
        returns (
            IVault vault,
            bytes32 poolId,
            IERC20[] memory ammTokens,
            uint256[] memory ammBalances
        )
    {
        vault = tempusAMM.getVault();
        poolId = tempusAMM.getPoolId();
        (ammTokens, ammBalances, ) = vault.getPoolTokens(poolId);
        require(
            ammTokens.length == 2 && ammBalances.length == 2 && ammBalances[0] > 0 && ammBalances[1] > 0,
            "AMM not initialized"
        );
    }

    function getAMMOrderedAmounts(
        ITempusAMM tempusAMM,
        uint256 principalAmount,
        uint256 yieldAmount
    ) private view returns (uint256[] memory) {
        IVault vault = tempusAMM.getVault();
        (IERC20[] memory ammTokens, , ) = vault.getPoolTokens(tempusAMM.getPoolId());
        uint256[] memory amounts = new uint256[](2);
        (amounts[0], amounts[1]) = (address(tempusAMM.tempusPool().principalShare()) == address(ammTokens[0]))
            ? (principalAmount, yieldAmount)
            : (yieldAmount, principalAmount);
        return amounts;
    }
}

File 2 of 16 : IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

File 3 of 16 : SafeERC20.sol
// SPDX-License-Identifier: MIT

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 4 of 16 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

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

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

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

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

        _;

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

File 5 of 16 : ITempusAMM.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity >=0.7.0;

import "./IVault.sol";
import "./../../ITempusPool.sol";

interface ITempusAMM {
    enum JoinKind {
        INIT,
        EXACT_TOKENS_IN_FOR_BPT_OUT
    }
    enum ExitKind {
        EXACT_BPT_IN_FOR_TOKENS_OUT,
        BPT_IN_FOR_EXACT_TOKENS_OUT
    }

    function getVault() external view returns (IVault);

    function getPoolId() external view returns (bytes32);

    function tempusPool() external view returns (ITempusPool);

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

    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) external returns (bool);

    /// Calculates the expected returned swap amount
    /// @param amount The given input amount of tokens
    /// @param yieldShareIn Specifies whether to calculate the swap from TYS to TPS (if true) or from TPS to TYS
    /// @return The expected returned amount of outToken
    function getExpectedReturnGivenIn(uint256 amount, bool yieldShareIn) external view returns (uint256);

    /// @dev Returns amount that user needs to swap to end up with almost the same amounts of Principals and Yields
    /// @param principals User's Principals balance
    /// @param yields User's Yields balance
    /// @param threshold Maximum difference between final balances of Principals and Yields
    /// @return amountIn Amount of Principals or Yields that user needs to swap to end with almost equal amounts
    /// @return yieldsIn Specifies the "direction" of the swap -
    ///         whether Yields should be swapped for Principals (yieldsIn=true) or vice versa
    function getSwapAmountToEndWithEqualShares(
        uint256 principals,
        uint256 yields,
        uint256 threshold
    ) external view returns (uint256 amountIn, bool yieldsIn);

    /// @dev queries exiting TempusAMM with exact BPT tokens in
    /// @param bptAmountIn amount of LP tokens in
    /// @return principals Amount of principals that user would receive back
    /// @return yields Amount of yields that user would receive back
    function getExpectedTokensOutGivenBPTIn(uint256 bptAmountIn)
        external
        view
        returns (uint256 principals, uint256 yields);

    /// @dev queries exiting TempusAMM with exact tokens out
    /// @param principalsStaked amount of Principals to withdraw
    /// @param yieldsStaked amount of Yields to withdraw
    /// @return lpTokens Amount of Lp tokens that user would redeem
    function getExpectedBPTInGivenTokensOut(uint256 principalsStaked, uint256 yieldsStaked)
        external
        view
        returns (uint256 lpTokens);

    /// @dev queries joining TempusAMM with exact tokens in
    /// @param amountsIn amount of tokens to be added to the pool
    /// @return amount of LP tokens that could be received
    function getExpectedLPTokensForTokensIn(uint256[] memory amountsIn) external view returns (uint256);

    /// @dev This function returns the appreciation of one BPT relative to the
    /// underlying tokens. This starts at 1 when the pool is created and grows over time
    function getRate() external view returns (uint256);
}

File 6 of 16 : IVault.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity >=0.7.0;

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

interface IVault {
    enum SwapKind {
        GIVEN_IN,
        GIVEN_OUT
    }

    struct SingleSwap {
        bytes32 poolId;
        SwapKind kind;
        IERC20 assetIn;
        IERC20 assetOut;
        uint256 amount;
        bytes userData;
    }
    struct FundManagement {
        address sender;
        bool fromInternalBalance;
        address payable recipient;
        bool toInternalBalance;
    }

    struct JoinPoolRequest {
        IERC20[] assets;
        uint256[] maxAmountsIn;
        bytes userData;
        bool fromInternalBalance;
    }

    struct ExitPoolRequest {
        IERC20[] assets;
        uint256[] minAmountsOut;
        bytes userData;
        bool toInternalBalance;
    }

    function swap(
        SingleSwap memory singleSwap,
        FundManagement memory funds,
        uint256 limit,
        uint256 deadline
    ) external payable returns (uint256);

    function joinPool(
        bytes32 poolId,
        address sender,
        address recipient,
        JoinPoolRequest memory request
    ) external payable;

    function exitPool(
        bytes32 poolId,
        address sender,
        address payable recipient,
        ExitPoolRequest memory request
    ) external;

    function getPoolTokens(bytes32 poolId)
        external
        view
        returns (
            IERC20[] memory tokens,
            uint256[] memory balances,
            uint256 lastChangeBlock
        );
}

File 7 of 16 : ITempusPool.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity >=0.7.6 <0.9.0;
pragma abicoder v2;

import "./token/IPoolShare.sol";
import "./utils/IOwnable.sol";
import "./utils/IVersioned.sol";

/// Setting and transferring of fees are restricted to the owner.
interface ITempusFees is IOwnable {
    /// The fees are in terms of yield bearing token (YBT).
    struct FeesConfig {
        uint256 depositPercent;
        uint256 earlyRedeemPercent;
        uint256 matureRedeemPercent;
    }

    /// Returns the current fee configuration.
    function getFeesConfig() external view returns (FeesConfig memory);

    /// Replace the current fee configuration with a new one.
    /// By default all the fees are expected to be set to zero.
    /// @notice This function can only be called by the owner.
    function setFeesConfig(FeesConfig calldata newFeesConfig) external;

    /// @return Maximum possible fee percentage that can be set for deposit
    function maxDepositFee() external view returns (uint256);

    /// @return Maximum possible fee percentage that can be set for early redeem
    function maxEarlyRedeemFee() external view returns (uint256);

    /// @return Maximum possible fee percentage that can be set for mature redeem
    function maxMatureRedeemFee() external view returns (uint256);

    /// Accumulated fees available for withdrawal.
    function totalFees() external view returns (uint256);

    /// Transfers accumulated Yield Bearing Token (YBT) fees
    /// from this pool contract to `recipient`.
    /// @param recipient Address which will receive the specified amount of YBT
    /// @notice This function can only be called by the owner.
    function transferFees(address recipient) external;
}

/// All state changing operations are restricted to the controller.
interface ITempusPool is ITempusFees, IVersioned {
    /// @return The name of underlying protocol, for example "Aave" for Aave protocol
    function protocolName() external view returns (bytes32);

    /// This token will be used as a token that user can deposit to mint same amounts
    /// of principal and interest shares.
    /// @return The underlying yield bearing token.
    function yieldBearingToken() external view returns (address);

    /// This is the address of the actual backing asset token
    /// in the case of ETH, this address will be 0
    /// @return Address of the Backing Token
    function backingToken() external view returns (address);

    /// @return uint256 value of one backing token, in case of 18 decimals 1e18
    function backingTokenONE() external view returns (uint256);

    /// @return This TempusPool's Tempus Principal Share (TPS)
    function principalShare() external view returns (IPoolShare);

    /// @return This TempusPool's Tempus Yield Share (TYS)
    function yieldShare() external view returns (IPoolShare);

    /// @return The TempusController address that is authorized to perform restricted actions
    function controller() external view returns (address);

    /// @return Start time of the pool.
    function startTime() external view returns (uint256);

    /// @return Maturity time of the pool.
    function maturityTime() external view returns (uint256);

    /// @return Time of exceptional halting of the pool.
    /// In case the pool is still in operation, this must return type(uint256).max.
    function exceptionalHaltTime() external view returns (uint256);

    /// @return The maximum allowed time (in seconds) to pass with negative yield.
    function maximumNegativeYieldDuration() external view returns (uint256);

    /// @return True if maturity has been reached and the pool was finalized.
    ///         This also includes the case when maturity was triggered due to
    ///         exceptional conditions (negative yield periods).
    function matured() external view returns (bool);

    /// Finalizes the pool. This can only happen on or after `maturityTime`.
    /// Once finalized depositing is not possible anymore, and the behaviour
    /// redemption will change.
    ///
    /// Can be called by anyone and can be called multiple times.
    function finalize() external;

    /// Yield bearing tokens deposit hook.
    /// @notice Deposit will fail if maturity has been reached.
    /// @notice This function can only be called by TempusController
    /// @notice This function assumes funds were already transferred to the TempusPool from the TempusController
    /// @param yieldTokenAmount Amount of yield bearing tokens to deposit in YieldToken decimal precision
    /// @param recipient Address which will receive Tempus Principal Shares (TPS) and Tempus Yield Shares (TYS)
    /// @return mintedShares Amount of TPS and TYS minted to `recipient`
    /// @return depositedBT The YBT value deposited, denominated as Backing Tokens
    /// @return fee The fee which was deducted (in terms of YBT)
    /// @return rate The interest rate at the time of the deposit
    function onDepositYieldBearing(uint256 yieldTokenAmount, address recipient)
        external
        returns (
            uint256 mintedShares,
            uint256 depositedBT,
            uint256 fee,
            uint256 rate
        );

    /// Backing tokens deposit hook.
    /// @notice Deposit will fail if maturity has been reached.
    /// @notice This function can only be called by TempusController
    /// @notice This function assumes funds were already transferred to the TempusPool from the TempusController
    /// @param backingTokenAmount amount of Backing Tokens to be deposited to underlying protocol in BackingToken decimal precision
    /// @param recipient Address which will receive Tempus Principal Shares (TPS) and Tempus Yield Shares (TYS)
    /// @return mintedShares Amount of TPS and TYS minted to `recipient`
    /// @return depositedYBT The BT value deposited, denominated as Yield Bearing Tokens
    /// @return fee The fee which was deducted (in terms of YBT)
    /// @return rate The interest rate at the time of the deposit
    function onDepositBacking(uint256 backingTokenAmount, address recipient)
        external
        payable
        returns (
            uint256 mintedShares,
            uint256 depositedYBT,
            uint256 fee,
            uint256 rate
        );

    /// Redeems yield bearing tokens from this TempusPool
    ///      msg.sender will receive the YBT
    ///      NOTE #1 Before maturity, principalAmount must equal to yieldAmount.
    ///      NOTE #2 This function can only be called by TempusController
    /// @param from Address to redeem its Tempus Shares
    /// @param principalAmount Amount of Tempus Principal Shares (TPS) to redeem for YBT in PrincipalShare decimal precision
    /// @param yieldAmount Amount of Tempus Yield Shares (TYS) to redeem for YBT in YieldShare decimal precision
    /// @param recipient Address to which redeemed YBT will be sent
    /// @return redeemableYieldTokens Amount of Yield Bearing Tokens redeemed to `recipient`
    /// @return fee The fee which was deducted (in terms of YBT)
    /// @return rate The interest rate at the time of the redemption
    function redeem(
        address from,
        uint256 principalAmount,
        uint256 yieldAmount,
        address recipient
    )
        external
        returns (
            uint256 redeemableYieldTokens,
            uint256 fee,
            uint256 rate
        );

    /// Redeems TPS+TYS held by msg.sender into backing tokens
    ///      `msg.sender` must approve TPS and TYS amounts to this TempusPool.
    ///      `msg.sender` will receive the backing tokens
    ///      NOTE #1 Before maturity, principalAmount must equal to yieldAmount.
    ///      NOTE #2 This function can only be called by TempusController
    /// @param from Address to redeem its Tempus Shares
    /// @param principalAmount Amount of Tempus Principal Shares (TPS) to redeem in PrincipalShare decimal precision
    /// @param yieldAmount Amount of Tempus Yield Shares (TYS) to redeem in YieldShare decimal precision
    /// @param recipient Address to which redeemed BT will be sent
    /// @return redeemableYieldTokens Amount of Backing Tokens redeemed to `recipient`, denominated in YBT
    /// @return redeemableBackingTokens Amount of Backing Tokens redeemed to `recipient`
    /// @return fee The fee which was deducted (in terms of YBT)
    /// @return rate The interest rate at the time of the redemption
    function redeemToBacking(
        address from,
        uint256 principalAmount,
        uint256 yieldAmount,
        address recipient
    )
        external
        payable
        returns (
            uint256 redeemableYieldTokens,
            uint256 redeemableBackingTokens,
            uint256 fee,
            uint256 rate
        );

    /// Gets the estimated amount of Principals and Yields after a successful deposit
    /// @param amount Amount of BackingTokens or YieldBearingTokens that would be deposited
    /// @param isBackingToken If true, @param amount is in BackingTokens, otherwise YieldBearingTokens
    /// @return Amount of Principals (TPS) and Yields (TYS) in Principal/YieldShare decimal precision
    ///         TPS and TYS are minted in 1:1 ratio, hence a single return value.
    function estimatedMintedShares(uint256 amount, bool isBackingToken) external view returns (uint256);

    /// Gets the estimated amount of YieldBearingTokens or BackingTokens received when calling `redeemXXX()` functions
    /// @param principals Amount of Principals (TPS) in PrincipalShare decimal precision
    /// @param yields Amount of Yields (TYS) in YieldShare decimal precision
    /// @param toBackingToken If true, redeem amount is estimated in BackingTokens instead of YieldBearingTokens
    /// @return Amount of YieldBearingTokens or BackingTokens in YBT/BT decimal precision
    function estimatedRedeem(
        uint256 principals,
        uint256 yields,
        bool toBackingToken
    ) external view returns (uint256);

    /// @dev This returns the stored Interest Rate of the YBT (Yield Bearing Token) pool
    ///      it is safe to call this after updateInterestRate() was called
    /// @return Stored Interest Rate, decimal precision depends on specific TempusPool implementation
    function currentInterestRate() external view returns (uint256);

    /// @return Initial interest rate of the underlying pool,
    ///         decimal precision depends on specific TempusPool implementation
    function initialInterestRate() external view returns (uint256);

    /// @return Interest rate at maturity of the underlying pool (or 0 if maturity not reached yet)
    ///         decimal precision depends on specific TempusPool implementation
    function maturityInterestRate() external view returns (uint256);

    /// @return Rate of one Tempus Yield Share expressed in Asset Tokens
    function pricePerYieldShare() external returns (uint256);

    /// @return Rate of one Tempus Principal Share expressed in Asset Tokens
    function pricePerPrincipalShare() external returns (uint256);

    /// Calculated with stored interest rates
    /// @return Rate of one Tempus Yield Share expressed in Asset Tokens,
    function pricePerYieldShareStored() external view returns (uint256);

    /// Calculated with stored interest rates
    /// @return Rate of one Tempus Principal Share expressed in Asset Tokens
    function pricePerPrincipalShareStored() external view returns (uint256);

    /// @dev This returns actual Backing Token amount for amount of YBT (Yield Bearing Tokens)
    ///      For example, in case of Aave and Lido the result is 1:1,
    ///      and for compound is `yieldTokens * currentInterestRate`
    /// @param yieldTokens Amount of YBT in YBT decimal precision
    /// @param interestRate The current interest rate
    /// @return Amount of Backing Tokens for specified @param yieldTokens
    function numAssetsPerYieldToken(uint yieldTokens, uint interestRate) external view returns (uint);

    /// @dev This returns amount of YBT (Yield Bearing Tokens) that can be converted
    ///      from @param backingTokens Backing Tokens
    /// @param backingTokens Amount of Backing Tokens in BT decimal precision
    /// @param interestRate The current interest rate
    /// @return Amount of YBT for specified @param backingTokens
    function numYieldTokensPerAsset(uint backingTokens, uint interestRate) external view returns (uint);
}

File 8 of 16 : Fixed256xVar.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.10;

/// @dev Fixed Point decimal math utils for variable decimal point precision
///      on 256-bit wide numbers
library Fixed256xVar {
    /// @dev Multiplies two variable precision fixed point decimal numbers
    /// @param one 1.0 expressed in the base precision of `a` and `b`
    /// @return result = a * b
    function mulfV(
        uint256 a,
        uint256 b,
        uint256 one
    ) internal pure returns (uint256) {
        // result is always truncated
        return (a * b) / one;
    }

    /// @dev Divides two variable precision fixed point decimal numbers
    /// @param one 1.0 expressed in the base precision of `a` and `b`
    /// @return result = a / b
    function divfV(
        uint256 a,
        uint256 b,
        uint256 one
    ) internal pure returns (uint256) {
        // result is always truncated
        return (a * one) / b;
    }
}

File 9 of 16 : AMMBalancesHelper.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.10;

import "../math/Fixed256xVar.sol";

library AMMBalancesHelper {
    using Fixed256xVar for uint256;

    uint256 internal constant ONE = 1e18;

    function getLiquidityProvisionSharesAmounts(uint256[] memory ammBalances, uint256 shares)
        internal
        pure
        returns (uint256[] memory)
    {
        uint256[2] memory ammDepositPercentages = getAMMBalancesRatio(ammBalances);
        uint256[] memory ammLiquidityProvisionAmounts = new uint256[](2);

        (ammLiquidityProvisionAmounts[0], ammLiquidityProvisionAmounts[1]) = (
            shares.mulfV(ammDepositPercentages[0], ONE),
            shares.mulfV(ammDepositPercentages[1], ONE)
        );

        return ammLiquidityProvisionAmounts;
    }

    function getAMMBalancesRatio(uint256[] memory ammBalances) internal pure returns (uint256[2] memory balancesRatio) {
        uint256 rate = ammBalances[0].divfV(ammBalances[1], ONE);

        (balancesRatio[0], balancesRatio[1]) = rate > ONE ? (ONE, ONE.divfV(rate, ONE)) : (rate, ONE);
    }
}

File 10 of 16 : UntrustedERC20.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.10;

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

/// @title UntrustedERC20
/// @dev Wrappers around ERC20 transfer operators that return the actual amount
/// transferred. This means they are usable with tokens, which charge a fee or royalty on transfer.
library UntrustedERC20 {
    using SafeERC20 for IERC20;

    /// Transfer tokens to a recipient.
    /// @param token The ERC20 token.
    /// @param to The recipient.
    /// @param value The requested amount.
    /// @return The actual amount of tokens transferred.
    function untrustedTransfer(
        IERC20 token,
        address to,
        uint256 value
    ) internal returns (uint256) {
        uint256 startBalance = token.balanceOf(to);
        token.safeTransfer(to, value);
        return token.balanceOf(to) - startBalance;
    }

    /// Transfer tokens to a recipient.
    /// @param token The ERC20 token.
    /// @param from The sender.
    /// @param to The recipient.
    /// @param value The requested amount.
    /// @return The actual amount of tokens transferred.
    function untrustedTransferFrom(
        IERC20 token,
        address from,
        address to,
        uint256 value
    ) internal returns (uint256) {
        uint256 startBalance = token.balanceOf(to);
        token.safeTransferFrom(from, to, value);
        return token.balanceOf(to) - startBalance;
    }
}

File 11 of 16 : Ownable.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.10;

import "./IOwnable.sol";

/// Implements Ownable with a two step transfer of ownership
abstract contract Ownable is IOwnable {
    address private _owner;
    address private _proposedOwner;

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

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

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

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

    /**
     * @dev Accepts ownership of the contract by a proposed account.
     * Can only be called by the proposed owner.
     */
    function acceptOwnership() public virtual override {
        require(msg.sender == _proposedOwner, "Ownable: Only proposed owner can accept ownership");
        _setOwner(_proposedOwner);
        _proposedOwner = address(0);
    }

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

File 12 of 16 : Versioned.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.7.6 <0.9.0;

import "./IVersioned.sol";

/// Implements versioning
abstract contract Versioned is IVersioned {
    uint16 private immutable _major;
    uint16 private immutable _minor;
    uint16 private immutable _patch;

    constructor(
        uint16 major,
        uint16 minor,
        uint16 patch
    ) {
        _major = major;
        _minor = minor;
        _patch = patch;
    }

    function version() external view returns (Version memory) {
        return Version(_major, _minor, _patch);
    }
}

File 13 of 16 : Address.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    function _verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) private pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

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

File 14 of 16 : IPoolShare.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity >=0.7.6 <0.9.0;

import "../ITempusPool.sol";

/// Interface of Tokens representing the principal or yield shares of a pool.
interface IPoolShare {
    enum ShareKind {
        Principal,
        Yield
    }

    /// @return The kind of the share.
    function kind() external view returns (ShareKind);

    /// @return The pool this share is part of.
    function pool() external view returns (ITempusPool);

    /// @dev Price per single share expressed in Backing Tokens of the underlying pool.
    ///      This is for the purpose of TempusAMM api support.
    ///      Example: exchanging Tempus Yield Share to DAI
    /// @return 1e18 decimal conversion rate per share
    function getPricePerFullShare() external returns (uint256);

    /// @return 1e18 decimal stored conversion rate per share
    function getPricePerFullShareStored() external view returns (uint256);
}

File 15 of 16 : IOwnable.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.7.6 <0.9.0;

/// Implements Ownable with a two step transfer of ownership
interface IOwnable {
    /**
     * @dev Change of ownership proposed.
     * @param currentOwner The current owner.
     * @param proposedOwner The proposed owner.
     */
    event OwnershipProposed(address indexed currentOwner, address indexed proposedOwner);

    /**
     * @dev Ownership transferred.
     * @param previousOwner The previous owner.
     * @param newOwner The new owner.
     */
    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() external view returns (address);

    /**
     * @dev Proposes a transfer of ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) external;

    /**
     * @dev Accepts ownership of the contract by a proposed account.
     * Can only be called by the proposed owner.
     */
    function acceptOwnership() external;
}

File 16 of 16 : IVersioned.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.7.6 <0.9.0;
pragma abicoder v2;

/// Implements versioning
interface IVersioned {
    struct Version {
        uint16 major;
        uint16 minor;
        uint16 patch;
    }

    /// @return The version of the contract.
    function version() external view returns (Version memory);
}

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

Contract Security Audit

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"pool","type":"address"},{"indexed":true,"internalType":"address","name":"depositor","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"yieldTokenAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"backingTokenValue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"shareAmounts","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"interestRate","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"}],"name":"Deposited","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"currentOwner","type":"address"},{"indexed":true,"internalType":"address","name":"proposedOwner","type":"address"}],"name":"OwnershipProposed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"pool","type":"address"},{"indexed":true,"internalType":"address","name":"redeemer","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"principalShareAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"yieldShareAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"yieldTokenAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"backingTokenValue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"interestRate","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"},{"indexed":false,"internalType":"bool","name":"isEarlyRedeem","type":"bool"}],"name":"Redeemed","type":"event"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ITempusAMM","name":"tempusAMM","type":"address"},{"internalType":"uint256","name":"tokenAmount","type":"uint256"},{"internalType":"bool","name":"isBackingToken","type":"bool"},{"internalType":"uint256","name":"minTYSRate","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"depositAndFix","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract ITempusAMM","name":"tempusAMM","type":"address"},{"internalType":"uint256","name":"tokenAmount","type":"uint256"},{"internalType":"bool","name":"isBackingToken","type":"bool"}],"name":"depositAndProvideLiquidity","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract ITempusPool","name":"targetPool","type":"address"},{"internalType":"uint256","name":"backingTokenAmount","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"}],"name":"depositBacking","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract ITempusPool","name":"targetPool","type":"address"},{"internalType":"uint256","name":"yieldTokenAmount","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"}],"name":"depositYieldBearing","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ITempusAMM","name":"tempusAMM","type":"address"},{"internalType":"uint256","name":"principals","type":"uint256"},{"internalType":"uint256","name":"yields","type":"uint256"},{"internalType":"uint256","name":"principalsStaked","type":"uint256"},{"internalType":"uint256","name":"yieldsStaked","type":"uint256"},{"internalType":"uint256","name":"maxLpTokensToRedeem","type":"uint256"},{"internalType":"bool","name":"toBackingToken","type":"bool"}],"name":"exitAmmGivenAmountsOutAndEarlyRedeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ITempusAMM","name":"tempusAMM","type":"address"},{"internalType":"uint256","name":"lpTokens","type":"uint256"},{"internalType":"uint256","name":"principals","type":"uint256"},{"internalType":"uint256","name":"yields","type":"uint256"},{"internalType":"uint256","name":"minPrincipalsStaked","type":"uint256"},{"internalType":"uint256","name":"minYieldsStaked","type":"uint256"},{"internalType":"uint256","name":"maxLeftoverShares","type":"uint256"},{"internalType":"uint256","name":"yieldsRate","type":"uint256"},{"internalType":"uint256","name":"maxSlippage","type":"uint256"},{"internalType":"bool","name":"toBackingToken","type":"bool"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"exitAmmGivenLpAndRedeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ITempusAMM","name":"tempusAMM","type":"address"},{"internalType":"uint256","name":"lpTokensAmount","type":"uint256"},{"internalType":"uint256","name":"principalAmountOutMin","type":"uint256"},{"internalType":"uint256","name":"yieldAmountOutMin","type":"uint256"},{"internalType":"bool","name":"toInternalBalances","type":"bool"}],"name":"exitTempusAMM","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ITempusAMM","name":"tempusAMM","type":"address"},{"internalType":"uint256","name":"sharesAmount","type":"uint256"}],"name":"provideLiquidity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ITempusPool","name":"targetPool","type":"address"},{"internalType":"uint256","name":"principalAmount","type":"uint256"},{"internalType":"uint256","name":"yieldAmount","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"}],"name":"redeemToBacking","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ITempusPool","name":"targetPool","type":"address"},{"internalType":"uint256","name":"principalAmount","type":"uint256"},{"internalType":"uint256","name":"yieldAmount","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"}],"name":"redeemToYieldBearing","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"authorizedContract","type":"address"},{"internalType":"bool","name":"isValid","type":"bool"}],"name":"register","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"version","outputs":[{"components":[{"internalType":"uint16","name":"major","type":"uint16"},{"internalType":"uint16","name":"minor","type":"uint16"},{"internalType":"uint16","name":"patch","type":"uint16"}],"internalType":"struct IVersioned.Version","name":"","type":"tuple"}],"stateMutability":"view","type":"function"}]

60e06040523480156200001157600080fd5b50600160008181558062000025336200003e565b61ffff92831660805290821660a0521660c05262000090565b600180546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60805160a05160c051614f1e620000c060003960006101d0015260006101a60152600061017c0152614f1e6000f3fe6080604052600436106100e85760003560e01c80638da5cb5b1161008a578063ab01b46911610059578063ab01b4691461030a578063c847b1011461032a578063e6eec2f11461034a578063f2fde38b1461035d57600080fd5b80638da5cb5b146102825780639bc84aec146102b7578063a3621663146102d7578063a51ca8ef146102f757600080fd5b806354fd4d50116100c657806354fd4d50146101425780635fea61201461022d5780636c8d4fa11461024d57806379ba50971461026d57600080fd5b80631c1db20a146100ed57806338e963eb1461010f578063507a3baf1461012f575b600080fd5b3480156100f957600080fd5b5061010d6101083660046144ac565b61037d565b005b34801561011b57600080fd5b5061010d61012a3660046144f6565b610492565b61010d61013d366004614546565b610595565b34801561014e57600080fd5b506101fb604080516060810182526000808252602082018190529181019190915260405180606001604052807f000000000000000000000000000000000000000000000000000000000000000061ffff1681526020017f000000000000000000000000000000000000000000000000000000000000000061ffff1681526020017f000000000000000000000000000000000000000000000000000000000000000061ffff16815250905090565b60408051825161ffff908116825260208085015182169083015292820151909216908201526060015b60405180910390f35b34801561023957600080fd5b5061010d610248366004614598565b610629565b34801561025957600080fd5b5061010d6102683660046144ac565b6106d8565b34801561027957600080fd5b5061010d6107dd565b34801561028e57600080fd5b5060015460405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610224565b3480156102c357600080fd5b5061010d6102d23660046145c4565b6108d0565b3480156102e357600080fd5b5061010d6102f236600461461a565b610958565b61010d610305366004614683565b6109e2565b34801561031657600080fd5b5061010d6103253660046146ba565b610a72565b34801561033657600080fd5b5061010d6103453660046146f3565b610b65565b61010d6103583660046144f6565b610d2b565b34801561036957600080fd5b5061010d610378366004614786565b610e2e565b600260005414156103ef576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064015b60405180910390fd5b600260005573ffffffffffffffffffffffffffffffffffffffff8116610471576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f726563697069656e742063616e206e6f7420626520307830000000000000000060448201526064016103e6565b61047a84610fe5565b6104878433858585611077565b505060016000555050565b600260005414156104ff576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016103e6565b600260005573ffffffffffffffffffffffffffffffffffffffff8116610581576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f726563697069656e742063616e206e6f7420626520307830000000000000000060448201526064016103e6565b61058a83610fe5565b6104878383836113d4565b60026000541415610602576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016103e6565b600260005561061085610fe5565b61061d8585858585611602565b50506001600055505050565b60026000541415610696576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016103e6565b60026000556106a482610fe5565b6000806000806106b386611958565b93509350935093506106ca33858585858a33611bc3565b505060016000555050505050565b60026000541415610745576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016103e6565b600260005573ffffffffffffffffffffffffffffffffffffffff81166107c7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f726563697069656e742063616e206e6f7420626520307830000000000000000060448201526064016103e6565b6107d084610fe5565b6104878433858585611dde565b60025473ffffffffffffffffffffffffffffffffffffffff163314610884576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603160248201527f4f776e61626c653a204f6e6c792070726f706f736564206f776e65722063616e60448201527f20616363657074206f776e65727368697000000000000000000000000000000060648201526084016103e6565b6002546108a69073ffffffffffffffffffffffffffffffffffffffff16612021565b600280547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055565b6002600054141561093d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016103e6565b600260005561094b85610fe5565b61061d8585858585612098565b600260005414156109c5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016103e6565b60026000556109d387610fe5565b6106ca878787878787876121c0565b60026000541415610a4f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016103e6565b6002600055610a5d83610fe5565b610a68838383612699565b5050600160005550565b33610a9260015473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1614610b0f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016103e6565b73ffffffffffffffffffffffffffffffffffffffff91909116600090815260036020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016911515919091179055565b60026000541415610bd2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016103e6565b6002600055610be08b610fe5565b8915610d09576040517f23b872dd000000000000000000000000000000000000000000000000000000008152336004820152306024820152604481018b905273ffffffffffffffffffffffffffffffffffffffff8c16906323b872dd906064016020604051808303816000875af1158015610c5f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c8391906147a3565b610ce9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f4c5020746f6b656e207472616e73666572206661696c6564000000000000000060448201526064016103e6565b6000610cf68c8989612836565b9050610d078c30308e856000612b5a565b505b610d198b8a8a8888888789612cb5565b50506001600055505050505050505050565b60026000541415610d98576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016103e6565b600260005573ffffffffffffffffffffffffffffffffffffffff8116610e1a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f726563697069656e742063616e206e6f7420626520307830000000000000000060448201526064016103e6565b610e2383610fe5565b61048783838361364e565b33610e4e60015473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1614610ecb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016103e6565b73ffffffffffffffffffffffffffffffffffffffff8116610f6e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016103e6565b600280547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff838116918217909255600154604051919216907fb51454ce8c7f26becd312a46c4815553887f2ec876a0b8dc813b87f62edf6f8090600090a350565b73ffffffffffffffffffffffffffffffffffffffff811660009081526003602052604090205460ff16611074576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f556e617574686f72697a656420636f6e7472616374206164647265737300000060448201526064016103e6565b50565b60008311806110865750600082115b611112576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f7072696e636970616c416d6f756e7420616e64207969656c64416d6f756e742060448201527f63616e6e6f7420626f746820626520300000000000000000000000000000000060648201526084016103e6565b6040517f43bcfab600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85811660048301526024820185905260448201849052828116606483015260009182918291908916906343bcfab6906084016060604051808303816000875af115801561119e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111c291906147c0565b92509250925060008873ffffffffffffffffffffffffffffffffffffffff1663960c6917858b73ffffffffffffffffffffffffffffffffffffffff1663ff4c7e316040518163ffffffff1660e01b8152600401602060405180830381865afa158015611232573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061125691906147ee565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b16815260048101929092526024820152604401602060405180830381865afa1580156112af573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112d391906147ee565b905060008973ffffffffffffffffffffffffffffffffffffffff1663454c87b36040518163ffffffff1660e01b8152600401602060405180830381865afa158015611322573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061134691906147a3565b604080518a8152602081018a9052908101879052606081018490526080810186905260a08101859052901560c08201819052915073ffffffffffffffffffffffffffffffffffffffff808816918b8216918d16907fcd7942cd399b7cdf1812afbdafdccdaa55899bc945c90e4af0ecf07736de030f9060e0015b60405180910390a450505050505050505050565b600080831161143f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f7969656c64546f6b656e416d6f756e742069732030000000000000000000000060448201526064016103e6565b60008473ffffffffffffffffffffffffffffffffffffffff16632d81f8386040518163ffffffff1660e01b8152600401602060405180830381865afa15801561148c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114b09190614807565b905060006114d673ffffffffffffffffffffffffffffffffffffffff8316338888613a32565b90506000806000808973ffffffffffffffffffffffffffffffffffffffff1663e8a8cf65868a6040518363ffffffff1660e01b815260040161153892919091825273ffffffffffffffffffffffffffffffffffffffff16602082015260400190565b6080604051808303816000875af1158015611557573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061157b9190614824565b604080518a81526020810185905290810185905260608101829052608081018390529397509195509350915073ffffffffffffffffffffffffffffffffffffffff808a169133918d16907f4c3988fb4c597926bdbfd4fb6863567acf4c384bd3c02f401fa99f158c783bb89060a00160405180910390a450919450505050505b9392505050565b60008573ffffffffffffffffffffffffffffffffffffffff1663f1563de96040518163ffffffff1660e01b8152600401602060405180830381865afa15801561164f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116739190614807565b905060008173ffffffffffffffffffffffffffffffffffffffff1663350836436040518163ffffffff1660e01b8152600401602060405180830381865afa1580156116c2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116e69190614807565b905060008273ffffffffffffffffffffffffffffffffffffffff1663c56c7a856040518163ffffffff1660e01b8152600401602060405180830381865afa158015611735573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117599190614807565b90506000611768848989613b92565b90506117fa8973ffffffffffffffffffffffffffffffffffffffff16638d928af86040518163ffffffff1660e01b8152600401602060405180830381865afa1580156117b8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117dc9190614807565b73ffffffffffffffffffffffffffffffffffffffff84169083613bbc565b6000611877878673ffffffffffffffffffffffffffffffffffffffff16632b532a976040518163ffffffff1660e01b8152600401602060405180830381865afa15801561184b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061186f91906147ee565b849190613d3e565b90506118878a838587858b613d55565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8616906370a0823190602401602060405180830381865afa1580156118f4573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061191891906147ee565b90506000811161192a5761192a61485a565b61194b73ffffffffffffffffffffffffffffffffffffffff86163383613fb8565b5050505050505050505050565b6000806060808473ffffffffffffffffffffffffffffffffffffffff16638d928af86040518163ffffffff1660e01b8152600401602060405180830381865afa1580156119a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119cd9190614807565b93508473ffffffffffffffffffffffffffffffffffffffff166338fff2d06040518163ffffffff1660e01b8152600401602060405180830381865afa158015611a1a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a3e91906147ee565b6040517ff94d46680000000000000000000000000000000000000000000000000000000081526004810182905290935073ffffffffffffffffffffffffffffffffffffffff85169063f94d466890602401600060405180830381865afa158015611aac573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201604052611af29190810190614996565b50815191935091506002148015611b0a575080516002145b8015611b305750600081600081518110611b2657611b26614a64565b6020026020010151115b8015611b565750600081600181518110611b4c57611b4c614a64565b6020026020010151115b611bbc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f414d4d206e6f7420696e697469616c697a65640000000000000000000000000060448201526064016103e6565b9193509193565b60606000611bd18585614013565b905073ffffffffffffffffffffffffffffffffffffffff89163014611c8457611c51893083600081518110611c0857611c08614a64565b602002602001015189600081518110611c2357611c23614a64565b602002602001015173ffffffffffffffffffffffffffffffffffffffff166140b9909392919063ffffffff16565b611c84893083600181518110611c6957611c69614a64565b602002602001015189600181518110611c2357611c23614a64565b611ce38882600081518110611c9b57611c9b614a64565b602002602001015188600081518110611cb657611cb6614a64565b602002602001015173ffffffffffffffffffffffffffffffffffffffff16613bbc9092919063ffffffff16565b611d158882600181518110611cfa57611cfa614a64565b602002602001015188600181518110611cb657611cb6614a64565b60408051608081018252878152602081018390526000918101600184604051602001611d42929190614afd565b60405160208183030381529060405281526020016000151581525090508873ffffffffffffffffffffffffffffffffffffffff1663b95cac28893087856040518563ffffffff1660e01b8152600401611d9e9493929190614c33565b600060405180830381600087803b158015611db857600080fd5b505af1158015611dcc573d6000803e3d6000fd5b50939c9b505050505050505050505050565b6000831180611ded5750600082115b611e79576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f7072696e636970616c416d6f756e7420616e64207969656c64416d6f756e742060448201527f63616e6e6f7420626f746820626520300000000000000000000000000000000060648201526084016103e6565b6040517f6c8d4fa100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8581166004830152602482018590526044820184905282811660648301526000918291829182918a1690636c8d4fa1906084016080604051808303816000875af1158015611f06573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f2a9190614824565b935093509350935060008973ffffffffffffffffffffffffffffffffffffffff1663454c87b36040518163ffffffff1660e01b8152600401602060405180830381865afa158015611f7f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fa391906147a3565b604080518a8152602081018a9052908101879052606081018690526080810185905260a08101849052901560c08201819052915073ffffffffffffffffffffffffffffffffffffffff808816918b8216918d16907fcd7942cd399b7cdf1812afbdafdccdaa55899bc945c90e4af0ecf07736de030f9060e0016113c0565b6001805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6040517f23b872dd0000000000000000000000000000000000000000000000000000000081523360048201523060248201526044810185905273ffffffffffffffffffffffffffffffffffffffff8616906323b872dd906064016020604051808303816000875af1158015612111573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061213591906147a3565b61219b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f4c5020746f6b656e207472616e73666572206661696c6564000000000000000060448201526064016103e6565b60006121a8868585612836565b90506121b8863033888587612b5a565b505050505050565b60008773ffffffffffffffffffffffffffffffffffffffff1663f1563de96040518163ffffffff1660e01b8152600401602060405180830381865afa15801561220d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122319190614807565b90508073ffffffffffffffffffffffffffffffffffffffff1663454c87b36040518163ffffffff1660e01b8152600401602060405180830381865afa15801561227e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122a291906147a3565b15612309576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f506f6f6c20616c72656164792066696e616c697a65640000000000000000000060448201526064016103e6565b6123138588614ca1565b965061231f8487614ca1565b95508587146123b0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f4e6565647320657175616c20616d6f756e7473206f662073686172657320626560448201527f666f7265206d617475726974790000000000000000000000000000000000000060648201526084016103e6565b6040517f23b872dd0000000000000000000000000000000000000000000000000000000081523360048201523060248201526044810184905273ffffffffffffffffffffffffffffffffffffffff8916906323b872dd906064016020604051808303816000875af1158015612429573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061244d91906147a3565b6124b3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f4c5020746f6b656e207472616e73666572206661696c6564000000000000000060448201526064016103e6565b60006124c0898787612836565b90506124d189303384886000614117565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8b16906370a0823190602401602060405180830381865afa15801561253e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061256291906147ee565b6040517f23b872dd0000000000000000000000000000000000000000000000000000000081523060048201523360248201526044810182905290915073ffffffffffffffffffffffffffffffffffffffff8b16906323b872dd906064016020604051808303816000875af11580156125de573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061260291906147a3565b612668576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f4c5020746f6b656e207472616e73666572206661696c6564000000000000000060448201526064016103e6565b83156126805761267b83338b8b33611dde565b61268d565b61268d83338b8b33611077565b50505050505050505050565b6000806000806126a887611958565b9350935093509350600061272b8873ffffffffffffffffffffffffffffffffffffffff1663f1563de96040518163ffffffff1660e01b8152600401602060405180830381865afa158015612700573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127249190614807565b8888613b92565b9050600061273e30878787878733611bc3565b90508060008151811061275357612753614a64565b60200260200101518211156127cc576127cc338260008151811061277957612779614a64565b60200260200101518461278c9190614cb9565b8660008151811061279f5761279f614a64565b602002602001015173ffffffffffffffffffffffffffffffffffffffff16613fb89092919063ffffffff16565b806001815181106127df576127df614a64565b602002602001015182111561282b5761282b338260018151811061280557612805614a64565b6020026020010151846128189190614cb9565b8660018151811061279f5761279f614a64565b505050505050505050565b606060008473ffffffffffffffffffffffffffffffffffffffff16638d928af86040518163ffffffff1660e01b8152600401602060405180830381865afa158015612885573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128a99190614807565b905060008173ffffffffffffffffffffffffffffffffffffffff1663f94d46688773ffffffffffffffffffffffffffffffffffffffff166338fff2d06040518163ffffffff1660e01b8152600401602060405180830381865afa158015612914573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061293891906147ee565b6040518263ffffffff1660e01b815260040161295691815260200190565b600060405180830381865afa158015612973573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682016040526129b99190810190614996565b50506040805160028082526060820183529293506000929091602083019080368337019050509050816000815181106129f4576129f4614a64565b602002602001015173ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff1663f1563de96040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a5d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a819190614807565b73ffffffffffffffffffffffffffffffffffffffff1663350836436040518163ffffffff1660e01b8152600401602060405180830381865afa158015612acb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612aef9190614807565b73ffffffffffffffffffffffffffffffffffffffff1614612b11578486612b14565b85855b82600081518110612b2757612b27614a64565b6020026020010183600181518110612b4157612b41614a64565b6020908102919091010191909152529695505050505050565b60008311612bc4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f4c5020746f6b656e20616d6f756e74206973203000000000000000000000000060448201526064016103e6565b6000806000612bd289611958565b509250925092506000604051806080016040528083815260200187815260200160006001811115612c0557612c05614a93565b6040805160ff909216602083015281018a90526060015b604051602081830303815290604052815260200186151581525090508373ffffffffffffffffffffffffffffffffffffffff16638bdb3913848b8b856040518563ffffffff1660e01b8152600401612c779493929190614c33565b600060405180830381600087803b158015612c9157600080fd5b505af1158015612ca5573d6000803e3d6000fd5b5050505050505050505050505050565b60008873ffffffffffffffffffffffffffffffffffffffff1663f1563de96040518163ffffffff1660e01b8152600401602060405180830381865afa158015612d02573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d269190614807565b905060008173ffffffffffffffffffffffffffffffffffffffff1663350836436040518163ffffffff1660e01b8152600401602060405180830381865afa158015612d75573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d999190614807565b905060008273ffffffffffffffffffffffffffffffffffffffff1663c56c7a856040518163ffffffff1660e01b8152600401602060405180830381865afa158015612de8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e0c9190614807565b6040517f23b872dd000000000000000000000000000000000000000000000000000000008152336004820152306024820152604481018c905290915073ffffffffffffffffffffffffffffffffffffffff8316906323b872dd906064016020604051808303816000875af1158015612e88573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612eac91906147a3565b612f12576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f5072696e636970616c73207472616e73666572206661696c656400000000000060448201526064016103e6565b6040517f23b872dd000000000000000000000000000000000000000000000000000000008152336004820152306024820152604481018a905273ffffffffffffffffffffffffffffffffffffffff8216906323b872dd906064016020604051808303816000875af1158015612f8b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612faf91906147a3565b613015576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f5969656c6473207472616e73666572206661696c65640000000000000000000060448201526064016103e6565b600087116130a5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f7969656c647352617465206d7573742062652067726561746572207468616e2060448201527f300000000000000000000000000000000000000000000000000000000000000060648201526084016103e6565b670de0b6b3a764000086111561313d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602860248201527f6d6178536c6970706167652063616e206e6f742062652067726561746572207460448201527f68616e203165313800000000000000000000000000000000000000000000000060648201526084016103e6565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff8316906370a0823190602401602060405180830381865afa1580156131a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131cb91906147ee565b6040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152909a5073ffffffffffffffffffffffffffffffffffffffff8216906370a0823190602401602060405180830381865afa158015613238573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061325c91906147ee565b98508273ffffffffffffffffffffffffffffffffffffffff1663454c87b36040518163ffffffff1660e01b8152600401602060405180830381865afa1580156132a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132cd91906147a3565b61362957878a8a116132e8576132e38a8c614cb9565b6132f2565b6132f28b8b614cb9565b10613612576040517f7b62525f000000000000000000000000000000000000000000000000000000008152600481018b9052602481018a905260448101899052600090819073ffffffffffffffffffffffffffffffffffffffff8e1690637b62525f906064016040805180830381865afa158015613374573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133989190614cd0565b915091506000816134235761341e8a8773ffffffffffffffffffffffffffffffffffffffff16632b532a976040518163ffffffff1660e01b8152600401602060405180830381865afa1580156133f2573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061341691906147ee565b85919061416b565b61349e565b61349e8a8773ffffffffffffffffffffffffffffffffffffffff16632b532a976040518163ffffffff1660e01b8152600401602060405180830381865afa158015613472573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061349691906147ee565b859190613d3e565b90506134c56134b58a670de0b6b3a7640000614cb9565b8290670de0b6b3a7640000613d3e565b90506134ed8e84846134d757876134d9565b865b856134e457876134e6565b885b858d613d55565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff8616906370a0823190602401602060405180830381865afa158015613557573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061357b91906147ee565b6040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152909d5073ffffffffffffffffffffffffffffffffffffffff8516906370a0823190602401602060405180830381865afa1580156135e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061360c91906147ee565b9b505050505b888a1115613621578889613624565b898a5b9a5098505b83156136415761363c83308c8c33611dde565b61194b565b61194b83308c8c33611077565b60008083116136b9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f6261636b696e67546f6b656e416d6f756e74206973203000000000000000000060448201526064016103e6565b60008473ffffffffffffffffffffffffffffffffffffffff166347e621b76040518163ffffffff1660e01b8152600401602060405180830381865afa158015613706573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061372a9190614807565b9050346137d75773ffffffffffffffffffffffffffffffffffffffff81166137ae576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f506f6f6c20726571756972657320455448206465706f7369747300000000000060448201526064016103e6565b6137d073ffffffffffffffffffffffffffffffffffffffff8216338787613a32565b935061390a565b73ffffffffffffffffffffffffffffffffffffffff81161561387b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f676976656e2054656d707573506f6f6c2773204261636b696e6720546f6b656e60448201527f206973206e6f742045544800000000000000000000000000000000000000000060648201526084016103e6565b83341461390a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602860248201527f4554482076616c756520646f6573206e6f74206d617463682070726f7669646560448201527f6420616d6f756e7400000000000000000000000000000000000000000000000060648201526084016103e6565b6040517f4b009e060000000000000000000000000000000000000000000000000000000081526004810185905273ffffffffffffffffffffffffffffffffffffffff84811660248301526000918291829182918a1690634b009e0690349060440160806040518083038185885af1158015613989573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906139ae9190614824565b60408051848152602081018e905290810185905260608101829052608081018390529397509195509350915073ffffffffffffffffffffffffffffffffffffffff8089169133918c16907f4c3988fb4c597926bdbfd4fb6863567acf4c384bd3c02f401fa99f158c783bb89060a00160405180910390a45091979650505050505050565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff838116600483015260009182918716906370a0823190602401602060405180830381865afa158015613aa3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ac791906147ee565b9050613aeb73ffffffffffffffffffffffffffffffffffffffff87168686866140b9565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85811660048301528291908816906370a0823190602401602060405180830381865afa158015613b5a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b7e91906147ee565b613b889190614cb9565b9695505050505050565b600081613ba957613ba48484306113d4565b613bb4565b613bb484843061364e565b949350505050565b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff8381166024830152600091839186169063dd62ed3e90604401602060405180830381865afa158015613c33573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c5791906147ee565b613c619190614ca1565b60405173ffffffffffffffffffffffffffffffffffffffff8516602482015260448101829052909150613d389085907f095ea7b300000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152614178565b50505050565b600081613d4b8486614cf5565b613bb49190614d32565b60008511613dbf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f496e76616c6964207377617020616d6f756e742e00000000000000000000000060448201526064016103e6565b613e4f8673ffffffffffffffffffffffffffffffffffffffff16638d928af86040518163ffffffff1660e01b8152600401602060405180830381865afa158015613e0d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e319190614807565b73ffffffffffffffffffffffffffffffffffffffff86169087613bbc565b600080613e5b88611958565b50509150915060006040518060c0016040528083815260200160006001811115613e8757613e87614a93565b81526020018873ffffffffffffffffffffffffffffffffffffffff1681526020018773ffffffffffffffffffffffffffffffffffffffff168152602001898152602001604051806020016040528060008152508152509050600060405180608001604052803073ffffffffffffffffffffffffffffffffffffffff1681526020016000151581526020013073ffffffffffffffffffffffffffffffffffffffff1681526020016000151581525090508373ffffffffffffffffffffffffffffffffffffffff166352bbbe29838389896040518563ffffffff1660e01b8152600401613f759493929190614d6d565b6020604051808303816000875af1158015613f94573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061194b91906147ee565b60405173ffffffffffffffffffffffffffffffffffffffff831660248201526044810182905261400e9084907fa9059cbb0000000000000000000000000000000000000000000000000000000090606401613cb6565b505050565b6060600061402084614284565b60408051600280825260608201835292935060009290916020830190803683375050835191925061405c91869150670de0b6b3a7640000613d3e565b6020830151614075908690670de0b6b3a7640000613d3e565b8260008151811061408857614088614a64565b60200260200101836001815181106140a2576140a2614a64565b602090810291909101019190915252949350505050565b60405173ffffffffffffffffffffffffffffffffffffffff80851660248301528316604482015260648101829052613d389085907f23b872dd0000000000000000000000000000000000000000000000000000000090608401613cb6565b600080600061412589611958565b509250925092506000604051806080016040528083815260200188815260200160018081111561415757614157614a93565b8989604051602001612c1c93929190614e8d565b600082613d4b8386614cf5565b60006141da826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166143209092919063ffffffff16565b80519091501561400e57808060200190518101906141f891906147a3565b61400e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016103e6565b61428c61446c565b60006142df836001815181106142a4576142a4614a64565b6020026020010151670de0b6b3a7640000856000815181106142c8576142c8614a64565b602002602001015161416b9092919063ffffffff16565b9050670de0b6b3a764000081116142ff5780670de0b6b3a7640000614313565b670de0b6b3a764000061431381838161416b565b6020840152825250919050565b6060613bb4848460008585843b614393576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016103e6565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516143bc9190614eb9565b60006040518083038185875af1925050503d80600081146143f9576040519150601f19603f3d011682016040523d82523d6000602084013e6143fe565b606091505b509150915061440e828286614419565b979650505050505050565b606083156144285750816115fb565b8251156144385782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103e69190614ed5565b60405180604001604052806002906020820280368337509192915050565b73ffffffffffffffffffffffffffffffffffffffff8116811461107457600080fd5b600080600080608085870312156144c257600080fd5b84356144cd8161448a565b9350602085013592506040850135915060608501356144eb8161448a565b939692955090935050565b60008060006060848603121561450b57600080fd5b83356145168161448a565b925060208401359150604084013561452d8161448a565b809150509250925092565b801515811461107457600080fd5b600080600080600060a0868803121561455e57600080fd5b85356145698161448a565b945060208601359350604086013561458081614538565b94979396509394606081013594506080013592915050565b600080604083850312156145ab57600080fd5b82356145b68161448a565b946020939093013593505050565b600080600080600060a086880312156145dc57600080fd5b85356145e78161448a565b9450602086013593506040860135925060608601359150608086013561460c81614538565b809150509295509295909350565b600080600080600080600060e0888a03121561463557600080fd5b87356146408161448a565b96506020880135955060408801359450606088013593506080880135925060a0880135915060c088013561467381614538565b8091505092959891949750929550565b60008060006060848603121561469857600080fd5b83356146a38161448a565b925060208401359150604084013561452d81614538565b600080604083850312156146cd57600080fd5b82356146d88161448a565b915060208301356146e881614538565b809150509250929050565b60008060008060008060008060008060006101608c8e03121561471557600080fd5b8b356147208161448a565b9a5060208c0135995060408c0135985060608c0135975060808c0135965060a08c0135955060c08c0135945060e08c013593506101008c013592506101208c013561476a81614538565b809250506101408c013590509295989b509295989b9093969950565b60006020828403121561479857600080fd5b81356115fb8161448a565b6000602082840312156147b557600080fd5b81516115fb81614538565b6000806000606084860312156147d557600080fd5b8351925060208401519150604084015190509250925092565b60006020828403121561480057600080fd5b5051919050565b60006020828403121561481957600080fd5b81516115fb8161448a565b6000806000806080858703121561483a57600080fd5b505082516020840151604085015160609095015191969095509092509050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156148ff576148ff614889565b604052919050565b600067ffffffffffffffff82111561492157614921614889565b5060051b60200190565b600082601f83011261493c57600080fd5b8151602061495161494c83614907565b6148b8565b82815260059290921b8401810191818101908684111561497057600080fd5b8286015b8481101561498b5780518352918301918301614974565b509695505050505050565b6000806000606084860312156149ab57600080fd5b835167ffffffffffffffff808211156149c357600080fd5b818601915086601f8301126149d757600080fd5b815160206149e761494c83614907565b82815260059290921b8401810191818101908a841115614a0657600080fd5b948201945b83861015614a2d578551614a1e8161448a565b82529482019490820190614a0b565b91890151919750909350505080821115614a4657600080fd5b50614a538682870161492b565b925050604084015190509250925092565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b600081518084526020808501945080840160005b83811015614af257815187529582019590820190600101614ad6565b509495945050505050565b60ff83168152604060208201526000613bb46040830184614ac2565b60005b83811015614b34578181015183820152602001614b1c565b83811115613d385750506000910152565b60008151808452614b5d816020860160208601614b19565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b8051608080845281519084018190526000916020919082019060a0860190845b81811015614be157835173ffffffffffffffffffffffffffffffffffffffff1683529284019291840191600101614baf565b505082850151915085810383870152614bfa8183614ac2565b9250505060408301518482036040860152614c158282614b45565b9150506060830151614c2b606086018215159052565b509392505050565b848152600073ffffffffffffffffffffffffffffffffffffffff808616602084015280851660408401525060806060830152613b886080830184614b8f565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60008219821115614cb457614cb4614c72565b500190565b600082821015614ccb57614ccb614c72565b500390565b60008060408385031215614ce357600080fd5b8251915060208301516146e881614538565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615614d2d57614d2d614c72565b500290565b600082614d68577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b60e08152845160e08201526000602086015160028110614db6577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b610100830152604086015173ffffffffffffffffffffffffffffffffffffffff166101208301526060860151614e0561014084018273ffffffffffffffffffffffffffffffffffffffff169052565b50608086015161016083015260a086015160c0610180840152614e2c6101a0840182614b45565b915050614e7b602083018673ffffffffffffffffffffffffffffffffffffffff808251168352602082015115156020840152806040830151166040840152506060810151151560608301525050565b60a082019390935260c0015292915050565b60ff84168152606060208201526000614ea96060830185614ac2565b9050826040830152949350505050565b60008251614ecb818460208701614b19565b9190910192915050565b6020815260006115fb6020830184614b4556fea2646970667358221220d140589d60b906492ef7477eb789d76033f75cbbda4466183b3d9140dac45f2e64736f6c634300080a0033

Deployed Bytecode

0x6080604052600436106100e85760003560e01c80638da5cb5b1161008a578063ab01b46911610059578063ab01b4691461030a578063c847b1011461032a578063e6eec2f11461034a578063f2fde38b1461035d57600080fd5b80638da5cb5b146102825780639bc84aec146102b7578063a3621663146102d7578063a51ca8ef146102f757600080fd5b806354fd4d50116100c657806354fd4d50146101425780635fea61201461022d5780636c8d4fa11461024d57806379ba50971461026d57600080fd5b80631c1db20a146100ed57806338e963eb1461010f578063507a3baf1461012f575b600080fd5b3480156100f957600080fd5b5061010d6101083660046144ac565b61037d565b005b34801561011b57600080fd5b5061010d61012a3660046144f6565b610492565b61010d61013d366004614546565b610595565b34801561014e57600080fd5b506101fb604080516060810182526000808252602082018190529181019190915260405180606001604052807f000000000000000000000000000000000000000000000000000000000000000161ffff1681526020017f000000000000000000000000000000000000000000000000000000000000000061ffff1681526020017f000000000000000000000000000000000000000000000000000000000000000061ffff16815250905090565b60408051825161ffff908116825260208085015182169083015292820151909216908201526060015b60405180910390f35b34801561023957600080fd5b5061010d610248366004614598565b610629565b34801561025957600080fd5b5061010d6102683660046144ac565b6106d8565b34801561027957600080fd5b5061010d6107dd565b34801561028e57600080fd5b5060015460405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610224565b3480156102c357600080fd5b5061010d6102d23660046145c4565b6108d0565b3480156102e357600080fd5b5061010d6102f236600461461a565b610958565b61010d610305366004614683565b6109e2565b34801561031657600080fd5b5061010d6103253660046146ba565b610a72565b34801561033657600080fd5b5061010d6103453660046146f3565b610b65565b61010d6103583660046144f6565b610d2b565b34801561036957600080fd5b5061010d610378366004614786565b610e2e565b600260005414156103ef576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064015b60405180910390fd5b600260005573ffffffffffffffffffffffffffffffffffffffff8116610471576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f726563697069656e742063616e206e6f7420626520307830000000000000000060448201526064016103e6565b61047a84610fe5565b6104878433858585611077565b505060016000555050565b600260005414156104ff576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016103e6565b600260005573ffffffffffffffffffffffffffffffffffffffff8116610581576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f726563697069656e742063616e206e6f7420626520307830000000000000000060448201526064016103e6565b61058a83610fe5565b6104878383836113d4565b60026000541415610602576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016103e6565b600260005561061085610fe5565b61061d8585858585611602565b50506001600055505050565b60026000541415610696576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016103e6565b60026000556106a482610fe5565b6000806000806106b386611958565b93509350935093506106ca33858585858a33611bc3565b505060016000555050505050565b60026000541415610745576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016103e6565b600260005573ffffffffffffffffffffffffffffffffffffffff81166107c7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f726563697069656e742063616e206e6f7420626520307830000000000000000060448201526064016103e6565b6107d084610fe5565b6104878433858585611dde565b60025473ffffffffffffffffffffffffffffffffffffffff163314610884576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603160248201527f4f776e61626c653a204f6e6c792070726f706f736564206f776e65722063616e60448201527f20616363657074206f776e65727368697000000000000000000000000000000060648201526084016103e6565b6002546108a69073ffffffffffffffffffffffffffffffffffffffff16612021565b600280547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055565b6002600054141561093d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016103e6565b600260005561094b85610fe5565b61061d8585858585612098565b600260005414156109c5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016103e6565b60026000556109d387610fe5565b6106ca878787878787876121c0565b60026000541415610a4f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016103e6565b6002600055610a5d83610fe5565b610a68838383612699565b5050600160005550565b33610a9260015473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1614610b0f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016103e6565b73ffffffffffffffffffffffffffffffffffffffff91909116600090815260036020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016911515919091179055565b60026000541415610bd2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016103e6565b6002600055610be08b610fe5565b8915610d09576040517f23b872dd000000000000000000000000000000000000000000000000000000008152336004820152306024820152604481018b905273ffffffffffffffffffffffffffffffffffffffff8c16906323b872dd906064016020604051808303816000875af1158015610c5f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c8391906147a3565b610ce9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f4c5020746f6b656e207472616e73666572206661696c6564000000000000000060448201526064016103e6565b6000610cf68c8989612836565b9050610d078c30308e856000612b5a565b505b610d198b8a8a8888888789612cb5565b50506001600055505050505050505050565b60026000541415610d98576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016103e6565b600260005573ffffffffffffffffffffffffffffffffffffffff8116610e1a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f726563697069656e742063616e206e6f7420626520307830000000000000000060448201526064016103e6565b610e2383610fe5565b61048783838361364e565b33610e4e60015473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1614610ecb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016103e6565b73ffffffffffffffffffffffffffffffffffffffff8116610f6e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016103e6565b600280547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff838116918217909255600154604051919216907fb51454ce8c7f26becd312a46c4815553887f2ec876a0b8dc813b87f62edf6f8090600090a350565b73ffffffffffffffffffffffffffffffffffffffff811660009081526003602052604090205460ff16611074576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f556e617574686f72697a656420636f6e7472616374206164647265737300000060448201526064016103e6565b50565b60008311806110865750600082115b611112576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f7072696e636970616c416d6f756e7420616e64207969656c64416d6f756e742060448201527f63616e6e6f7420626f746820626520300000000000000000000000000000000060648201526084016103e6565b6040517f43bcfab600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85811660048301526024820185905260448201849052828116606483015260009182918291908916906343bcfab6906084016060604051808303816000875af115801561119e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111c291906147c0565b92509250925060008873ffffffffffffffffffffffffffffffffffffffff1663960c6917858b73ffffffffffffffffffffffffffffffffffffffff1663ff4c7e316040518163ffffffff1660e01b8152600401602060405180830381865afa158015611232573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061125691906147ee565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b16815260048101929092526024820152604401602060405180830381865afa1580156112af573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112d391906147ee565b905060008973ffffffffffffffffffffffffffffffffffffffff1663454c87b36040518163ffffffff1660e01b8152600401602060405180830381865afa158015611322573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061134691906147a3565b604080518a8152602081018a9052908101879052606081018490526080810186905260a08101859052901560c08201819052915073ffffffffffffffffffffffffffffffffffffffff808816918b8216918d16907fcd7942cd399b7cdf1812afbdafdccdaa55899bc945c90e4af0ecf07736de030f9060e0015b60405180910390a450505050505050505050565b600080831161143f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f7969656c64546f6b656e416d6f756e742069732030000000000000000000000060448201526064016103e6565b60008473ffffffffffffffffffffffffffffffffffffffff16632d81f8386040518163ffffffff1660e01b8152600401602060405180830381865afa15801561148c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114b09190614807565b905060006114d673ffffffffffffffffffffffffffffffffffffffff8316338888613a32565b90506000806000808973ffffffffffffffffffffffffffffffffffffffff1663e8a8cf65868a6040518363ffffffff1660e01b815260040161153892919091825273ffffffffffffffffffffffffffffffffffffffff16602082015260400190565b6080604051808303816000875af1158015611557573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061157b9190614824565b604080518a81526020810185905290810185905260608101829052608081018390529397509195509350915073ffffffffffffffffffffffffffffffffffffffff808a169133918d16907f4c3988fb4c597926bdbfd4fb6863567acf4c384bd3c02f401fa99f158c783bb89060a00160405180910390a450919450505050505b9392505050565b60008573ffffffffffffffffffffffffffffffffffffffff1663f1563de96040518163ffffffff1660e01b8152600401602060405180830381865afa15801561164f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116739190614807565b905060008173ffffffffffffffffffffffffffffffffffffffff1663350836436040518163ffffffff1660e01b8152600401602060405180830381865afa1580156116c2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116e69190614807565b905060008273ffffffffffffffffffffffffffffffffffffffff1663c56c7a856040518163ffffffff1660e01b8152600401602060405180830381865afa158015611735573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117599190614807565b90506000611768848989613b92565b90506117fa8973ffffffffffffffffffffffffffffffffffffffff16638d928af86040518163ffffffff1660e01b8152600401602060405180830381865afa1580156117b8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117dc9190614807565b73ffffffffffffffffffffffffffffffffffffffff84169083613bbc565b6000611877878673ffffffffffffffffffffffffffffffffffffffff16632b532a976040518163ffffffff1660e01b8152600401602060405180830381865afa15801561184b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061186f91906147ee565b849190613d3e565b90506118878a838587858b613d55565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8616906370a0823190602401602060405180830381865afa1580156118f4573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061191891906147ee565b90506000811161192a5761192a61485a565b61194b73ffffffffffffffffffffffffffffffffffffffff86163383613fb8565b5050505050505050505050565b6000806060808473ffffffffffffffffffffffffffffffffffffffff16638d928af86040518163ffffffff1660e01b8152600401602060405180830381865afa1580156119a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119cd9190614807565b93508473ffffffffffffffffffffffffffffffffffffffff166338fff2d06040518163ffffffff1660e01b8152600401602060405180830381865afa158015611a1a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a3e91906147ee565b6040517ff94d46680000000000000000000000000000000000000000000000000000000081526004810182905290935073ffffffffffffffffffffffffffffffffffffffff85169063f94d466890602401600060405180830381865afa158015611aac573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201604052611af29190810190614996565b50815191935091506002148015611b0a575080516002145b8015611b305750600081600081518110611b2657611b26614a64565b6020026020010151115b8015611b565750600081600181518110611b4c57611b4c614a64565b6020026020010151115b611bbc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f414d4d206e6f7420696e697469616c697a65640000000000000000000000000060448201526064016103e6565b9193509193565b60606000611bd18585614013565b905073ffffffffffffffffffffffffffffffffffffffff89163014611c8457611c51893083600081518110611c0857611c08614a64565b602002602001015189600081518110611c2357611c23614a64565b602002602001015173ffffffffffffffffffffffffffffffffffffffff166140b9909392919063ffffffff16565b611c84893083600181518110611c6957611c69614a64565b602002602001015189600181518110611c2357611c23614a64565b611ce38882600081518110611c9b57611c9b614a64565b602002602001015188600081518110611cb657611cb6614a64565b602002602001015173ffffffffffffffffffffffffffffffffffffffff16613bbc9092919063ffffffff16565b611d158882600181518110611cfa57611cfa614a64565b602002602001015188600181518110611cb657611cb6614a64565b60408051608081018252878152602081018390526000918101600184604051602001611d42929190614afd565b60405160208183030381529060405281526020016000151581525090508873ffffffffffffffffffffffffffffffffffffffff1663b95cac28893087856040518563ffffffff1660e01b8152600401611d9e9493929190614c33565b600060405180830381600087803b158015611db857600080fd5b505af1158015611dcc573d6000803e3d6000fd5b50939c9b505050505050505050505050565b6000831180611ded5750600082115b611e79576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f7072696e636970616c416d6f756e7420616e64207969656c64416d6f756e742060448201527f63616e6e6f7420626f746820626520300000000000000000000000000000000060648201526084016103e6565b6040517f6c8d4fa100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8581166004830152602482018590526044820184905282811660648301526000918291829182918a1690636c8d4fa1906084016080604051808303816000875af1158015611f06573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f2a9190614824565b935093509350935060008973ffffffffffffffffffffffffffffffffffffffff1663454c87b36040518163ffffffff1660e01b8152600401602060405180830381865afa158015611f7f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fa391906147a3565b604080518a8152602081018a9052908101879052606081018690526080810185905260a08101849052901560c08201819052915073ffffffffffffffffffffffffffffffffffffffff808816918b8216918d16907fcd7942cd399b7cdf1812afbdafdccdaa55899bc945c90e4af0ecf07736de030f9060e0016113c0565b6001805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6040517f23b872dd0000000000000000000000000000000000000000000000000000000081523360048201523060248201526044810185905273ffffffffffffffffffffffffffffffffffffffff8616906323b872dd906064016020604051808303816000875af1158015612111573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061213591906147a3565b61219b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f4c5020746f6b656e207472616e73666572206661696c6564000000000000000060448201526064016103e6565b60006121a8868585612836565b90506121b8863033888587612b5a565b505050505050565b60008773ffffffffffffffffffffffffffffffffffffffff1663f1563de96040518163ffffffff1660e01b8152600401602060405180830381865afa15801561220d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122319190614807565b90508073ffffffffffffffffffffffffffffffffffffffff1663454c87b36040518163ffffffff1660e01b8152600401602060405180830381865afa15801561227e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122a291906147a3565b15612309576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f506f6f6c20616c72656164792066696e616c697a65640000000000000000000060448201526064016103e6565b6123138588614ca1565b965061231f8487614ca1565b95508587146123b0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f4e6565647320657175616c20616d6f756e7473206f662073686172657320626560448201527f666f7265206d617475726974790000000000000000000000000000000000000060648201526084016103e6565b6040517f23b872dd0000000000000000000000000000000000000000000000000000000081523360048201523060248201526044810184905273ffffffffffffffffffffffffffffffffffffffff8916906323b872dd906064016020604051808303816000875af1158015612429573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061244d91906147a3565b6124b3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f4c5020746f6b656e207472616e73666572206661696c6564000000000000000060448201526064016103e6565b60006124c0898787612836565b90506124d189303384886000614117565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8b16906370a0823190602401602060405180830381865afa15801561253e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061256291906147ee565b6040517f23b872dd0000000000000000000000000000000000000000000000000000000081523060048201523360248201526044810182905290915073ffffffffffffffffffffffffffffffffffffffff8b16906323b872dd906064016020604051808303816000875af11580156125de573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061260291906147a3565b612668576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f4c5020746f6b656e207472616e73666572206661696c6564000000000000000060448201526064016103e6565b83156126805761267b83338b8b33611dde565b61268d565b61268d83338b8b33611077565b50505050505050505050565b6000806000806126a887611958565b9350935093509350600061272b8873ffffffffffffffffffffffffffffffffffffffff1663f1563de96040518163ffffffff1660e01b8152600401602060405180830381865afa158015612700573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127249190614807565b8888613b92565b9050600061273e30878787878733611bc3565b90508060008151811061275357612753614a64565b60200260200101518211156127cc576127cc338260008151811061277957612779614a64565b60200260200101518461278c9190614cb9565b8660008151811061279f5761279f614a64565b602002602001015173ffffffffffffffffffffffffffffffffffffffff16613fb89092919063ffffffff16565b806001815181106127df576127df614a64565b602002602001015182111561282b5761282b338260018151811061280557612805614a64565b6020026020010151846128189190614cb9565b8660018151811061279f5761279f614a64565b505050505050505050565b606060008473ffffffffffffffffffffffffffffffffffffffff16638d928af86040518163ffffffff1660e01b8152600401602060405180830381865afa158015612885573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128a99190614807565b905060008173ffffffffffffffffffffffffffffffffffffffff1663f94d46688773ffffffffffffffffffffffffffffffffffffffff166338fff2d06040518163ffffffff1660e01b8152600401602060405180830381865afa158015612914573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061293891906147ee565b6040518263ffffffff1660e01b815260040161295691815260200190565b600060405180830381865afa158015612973573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682016040526129b99190810190614996565b50506040805160028082526060820183529293506000929091602083019080368337019050509050816000815181106129f4576129f4614a64565b602002602001015173ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff1663f1563de96040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a5d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a819190614807565b73ffffffffffffffffffffffffffffffffffffffff1663350836436040518163ffffffff1660e01b8152600401602060405180830381865afa158015612acb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612aef9190614807565b73ffffffffffffffffffffffffffffffffffffffff1614612b11578486612b14565b85855b82600081518110612b2757612b27614a64565b6020026020010183600181518110612b4157612b41614a64565b6020908102919091010191909152529695505050505050565b60008311612bc4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f4c5020746f6b656e20616d6f756e74206973203000000000000000000000000060448201526064016103e6565b6000806000612bd289611958565b509250925092506000604051806080016040528083815260200187815260200160006001811115612c0557612c05614a93565b6040805160ff909216602083015281018a90526060015b604051602081830303815290604052815260200186151581525090508373ffffffffffffffffffffffffffffffffffffffff16638bdb3913848b8b856040518563ffffffff1660e01b8152600401612c779493929190614c33565b600060405180830381600087803b158015612c9157600080fd5b505af1158015612ca5573d6000803e3d6000fd5b5050505050505050505050505050565b60008873ffffffffffffffffffffffffffffffffffffffff1663f1563de96040518163ffffffff1660e01b8152600401602060405180830381865afa158015612d02573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d269190614807565b905060008173ffffffffffffffffffffffffffffffffffffffff1663350836436040518163ffffffff1660e01b8152600401602060405180830381865afa158015612d75573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d999190614807565b905060008273ffffffffffffffffffffffffffffffffffffffff1663c56c7a856040518163ffffffff1660e01b8152600401602060405180830381865afa158015612de8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e0c9190614807565b6040517f23b872dd000000000000000000000000000000000000000000000000000000008152336004820152306024820152604481018c905290915073ffffffffffffffffffffffffffffffffffffffff8316906323b872dd906064016020604051808303816000875af1158015612e88573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612eac91906147a3565b612f12576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f5072696e636970616c73207472616e73666572206661696c656400000000000060448201526064016103e6565b6040517f23b872dd000000000000000000000000000000000000000000000000000000008152336004820152306024820152604481018a905273ffffffffffffffffffffffffffffffffffffffff8216906323b872dd906064016020604051808303816000875af1158015612f8b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612faf91906147a3565b613015576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f5969656c6473207472616e73666572206661696c65640000000000000000000060448201526064016103e6565b600087116130a5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f7969656c647352617465206d7573742062652067726561746572207468616e2060448201527f300000000000000000000000000000000000000000000000000000000000000060648201526084016103e6565b670de0b6b3a764000086111561313d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602860248201527f6d6178536c6970706167652063616e206e6f742062652067726561746572207460448201527f68616e203165313800000000000000000000000000000000000000000000000060648201526084016103e6565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff8316906370a0823190602401602060405180830381865afa1580156131a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131cb91906147ee565b6040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152909a5073ffffffffffffffffffffffffffffffffffffffff8216906370a0823190602401602060405180830381865afa158015613238573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061325c91906147ee565b98508273ffffffffffffffffffffffffffffffffffffffff1663454c87b36040518163ffffffff1660e01b8152600401602060405180830381865afa1580156132a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132cd91906147a3565b61362957878a8a116132e8576132e38a8c614cb9565b6132f2565b6132f28b8b614cb9565b10613612576040517f7b62525f000000000000000000000000000000000000000000000000000000008152600481018b9052602481018a905260448101899052600090819073ffffffffffffffffffffffffffffffffffffffff8e1690637b62525f906064016040805180830381865afa158015613374573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133989190614cd0565b915091506000816134235761341e8a8773ffffffffffffffffffffffffffffffffffffffff16632b532a976040518163ffffffff1660e01b8152600401602060405180830381865afa1580156133f2573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061341691906147ee565b85919061416b565b61349e565b61349e8a8773ffffffffffffffffffffffffffffffffffffffff16632b532a976040518163ffffffff1660e01b8152600401602060405180830381865afa158015613472573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061349691906147ee565b859190613d3e565b90506134c56134b58a670de0b6b3a7640000614cb9565b8290670de0b6b3a7640000613d3e565b90506134ed8e84846134d757876134d9565b865b856134e457876134e6565b885b858d613d55565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff8616906370a0823190602401602060405180830381865afa158015613557573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061357b91906147ee565b6040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152909d5073ffffffffffffffffffffffffffffffffffffffff8516906370a0823190602401602060405180830381865afa1580156135e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061360c91906147ee565b9b505050505b888a1115613621578889613624565b898a5b9a5098505b83156136415761363c83308c8c33611dde565b61194b565b61194b83308c8c33611077565b60008083116136b9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f6261636b696e67546f6b656e416d6f756e74206973203000000000000000000060448201526064016103e6565b60008473ffffffffffffffffffffffffffffffffffffffff166347e621b76040518163ffffffff1660e01b8152600401602060405180830381865afa158015613706573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061372a9190614807565b9050346137d75773ffffffffffffffffffffffffffffffffffffffff81166137ae576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f506f6f6c20726571756972657320455448206465706f7369747300000000000060448201526064016103e6565b6137d073ffffffffffffffffffffffffffffffffffffffff8216338787613a32565b935061390a565b73ffffffffffffffffffffffffffffffffffffffff81161561387b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f676976656e2054656d707573506f6f6c2773204261636b696e6720546f6b656e60448201527f206973206e6f742045544800000000000000000000000000000000000000000060648201526084016103e6565b83341461390a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602860248201527f4554482076616c756520646f6573206e6f74206d617463682070726f7669646560448201527f6420616d6f756e7400000000000000000000000000000000000000000000000060648201526084016103e6565b6040517f4b009e060000000000000000000000000000000000000000000000000000000081526004810185905273ffffffffffffffffffffffffffffffffffffffff84811660248301526000918291829182918a1690634b009e0690349060440160806040518083038185885af1158015613989573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906139ae9190614824565b60408051848152602081018e905290810185905260608101829052608081018390529397509195509350915073ffffffffffffffffffffffffffffffffffffffff8089169133918c16907f4c3988fb4c597926bdbfd4fb6863567acf4c384bd3c02f401fa99f158c783bb89060a00160405180910390a45091979650505050505050565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff838116600483015260009182918716906370a0823190602401602060405180830381865afa158015613aa3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ac791906147ee565b9050613aeb73ffffffffffffffffffffffffffffffffffffffff87168686866140b9565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85811660048301528291908816906370a0823190602401602060405180830381865afa158015613b5a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b7e91906147ee565b613b889190614cb9565b9695505050505050565b600081613ba957613ba48484306113d4565b613bb4565b613bb484843061364e565b949350505050565b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff8381166024830152600091839186169063dd62ed3e90604401602060405180830381865afa158015613c33573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c5791906147ee565b613c619190614ca1565b60405173ffffffffffffffffffffffffffffffffffffffff8516602482015260448101829052909150613d389085907f095ea7b300000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152614178565b50505050565b600081613d4b8486614cf5565b613bb49190614d32565b60008511613dbf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f496e76616c6964207377617020616d6f756e742e00000000000000000000000060448201526064016103e6565b613e4f8673ffffffffffffffffffffffffffffffffffffffff16638d928af86040518163ffffffff1660e01b8152600401602060405180830381865afa158015613e0d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e319190614807565b73ffffffffffffffffffffffffffffffffffffffff86169087613bbc565b600080613e5b88611958565b50509150915060006040518060c0016040528083815260200160006001811115613e8757613e87614a93565b81526020018873ffffffffffffffffffffffffffffffffffffffff1681526020018773ffffffffffffffffffffffffffffffffffffffff168152602001898152602001604051806020016040528060008152508152509050600060405180608001604052803073ffffffffffffffffffffffffffffffffffffffff1681526020016000151581526020013073ffffffffffffffffffffffffffffffffffffffff1681526020016000151581525090508373ffffffffffffffffffffffffffffffffffffffff166352bbbe29838389896040518563ffffffff1660e01b8152600401613f759493929190614d6d565b6020604051808303816000875af1158015613f94573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061194b91906147ee565b60405173ffffffffffffffffffffffffffffffffffffffff831660248201526044810182905261400e9084907fa9059cbb0000000000000000000000000000000000000000000000000000000090606401613cb6565b505050565b6060600061402084614284565b60408051600280825260608201835292935060009290916020830190803683375050835191925061405c91869150670de0b6b3a7640000613d3e565b6020830151614075908690670de0b6b3a7640000613d3e565b8260008151811061408857614088614a64565b60200260200101836001815181106140a2576140a2614a64565b602090810291909101019190915252949350505050565b60405173ffffffffffffffffffffffffffffffffffffffff80851660248301528316604482015260648101829052613d389085907f23b872dd0000000000000000000000000000000000000000000000000000000090608401613cb6565b600080600061412589611958565b509250925092506000604051806080016040528083815260200188815260200160018081111561415757614157614a93565b8989604051602001612c1c93929190614e8d565b600082613d4b8386614cf5565b60006141da826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166143209092919063ffffffff16565b80519091501561400e57808060200190518101906141f891906147a3565b61400e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016103e6565b61428c61446c565b60006142df836001815181106142a4576142a4614a64565b6020026020010151670de0b6b3a7640000856000815181106142c8576142c8614a64565b602002602001015161416b9092919063ffffffff16565b9050670de0b6b3a764000081116142ff5780670de0b6b3a7640000614313565b670de0b6b3a764000061431381838161416b565b6020840152825250919050565b6060613bb4848460008585843b614393576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016103e6565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516143bc9190614eb9565b60006040518083038185875af1925050503d80600081146143f9576040519150601f19603f3d011682016040523d82523d6000602084013e6143fe565b606091505b509150915061440e828286614419565b979650505050505050565b606083156144285750816115fb565b8251156144385782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103e69190614ed5565b60405180604001604052806002906020820280368337509192915050565b73ffffffffffffffffffffffffffffffffffffffff8116811461107457600080fd5b600080600080608085870312156144c257600080fd5b84356144cd8161448a565b9350602085013592506040850135915060608501356144eb8161448a565b939692955090935050565b60008060006060848603121561450b57600080fd5b83356145168161448a565b925060208401359150604084013561452d8161448a565b809150509250925092565b801515811461107457600080fd5b600080600080600060a0868803121561455e57600080fd5b85356145698161448a565b945060208601359350604086013561458081614538565b94979396509394606081013594506080013592915050565b600080604083850312156145ab57600080fd5b82356145b68161448a565b946020939093013593505050565b600080600080600060a086880312156145dc57600080fd5b85356145e78161448a565b9450602086013593506040860135925060608601359150608086013561460c81614538565b809150509295509295909350565b600080600080600080600060e0888a03121561463557600080fd5b87356146408161448a565b96506020880135955060408801359450606088013593506080880135925060a0880135915060c088013561467381614538565b8091505092959891949750929550565b60008060006060848603121561469857600080fd5b83356146a38161448a565b925060208401359150604084013561452d81614538565b600080604083850312156146cd57600080fd5b82356146d88161448a565b915060208301356146e881614538565b809150509250929050565b60008060008060008060008060008060006101608c8e03121561471557600080fd5b8b356147208161448a565b9a5060208c0135995060408c0135985060608c0135975060808c0135965060a08c0135955060c08c0135945060e08c013593506101008c013592506101208c013561476a81614538565b809250506101408c013590509295989b509295989b9093969950565b60006020828403121561479857600080fd5b81356115fb8161448a565b6000602082840312156147b557600080fd5b81516115fb81614538565b6000806000606084860312156147d557600080fd5b8351925060208401519150604084015190509250925092565b60006020828403121561480057600080fd5b5051919050565b60006020828403121561481957600080fd5b81516115fb8161448a565b6000806000806080858703121561483a57600080fd5b505082516020840151604085015160609095015191969095509092509050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156148ff576148ff614889565b604052919050565b600067ffffffffffffffff82111561492157614921614889565b5060051b60200190565b600082601f83011261493c57600080fd5b8151602061495161494c83614907565b6148b8565b82815260059290921b8401810191818101908684111561497057600080fd5b8286015b8481101561498b5780518352918301918301614974565b509695505050505050565b6000806000606084860312156149ab57600080fd5b835167ffffffffffffffff808211156149c357600080fd5b818601915086601f8301126149d757600080fd5b815160206149e761494c83614907565b82815260059290921b8401810191818101908a841115614a0657600080fd5b948201945b83861015614a2d578551614a1e8161448a565b82529482019490820190614a0b565b91890151919750909350505080821115614a4657600080fd5b50614a538682870161492b565b925050604084015190509250925092565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b600081518084526020808501945080840160005b83811015614af257815187529582019590820190600101614ad6565b509495945050505050565b60ff83168152604060208201526000613bb46040830184614ac2565b60005b83811015614b34578181015183820152602001614b1c565b83811115613d385750506000910152565b60008151808452614b5d816020860160208601614b19565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b8051608080845281519084018190526000916020919082019060a0860190845b81811015614be157835173ffffffffffffffffffffffffffffffffffffffff1683529284019291840191600101614baf565b505082850151915085810383870152614bfa8183614ac2565b9250505060408301518482036040860152614c158282614b45565b9150506060830151614c2b606086018215159052565b509392505050565b848152600073ffffffffffffffffffffffffffffffffffffffff808616602084015280851660408401525060806060830152613b886080830184614b8f565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60008219821115614cb457614cb4614c72565b500190565b600082821015614ccb57614ccb614c72565b500390565b60008060408385031215614ce357600080fd5b8251915060208301516146e881614538565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615614d2d57614d2d614c72565b500290565b600082614d68577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b60e08152845160e08201526000602086015160028110614db6577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b610100830152604086015173ffffffffffffffffffffffffffffffffffffffff166101208301526060860151614e0561014084018273ffffffffffffffffffffffffffffffffffffffff169052565b50608086015161016083015260a086015160c0610180840152614e2c6101a0840182614b45565b915050614e7b602083018673ffffffffffffffffffffffffffffffffffffffff808251168352602082015115156020840152806040830151166040840152506060810151151560608301525050565b60a082019390935260c0015292915050565b60ff84168152606060208201526000614ea96060830185614ac2565b9050826040830152949350505050565b60008251614ecb818460208701614b19565b9190910192915050565b6020815260006115fb6020830184614b4556fea2646970667358221220d140589d60b906492ef7477eb789d76033f75cbbda4466183b3d9140dac45f2e64736f6c634300080a0033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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